Giant blob of minor changes
[dotfiles/.git] / .config / coc / extensions / node_modules / coc-html / 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 __makeTemplateObject = (this && this.__makeTemplateObject) || function (cooked, raw) {
37     if (Object.defineProperty) { Object.defineProperty(cooked, "raw", { value: raw }); } else { cooked.raw = raw; }
38     return cooked;
39 };
40 var __generator = (this && this.__generator) || function (thisArg, body) {
41     var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
42     return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
43     function verb(n) { return function (v) { return step([n, v]); }; }
44     function step(op) {
45         if (f) throw new TypeError("Generator is already executing.");
46         while (_) try {
47             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;
48             if (y = 0, t) op = [op[0] & 2, t.value];
49             switch (op[0]) {
50                 case 0: case 1: t = op; break;
51                 case 4: _.label++; return { value: op[1], done: false };
52                 case 5: _.label++; y = op[1]; op = [0]; continue;
53                 case 7: op = _.ops.pop(); _.trys.pop(); continue;
54                 default:
55                     if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
56                     if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
57                     if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
58                     if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
59                     if (t[2]) _.ops.pop();
60                     _.trys.pop(); continue;
61             }
62             op = body.call(thisArg, _);
63         } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
64         if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
65     }
66 };
67 var ts;
68 (function (ts) {
69     ts.versionMajorMinor = "4.1";
70     ts.version = "4.1.3";
71     var NativeCollections;
72     (function (NativeCollections) {
73         function tryGetNativeMap() {
74             return typeof Map !== "undefined" && "entries" in Map.prototype && new Map([[0, 0]]).size === 1 ? Map : undefined;
75         }
76         NativeCollections.tryGetNativeMap = tryGetNativeMap;
77         function tryGetNativeSet() {
78             return typeof Set !== "undefined" && "entries" in Set.prototype && new Set([0]).size === 1 ? Set : undefined;
79         }
80         NativeCollections.tryGetNativeSet = tryGetNativeSet;
81     })(NativeCollections = ts.NativeCollections || (ts.NativeCollections = {}));
82 })(ts || (ts = {}));
83 var ts;
84 (function (ts) {
85     function getCollectionImplementation(name, nativeFactory, shimFactory) {
86         var _a;
87         var constructor = (_a = ts.NativeCollections[nativeFactory]()) !== null && _a !== void 0 ? _a : ts.ShimCollections === null || ts.ShimCollections === void 0 ? void 0 : ts.ShimCollections[shimFactory](getIterator);
88         if (constructor)
89             return constructor;
90         throw new Error("TypeScript requires an environment that provides a compatible native " + name + " implementation.");
91     }
92     ts.Map = getCollectionImplementation("Map", "tryGetNativeMap", "createMapShim");
93     ts.Set = getCollectionImplementation("Set", "tryGetNativeSet", "createSetShim");
94     function getIterator(iterable) {
95         if (iterable) {
96             if (isArray(iterable))
97                 return arrayIterator(iterable);
98             if (iterable instanceof ts.Map)
99                 return iterable.entries();
100             if (iterable instanceof ts.Set)
101                 return iterable.values();
102             throw new Error("Iteration not supported.");
103         }
104     }
105     ts.getIterator = getIterator;
106     ts.emptyArray = [];
107     ts.emptyMap = new ts.Map();
108     ts.emptySet = new ts.Set();
109     function createMap() {
110         return new ts.Map();
111     }
112     ts.createMap = createMap;
113     function createMapFromTemplate(template) {
114         var map = new ts.Map();
115         for (var key in template) {
116             if (hasOwnProperty.call(template, key)) {
117                 map.set(key, template[key]);
118             }
119         }
120         return map;
121     }
122     ts.createMapFromTemplate = createMapFromTemplate;
123     function length(array) {
124         return array ? array.length : 0;
125     }
126     ts.length = length;
127     function forEach(array, callback) {
128         if (array) {
129             for (var i = 0; i < array.length; i++) {
130                 var result = callback(array[i], i);
131                 if (result) {
132                     return result;
133                 }
134             }
135         }
136         return undefined;
137     }
138     ts.forEach = forEach;
139     function forEachRight(array, callback) {
140         if (array) {
141             for (var i = array.length - 1; i >= 0; i--) {
142                 var result = callback(array[i], i);
143                 if (result) {
144                     return result;
145                 }
146             }
147         }
148         return undefined;
149     }
150     ts.forEachRight = forEachRight;
151     function firstDefined(array, callback) {
152         if (array === undefined) {
153             return undefined;
154         }
155         for (var i = 0; i < array.length; i++) {
156             var result = callback(array[i], i);
157             if (result !== undefined) {
158                 return result;
159             }
160         }
161         return undefined;
162     }
163     ts.firstDefined = firstDefined;
164     function firstDefinedIterator(iter, callback) {
165         while (true) {
166             var iterResult = iter.next();
167             if (iterResult.done) {
168                 return undefined;
169             }
170             var result = callback(iterResult.value);
171             if (result !== undefined) {
172                 return result;
173             }
174         }
175     }
176     ts.firstDefinedIterator = firstDefinedIterator;
177     function reduceLeftIterator(iterator, f, initial) {
178         var result = initial;
179         if (iterator) {
180             for (var step = iterator.next(), pos = 0; !step.done; step = iterator.next(), pos++) {
181                 result = f(result, step.value, pos);
182             }
183         }
184         return result;
185     }
186     ts.reduceLeftIterator = reduceLeftIterator;
187     function zipWith(arrayA, arrayB, callback) {
188         var result = [];
189         ts.Debug.assertEqual(arrayA.length, arrayB.length);
190         for (var i = 0; i < arrayA.length; i++) {
191             result.push(callback(arrayA[i], arrayB[i], i));
192         }
193         return result;
194     }
195     ts.zipWith = zipWith;
196     function zipToIterator(arrayA, arrayB) {
197         ts.Debug.assertEqual(arrayA.length, arrayB.length);
198         var i = 0;
199         return {
200             next: function () {
201                 if (i === arrayA.length) {
202                     return { value: undefined, done: true };
203                 }
204                 i++;
205                 return { value: [arrayA[i - 1], arrayB[i - 1]], done: false };
206             }
207         };
208     }
209     ts.zipToIterator = zipToIterator;
210     function zipToMap(keys, values) {
211         ts.Debug.assert(keys.length === values.length);
212         var map = new ts.Map();
213         for (var i = 0; i < keys.length; ++i) {
214             map.set(keys[i], values[i]);
215         }
216         return map;
217     }
218     ts.zipToMap = zipToMap;
219     function intersperse(input, element) {
220         if (input.length <= 1) {
221             return input;
222         }
223         var result = [];
224         for (var i = 0, n = input.length; i < n; i++) {
225             if (i)
226                 result.push(element);
227             result.push(input[i]);
228         }
229         return result;
230     }
231     ts.intersperse = intersperse;
232     function every(array, callback) {
233         if (array) {
234             for (var i = 0; i < array.length; i++) {
235                 if (!callback(array[i], i)) {
236                     return false;
237                 }
238             }
239         }
240         return true;
241     }
242     ts.every = every;
243     function find(array, predicate) {
244         for (var i = 0; i < array.length; i++) {
245             var value = array[i];
246             if (predicate(value, i)) {
247                 return value;
248             }
249         }
250         return undefined;
251     }
252     ts.find = find;
253     function findLast(array, predicate) {
254         for (var i = array.length - 1; i >= 0; i--) {
255             var value = array[i];
256             if (predicate(value, i)) {
257                 return value;
258             }
259         }
260         return undefined;
261     }
262     ts.findLast = findLast;
263     function findIndex(array, predicate, startIndex) {
264         for (var i = startIndex || 0; i < array.length; i++) {
265             if (predicate(array[i], i)) {
266                 return i;
267             }
268         }
269         return -1;
270     }
271     ts.findIndex = findIndex;
272     function findLastIndex(array, predicate, startIndex) {
273         for (var i = startIndex === undefined ? array.length - 1 : startIndex; i >= 0; i--) {
274             if (predicate(array[i], i)) {
275                 return i;
276             }
277         }
278         return -1;
279     }
280     ts.findLastIndex = findLastIndex;
281     function findMap(array, callback) {
282         for (var i = 0; i < array.length; i++) {
283             var result = callback(array[i], i);
284             if (result) {
285                 return result;
286             }
287         }
288         return ts.Debug.fail();
289     }
290     ts.findMap = findMap;
291     function contains(array, value, equalityComparer) {
292         if (equalityComparer === void 0) { equalityComparer = equateValues; }
293         if (array) {
294             for (var _i = 0, array_1 = array; _i < array_1.length; _i++) {
295                 var v = array_1[_i];
296                 if (equalityComparer(v, value)) {
297                     return true;
298                 }
299             }
300         }
301         return false;
302     }
303     ts.contains = contains;
304     function arraysEqual(a, b, equalityComparer) {
305         if (equalityComparer === void 0) { equalityComparer = equateValues; }
306         return a.length === b.length && a.every(function (x, i) { return equalityComparer(x, b[i]); });
307     }
308     ts.arraysEqual = arraysEqual;
309     function indexOfAnyCharCode(text, charCodes, start) {
310         for (var i = start || 0; i < text.length; i++) {
311             if (contains(charCodes, text.charCodeAt(i))) {
312                 return i;
313             }
314         }
315         return -1;
316     }
317     ts.indexOfAnyCharCode = indexOfAnyCharCode;
318     function countWhere(array, predicate) {
319         var count = 0;
320         if (array) {
321             for (var i = 0; i < array.length; i++) {
322                 var v = array[i];
323                 if (predicate(v, i)) {
324                     count++;
325                 }
326             }
327         }
328         return count;
329     }
330     ts.countWhere = countWhere;
331     function filter(array, f) {
332         if (array) {
333             var len = array.length;
334             var i = 0;
335             while (i < len && f(array[i]))
336                 i++;
337             if (i < len) {
338                 var result = array.slice(0, i);
339                 i++;
340                 while (i < len) {
341                     var item = array[i];
342                     if (f(item)) {
343                         result.push(item);
344                     }
345                     i++;
346                 }
347                 return result;
348             }
349         }
350         return array;
351     }
352     ts.filter = filter;
353     function filterMutate(array, f) {
354         var outIndex = 0;
355         for (var i = 0; i < array.length; i++) {
356             if (f(array[i], i, array)) {
357                 array[outIndex] = array[i];
358                 outIndex++;
359             }
360         }
361         array.length = outIndex;
362     }
363     ts.filterMutate = filterMutate;
364     function clear(array) {
365         array.length = 0;
366     }
367     ts.clear = clear;
368     function map(array, f) {
369         var result;
370         if (array) {
371             result = [];
372             for (var i = 0; i < array.length; i++) {
373                 result.push(f(array[i], i));
374             }
375         }
376         return result;
377     }
378     ts.map = map;
379     function mapIterator(iter, mapFn) {
380         return {
381             next: function () {
382                 var iterRes = iter.next();
383                 return iterRes.done ? iterRes : { value: mapFn(iterRes.value), done: false };
384             }
385         };
386     }
387     ts.mapIterator = mapIterator;
388     function sameMap(array, f) {
389         if (array) {
390             for (var i = 0; i < array.length; i++) {
391                 var item = array[i];
392                 var mapped = f(item, i);
393                 if (item !== mapped) {
394                     var result = array.slice(0, i);
395                     result.push(mapped);
396                     for (i++; i < array.length; i++) {
397                         result.push(f(array[i], i));
398                     }
399                     return result;
400                 }
401             }
402         }
403         return array;
404     }
405     ts.sameMap = sameMap;
406     function flatten(array) {
407         var result = [];
408         for (var _i = 0, array_2 = array; _i < array_2.length; _i++) {
409             var v = array_2[_i];
410             if (v) {
411                 if (isArray(v)) {
412                     addRange(result, v);
413                 }
414                 else {
415                     result.push(v);
416                 }
417             }
418         }
419         return result;
420     }
421     ts.flatten = flatten;
422     function flatMap(array, mapfn) {
423         var result;
424         if (array) {
425             for (var i = 0; i < array.length; i++) {
426                 var v = mapfn(array[i], i);
427                 if (v) {
428                     if (isArray(v)) {
429                         result = addRange(result, v);
430                     }
431                     else {
432                         result = append(result, v);
433                     }
434                 }
435             }
436         }
437         return result || ts.emptyArray;
438     }
439     ts.flatMap = flatMap;
440     function flatMapToMutable(array, mapfn) {
441         var result = [];
442         if (array) {
443             for (var i = 0; i < array.length; i++) {
444                 var v = mapfn(array[i], i);
445                 if (v) {
446                     if (isArray(v)) {
447                         addRange(result, v);
448                     }
449                     else {
450                         result.push(v);
451                     }
452                 }
453             }
454         }
455         return result;
456     }
457     ts.flatMapToMutable = flatMapToMutable;
458     function flatMapIterator(iter, mapfn) {
459         var first = iter.next();
460         if (first.done) {
461             return ts.emptyIterator;
462         }
463         var currentIter = getIterator(first.value);
464         return {
465             next: function () {
466                 while (true) {
467                     var currentRes = currentIter.next();
468                     if (!currentRes.done) {
469                         return currentRes;
470                     }
471                     var iterRes = iter.next();
472                     if (iterRes.done) {
473                         return iterRes;
474                     }
475                     currentIter = getIterator(iterRes.value);
476                 }
477             },
478         };
479         function getIterator(x) {
480             var res = mapfn(x);
481             return res === undefined ? ts.emptyIterator : isArray(res) ? arrayIterator(res) : res;
482         }
483     }
484     ts.flatMapIterator = flatMapIterator;
485     function sameFlatMap(array, mapfn) {
486         var result;
487         if (array) {
488             for (var i = 0; i < array.length; i++) {
489                 var item = array[i];
490                 var mapped = mapfn(item, i);
491                 if (result || item !== mapped || isArray(mapped)) {
492                     if (!result) {
493                         result = array.slice(0, i);
494                     }
495                     if (isArray(mapped)) {
496                         addRange(result, mapped);
497                     }
498                     else {
499                         result.push(mapped);
500                     }
501                 }
502             }
503         }
504         return result || array;
505     }
506     ts.sameFlatMap = sameFlatMap;
507     function mapAllOrFail(array, mapFn) {
508         var result = [];
509         for (var i = 0; i < array.length; i++) {
510             var mapped = mapFn(array[i], i);
511             if (mapped === undefined) {
512                 return undefined;
513             }
514             result.push(mapped);
515         }
516         return result;
517     }
518     ts.mapAllOrFail = mapAllOrFail;
519     function mapDefined(array, mapFn) {
520         var result = [];
521         if (array) {
522             for (var i = 0; i < array.length; i++) {
523                 var mapped = mapFn(array[i], i);
524                 if (mapped !== undefined) {
525                     result.push(mapped);
526                 }
527             }
528         }
529         return result;
530     }
531     ts.mapDefined = mapDefined;
532     function mapDefinedIterator(iter, mapFn) {
533         return {
534             next: function () {
535                 while (true) {
536                     var res = iter.next();
537                     if (res.done) {
538                         return res;
539                     }
540                     var value = mapFn(res.value);
541                     if (value !== undefined) {
542                         return { value: value, done: false };
543                     }
544                 }
545             }
546         };
547     }
548     ts.mapDefinedIterator = mapDefinedIterator;
549     function mapDefinedEntries(map, f) {
550         if (!map) {
551             return undefined;
552         }
553         var result = new ts.Map();
554         map.forEach(function (value, key) {
555             var entry = f(key, value);
556             if (entry !== undefined) {
557                 var newKey = entry[0], newValue = entry[1];
558                 if (newKey !== undefined && newValue !== undefined) {
559                     result.set(newKey, newValue);
560                 }
561             }
562         });
563         return result;
564     }
565     ts.mapDefinedEntries = mapDefinedEntries;
566     function mapDefinedValues(set, f) {
567         if (set) {
568             var result_1 = new ts.Set();
569             set.forEach(function (value) {
570                 var newValue = f(value);
571                 if (newValue !== undefined) {
572                     result_1.add(newValue);
573                 }
574             });
575             return result_1;
576         }
577     }
578     ts.mapDefinedValues = mapDefinedValues;
579     function getOrUpdate(map, key, callback) {
580         if (map.has(key)) {
581             return map.get(key);
582         }
583         var value = callback();
584         map.set(key, value);
585         return value;
586     }
587     ts.getOrUpdate = getOrUpdate;
588     function tryAddToSet(set, value) {
589         if (!set.has(value)) {
590             set.add(value);
591             return true;
592         }
593         return false;
594     }
595     ts.tryAddToSet = tryAddToSet;
596     ts.emptyIterator = { next: function () { return ({ value: undefined, done: true }); } };
597     function singleIterator(value) {
598         var done = false;
599         return {
600             next: function () {
601                 var wasDone = done;
602                 done = true;
603                 return wasDone ? { value: undefined, done: true } : { value: value, done: false };
604             }
605         };
606     }
607     ts.singleIterator = singleIterator;
608     function spanMap(array, keyfn, mapfn) {
609         var result;
610         if (array) {
611             result = [];
612             var len = array.length;
613             var previousKey = void 0;
614             var key = void 0;
615             var start = 0;
616             var pos = 0;
617             while (start < len) {
618                 while (pos < len) {
619                     var value = array[pos];
620                     key = keyfn(value, pos);
621                     if (pos === 0) {
622                         previousKey = key;
623                     }
624                     else if (key !== previousKey) {
625                         break;
626                     }
627                     pos++;
628                 }
629                 if (start < pos) {
630                     var v = mapfn(array.slice(start, pos), previousKey, start, pos);
631                     if (v) {
632                         result.push(v);
633                     }
634                     start = pos;
635                 }
636                 previousKey = key;
637                 pos++;
638             }
639         }
640         return result;
641     }
642     ts.spanMap = spanMap;
643     function mapEntries(map, f) {
644         if (!map) {
645             return undefined;
646         }
647         var result = new ts.Map();
648         map.forEach(function (value, key) {
649             var _a = f(key, value), newKey = _a[0], newValue = _a[1];
650             result.set(newKey, newValue);
651         });
652         return result;
653     }
654     ts.mapEntries = mapEntries;
655     function some(array, predicate) {
656         if (array) {
657             if (predicate) {
658                 for (var _i = 0, array_3 = array; _i < array_3.length; _i++) {
659                     var v = array_3[_i];
660                     if (predicate(v)) {
661                         return true;
662                     }
663                 }
664             }
665             else {
666                 return array.length > 0;
667             }
668         }
669         return false;
670     }
671     ts.some = some;
672     function getRangesWhere(arr, pred, cb) {
673         var start;
674         for (var i = 0; i < arr.length; i++) {
675             if (pred(arr[i])) {
676                 start = start === undefined ? i : start;
677             }
678             else {
679                 if (start !== undefined) {
680                     cb(start, i);
681                     start = undefined;
682                 }
683             }
684         }
685         if (start !== undefined)
686             cb(start, arr.length);
687     }
688     ts.getRangesWhere = getRangesWhere;
689     function concatenate(array1, array2) {
690         if (!some(array2))
691             return array1;
692         if (!some(array1))
693             return array2;
694         return __spreadArrays(array1, array2);
695     }
696     ts.concatenate = concatenate;
697     function selectIndex(_, i) {
698         return i;
699     }
700     function indicesOf(array) {
701         return array.map(selectIndex);
702     }
703     ts.indicesOf = indicesOf;
704     function deduplicateRelational(array, equalityComparer, comparer) {
705         var indices = indicesOf(array);
706         stableSortIndices(array, indices, comparer);
707         var last = array[indices[0]];
708         var deduplicated = [indices[0]];
709         for (var i = 1; i < indices.length; i++) {
710             var index = indices[i];
711             var item = array[index];
712             if (!equalityComparer(last, item)) {
713                 deduplicated.push(index);
714                 last = item;
715             }
716         }
717         deduplicated.sort();
718         return deduplicated.map(function (i) { return array[i]; });
719     }
720     function deduplicateEquality(array, equalityComparer) {
721         var result = [];
722         for (var _i = 0, array_4 = array; _i < array_4.length; _i++) {
723             var item = array_4[_i];
724             pushIfUnique(result, item, equalityComparer);
725         }
726         return result;
727     }
728     function deduplicate(array, equalityComparer, comparer) {
729         return array.length === 0 ? [] :
730             array.length === 1 ? array.slice() :
731                 comparer ? deduplicateRelational(array, equalityComparer, comparer) :
732                     deduplicateEquality(array, equalityComparer);
733     }
734     ts.deduplicate = deduplicate;
735     function deduplicateSorted(array, comparer) {
736         if (array.length === 0)
737             return ts.emptyArray;
738         var last = array[0];
739         var deduplicated = [last];
740         for (var i = 1; i < array.length; i++) {
741             var next = array[i];
742             switch (comparer(next, last)) {
743                 case true:
744                 case 0:
745                     continue;
746                 case -1:
747                     return ts.Debug.fail("Array is unsorted.");
748             }
749             deduplicated.push(last = next);
750         }
751         return deduplicated;
752     }
753     function insertSorted(array, insert, compare) {
754         if (array.length === 0) {
755             array.push(insert);
756             return;
757         }
758         var insertIndex = binarySearch(array, insert, identity, compare);
759         if (insertIndex < 0) {
760             array.splice(~insertIndex, 0, insert);
761         }
762     }
763     ts.insertSorted = insertSorted;
764     function sortAndDeduplicate(array, comparer, equalityComparer) {
765         return deduplicateSorted(sort(array, comparer), equalityComparer || comparer || compareStringsCaseSensitive);
766     }
767     ts.sortAndDeduplicate = sortAndDeduplicate;
768     function arrayIsSorted(array, comparer) {
769         if (array.length < 2)
770             return true;
771         var prevElement = array[0];
772         for (var _i = 0, _a = array.slice(1); _i < _a.length; _i++) {
773             var element = _a[_i];
774             if (comparer(prevElement, element) === 1) {
775                 return false;
776             }
777             prevElement = element;
778         }
779         return true;
780     }
781     ts.arrayIsSorted = arrayIsSorted;
782     function arrayIsEqualTo(array1, array2, equalityComparer) {
783         if (equalityComparer === void 0) { equalityComparer = equateValues; }
784         if (!array1 || !array2) {
785             return array1 === array2;
786         }
787         if (array1.length !== array2.length) {
788             return false;
789         }
790         for (var i = 0; i < array1.length; i++) {
791             if (!equalityComparer(array1[i], array2[i], i)) {
792                 return false;
793             }
794         }
795         return true;
796     }
797     ts.arrayIsEqualTo = arrayIsEqualTo;
798     function compact(array) {
799         var result;
800         if (array) {
801             for (var i = 0; i < array.length; i++) {
802                 var v = array[i];
803                 if (result || !v) {
804                     if (!result) {
805                         result = array.slice(0, i);
806                     }
807                     if (v) {
808                         result.push(v);
809                     }
810                 }
811             }
812         }
813         return result || array;
814     }
815     ts.compact = compact;
816     function relativeComplement(arrayA, arrayB, comparer) {
817         if (!arrayB || !arrayA || arrayB.length === 0 || arrayA.length === 0)
818             return arrayB;
819         var result = [];
820         loopB: for (var offsetA = 0, offsetB = 0; offsetB < arrayB.length; offsetB++) {
821             if (offsetB > 0) {
822                 ts.Debug.assertGreaterThanOrEqual(comparer(arrayB[offsetB], arrayB[offsetB - 1]), 0);
823             }
824             loopA: for (var startA = offsetA; offsetA < arrayA.length; offsetA++) {
825                 if (offsetA > startA) {
826                     ts.Debug.assertGreaterThanOrEqual(comparer(arrayA[offsetA], arrayA[offsetA - 1]), 0);
827                 }
828                 switch (comparer(arrayB[offsetB], arrayA[offsetA])) {
829                     case -1:
830                         result.push(arrayB[offsetB]);
831                         continue loopB;
832                     case 0:
833                         continue loopB;
834                     case 1:
835                         continue loopA;
836                 }
837             }
838         }
839         return result;
840     }
841     ts.relativeComplement = relativeComplement;
842     function sum(array, prop) {
843         var result = 0;
844         for (var _i = 0, array_5 = array; _i < array_5.length; _i++) {
845             var v = array_5[_i];
846             result += v[prop];
847         }
848         return result;
849     }
850     ts.sum = sum;
851     function append(to, value) {
852         if (value === undefined)
853             return to;
854         if (to === undefined)
855             return [value];
856         to.push(value);
857         return to;
858     }
859     ts.append = append;
860     function combine(xs, ys) {
861         if (xs === undefined)
862             return ys;
863         if (ys === undefined)
864             return xs;
865         if (isArray(xs))
866             return isArray(ys) ? concatenate(xs, ys) : append(xs, ys);
867         if (isArray(ys))
868             return append(ys, xs);
869         return [xs, ys];
870     }
871     ts.combine = combine;
872     function toOffset(array, offset) {
873         return offset < 0 ? array.length + offset : offset;
874     }
875     function addRange(to, from, start, end) {
876         if (from === undefined || from.length === 0)
877             return to;
878         if (to === undefined)
879             return from.slice(start, end);
880         start = start === undefined ? 0 : toOffset(from, start);
881         end = end === undefined ? from.length : toOffset(from, end);
882         for (var i = start; i < end && i < from.length; i++) {
883             if (from[i] !== undefined) {
884                 to.push(from[i]);
885             }
886         }
887         return to;
888     }
889     ts.addRange = addRange;
890     function pushIfUnique(array, toAdd, equalityComparer) {
891         if (contains(array, toAdd, equalityComparer)) {
892             return false;
893         }
894         else {
895             array.push(toAdd);
896             return true;
897         }
898     }
899     ts.pushIfUnique = pushIfUnique;
900     function appendIfUnique(array, toAdd, equalityComparer) {
901         if (array) {
902             pushIfUnique(array, toAdd, equalityComparer);
903             return array;
904         }
905         else {
906             return [toAdd];
907         }
908     }
909     ts.appendIfUnique = appendIfUnique;
910     function stableSortIndices(array, indices, comparer) {
911         indices.sort(function (x, y) { return comparer(array[x], array[y]) || compareValues(x, y); });
912     }
913     function sort(array, comparer) {
914         return (array.length === 0 ? array : array.slice().sort(comparer));
915     }
916     ts.sort = sort;
917     function arrayIterator(array) {
918         var i = 0;
919         return { next: function () {
920                 if (i === array.length) {
921                     return { value: undefined, done: true };
922                 }
923                 else {
924                     i++;
925                     return { value: array[i - 1], done: false };
926                 }
927             } };
928     }
929     ts.arrayIterator = arrayIterator;
930     function arrayReverseIterator(array) {
931         var i = array.length;
932         return {
933             next: function () {
934                 if (i === 0) {
935                     return { value: undefined, done: true };
936                 }
937                 else {
938                     i--;
939                     return { value: array[i], done: false };
940                 }
941             }
942         };
943     }
944     ts.arrayReverseIterator = arrayReverseIterator;
945     function stableSort(array, comparer) {
946         var indices = indicesOf(array);
947         stableSortIndices(array, indices, comparer);
948         return indices.map(function (i) { return array[i]; });
949     }
950     ts.stableSort = stableSort;
951     function rangeEquals(array1, array2, pos, end) {
952         while (pos < end) {
953             if (array1[pos] !== array2[pos]) {
954                 return false;
955             }
956             pos++;
957         }
958         return true;
959     }
960     ts.rangeEquals = rangeEquals;
961     function elementAt(array, offset) {
962         if (array) {
963             offset = toOffset(array, offset);
964             if (offset < array.length) {
965                 return array[offset];
966             }
967         }
968         return undefined;
969     }
970     ts.elementAt = elementAt;
971     function firstOrUndefined(array) {
972         return array.length === 0 ? undefined : array[0];
973     }
974     ts.firstOrUndefined = firstOrUndefined;
975     function first(array) {
976         ts.Debug.assert(array.length !== 0);
977         return array[0];
978     }
979     ts.first = first;
980     function lastOrUndefined(array) {
981         return array.length === 0 ? undefined : array[array.length - 1];
982     }
983     ts.lastOrUndefined = lastOrUndefined;
984     function last(array) {
985         ts.Debug.assert(array.length !== 0);
986         return array[array.length - 1];
987     }
988     ts.last = last;
989     function singleOrUndefined(array) {
990         return array && array.length === 1
991             ? array[0]
992             : undefined;
993     }
994     ts.singleOrUndefined = singleOrUndefined;
995     function singleOrMany(array) {
996         return array && array.length === 1
997             ? array[0]
998             : array;
999     }
1000     ts.singleOrMany = singleOrMany;
1001     function replaceElement(array, index, value) {
1002         var result = array.slice(0);
1003         result[index] = value;
1004         return result;
1005     }
1006     ts.replaceElement = replaceElement;
1007     function binarySearch(array, value, keySelector, keyComparer, offset) {
1008         return binarySearchKey(array, keySelector(value), keySelector, keyComparer, offset);
1009     }
1010     ts.binarySearch = binarySearch;
1011     function binarySearchKey(array, key, keySelector, keyComparer, offset) {
1012         if (!some(array)) {
1013             return -1;
1014         }
1015         var low = offset || 0;
1016         var high = array.length - 1;
1017         while (low <= high) {
1018             var middle = low + ((high - low) >> 1);
1019             var midKey = keySelector(array[middle], middle);
1020             switch (keyComparer(midKey, key)) {
1021                 case -1:
1022                     low = middle + 1;
1023                     break;
1024                 case 0:
1025                     return middle;
1026                 case 1:
1027                     high = middle - 1;
1028                     break;
1029             }
1030         }
1031         return ~low;
1032     }
1033     ts.binarySearchKey = binarySearchKey;
1034     function reduceLeft(array, f, initial, start, count) {
1035         if (array && array.length > 0) {
1036             var size = array.length;
1037             if (size > 0) {
1038                 var pos = start === undefined || start < 0 ? 0 : start;
1039                 var end = count === undefined || pos + count > size - 1 ? size - 1 : pos + count;
1040                 var result = void 0;
1041                 if (arguments.length <= 2) {
1042                     result = array[pos];
1043                     pos++;
1044                 }
1045                 else {
1046                     result = initial;
1047                 }
1048                 while (pos <= end) {
1049                     result = f(result, array[pos], pos);
1050                     pos++;
1051                 }
1052                 return result;
1053             }
1054         }
1055         return initial;
1056     }
1057     ts.reduceLeft = reduceLeft;
1058     var hasOwnProperty = Object.prototype.hasOwnProperty;
1059     function hasProperty(map, key) {
1060         return hasOwnProperty.call(map, key);
1061     }
1062     ts.hasProperty = hasProperty;
1063     function getProperty(map, key) {
1064         return hasOwnProperty.call(map, key) ? map[key] : undefined;
1065     }
1066     ts.getProperty = getProperty;
1067     function getOwnKeys(map) {
1068         var keys = [];
1069         for (var key in map) {
1070             if (hasOwnProperty.call(map, key)) {
1071                 keys.push(key);
1072             }
1073         }
1074         return keys;
1075     }
1076     ts.getOwnKeys = getOwnKeys;
1077     function getAllKeys(obj) {
1078         var result = [];
1079         do {
1080             var names = Object.getOwnPropertyNames(obj);
1081             for (var _i = 0, names_1 = names; _i < names_1.length; _i++) {
1082                 var name = names_1[_i];
1083                 pushIfUnique(result, name);
1084             }
1085         } while (obj = Object.getPrototypeOf(obj));
1086         return result;
1087     }
1088     ts.getAllKeys = getAllKeys;
1089     function getOwnValues(sparseArray) {
1090         var values = [];
1091         for (var key in sparseArray) {
1092             if (hasOwnProperty.call(sparseArray, key)) {
1093                 values.push(sparseArray[key]);
1094             }
1095         }
1096         return values;
1097     }
1098     ts.getOwnValues = getOwnValues;
1099     var _entries = Object.entries || (function (obj) {
1100         var keys = getOwnKeys(obj);
1101         var result = Array(keys.length);
1102         for (var i = 0; i < keys.length; i++) {
1103             result[i] = [keys[i], obj[keys[i]]];
1104         }
1105         return result;
1106     });
1107     function getEntries(obj) {
1108         return obj ? _entries(obj) : [];
1109     }
1110     ts.getEntries = getEntries;
1111     function arrayOf(count, f) {
1112         var result = new Array(count);
1113         for (var i = 0; i < count; i++) {
1114             result[i] = f(i);
1115         }
1116         return result;
1117     }
1118     ts.arrayOf = arrayOf;
1119     function arrayFrom(iterator, map) {
1120         var result = [];
1121         for (var iterResult = iterator.next(); !iterResult.done; iterResult = iterator.next()) {
1122             result.push(map ? map(iterResult.value) : iterResult.value);
1123         }
1124         return result;
1125     }
1126     ts.arrayFrom = arrayFrom;
1127     function assign(t) {
1128         var args = [];
1129         for (var _i = 1; _i < arguments.length; _i++) {
1130             args[_i - 1] = arguments[_i];
1131         }
1132         for (var _a = 0, args_1 = args; _a < args_1.length; _a++) {
1133             var arg = args_1[_a];
1134             if (arg === undefined)
1135                 continue;
1136             for (var p in arg) {
1137                 if (hasProperty(arg, p)) {
1138                     t[p] = arg[p];
1139                 }
1140             }
1141         }
1142         return t;
1143     }
1144     ts.assign = assign;
1145     function equalOwnProperties(left, right, equalityComparer) {
1146         if (equalityComparer === void 0) { equalityComparer = equateValues; }
1147         if (left === right)
1148             return true;
1149         if (!left || !right)
1150             return false;
1151         for (var key in left) {
1152             if (hasOwnProperty.call(left, key)) {
1153                 if (!hasOwnProperty.call(right, key))
1154                     return false;
1155                 if (!equalityComparer(left[key], right[key]))
1156                     return false;
1157             }
1158         }
1159         for (var key in right) {
1160             if (hasOwnProperty.call(right, key)) {
1161                 if (!hasOwnProperty.call(left, key))
1162                     return false;
1163             }
1164         }
1165         return true;
1166     }
1167     ts.equalOwnProperties = equalOwnProperties;
1168     function arrayToMap(array, makeKey, makeValue) {
1169         if (makeValue === void 0) { makeValue = identity; }
1170         var result = new ts.Map();
1171         for (var _i = 0, array_6 = array; _i < array_6.length; _i++) {
1172             var value = array_6[_i];
1173             var key = makeKey(value);
1174             if (key !== undefined)
1175                 result.set(key, makeValue(value));
1176         }
1177         return result;
1178     }
1179     ts.arrayToMap = arrayToMap;
1180     function arrayToNumericMap(array, makeKey, makeValue) {
1181         if (makeValue === void 0) { makeValue = identity; }
1182         var result = [];
1183         for (var _i = 0, array_7 = array; _i < array_7.length; _i++) {
1184             var value = array_7[_i];
1185             result[makeKey(value)] = makeValue(value);
1186         }
1187         return result;
1188     }
1189     ts.arrayToNumericMap = arrayToNumericMap;
1190     function arrayToMultiMap(values, makeKey, makeValue) {
1191         if (makeValue === void 0) { makeValue = identity; }
1192         var result = createMultiMap();
1193         for (var _i = 0, values_1 = values; _i < values_1.length; _i++) {
1194             var value = values_1[_i];
1195             result.add(makeKey(value), makeValue(value));
1196         }
1197         return result;
1198     }
1199     ts.arrayToMultiMap = arrayToMultiMap;
1200     function group(values, getGroupId, resultSelector) {
1201         if (resultSelector === void 0) { resultSelector = identity; }
1202         return arrayFrom(arrayToMultiMap(values, getGroupId).values(), resultSelector);
1203     }
1204     ts.group = group;
1205     function clone(object) {
1206         var result = {};
1207         for (var id in object) {
1208             if (hasOwnProperty.call(object, id)) {
1209                 result[id] = object[id];
1210             }
1211         }
1212         return result;
1213     }
1214     ts.clone = clone;
1215     function extend(first, second) {
1216         var result = {};
1217         for (var id in second) {
1218             if (hasOwnProperty.call(second, id)) {
1219                 result[id] = second[id];
1220             }
1221         }
1222         for (var id in first) {
1223             if (hasOwnProperty.call(first, id)) {
1224                 result[id] = first[id];
1225             }
1226         }
1227         return result;
1228     }
1229     ts.extend = extend;
1230     function copyProperties(first, second) {
1231         for (var id in second) {
1232             if (hasOwnProperty.call(second, id)) {
1233                 first[id] = second[id];
1234             }
1235         }
1236     }
1237     ts.copyProperties = copyProperties;
1238     function maybeBind(obj, fn) {
1239         return fn ? fn.bind(obj) : undefined;
1240     }
1241     ts.maybeBind = maybeBind;
1242     function createMultiMap() {
1243         var map = new ts.Map();
1244         map.add = multiMapAdd;
1245         map.remove = multiMapRemove;
1246         return map;
1247     }
1248     ts.createMultiMap = createMultiMap;
1249     function multiMapAdd(key, value) {
1250         var values = this.get(key);
1251         if (values) {
1252             values.push(value);
1253         }
1254         else {
1255             this.set(key, values = [value]);
1256         }
1257         return values;
1258     }
1259     function multiMapRemove(key, value) {
1260         var values = this.get(key);
1261         if (values) {
1262             unorderedRemoveItem(values, value);
1263             if (!values.length) {
1264                 this.delete(key);
1265             }
1266         }
1267     }
1268     function createUnderscoreEscapedMultiMap() {
1269         return createMultiMap();
1270     }
1271     ts.createUnderscoreEscapedMultiMap = createUnderscoreEscapedMultiMap;
1272     function isArray(value) {
1273         return Array.isArray ? Array.isArray(value) : value instanceof Array;
1274     }
1275     ts.isArray = isArray;
1276     function toArray(value) {
1277         return isArray(value) ? value : [value];
1278     }
1279     ts.toArray = toArray;
1280     function isString(text) {
1281         return typeof text === "string";
1282     }
1283     ts.isString = isString;
1284     function isNumber(x) {
1285         return typeof x === "number";
1286     }
1287     ts.isNumber = isNumber;
1288     function tryCast(value, test) {
1289         return value !== undefined && test(value) ? value : undefined;
1290     }
1291     ts.tryCast = tryCast;
1292     function cast(value, test) {
1293         if (value !== undefined && test(value))
1294             return value;
1295         return ts.Debug.fail("Invalid cast. The supplied value " + value + " did not pass the test '" + ts.Debug.getFunctionName(test) + "'.");
1296     }
1297     ts.cast = cast;
1298     function noop(_) { }
1299     ts.noop = noop;
1300     function returnFalse() { return false; }
1301     ts.returnFalse = returnFalse;
1302     function returnTrue() { return true; }
1303     ts.returnTrue = returnTrue;
1304     function returnUndefined() { return undefined; }
1305     ts.returnUndefined = returnUndefined;
1306     function identity(x) { return x; }
1307     ts.identity = identity;
1308     function toLowerCase(x) { return x.toLowerCase(); }
1309     ts.toLowerCase = toLowerCase;
1310     var fileNameLowerCaseRegExp = /[^\u0130\u0131\u00DFa-z0-9\\/:\-_\. ]+/g;
1311     function toFileNameLowerCase(x) {
1312         return fileNameLowerCaseRegExp.test(x) ?
1313             x.replace(fileNameLowerCaseRegExp, toLowerCase) :
1314             x;
1315     }
1316     ts.toFileNameLowerCase = toFileNameLowerCase;
1317     function notImplemented() {
1318         throw new Error("Not implemented");
1319     }
1320     ts.notImplemented = notImplemented;
1321     function memoize(callback) {
1322         var value;
1323         return function () {
1324             if (callback) {
1325                 value = callback();
1326                 callback = undefined;
1327             }
1328             return value;
1329         };
1330     }
1331     ts.memoize = memoize;
1332     function memoizeOne(callback) {
1333         var map = new ts.Map();
1334         return function (arg) {
1335             var key = typeof arg + ":" + arg;
1336             var value = map.get(key);
1337             if (value === undefined && !map.has(key)) {
1338                 value = callback(arg);
1339                 map.set(key, value);
1340             }
1341             return value;
1342         };
1343     }
1344     ts.memoizeOne = memoizeOne;
1345     function compose(a, b, c, d, e) {
1346         if (!!e) {
1347             var args_2 = [];
1348             for (var i = 0; i < arguments.length; i++) {
1349                 args_2[i] = arguments[i];
1350             }
1351             return function (t) { return reduceLeft(args_2, function (u, f) { return f(u); }, t); };
1352         }
1353         else if (d) {
1354             return function (t) { return d(c(b(a(t)))); };
1355         }
1356         else if (c) {
1357             return function (t) { return c(b(a(t))); };
1358         }
1359         else if (b) {
1360             return function (t) { return b(a(t)); };
1361         }
1362         else if (a) {
1363             return function (t) { return a(t); };
1364         }
1365         else {
1366             return function (t) { return t; };
1367         }
1368     }
1369     ts.compose = compose;
1370     function equateValues(a, b) {
1371         return a === b;
1372     }
1373     ts.equateValues = equateValues;
1374     function equateStringsCaseInsensitive(a, b) {
1375         return a === b
1376             || a !== undefined
1377                 && b !== undefined
1378                 && a.toUpperCase() === b.toUpperCase();
1379     }
1380     ts.equateStringsCaseInsensitive = equateStringsCaseInsensitive;
1381     function equateStringsCaseSensitive(a, b) {
1382         return equateValues(a, b);
1383     }
1384     ts.equateStringsCaseSensitive = equateStringsCaseSensitive;
1385     function compareComparableValues(a, b) {
1386         return a === b ? 0 :
1387             a === undefined ? -1 :
1388                 b === undefined ? 1 :
1389                     a < b ? -1 :
1390                         1;
1391     }
1392     function compareValues(a, b) {
1393         return compareComparableValues(a, b);
1394     }
1395     ts.compareValues = compareValues;
1396     function compareTextSpans(a, b) {
1397         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);
1398     }
1399     ts.compareTextSpans = compareTextSpans;
1400     function min(a, b, compare) {
1401         return compare(a, b) === -1 ? a : b;
1402     }
1403     ts.min = min;
1404     function compareStringsCaseInsensitive(a, b) {
1405         if (a === b)
1406             return 0;
1407         if (a === undefined)
1408             return -1;
1409         if (b === undefined)
1410             return 1;
1411         a = a.toUpperCase();
1412         b = b.toUpperCase();
1413         return a < b ? -1 : a > b ? 1 : 0;
1414     }
1415     ts.compareStringsCaseInsensitive = compareStringsCaseInsensitive;
1416     function compareStringsCaseSensitive(a, b) {
1417         return compareComparableValues(a, b);
1418     }
1419     ts.compareStringsCaseSensitive = compareStringsCaseSensitive;
1420     function getStringComparer(ignoreCase) {
1421         return ignoreCase ? compareStringsCaseInsensitive : compareStringsCaseSensitive;
1422     }
1423     ts.getStringComparer = getStringComparer;
1424     var createUIStringComparer = (function () {
1425         var defaultComparer;
1426         var enUSComparer;
1427         var stringComparerFactory = getStringComparerFactory();
1428         return createStringComparer;
1429         function compareWithCallback(a, b, comparer) {
1430             if (a === b)
1431                 return 0;
1432             if (a === undefined)
1433                 return -1;
1434             if (b === undefined)
1435                 return 1;
1436             var value = comparer(a, b);
1437             return value < 0 ? -1 : value > 0 ? 1 : 0;
1438         }
1439         function createIntlCollatorStringComparer(locale) {
1440             var comparer = new Intl.Collator(locale, { usage: "sort", sensitivity: "variant" }).compare;
1441             return function (a, b) { return compareWithCallback(a, b, comparer); };
1442         }
1443         function createLocaleCompareStringComparer(locale) {
1444             if (locale !== undefined)
1445                 return createFallbackStringComparer();
1446             return function (a, b) { return compareWithCallback(a, b, compareStrings); };
1447             function compareStrings(a, b) {
1448                 return a.localeCompare(b);
1449             }
1450         }
1451         function createFallbackStringComparer() {
1452             return function (a, b) { return compareWithCallback(a, b, compareDictionaryOrder); };
1453             function compareDictionaryOrder(a, b) {
1454                 return compareStrings(a.toUpperCase(), b.toUpperCase()) || compareStrings(a, b);
1455             }
1456             function compareStrings(a, b) {
1457                 return a < b ? -1 : a > b ? 1 : 0;
1458             }
1459         }
1460         function getStringComparerFactory() {
1461             if (typeof Intl === "object" && typeof Intl.Collator === "function") {
1462                 return createIntlCollatorStringComparer;
1463             }
1464             if (typeof String.prototype.localeCompare === "function" &&
1465                 typeof String.prototype.toLocaleUpperCase === "function" &&
1466                 "a".localeCompare("B") < 0) {
1467                 return createLocaleCompareStringComparer;
1468             }
1469             return createFallbackStringComparer;
1470         }
1471         function createStringComparer(locale) {
1472             if (locale === undefined) {
1473                 return defaultComparer || (defaultComparer = stringComparerFactory(locale));
1474             }
1475             else if (locale === "en-US") {
1476                 return enUSComparer || (enUSComparer = stringComparerFactory(locale));
1477             }
1478             else {
1479                 return stringComparerFactory(locale);
1480             }
1481         }
1482     })();
1483     var uiComparerCaseSensitive;
1484     var uiLocale;
1485     function getUILocale() {
1486         return uiLocale;
1487     }
1488     ts.getUILocale = getUILocale;
1489     function setUILocale(value) {
1490         if (uiLocale !== value) {
1491             uiLocale = value;
1492             uiComparerCaseSensitive = undefined;
1493         }
1494     }
1495     ts.setUILocale = setUILocale;
1496     function compareStringsCaseSensitiveUI(a, b) {
1497         var comparer = uiComparerCaseSensitive || (uiComparerCaseSensitive = createUIStringComparer(uiLocale));
1498         return comparer(a, b);
1499     }
1500     ts.compareStringsCaseSensitiveUI = compareStringsCaseSensitiveUI;
1501     function compareProperties(a, b, key, comparer) {
1502         return a === b ? 0 :
1503             a === undefined ? -1 :
1504                 b === undefined ? 1 :
1505                     comparer(a[key], b[key]);
1506     }
1507     ts.compareProperties = compareProperties;
1508     function compareBooleans(a, b) {
1509         return compareValues(a ? 1 : 0, b ? 1 : 0);
1510     }
1511     ts.compareBooleans = compareBooleans;
1512     function getSpellingSuggestion(name, candidates, getName) {
1513         var maximumLengthDifference = Math.min(2, Math.floor(name.length * 0.34));
1514         var bestDistance = Math.floor(name.length * 0.4) + 1;
1515         var bestCandidate;
1516         var justCheckExactMatches = false;
1517         var nameLowerCase = name.toLowerCase();
1518         for (var _i = 0, candidates_1 = candidates; _i < candidates_1.length; _i++) {
1519             var candidate = candidates_1[_i];
1520             var candidateName = getName(candidate);
1521             if (candidateName !== undefined && Math.abs(candidateName.length - nameLowerCase.length) <= maximumLengthDifference) {
1522                 var candidateNameLowerCase = candidateName.toLowerCase();
1523                 if (candidateNameLowerCase === nameLowerCase) {
1524                     if (candidateName === name) {
1525                         continue;
1526                     }
1527                     return candidate;
1528                 }
1529                 if (justCheckExactMatches) {
1530                     continue;
1531                 }
1532                 if (candidateName.length < 3) {
1533                     continue;
1534                 }
1535                 var distance = levenshteinWithMax(nameLowerCase, candidateNameLowerCase, bestDistance - 1);
1536                 if (distance === undefined) {
1537                     continue;
1538                 }
1539                 if (distance < 3) {
1540                     justCheckExactMatches = true;
1541                     bestCandidate = candidate;
1542                 }
1543                 else {
1544                     ts.Debug.assert(distance < bestDistance);
1545                     bestDistance = distance;
1546                     bestCandidate = candidate;
1547                 }
1548             }
1549         }
1550         return bestCandidate;
1551     }
1552     ts.getSpellingSuggestion = getSpellingSuggestion;
1553     function levenshteinWithMax(s1, s2, max) {
1554         var previous = new Array(s2.length + 1);
1555         var current = new Array(s2.length + 1);
1556         var big = max + 1;
1557         for (var i = 0; i <= s2.length; i++) {
1558             previous[i] = i;
1559         }
1560         for (var i = 1; i <= s1.length; i++) {
1561             var c1 = s1.charCodeAt(i - 1);
1562             var minJ = i > max ? i - max : 1;
1563             var maxJ = s2.length > max + i ? max + i : s2.length;
1564             current[0] = i;
1565             var colMin = i;
1566             for (var j = 1; j < minJ; j++) {
1567                 current[j] = big;
1568             }
1569             for (var j = minJ; j <= maxJ; j++) {
1570                 var dist = c1 === s2.charCodeAt(j - 1)
1571                     ? previous[j - 1]
1572                     : Math.min(previous[j] + 1, current[j - 1] + 1, previous[j - 1] + 2);
1573                 current[j] = dist;
1574                 colMin = Math.min(colMin, dist);
1575             }
1576             for (var j = maxJ + 1; j <= s2.length; j++) {
1577                 current[j] = big;
1578             }
1579             if (colMin > max) {
1580                 return undefined;
1581             }
1582             var temp = previous;
1583             previous = current;
1584             current = temp;
1585         }
1586         var res = previous[s2.length];
1587         return res > max ? undefined : res;
1588     }
1589     function endsWith(str, suffix) {
1590         var expectedPos = str.length - suffix.length;
1591         return expectedPos >= 0 && str.indexOf(suffix, expectedPos) === expectedPos;
1592     }
1593     ts.endsWith = endsWith;
1594     function removeSuffix(str, suffix) {
1595         return endsWith(str, suffix) ? str.slice(0, str.length - suffix.length) : str;
1596     }
1597     ts.removeSuffix = removeSuffix;
1598     function tryRemoveSuffix(str, suffix) {
1599         return endsWith(str, suffix) ? str.slice(0, str.length - suffix.length) : undefined;
1600     }
1601     ts.tryRemoveSuffix = tryRemoveSuffix;
1602     function stringContains(str, substring) {
1603         return str.indexOf(substring) !== -1;
1604     }
1605     ts.stringContains = stringContains;
1606     function removeMinAndVersionNumbers(fileName) {
1607         var trailingMinOrVersion = /[.-]((min)|(\d+(\.\d+)*))$/;
1608         return fileName.replace(trailingMinOrVersion, "").replace(trailingMinOrVersion, "");
1609     }
1610     ts.removeMinAndVersionNumbers = removeMinAndVersionNumbers;
1611     function orderedRemoveItem(array, item) {
1612         for (var i = 0; i < array.length; i++) {
1613             if (array[i] === item) {
1614                 orderedRemoveItemAt(array, i);
1615                 return true;
1616             }
1617         }
1618         return false;
1619     }
1620     ts.orderedRemoveItem = orderedRemoveItem;
1621     function orderedRemoveItemAt(array, index) {
1622         for (var i = index; i < array.length - 1; i++) {
1623             array[i] = array[i + 1];
1624         }
1625         array.pop();
1626     }
1627     ts.orderedRemoveItemAt = orderedRemoveItemAt;
1628     function unorderedRemoveItemAt(array, index) {
1629         array[index] = array[array.length - 1];
1630         array.pop();
1631     }
1632     ts.unorderedRemoveItemAt = unorderedRemoveItemAt;
1633     function unorderedRemoveItem(array, item) {
1634         return unorderedRemoveFirstItemWhere(array, function (element) { return element === item; });
1635     }
1636     ts.unorderedRemoveItem = unorderedRemoveItem;
1637     function unorderedRemoveFirstItemWhere(array, predicate) {
1638         for (var i = 0; i < array.length; i++) {
1639             if (predicate(array[i])) {
1640                 unorderedRemoveItemAt(array, i);
1641                 return true;
1642             }
1643         }
1644         return false;
1645     }
1646     function createGetCanonicalFileName(useCaseSensitiveFileNames) {
1647         return useCaseSensitiveFileNames ? identity : toFileNameLowerCase;
1648     }
1649     ts.createGetCanonicalFileName = createGetCanonicalFileName;
1650     function patternText(_a) {
1651         var prefix = _a.prefix, suffix = _a.suffix;
1652         return prefix + "*" + suffix;
1653     }
1654     ts.patternText = patternText;
1655     function matchedText(pattern, candidate) {
1656         ts.Debug.assert(isPatternMatch(pattern, candidate));
1657         return candidate.substring(pattern.prefix.length, candidate.length - pattern.suffix.length);
1658     }
1659     ts.matchedText = matchedText;
1660     function findBestPatternMatch(values, getPattern, candidate) {
1661         var matchedValue;
1662         var longestMatchPrefixLength = -1;
1663         for (var _i = 0, values_2 = values; _i < values_2.length; _i++) {
1664             var v = values_2[_i];
1665             var pattern = getPattern(v);
1666             if (isPatternMatch(pattern, candidate) && pattern.prefix.length > longestMatchPrefixLength) {
1667                 longestMatchPrefixLength = pattern.prefix.length;
1668                 matchedValue = v;
1669             }
1670         }
1671         return matchedValue;
1672     }
1673     ts.findBestPatternMatch = findBestPatternMatch;
1674     function startsWith(str, prefix) {
1675         return str.lastIndexOf(prefix, 0) === 0;
1676     }
1677     ts.startsWith = startsWith;
1678     function removePrefix(str, prefix) {
1679         return startsWith(str, prefix) ? str.substr(prefix.length) : str;
1680     }
1681     ts.removePrefix = removePrefix;
1682     function tryRemovePrefix(str, prefix, getCanonicalFileName) {
1683         if (getCanonicalFileName === void 0) { getCanonicalFileName = identity; }
1684         return startsWith(getCanonicalFileName(str), getCanonicalFileName(prefix)) ? str.substring(prefix.length) : undefined;
1685     }
1686     ts.tryRemovePrefix = tryRemovePrefix;
1687     function isPatternMatch(_a, candidate) {
1688         var prefix = _a.prefix, suffix = _a.suffix;
1689         return candidate.length >= prefix.length + suffix.length &&
1690             startsWith(candidate, prefix) &&
1691             endsWith(candidate, suffix);
1692     }
1693     function and(f, g) {
1694         return function (arg) { return f(arg) && g(arg); };
1695     }
1696     ts.and = and;
1697     function or() {
1698         var fs = [];
1699         for (var _i = 0; _i < arguments.length; _i++) {
1700             fs[_i] = arguments[_i];
1701         }
1702         return function () {
1703             var args = [];
1704             for (var _i = 0; _i < arguments.length; _i++) {
1705                 args[_i] = arguments[_i];
1706             }
1707             for (var _a = 0, fs_1 = fs; _a < fs_1.length; _a++) {
1708                 var f = fs_1[_a];
1709                 if (f.apply(void 0, args)) {
1710                     return true;
1711                 }
1712             }
1713             return false;
1714         };
1715     }
1716     ts.or = or;
1717     function not(fn) {
1718         return function () {
1719             var args = [];
1720             for (var _i = 0; _i < arguments.length; _i++) {
1721                 args[_i] = arguments[_i];
1722             }
1723             return !fn.apply(void 0, args);
1724         };
1725     }
1726     ts.not = not;
1727     function assertType(_) { }
1728     ts.assertType = assertType;
1729     function singleElementArray(t) {
1730         return t === undefined ? undefined : [t];
1731     }
1732     ts.singleElementArray = singleElementArray;
1733     function enumerateInsertsAndDeletes(newItems, oldItems, comparer, inserted, deleted, unchanged) {
1734         unchanged = unchanged || noop;
1735         var newIndex = 0;
1736         var oldIndex = 0;
1737         var newLen = newItems.length;
1738         var oldLen = oldItems.length;
1739         var hasChanges = false;
1740         while (newIndex < newLen && oldIndex < oldLen) {
1741             var newItem = newItems[newIndex];
1742             var oldItem = oldItems[oldIndex];
1743             var compareResult = comparer(newItem, oldItem);
1744             if (compareResult === -1) {
1745                 inserted(newItem);
1746                 newIndex++;
1747                 hasChanges = true;
1748             }
1749             else if (compareResult === 1) {
1750                 deleted(oldItem);
1751                 oldIndex++;
1752                 hasChanges = true;
1753             }
1754             else {
1755                 unchanged(oldItem, newItem);
1756                 newIndex++;
1757                 oldIndex++;
1758             }
1759         }
1760         while (newIndex < newLen) {
1761             inserted(newItems[newIndex++]);
1762             hasChanges = true;
1763         }
1764         while (oldIndex < oldLen) {
1765             deleted(oldItems[oldIndex++]);
1766             hasChanges = true;
1767         }
1768         return hasChanges;
1769     }
1770     ts.enumerateInsertsAndDeletes = enumerateInsertsAndDeletes;
1771     function fill(length, cb) {
1772         var result = Array(length);
1773         for (var i = 0; i < length; i++) {
1774             result[i] = cb(i);
1775         }
1776         return result;
1777     }
1778     ts.fill = fill;
1779     function cartesianProduct(arrays) {
1780         var result = [];
1781         cartesianProductWorker(arrays, result, undefined, 0);
1782         return result;
1783     }
1784     ts.cartesianProduct = cartesianProduct;
1785     function cartesianProductWorker(arrays, result, outer, index) {
1786         for (var _i = 0, _a = arrays[index]; _i < _a.length; _i++) {
1787             var element = _a[_i];
1788             var inner = void 0;
1789             if (outer) {
1790                 inner = outer.slice();
1791                 inner.push(element);
1792             }
1793             else {
1794                 inner = [element];
1795             }
1796             if (index === arrays.length - 1) {
1797                 result.push(inner);
1798             }
1799             else {
1800                 cartesianProductWorker(arrays, result, inner, index + 1);
1801             }
1802         }
1803     }
1804     function padLeft(s, length, padString) {
1805         if (padString === void 0) { padString = " "; }
1806         return length <= s.length ? s : padString.repeat(length - s.length) + s;
1807     }
1808     ts.padLeft = padLeft;
1809     function padRight(s, length, padString) {
1810         if (padString === void 0) { padString = " "; }
1811         return length <= s.length ? s : s + padString.repeat(length - s.length);
1812     }
1813     ts.padRight = padRight;
1814     function takeWhile(array, predicate) {
1815         var len = array.length;
1816         var index = 0;
1817         while (index < len && predicate(array[index])) {
1818             index++;
1819         }
1820         return array.slice(0, index);
1821     }
1822     ts.takeWhile = takeWhile;
1823 })(ts || (ts = {}));
1824 var ts;
1825 (function (ts) {
1826     var LogLevel;
1827     (function (LogLevel) {
1828         LogLevel[LogLevel["Off"] = 0] = "Off";
1829         LogLevel[LogLevel["Error"] = 1] = "Error";
1830         LogLevel[LogLevel["Warning"] = 2] = "Warning";
1831         LogLevel[LogLevel["Info"] = 3] = "Info";
1832         LogLevel[LogLevel["Verbose"] = 4] = "Verbose";
1833     })(LogLevel = ts.LogLevel || (ts.LogLevel = {}));
1834     var Debug;
1835     (function (Debug) {
1836         var typeScriptVersion;
1837         var currentAssertionLevel = 0;
1838         Debug.currentLogLevel = LogLevel.Warning;
1839         Debug.isDebugging = false;
1840         function getTypeScriptVersion() {
1841             return typeScriptVersion !== null && typeScriptVersion !== void 0 ? typeScriptVersion : (typeScriptVersion = new ts.Version(ts.version));
1842         }
1843         Debug.getTypeScriptVersion = getTypeScriptVersion;
1844         function shouldLog(level) {
1845             return Debug.currentLogLevel <= level;
1846         }
1847         Debug.shouldLog = shouldLog;
1848         function logMessage(level, s) {
1849             if (Debug.loggingHost && shouldLog(level)) {
1850                 Debug.loggingHost.log(level, s);
1851             }
1852         }
1853         function log(s) {
1854             logMessage(LogLevel.Info, s);
1855         }
1856         Debug.log = log;
1857         (function (log_1) {
1858             function error(s) {
1859                 logMessage(LogLevel.Error, s);
1860             }
1861             log_1.error = error;
1862             function warn(s) {
1863                 logMessage(LogLevel.Warning, s);
1864             }
1865             log_1.warn = warn;
1866             function log(s) {
1867                 logMessage(LogLevel.Info, s);
1868             }
1869             log_1.log = log;
1870             function trace(s) {
1871                 logMessage(LogLevel.Verbose, s);
1872             }
1873             log_1.trace = trace;
1874         })(log = Debug.log || (Debug.log = {}));
1875         var assertionCache = {};
1876         function getAssertionLevel() {
1877             return currentAssertionLevel;
1878         }
1879         Debug.getAssertionLevel = getAssertionLevel;
1880         function setAssertionLevel(level) {
1881             var prevAssertionLevel = currentAssertionLevel;
1882             currentAssertionLevel = level;
1883             if (level > prevAssertionLevel) {
1884                 for (var _i = 0, _a = ts.getOwnKeys(assertionCache); _i < _a.length; _i++) {
1885                     var key = _a[_i];
1886                     var cachedFunc = assertionCache[key];
1887                     if (cachedFunc !== undefined && Debug[key] !== cachedFunc.assertion && level >= cachedFunc.level) {
1888                         Debug[key] = cachedFunc;
1889                         assertionCache[key] = undefined;
1890                     }
1891                 }
1892             }
1893         }
1894         Debug.setAssertionLevel = setAssertionLevel;
1895         function shouldAssert(level) {
1896             return currentAssertionLevel >= level;
1897         }
1898         Debug.shouldAssert = shouldAssert;
1899         function shouldAssertFunction(level, name) {
1900             if (!shouldAssert(level)) {
1901                 assertionCache[name] = { level: level, assertion: Debug[name] };
1902                 Debug[name] = ts.noop;
1903                 return false;
1904             }
1905             return true;
1906         }
1907         function fail(message, stackCrawlMark) {
1908             debugger;
1909             var e = new Error(message ? "Debug Failure. " + message : "Debug Failure.");
1910             if (Error.captureStackTrace) {
1911                 Error.captureStackTrace(e, stackCrawlMark || fail);
1912             }
1913             throw e;
1914         }
1915         Debug.fail = fail;
1916         function failBadSyntaxKind(node, message, stackCrawlMark) {
1917             return fail((message || "Unexpected node.") + "\r\nNode " + formatSyntaxKind(node.kind) + " was unexpected.", stackCrawlMark || failBadSyntaxKind);
1918         }
1919         Debug.failBadSyntaxKind = failBadSyntaxKind;
1920         function assert(expression, message, verboseDebugInfo, stackCrawlMark) {
1921             if (!expression) {
1922                 message = message ? "False expression: " + message : "False expression.";
1923                 if (verboseDebugInfo) {
1924                     message += "\r\nVerbose Debug Information: " + (typeof verboseDebugInfo === "string" ? verboseDebugInfo : verboseDebugInfo());
1925                 }
1926                 fail(message, stackCrawlMark || assert);
1927             }
1928         }
1929         Debug.assert = assert;
1930         function assertEqual(a, b, msg, msg2, stackCrawlMark) {
1931             if (a !== b) {
1932                 var message = msg ? msg2 ? msg + " " + msg2 : msg : "";
1933                 fail("Expected " + a + " === " + b + ". " + message, stackCrawlMark || assertEqual);
1934             }
1935         }
1936         Debug.assertEqual = assertEqual;
1937         function assertLessThan(a, b, msg, stackCrawlMark) {
1938             if (a >= b) {
1939                 fail("Expected " + a + " < " + b + ". " + (msg || ""), stackCrawlMark || assertLessThan);
1940             }
1941         }
1942         Debug.assertLessThan = assertLessThan;
1943         function assertLessThanOrEqual(a, b, stackCrawlMark) {
1944             if (a > b) {
1945                 fail("Expected " + a + " <= " + b, stackCrawlMark || assertLessThanOrEqual);
1946             }
1947         }
1948         Debug.assertLessThanOrEqual = assertLessThanOrEqual;
1949         function assertGreaterThanOrEqual(a, b, stackCrawlMark) {
1950             if (a < b) {
1951                 fail("Expected " + a + " >= " + b, stackCrawlMark || assertGreaterThanOrEqual);
1952             }
1953         }
1954         Debug.assertGreaterThanOrEqual = assertGreaterThanOrEqual;
1955         function assertIsDefined(value, message, stackCrawlMark) {
1956             if (value === undefined || value === null) {
1957                 fail(message, stackCrawlMark || assertIsDefined);
1958             }
1959         }
1960         Debug.assertIsDefined = assertIsDefined;
1961         function checkDefined(value, message, stackCrawlMark) {
1962             assertIsDefined(value, message, stackCrawlMark || checkDefined);
1963             return value;
1964         }
1965         Debug.checkDefined = checkDefined;
1966         Debug.assertDefined = checkDefined;
1967         function assertEachIsDefined(value, message, stackCrawlMark) {
1968             for (var _i = 0, value_1 = value; _i < value_1.length; _i++) {
1969                 var v = value_1[_i];
1970                 assertIsDefined(v, message, stackCrawlMark || assertEachIsDefined);
1971             }
1972         }
1973         Debug.assertEachIsDefined = assertEachIsDefined;
1974         function checkEachDefined(value, message, stackCrawlMark) {
1975             assertEachIsDefined(value, message, stackCrawlMark || checkEachDefined);
1976             return value;
1977         }
1978         Debug.checkEachDefined = checkEachDefined;
1979         Debug.assertEachDefined = checkEachDefined;
1980         function assertNever(member, message, stackCrawlMark) {
1981             if (message === void 0) { message = "Illegal value:"; }
1982             var detail = typeof member === "object" && ts.hasProperty(member, "kind") && ts.hasProperty(member, "pos") && formatSyntaxKind ? "SyntaxKind: " + formatSyntaxKind(member.kind) : JSON.stringify(member);
1983             return fail(message + " " + detail, stackCrawlMark || assertNever);
1984         }
1985         Debug.assertNever = assertNever;
1986         function assertEachNode(nodes, test, message, stackCrawlMark) {
1987             if (shouldAssertFunction(1, "assertEachNode")) {
1988                 assert(test === undefined || ts.every(nodes, test), message || "Unexpected node.", function () { return "Node array did not pass test '" + getFunctionName(test) + "'."; }, stackCrawlMark || assertEachNode);
1989             }
1990         }
1991         Debug.assertEachNode = assertEachNode;
1992         function assertNode(node, test, message, stackCrawlMark) {
1993             if (shouldAssertFunction(1, "assertNode")) {
1994                 assert(node !== undefined && (test === undefined || test(node)), message || "Unexpected node.", function () { return "Node " + formatSyntaxKind(node.kind) + " did not pass test '" + getFunctionName(test) + "'."; }, stackCrawlMark || assertNode);
1995             }
1996         }
1997         Debug.assertNode = assertNode;
1998         function assertNotNode(node, test, message, stackCrawlMark) {
1999             if (shouldAssertFunction(1, "assertNotNode")) {
2000                 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);
2001             }
2002         }
2003         Debug.assertNotNode = assertNotNode;
2004         function assertOptionalNode(node, test, message, stackCrawlMark) {
2005             if (shouldAssertFunction(1, "assertOptionalNode")) {
2006                 assert(test === undefined || node === undefined || test(node), message || "Unexpected node.", function () { return "Node " + formatSyntaxKind(node.kind) + " did not pass test '" + getFunctionName(test) + "'."; }, stackCrawlMark || assertOptionalNode);
2007             }
2008         }
2009         Debug.assertOptionalNode = assertOptionalNode;
2010         function assertOptionalToken(node, kind, message, stackCrawlMark) {
2011             if (shouldAssertFunction(1, "assertOptionalToken")) {
2012                 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);
2013             }
2014         }
2015         Debug.assertOptionalToken = assertOptionalToken;
2016         function assertMissingNode(node, message, stackCrawlMark) {
2017             if (shouldAssertFunction(1, "assertMissingNode")) {
2018                 assert(node === undefined, message || "Unexpected node.", function () { return "Node " + formatSyntaxKind(node.kind) + " was unexpected'."; }, stackCrawlMark || assertMissingNode);
2019             }
2020         }
2021         Debug.assertMissingNode = assertMissingNode;
2022         function getFunctionName(func) {
2023             if (typeof func !== "function") {
2024                 return "";
2025             }
2026             else if (func.hasOwnProperty("name")) {
2027                 return func.name;
2028             }
2029             else {
2030                 var text = Function.prototype.toString.call(func);
2031                 var match = /^function\s+([\w\$]+)\s*\(/.exec(text);
2032                 return match ? match[1] : "";
2033             }
2034         }
2035         Debug.getFunctionName = getFunctionName;
2036         function formatSymbol(symbol) {
2037             return "{ name: " + ts.unescapeLeadingUnderscores(symbol.escapedName) + "; flags: " + formatSymbolFlags(symbol.flags) + "; declarations: " + ts.map(symbol.declarations, function (node) { return formatSyntaxKind(node.kind); }) + " }";
2038         }
2039         Debug.formatSymbol = formatSymbol;
2040         function formatEnum(value, enumObject, isFlags) {
2041             if (value === void 0) { value = 0; }
2042             var members = getEnumMembers(enumObject);
2043             if (value === 0) {
2044                 return members.length > 0 && members[0][0] === 0 ? members[0][1] : "0";
2045             }
2046             if (isFlags) {
2047                 var result = "";
2048                 var remainingFlags = value;
2049                 for (var _i = 0, members_1 = members; _i < members_1.length; _i++) {
2050                     var _a = members_1[_i], enumValue = _a[0], enumName = _a[1];
2051                     if (enumValue > value) {
2052                         break;
2053                     }
2054                     if (enumValue !== 0 && enumValue & value) {
2055                         result = "" + result + (result ? "|" : "") + enumName;
2056                         remainingFlags &= ~enumValue;
2057                     }
2058                 }
2059                 if (remainingFlags === 0) {
2060                     return result;
2061                 }
2062             }
2063             else {
2064                 for (var _b = 0, members_2 = members; _b < members_2.length; _b++) {
2065                     var _c = members_2[_b], enumValue = _c[0], enumName = _c[1];
2066                     if (enumValue === value) {
2067                         return enumName;
2068                     }
2069                 }
2070             }
2071             return value.toString();
2072         }
2073         Debug.formatEnum = formatEnum;
2074         function getEnumMembers(enumObject) {
2075             var result = [];
2076             for (var name in enumObject) {
2077                 var value = enumObject[name];
2078                 if (typeof value === "number") {
2079                     result.push([value, name]);
2080                 }
2081             }
2082             return ts.stableSort(result, function (x, y) { return ts.compareValues(x[0], y[0]); });
2083         }
2084         function formatSyntaxKind(kind) {
2085             return formatEnum(kind, ts.SyntaxKind, false);
2086         }
2087         Debug.formatSyntaxKind = formatSyntaxKind;
2088         function formatNodeFlags(flags) {
2089             return formatEnum(flags, ts.NodeFlags, true);
2090         }
2091         Debug.formatNodeFlags = formatNodeFlags;
2092         function formatModifierFlags(flags) {
2093             return formatEnum(flags, ts.ModifierFlags, true);
2094         }
2095         Debug.formatModifierFlags = formatModifierFlags;
2096         function formatTransformFlags(flags) {
2097             return formatEnum(flags, ts.TransformFlags, true);
2098         }
2099         Debug.formatTransformFlags = formatTransformFlags;
2100         function formatEmitFlags(flags) {
2101             return formatEnum(flags, ts.EmitFlags, true);
2102         }
2103         Debug.formatEmitFlags = formatEmitFlags;
2104         function formatSymbolFlags(flags) {
2105             return formatEnum(flags, ts.SymbolFlags, true);
2106         }
2107         Debug.formatSymbolFlags = formatSymbolFlags;
2108         function formatTypeFlags(flags) {
2109             return formatEnum(flags, ts.TypeFlags, true);
2110         }
2111         Debug.formatTypeFlags = formatTypeFlags;
2112         function formatObjectFlags(flags) {
2113             return formatEnum(flags, ts.ObjectFlags, true);
2114         }
2115         Debug.formatObjectFlags = formatObjectFlags;
2116         function formatFlowFlags(flags) {
2117             return formatEnum(flags, ts.FlowFlags, true);
2118         }
2119         Debug.formatFlowFlags = formatFlowFlags;
2120         var isDebugInfoEnabled = false;
2121         var extendedDebugModule;
2122         function extendedDebug() {
2123             enableDebugInfo();
2124             if (!extendedDebugModule) {
2125                 throw new Error("Debugging helpers could not be loaded.");
2126             }
2127             return extendedDebugModule;
2128         }
2129         function printControlFlowGraph(flowNode) {
2130             return console.log(formatControlFlowGraph(flowNode));
2131         }
2132         Debug.printControlFlowGraph = printControlFlowGraph;
2133         function formatControlFlowGraph(flowNode) {
2134             return extendedDebug().formatControlFlowGraph(flowNode);
2135         }
2136         Debug.formatControlFlowGraph = formatControlFlowGraph;
2137         var flowNodeProto;
2138         function attachFlowNodeDebugInfoWorker(flowNode) {
2139             if (!("__debugFlowFlags" in flowNode)) {
2140                 Object.defineProperties(flowNode, {
2141                     __tsDebuggerDisplay: {
2142                         value: function () {
2143                             var flowHeader = this.flags & 2 ? "FlowStart" :
2144                                 this.flags & 4 ? "FlowBranchLabel" :
2145                                     this.flags & 8 ? "FlowLoopLabel" :
2146                                         this.flags & 16 ? "FlowAssignment" :
2147                                             this.flags & 32 ? "FlowTrueCondition" :
2148                                                 this.flags & 64 ? "FlowFalseCondition" :
2149                                                     this.flags & 128 ? "FlowSwitchClause" :
2150                                                         this.flags & 256 ? "FlowArrayMutation" :
2151                                                             this.flags & 512 ? "FlowCall" :
2152                                                                 this.flags & 1024 ? "FlowReduceLabel" :
2153                                                                     this.flags & 1 ? "FlowUnreachable" :
2154                                                                         "UnknownFlow";
2155                             var remainingFlags = this.flags & ~(2048 - 1);
2156                             return "" + flowHeader + (remainingFlags ? " (" + formatFlowFlags(remainingFlags) + ")" : "");
2157                         }
2158                     },
2159                     __debugFlowFlags: { get: function () { return formatEnum(this.flags, ts.FlowFlags, true); } },
2160                     __debugToString: { value: function () { return formatControlFlowGraph(this); } }
2161                 });
2162             }
2163         }
2164         function attachFlowNodeDebugInfo(flowNode) {
2165             if (isDebugInfoEnabled) {
2166                 if (typeof Object.setPrototypeOf === "function") {
2167                     if (!flowNodeProto) {
2168                         flowNodeProto = Object.create(Object.prototype);
2169                         attachFlowNodeDebugInfoWorker(flowNodeProto);
2170                     }
2171                     Object.setPrototypeOf(flowNode, flowNodeProto);
2172                 }
2173                 else {
2174                     attachFlowNodeDebugInfoWorker(flowNode);
2175                 }
2176             }
2177         }
2178         Debug.attachFlowNodeDebugInfo = attachFlowNodeDebugInfo;
2179         var nodeArrayProto;
2180         function attachNodeArrayDebugInfoWorker(array) {
2181             if (!("__tsDebuggerDisplay" in array)) {
2182                 Object.defineProperties(array, {
2183                     __tsDebuggerDisplay: {
2184                         value: function (defaultValue) {
2185                             defaultValue = String(defaultValue).replace(/(?:,[\s\w\d_]+:[^,]+)+\]$/, "]");
2186                             return "NodeArray " + defaultValue;
2187                         }
2188                     }
2189                 });
2190             }
2191         }
2192         function attachNodeArrayDebugInfo(array) {
2193             if (isDebugInfoEnabled) {
2194                 if (typeof Object.setPrototypeOf === "function") {
2195                     if (!nodeArrayProto) {
2196                         nodeArrayProto = Object.create(Array.prototype);
2197                         attachNodeArrayDebugInfoWorker(nodeArrayProto);
2198                     }
2199                     Object.setPrototypeOf(array, nodeArrayProto);
2200                 }
2201                 else {
2202                     attachNodeArrayDebugInfoWorker(array);
2203                 }
2204             }
2205         }
2206         Debug.attachNodeArrayDebugInfo = attachNodeArrayDebugInfo;
2207         function enableDebugInfo() {
2208             if (isDebugInfoEnabled)
2209                 return;
2210             var weakTypeTextMap;
2211             var weakNodeTextMap;
2212             function getWeakTypeTextMap() {
2213                 if (weakTypeTextMap === undefined) {
2214                     if (typeof WeakMap === "function")
2215                         weakTypeTextMap = new WeakMap();
2216                 }
2217                 return weakTypeTextMap;
2218             }
2219             function getWeakNodeTextMap() {
2220                 if (weakNodeTextMap === undefined) {
2221                     if (typeof WeakMap === "function")
2222                         weakNodeTextMap = new WeakMap();
2223                 }
2224                 return weakNodeTextMap;
2225             }
2226             Object.defineProperties(ts.objectAllocator.getSymbolConstructor().prototype, {
2227                 __tsDebuggerDisplay: {
2228                     value: function () {
2229                         var symbolHeader = this.flags & 33554432 ? "TransientSymbol" :
2230                             "Symbol";
2231                         var remainingSymbolFlags = this.flags & ~33554432;
2232                         return symbolHeader + " '" + ts.symbolName(this) + "'" + (remainingSymbolFlags ? " (" + formatSymbolFlags(remainingSymbolFlags) + ")" : "");
2233                     }
2234                 },
2235                 __debugFlags: { get: function () { return formatSymbolFlags(this.flags); } }
2236             });
2237             Object.defineProperties(ts.objectAllocator.getTypeConstructor().prototype, {
2238                 __tsDebuggerDisplay: {
2239                     value: function () {
2240                         var typeHeader = this.flags & 98304 ? "NullableType" :
2241                             this.flags & 384 ? "LiteralType " + JSON.stringify(this.value) :
2242                                 this.flags & 2048 ? "LiteralType " + (this.value.negative ? "-" : "") + this.value.base10Value + "n" :
2243                                     this.flags & 8192 ? "UniqueESSymbolType" :
2244                                         this.flags & 32 ? "EnumType" :
2245                                             this.flags & 67359327 ? "IntrinsicType " + this.intrinsicName :
2246                                                 this.flags & 1048576 ? "UnionType" :
2247                                                     this.flags & 2097152 ? "IntersectionType" :
2248                                                         this.flags & 4194304 ? "IndexType" :
2249                                                             this.flags & 8388608 ? "IndexedAccessType" :
2250                                                                 this.flags & 16777216 ? "ConditionalType" :
2251                                                                     this.flags & 33554432 ? "SubstitutionType" :
2252                                                                         this.flags & 262144 ? "TypeParameter" :
2253                                                                             this.flags & 524288 ?
2254                                                                                 this.objectFlags & 3 ? "InterfaceType" :
2255                                                                                     this.objectFlags & 4 ? "TypeReference" :
2256                                                                                         this.objectFlags & 8 ? "TupleType" :
2257                                                                                             this.objectFlags & 16 ? "AnonymousType" :
2258                                                                                                 this.objectFlags & 32 ? "MappedType" :
2259                                                                                                     this.objectFlags & 2048 ? "ReverseMappedType" :
2260                                                                                                         this.objectFlags & 256 ? "EvolvingArrayType" :
2261                                                                                                             "ObjectType" :
2262                                                                                 "Type";
2263                         var remainingObjectFlags = this.flags & 524288 ? this.objectFlags & ~2367 : 0;
2264                         return "" + typeHeader + (this.symbol ? " '" + ts.symbolName(this.symbol) + "'" : "") + (remainingObjectFlags ? " (" + formatObjectFlags(remainingObjectFlags) + ")" : "");
2265                     }
2266                 },
2267                 __debugFlags: { get: function () { return formatTypeFlags(this.flags); } },
2268                 __debugObjectFlags: { get: function () { return this.flags & 524288 ? formatObjectFlags(this.objectFlags) : ""; } },
2269                 __debugTypeToString: {
2270                     value: function () {
2271                         var map = getWeakTypeTextMap();
2272                         var text = map === null || map === void 0 ? void 0 : map.get(this);
2273                         if (text === undefined) {
2274                             text = this.checker.typeToString(this);
2275                             map === null || map === void 0 ? void 0 : map.set(this, text);
2276                         }
2277                         return text;
2278                     }
2279                 },
2280             });
2281             var nodeConstructors = [
2282                 ts.objectAllocator.getNodeConstructor(),
2283                 ts.objectAllocator.getIdentifierConstructor(),
2284                 ts.objectAllocator.getTokenConstructor(),
2285                 ts.objectAllocator.getSourceFileConstructor()
2286             ];
2287             for (var _i = 0, nodeConstructors_1 = nodeConstructors; _i < nodeConstructors_1.length; _i++) {
2288                 var ctor = nodeConstructors_1[_i];
2289                 if (!ctor.prototype.hasOwnProperty("__debugKind")) {
2290                     Object.defineProperties(ctor.prototype, {
2291                         __tsDebuggerDisplay: {
2292                             value: function () {
2293                                 var nodeHeader = ts.isGeneratedIdentifier(this) ? "GeneratedIdentifier" :
2294                                     ts.isIdentifier(this) ? "Identifier '" + ts.idText(this) + "'" :
2295                                         ts.isPrivateIdentifier(this) ? "PrivateIdentifier '" + ts.idText(this) + "'" :
2296                                             ts.isStringLiteral(this) ? "StringLiteral " + JSON.stringify(this.text.length < 10 ? this.text : this.text.slice(10) + "...") :
2297                                                 ts.isNumericLiteral(this) ? "NumericLiteral " + this.text :
2298                                                     ts.isBigIntLiteral(this) ? "BigIntLiteral " + this.text + "n" :
2299                                                         ts.isTypeParameterDeclaration(this) ? "TypeParameterDeclaration" :
2300                                                             ts.isParameter(this) ? "ParameterDeclaration" :
2301                                                                 ts.isConstructorDeclaration(this) ? "ConstructorDeclaration" :
2302                                                                     ts.isGetAccessorDeclaration(this) ? "GetAccessorDeclaration" :
2303                                                                         ts.isSetAccessorDeclaration(this) ? "SetAccessorDeclaration" :
2304                                                                             ts.isCallSignatureDeclaration(this) ? "CallSignatureDeclaration" :
2305                                                                                 ts.isConstructSignatureDeclaration(this) ? "ConstructSignatureDeclaration" :
2306                                                                                     ts.isIndexSignatureDeclaration(this) ? "IndexSignatureDeclaration" :
2307                                                                                         ts.isTypePredicateNode(this) ? "TypePredicateNode" :
2308                                                                                             ts.isTypeReferenceNode(this) ? "TypeReferenceNode" :
2309                                                                                                 ts.isFunctionTypeNode(this) ? "FunctionTypeNode" :
2310                                                                                                     ts.isConstructorTypeNode(this) ? "ConstructorTypeNode" :
2311                                                                                                         ts.isTypeQueryNode(this) ? "TypeQueryNode" :
2312                                                                                                             ts.isTypeLiteralNode(this) ? "TypeLiteralNode" :
2313                                                                                                                 ts.isArrayTypeNode(this) ? "ArrayTypeNode" :
2314                                                                                                                     ts.isTupleTypeNode(this) ? "TupleTypeNode" :
2315                                                                                                                         ts.isOptionalTypeNode(this) ? "OptionalTypeNode" :
2316                                                                                                                             ts.isRestTypeNode(this) ? "RestTypeNode" :
2317                                                                                                                                 ts.isUnionTypeNode(this) ? "UnionTypeNode" :
2318                                                                                                                                     ts.isIntersectionTypeNode(this) ? "IntersectionTypeNode" :
2319                                                                                                                                         ts.isConditionalTypeNode(this) ? "ConditionalTypeNode" :
2320                                                                                                                                             ts.isInferTypeNode(this) ? "InferTypeNode" :
2321                                                                                                                                                 ts.isParenthesizedTypeNode(this) ? "ParenthesizedTypeNode" :
2322                                                                                                                                                     ts.isThisTypeNode(this) ? "ThisTypeNode" :
2323                                                                                                                                                         ts.isTypeOperatorNode(this) ? "TypeOperatorNode" :
2324                                                                                                                                                             ts.isIndexedAccessTypeNode(this) ? "IndexedAccessTypeNode" :
2325                                                                                                                                                                 ts.isMappedTypeNode(this) ? "MappedTypeNode" :
2326                                                                                                                                                                     ts.isLiteralTypeNode(this) ? "LiteralTypeNode" :
2327                                                                                                                                                                         ts.isNamedTupleMember(this) ? "NamedTupleMember" :
2328                                                                                                                                                                             ts.isImportTypeNode(this) ? "ImportTypeNode" :
2329                                                                                                                                                                                 formatSyntaxKind(this.kind);
2330                                 return "" + nodeHeader + (this.flags ? " (" + formatNodeFlags(this.flags) + ")" : "");
2331                             }
2332                         },
2333                         __debugKind: { get: function () { return formatSyntaxKind(this.kind); } },
2334                         __debugNodeFlags: { get: function () { return formatNodeFlags(this.flags); } },
2335                         __debugModifierFlags: { get: function () { return formatModifierFlags(ts.getEffectiveModifierFlagsNoCache(this)); } },
2336                         __debugTransformFlags: { get: function () { return formatTransformFlags(this.transformFlags); } },
2337                         __debugIsParseTreeNode: { get: function () { return ts.isParseTreeNode(this); } },
2338                         __debugEmitFlags: { get: function () { return formatEmitFlags(ts.getEmitFlags(this)); } },
2339                         __debugGetText: {
2340                             value: function (includeTrivia) {
2341                                 if (ts.nodeIsSynthesized(this))
2342                                     return "";
2343                                 var map = getWeakNodeTextMap();
2344                                 var text = map === null || map === void 0 ? void 0 : map.get(this);
2345                                 if (text === undefined) {
2346                                     var parseNode = ts.getParseTreeNode(this);
2347                                     var sourceFile = parseNode && ts.getSourceFileOfNode(parseNode);
2348                                     text = sourceFile ? ts.getSourceTextOfNodeFromSourceFile(sourceFile, parseNode, includeTrivia) : "";
2349                                     map === null || map === void 0 ? void 0 : map.set(this, text);
2350                                 }
2351                                 return text;
2352                             }
2353                         }
2354                     });
2355                 }
2356             }
2357             try {
2358                 if (ts.sys && ts.sys.require) {
2359                     var basePath = ts.getDirectoryPath(ts.resolvePath(ts.sys.getExecutingFilePath()));
2360                     var result = ts.sys.require(basePath, "./compiler-debug");
2361                     if (!result.error) {
2362                         result.module.init(ts);
2363                         extendedDebugModule = result.module;
2364                     }
2365                 }
2366             }
2367             catch (_a) {
2368             }
2369             isDebugInfoEnabled = true;
2370         }
2371         Debug.enableDebugInfo = enableDebugInfo;
2372         function formatDeprecationMessage(name, error, errorAfter, since, message) {
2373             var deprecationMessage = error ? "DeprecationError: " : "DeprecationWarning: ";
2374             deprecationMessage += "'" + name + "' ";
2375             deprecationMessage += since ? "has been deprecated since v" + since : "is deprecated";
2376             deprecationMessage += error ? " and can no longer be used." : errorAfter ? " and will no longer be usable after v" + errorAfter + "." : ".";
2377             deprecationMessage += message ? " " + ts.formatStringFromArgs(message, [name], 0) : "";
2378             return deprecationMessage;
2379         }
2380         function createErrorDeprecation(name, errorAfter, since, message) {
2381             var deprecationMessage = formatDeprecationMessage(name, true, errorAfter, since, message);
2382             return function () {
2383                 throw new TypeError(deprecationMessage);
2384             };
2385         }
2386         function createWarningDeprecation(name, errorAfter, since, message) {
2387             var hasWrittenDeprecation = false;
2388             return function () {
2389                 if (!hasWrittenDeprecation) {
2390                     log.warn(formatDeprecationMessage(name, false, errorAfter, since, message));
2391                     hasWrittenDeprecation = true;
2392                 }
2393             };
2394         }
2395         function createDeprecation(name, options) {
2396             var _a, _b;
2397             if (options === void 0) { options = {}; }
2398             var version = typeof options.typeScriptVersion === "string" ? new ts.Version(options.typeScriptVersion) : (_a = options.typeScriptVersion) !== null && _a !== void 0 ? _a : getTypeScriptVersion();
2399             var errorAfter = typeof options.errorAfter === "string" ? new ts.Version(options.errorAfter) : options.errorAfter;
2400             var warnAfter = typeof options.warnAfter === "string" ? new ts.Version(options.warnAfter) : options.warnAfter;
2401             var since = typeof options.since === "string" ? new ts.Version(options.since) : (_b = options.since) !== null && _b !== void 0 ? _b : warnAfter;
2402             var error = options.error || errorAfter && version.compareTo(errorAfter) <= 0;
2403             var warn = !warnAfter || version.compareTo(warnAfter) >= 0;
2404             return error ? createErrorDeprecation(name, errorAfter, since, options.message) :
2405                 warn ? createWarningDeprecation(name, errorAfter, since, options.message) :
2406                     ts.noop;
2407         }
2408         function wrapFunction(deprecation, func) {
2409             return function () {
2410                 deprecation();
2411                 return func.apply(this, arguments);
2412             };
2413         }
2414         function deprecate(func, options) {
2415             var deprecation = createDeprecation(getFunctionName(func), options);
2416             return wrapFunction(deprecation, func);
2417         }
2418         Debug.deprecate = deprecate;
2419     })(Debug = ts.Debug || (ts.Debug = {}));
2420 })(ts || (ts = {}));
2421 var ts;
2422 (function (ts) {
2423     var versionRegExp = /^(0|[1-9]\d*)(?:\.(0|[1-9]\d*)(?:\.(0|[1-9]\d*)(?:\-([a-z0-9-.]+))?(?:\+([a-z0-9-.]+))?)?)?$/i;
2424     var prereleaseRegExp = /^(?:0|[1-9]\d*|[a-z-][a-z0-9-]*)(?:\.(?:0|[1-9]\d*|[a-z-][a-z0-9-]*))*$/i;
2425     var buildRegExp = /^[a-z0-9-]+(?:\.[a-z0-9-]+)*$/i;
2426     var numericIdentifierRegExp = /^(0|[1-9]\d*)$/;
2427     var Version = (function () {
2428         function Version(major, minor, patch, prerelease, build) {
2429             if (minor === void 0) { minor = 0; }
2430             if (patch === void 0) { patch = 0; }
2431             if (prerelease === void 0) { prerelease = ""; }
2432             if (build === void 0) { build = ""; }
2433             if (typeof major === "string") {
2434                 var result = ts.Debug.checkDefined(tryParseComponents(major), "Invalid version");
2435                 (major = result.major, minor = result.minor, patch = result.patch, prerelease = result.prerelease, build = result.build);
2436             }
2437             ts.Debug.assert(major >= 0, "Invalid argument: major");
2438             ts.Debug.assert(minor >= 0, "Invalid argument: minor");
2439             ts.Debug.assert(patch >= 0, "Invalid argument: patch");
2440             ts.Debug.assert(!prerelease || prereleaseRegExp.test(prerelease), "Invalid argument: prerelease");
2441             ts.Debug.assert(!build || buildRegExp.test(build), "Invalid argument: build");
2442             this.major = major;
2443             this.minor = minor;
2444             this.patch = patch;
2445             this.prerelease = prerelease ? prerelease.split(".") : ts.emptyArray;
2446             this.build = build ? build.split(".") : ts.emptyArray;
2447         }
2448         Version.tryParse = function (text) {
2449             var result = tryParseComponents(text);
2450             if (!result)
2451                 return undefined;
2452             var major = result.major, minor = result.minor, patch = result.patch, prerelease = result.prerelease, build = result.build;
2453             return new Version(major, minor, patch, prerelease, build);
2454         };
2455         Version.prototype.compareTo = function (other) {
2456             if (this === other)
2457                 return 0;
2458             if (other === undefined)
2459                 return 1;
2460             return ts.compareValues(this.major, other.major)
2461                 || ts.compareValues(this.minor, other.minor)
2462                 || ts.compareValues(this.patch, other.patch)
2463                 || comparePrereleaseIdentifiers(this.prerelease, other.prerelease);
2464         };
2465         Version.prototype.increment = function (field) {
2466             switch (field) {
2467                 case "major": return new Version(this.major + 1, 0, 0);
2468                 case "minor": return new Version(this.major, this.minor + 1, 0);
2469                 case "patch": return new Version(this.major, this.minor, this.patch + 1);
2470                 default: return ts.Debug.assertNever(field);
2471             }
2472         };
2473         Version.prototype.toString = function () {
2474             var result = this.major + "." + this.minor + "." + this.patch;
2475             if (ts.some(this.prerelease))
2476                 result += "-" + this.prerelease.join(".");
2477             if (ts.some(this.build))
2478                 result += "+" + this.build.join(".");
2479             return result;
2480         };
2481         Version.zero = new Version(0, 0, 0);
2482         return Version;
2483     }());
2484     ts.Version = Version;
2485     function tryParseComponents(text) {
2486         var match = versionRegExp.exec(text);
2487         if (!match)
2488             return undefined;
2489         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;
2490         if (prerelease && !prereleaseRegExp.test(prerelease))
2491             return undefined;
2492         if (build && !buildRegExp.test(build))
2493             return undefined;
2494         return {
2495             major: parseInt(major, 10),
2496             minor: parseInt(minor, 10),
2497             patch: parseInt(patch, 10),
2498             prerelease: prerelease,
2499             build: build
2500         };
2501     }
2502     function comparePrereleaseIdentifiers(left, right) {
2503         if (left === right)
2504             return 0;
2505         if (left.length === 0)
2506             return right.length === 0 ? 0 : 1;
2507         if (right.length === 0)
2508             return -1;
2509         var length = Math.min(left.length, right.length);
2510         for (var i = 0; i < length; i++) {
2511             var leftIdentifier = left[i];
2512             var rightIdentifier = right[i];
2513             if (leftIdentifier === rightIdentifier)
2514                 continue;
2515             var leftIsNumeric = numericIdentifierRegExp.test(leftIdentifier);
2516             var rightIsNumeric = numericIdentifierRegExp.test(rightIdentifier);
2517             if (leftIsNumeric || rightIsNumeric) {
2518                 if (leftIsNumeric !== rightIsNumeric)
2519                     return leftIsNumeric ? -1 : 1;
2520                 var result = ts.compareValues(+leftIdentifier, +rightIdentifier);
2521                 if (result)
2522                     return result;
2523             }
2524             else {
2525                 var result = ts.compareStringsCaseSensitive(leftIdentifier, rightIdentifier);
2526                 if (result)
2527                     return result;
2528             }
2529         }
2530         return ts.compareValues(left.length, right.length);
2531     }
2532     var VersionRange = (function () {
2533         function VersionRange(spec) {
2534             this._alternatives = spec ? ts.Debug.checkDefined(parseRange(spec), "Invalid range spec.") : ts.emptyArray;
2535         }
2536         VersionRange.tryParse = function (text) {
2537             var sets = parseRange(text);
2538             if (sets) {
2539                 var range = new VersionRange("");
2540                 range._alternatives = sets;
2541                 return range;
2542             }
2543             return undefined;
2544         };
2545         VersionRange.prototype.test = function (version) {
2546             if (typeof version === "string")
2547                 version = new Version(version);
2548             return testDisjunction(version, this._alternatives);
2549         };
2550         VersionRange.prototype.toString = function () {
2551             return formatDisjunction(this._alternatives);
2552         };
2553         return VersionRange;
2554     }());
2555     ts.VersionRange = VersionRange;
2556     var logicalOrRegExp = /\s*\|\|\s*/g;
2557     var whitespaceRegExp = /\s+/g;
2558     var partialRegExp = /^([xX*0]|[1-9]\d*)(?:\.([xX*0]|[1-9]\d*)(?:\.([xX*0]|[1-9]\d*)(?:-([a-z0-9-.]+))?(?:\+([a-z0-9-.]+))?)?)?$/i;
2559     var hyphenRegExp = /^\s*([a-z0-9-+.*]+)\s+-\s+([a-z0-9-+.*]+)\s*$/i;
2560     var rangeRegExp = /^\s*(~|\^|<|<=|>|>=|=)?\s*([a-z0-9-+.*]+)$/i;
2561     function parseRange(text) {
2562         var alternatives = [];
2563         for (var _i = 0, _a = text.trim().split(logicalOrRegExp); _i < _a.length; _i++) {
2564             var range = _a[_i];
2565             if (!range)
2566                 continue;
2567             var comparators = [];
2568             var match = hyphenRegExp.exec(range);
2569             if (match) {
2570                 if (!parseHyphen(match[1], match[2], comparators))
2571                     return undefined;
2572             }
2573             else {
2574                 for (var _b = 0, _c = range.split(whitespaceRegExp); _b < _c.length; _b++) {
2575                     var simple = _c[_b];
2576                     var match_1 = rangeRegExp.exec(simple);
2577                     if (!match_1 || !parseComparator(match_1[1], match_1[2], comparators))
2578                         return undefined;
2579                 }
2580             }
2581             alternatives.push(comparators);
2582         }
2583         return alternatives;
2584     }
2585     function parsePartial(text) {
2586         var match = partialRegExp.exec(text);
2587         if (!match)
2588             return undefined;
2589         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];
2590         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);
2591         return { version: version, major: major, minor: minor, patch: patch };
2592     }
2593     function parseHyphen(left, right, comparators) {
2594         var leftResult = parsePartial(left);
2595         if (!leftResult)
2596             return false;
2597         var rightResult = parsePartial(right);
2598         if (!rightResult)
2599             return false;
2600         if (!isWildcard(leftResult.major)) {
2601             comparators.push(createComparator(">=", leftResult.version));
2602         }
2603         if (!isWildcard(rightResult.major)) {
2604             comparators.push(isWildcard(rightResult.minor) ? createComparator("<", rightResult.version.increment("major")) :
2605                 isWildcard(rightResult.patch) ? createComparator("<", rightResult.version.increment("minor")) :
2606                     createComparator("<=", rightResult.version));
2607         }
2608         return true;
2609     }
2610     function parseComparator(operator, text, comparators) {
2611         var result = parsePartial(text);
2612         if (!result)
2613             return false;
2614         var version = result.version, major = result.major, minor = result.minor, patch = result.patch;
2615         if (!isWildcard(major)) {
2616             switch (operator) {
2617                 case "~":
2618                     comparators.push(createComparator(">=", version));
2619                     comparators.push(createComparator("<", version.increment(isWildcard(minor) ? "major" :
2620                         "minor")));
2621                     break;
2622                 case "^":
2623                     comparators.push(createComparator(">=", version));
2624                     comparators.push(createComparator("<", version.increment(version.major > 0 || isWildcard(minor) ? "major" :
2625                         version.minor > 0 || isWildcard(patch) ? "minor" :
2626                             "patch")));
2627                     break;
2628                 case "<":
2629                 case ">=":
2630                     comparators.push(createComparator(operator, version));
2631                     break;
2632                 case "<=":
2633                 case ">":
2634                     comparators.push(isWildcard(minor) ? createComparator(operator === "<=" ? "<" : ">=", version.increment("major")) :
2635                         isWildcard(patch) ? createComparator(operator === "<=" ? "<" : ">=", version.increment("minor")) :
2636                             createComparator(operator, version));
2637                     break;
2638                 case "=":
2639                 case undefined:
2640                     if (isWildcard(minor) || isWildcard(patch)) {
2641                         comparators.push(createComparator(">=", version));
2642                         comparators.push(createComparator("<", version.increment(isWildcard(minor) ? "major" : "minor")));
2643                     }
2644                     else {
2645                         comparators.push(createComparator("=", version));
2646                     }
2647                     break;
2648                 default:
2649                     return false;
2650             }
2651         }
2652         else if (operator === "<" || operator === ">") {
2653             comparators.push(createComparator("<", Version.zero));
2654         }
2655         return true;
2656     }
2657     function isWildcard(part) {
2658         return part === "*" || part === "x" || part === "X";
2659     }
2660     function createComparator(operator, operand) {
2661         return { operator: operator, operand: operand };
2662     }
2663     function testDisjunction(version, alternatives) {
2664         if (alternatives.length === 0)
2665             return true;
2666         for (var _i = 0, alternatives_1 = alternatives; _i < alternatives_1.length; _i++) {
2667             var alternative = alternatives_1[_i];
2668             if (testAlternative(version, alternative))
2669                 return true;
2670         }
2671         return false;
2672     }
2673     function testAlternative(version, comparators) {
2674         for (var _i = 0, comparators_1 = comparators; _i < comparators_1.length; _i++) {
2675             var comparator = comparators_1[_i];
2676             if (!testComparator(version, comparator.operator, comparator.operand))
2677                 return false;
2678         }
2679         return true;
2680     }
2681     function testComparator(version, operator, operand) {
2682         var cmp = version.compareTo(operand);
2683         switch (operator) {
2684             case "<": return cmp < 0;
2685             case "<=": return cmp <= 0;
2686             case ">": return cmp > 0;
2687             case ">=": return cmp >= 0;
2688             case "=": return cmp === 0;
2689             default: return ts.Debug.assertNever(operator);
2690         }
2691     }
2692     function formatDisjunction(alternatives) {
2693         return ts.map(alternatives, formatAlternative).join(" || ") || "*";
2694     }
2695     function formatAlternative(comparators) {
2696         return ts.map(comparators, formatComparator).join(" ");
2697     }
2698     function formatComparator(comparator) {
2699         return "" + comparator.operator + comparator.operand;
2700     }
2701 })(ts || (ts = {}));
2702 var ts;
2703 (function (ts) {
2704     function hasRequiredAPI(performance, PerformanceObserver) {
2705         return typeof performance === "object" &&
2706             typeof performance.timeOrigin === "number" &&
2707             typeof performance.mark === "function" &&
2708             typeof performance.measure === "function" &&
2709             typeof performance.now === "function" &&
2710             typeof PerformanceObserver === "function";
2711     }
2712     function tryGetWebPerformanceHooks() {
2713         if (typeof performance === "object" &&
2714             typeof PerformanceObserver === "function" &&
2715             hasRequiredAPI(performance, PerformanceObserver)) {
2716             return {
2717                 performance: performance,
2718                 PerformanceObserver: PerformanceObserver
2719             };
2720         }
2721     }
2722     function tryGetNodePerformanceHooks() {
2723         if (typeof module === "object" && typeof require === "function") {
2724             try {
2725                 var _a = require("perf_hooks"), performance_1 = _a.performance, PerformanceObserver_1 = _a.PerformanceObserver;
2726                 if (hasRequiredAPI(performance_1, PerformanceObserver_1)) {
2727                     var version_1 = new ts.Version(process.versions.node);
2728                     var range = new ts.VersionRange("<12.16.3 || 13 <13.13");
2729                     if (range.test(version_1)) {
2730                         return {
2731                             performance: {
2732                                 get timeOrigin() { return performance_1.timeOrigin; },
2733                                 now: function () { return performance_1.now(); },
2734                                 mark: function (name) { return performance_1.mark(name); },
2735                                 measure: function (name, start, end) {
2736                                     if (start === void 0) { start = "nodeStart"; }
2737                                     if (end === undefined) {
2738                                         end = "__performance.measure-fix__";
2739                                         performance_1.mark(end);
2740                                     }
2741                                     performance_1.measure(name, start, end);
2742                                     if (end === "__performance.measure-fix__") {
2743                                         performance_1.clearMarks("__performance.measure-fix__");
2744                                     }
2745                                 }
2746                             },
2747                             PerformanceObserver: PerformanceObserver_1
2748                         };
2749                     }
2750                     return {
2751                         performance: performance_1,
2752                         PerformanceObserver: PerformanceObserver_1
2753                     };
2754                 }
2755             }
2756             catch (_b) {
2757             }
2758         }
2759     }
2760     var nativePerformanceHooks = tryGetWebPerformanceHooks() || tryGetNodePerformanceHooks();
2761     var nativePerformance = nativePerformanceHooks === null || nativePerformanceHooks === void 0 ? void 0 : nativePerformanceHooks.performance;
2762     function tryGetNativePerformanceHooks() {
2763         return nativePerformanceHooks;
2764     }
2765     ts.tryGetNativePerformanceHooks = tryGetNativePerformanceHooks;
2766     ts.timestamp = nativePerformance ? function () { return nativePerformance.now(); } :
2767         Date.now ? Date.now :
2768             function () { return +(new Date()); };
2769 })(ts || (ts = {}));
2770 var ts;
2771 (function (ts) {
2772     var performance;
2773     (function (performance) {
2774         var perfHooks;
2775         var perfObserver;
2776         var performanceImpl;
2777         function createTimerIf(condition, measureName, startMarkName, endMarkName) {
2778             return condition ? createTimer(measureName, startMarkName, endMarkName) : performance.nullTimer;
2779         }
2780         performance.createTimerIf = createTimerIf;
2781         function createTimer(measureName, startMarkName, endMarkName) {
2782             var enterCount = 0;
2783             return {
2784                 enter: enter,
2785                 exit: exit
2786             };
2787             function enter() {
2788                 if (++enterCount === 1) {
2789                     mark(startMarkName);
2790                 }
2791             }
2792             function exit() {
2793                 if (--enterCount === 0) {
2794                     mark(endMarkName);
2795                     measure(measureName, startMarkName, endMarkName);
2796                 }
2797                 else if (enterCount < 0) {
2798                     ts.Debug.fail("enter/exit count does not match.");
2799                 }
2800             }
2801         }
2802         performance.createTimer = createTimer;
2803         performance.nullTimer = { enter: ts.noop, exit: ts.noop };
2804         var counts = new ts.Map();
2805         var durations = new ts.Map();
2806         function mark(markName) {
2807             performanceImpl === null || performanceImpl === void 0 ? void 0 : performanceImpl.mark(markName);
2808         }
2809         performance.mark = mark;
2810         function measure(measureName, startMarkName, endMarkName) {
2811             performanceImpl === null || performanceImpl === void 0 ? void 0 : performanceImpl.measure(measureName, startMarkName, endMarkName);
2812         }
2813         performance.measure = measure;
2814         function getCount(markName) {
2815             return counts.get(markName) || 0;
2816         }
2817         performance.getCount = getCount;
2818         function getDuration(measureName) {
2819             return durations.get(measureName) || 0;
2820         }
2821         performance.getDuration = getDuration;
2822         function forEachMeasure(cb) {
2823             durations.forEach(function (duration, measureName) { return cb(measureName, duration); });
2824         }
2825         performance.forEachMeasure = forEachMeasure;
2826         function isEnabled() {
2827             return !!performanceImpl;
2828         }
2829         performance.isEnabled = isEnabled;
2830         function enable() {
2831             if (!performanceImpl) {
2832                 perfHooks || (perfHooks = ts.tryGetNativePerformanceHooks());
2833                 if (!perfHooks)
2834                     return false;
2835                 perfObserver || (perfObserver = new perfHooks.PerformanceObserver(updateStatisticsFromList));
2836                 perfObserver.observe({ entryTypes: ["mark", "measure"] });
2837                 performanceImpl = perfHooks.performance;
2838             }
2839             return true;
2840         }
2841         performance.enable = enable;
2842         function disable() {
2843             perfObserver === null || perfObserver === void 0 ? void 0 : perfObserver.disconnect();
2844             performanceImpl = undefined;
2845             counts.clear();
2846             durations.clear();
2847         }
2848         performance.disable = disable;
2849         function updateStatisticsFromList(list) {
2850             for (var _i = 0, _a = list.getEntriesByType("mark"); _i < _a.length; _i++) {
2851                 var mark_1 = _a[_i];
2852                 counts.set(mark_1.name, (counts.get(mark_1.name) || 0) + 1);
2853             }
2854             for (var _b = 0, _c = list.getEntriesByType("measure"); _b < _c.length; _b++) {
2855                 var measure_1 = _c[_b];
2856                 durations.set(measure_1.name, (durations.get(measure_1.name) || 0) + measure_1.duration);
2857             }
2858         }
2859     })(performance = ts.performance || (ts.performance = {}));
2860 })(ts || (ts = {}));
2861 var ts;
2862 (function (ts) {
2863     var _a;
2864     var nullLogger = {
2865         logEvent: ts.noop,
2866         logErrEvent: ts.noop,
2867         logPerfEvent: ts.noop,
2868         logInfoEvent: ts.noop,
2869         logStartCommand: ts.noop,
2870         logStopCommand: ts.noop,
2871         logStartUpdateProgram: ts.noop,
2872         logStopUpdateProgram: ts.noop,
2873         logStartUpdateGraph: ts.noop,
2874         logStopUpdateGraph: ts.noop,
2875         logStartResolveModule: ts.noop,
2876         logStopResolveModule: ts.noop,
2877         logStartParseSourceFile: ts.noop,
2878         logStopParseSourceFile: ts.noop,
2879         logStartReadFile: ts.noop,
2880         logStopReadFile: ts.noop,
2881         logStartBindFile: ts.noop,
2882         logStopBindFile: ts.noop,
2883         logStartScheduledOperation: ts.noop,
2884         logStopScheduledOperation: ts.noop,
2885     };
2886     var etwModule;
2887     try {
2888         var etwModulePath = (_a = process.env.TS_ETW_MODULE_PATH) !== null && _a !== void 0 ? _a : "./node_modules/@microsoft/typescript-etw";
2889         etwModule = require(etwModulePath);
2890     }
2891     catch (e) {
2892         etwModule = undefined;
2893     }
2894     ts.perfLogger = etwModule && etwModule.logEvent ? etwModule : nullLogger;
2895 })(ts || (ts = {}));
2896 var ts;
2897 (function (ts) {
2898     var tracing;
2899     (function (tracing) {
2900         var fs;
2901         var traceCount = 0;
2902         var traceFd;
2903         var legendPath;
2904         var legend = [];
2905         function startTracing(configFilePath, traceDir, isBuildMode) {
2906             ts.Debug.assert(!traceFd, "Tracing already started");
2907             if (fs === undefined) {
2908                 try {
2909                     fs = require("fs");
2910                 }
2911                 catch (_a) {
2912                     fs = false;
2913                 }
2914             }
2915             if (!fs) {
2916                 return;
2917             }
2918             if (legendPath === undefined) {
2919                 legendPath = ts.combinePaths(traceDir, "legend.json");
2920             }
2921             if (!fs.existsSync(traceDir)) {
2922                 fs.mkdirSync(traceDir, { recursive: true });
2923             }
2924             var countPart = isBuildMode ? "." + ++traceCount : "";
2925             var tracePath = ts.combinePaths(traceDir, "trace" + countPart + ".json");
2926             var typesPath = ts.combinePaths(traceDir, "types" + countPart + ".json");
2927             legend.push({
2928                 configFilePath: configFilePath,
2929                 tracePath: tracePath,
2930                 typesPath: typesPath,
2931             });
2932             traceFd = fs.openSync(tracePath, "w");
2933             var meta = { cat: "__metadata", ph: "M", ts: 1000 * ts.timestamp(), pid: 1, tid: 1 };
2934             fs.writeSync(traceFd, "[\n"
2935                 + [__assign({ name: "process_name", args: { name: "tsc" } }, meta), __assign({ name: "thread_name", args: { name: "Main" } }, meta), __assign(__assign({ name: "TracingStartedInBrowser" }, meta), { cat: "disabled-by-default-devtools.timeline" })]
2936                     .map(function (v) { return JSON.stringify(v); }).join(",\n"));
2937         }
2938         tracing.startTracing = startTracing;
2939         function stopTracing(typeCatalog) {
2940             if (!traceFd) {
2941                 ts.Debug.assert(!fs, "Tracing is not in progress");
2942                 return;
2943             }
2944             ts.Debug.assert(fs);
2945             fs.writeSync(traceFd, "\n]\n");
2946             fs.closeSync(traceFd);
2947             traceFd = undefined;
2948             if (typeCatalog) {
2949                 dumpTypes(typeCatalog);
2950             }
2951             else {
2952                 legend[legend.length - 1].typesPath = undefined;
2953             }
2954         }
2955         tracing.stopTracing = stopTracing;
2956         function isTracing() {
2957             return !!traceFd;
2958         }
2959         tracing.isTracing = isTracing;
2960         function begin(phase, name, args) {
2961             if (!traceFd)
2962                 return;
2963             writeEvent("B", phase, name, args);
2964         }
2965         tracing.begin = begin;
2966         function end(phase, name, args) {
2967             if (!traceFd)
2968                 return;
2969             writeEvent("E", phase, name, args);
2970         }
2971         tracing.end = end;
2972         function instant(phase, name, args) {
2973             if (!traceFd)
2974                 return;
2975             writeEvent("I", phase, name, args, "\"s\":\"g\"");
2976         }
2977         tracing.instant = instant;
2978         var completeEvents = [];
2979         function push(phase, name, args) {
2980             if (!traceFd)
2981                 return;
2982             completeEvents.push({ phase: phase, name: name, args: args, time: 1000 * ts.timestamp() });
2983         }
2984         tracing.push = push;
2985         function pop() {
2986             if (!traceFd)
2987                 return;
2988             ts.Debug.assert(completeEvents.length > 0);
2989             var _a = completeEvents.pop(), phase = _a.phase, name = _a.name, args = _a.args, time = _a.time;
2990             var dur = 1000 * ts.timestamp() - time;
2991             writeEvent("X", phase, name, args, "\"dur\":" + dur, time);
2992         }
2993         tracing.pop = pop;
2994         function writeEvent(eventType, phase, name, args, extras, time) {
2995             if (time === void 0) { time = 1000 * ts.timestamp(); }
2996             ts.Debug.assert(traceFd);
2997             ts.Debug.assert(fs);
2998             ts.performance.mark("beginTracing");
2999             fs.writeSync(traceFd, ",\n{\"pid\":1,\"tid\":1,\"ph\":\"" + eventType + "\",\"cat\":\"" + phase + "\",\"ts\":" + time + ",\"name\":\"" + name + "\"");
3000             if (extras)
3001                 fs.writeSync(traceFd, "," + extras);
3002             if (args)
3003                 fs.writeSync(traceFd, ",\"args\":" + JSON.stringify(args));
3004             fs.writeSync(traceFd, "}");
3005             ts.performance.mark("endTracing");
3006             ts.performance.measure("Tracing", "beginTracing", "endTracing");
3007         }
3008         function indexFromOne(lc) {
3009             return {
3010                 line: lc.line + 1,
3011                 character: lc.character + 1,
3012             };
3013         }
3014         function dumpTypes(types) {
3015             var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r;
3016             ts.Debug.assert(fs);
3017             ts.performance.mark("beginDumpTypes");
3018             var typesPath = legend[legend.length - 1].typesPath;
3019             var typesFd = fs.openSync(typesPath, "w");
3020             var recursionIdentityMap = new ts.Map();
3021             fs.writeSync(typesFd, "[");
3022             var numTypes = types.length;
3023             for (var i = 0; i < numTypes; i++) {
3024                 var type = types[i];
3025                 var objectFlags = type.objectFlags;
3026                 var symbol = (_a = type.aliasSymbol) !== null && _a !== void 0 ? _a : type.symbol;
3027                 var firstDeclaration = (_b = symbol === null || symbol === void 0 ? void 0 : symbol.declarations) === null || _b === void 0 ? void 0 : _b[0];
3028                 var firstFile = firstDeclaration && ts.getSourceFileOfNode(firstDeclaration);
3029                 var display = void 0;
3030                 if ((objectFlags & 16) | (type.flags & 2944)) {
3031                     try {
3032                         display = (_c = type.checker) === null || _c === void 0 ? void 0 : _c.typeToString(type);
3033                     }
3034                     catch (_s) {
3035                         display = undefined;
3036                     }
3037                 }
3038                 var indexedAccessProperties = {};
3039                 if (type.flags & 8388608) {
3040                     var indexedAccessType = type;
3041                     indexedAccessProperties = {
3042                         indexedAccessObjectType: (_d = indexedAccessType.objectType) === null || _d === void 0 ? void 0 : _d.id,
3043                         indexedAccessIndexType: (_e = indexedAccessType.indexType) === null || _e === void 0 ? void 0 : _e.id,
3044                     };
3045                 }
3046                 var referenceProperties = {};
3047                 if (objectFlags & 4) {
3048                     var referenceType = type;
3049                     referenceProperties = {
3050                         instantiatedType: (_f = referenceType.target) === null || _f === void 0 ? void 0 : _f.id,
3051                         typeArguments: (_g = referenceType.resolvedTypeArguments) === null || _g === void 0 ? void 0 : _g.map(function (t) { return t.id; }),
3052                     };
3053                 }
3054                 var conditionalProperties = {};
3055                 if (type.flags & 16777216) {
3056                     var conditionalType = type;
3057                     conditionalProperties = {
3058                         conditionalCheckType: (_h = conditionalType.checkType) === null || _h === void 0 ? void 0 : _h.id,
3059                         conditionalExtendsType: (_j = conditionalType.extendsType) === null || _j === void 0 ? void 0 : _j.id,
3060                         conditionalTrueType: (_l = (_k = conditionalType.resolvedTrueType) === null || _k === void 0 ? void 0 : _k.id) !== null && _l !== void 0 ? _l : -1,
3061                         conditionalFalseType: (_o = (_m = conditionalType.resolvedFalseType) === null || _m === void 0 ? void 0 : _m.id) !== null && _o !== void 0 ? _o : -1,
3062                     };
3063                 }
3064                 var recursionToken = void 0;
3065                 var recursionIdentity = type.checker.getRecursionIdentity(type);
3066                 if (recursionIdentity) {
3067                     recursionToken = recursionIdentityMap.get(recursionIdentity);
3068                     if (!recursionToken) {
3069                         recursionToken = recursionIdentityMap.size;
3070                         recursionIdentityMap.set(recursionIdentity, recursionToken);
3071                     }
3072                 }
3073                 var descriptor = __assign(__assign(__assign(__assign({ id: type.id, intrinsicName: type.intrinsicName, symbolName: (symbol === null || symbol === void 0 ? void 0 : symbol.escapedName) && ts.unescapeLeadingUnderscores(symbol.escapedName), recursionId: recursionToken, unionTypes: (type.flags & 1048576) ? (_p = type.types) === null || _p === void 0 ? void 0 : _p.map(function (t) { return t.id; }) : undefined, intersectionTypes: (type.flags & 2097152) ? type.types.map(function (t) { return t.id; }) : undefined, aliasTypeArguments: (_q = type.aliasTypeArguments) === null || _q === void 0 ? void 0 : _q.map(function (t) { return t.id; }), keyofType: (type.flags & 4194304) ? (_r = type.type) === null || _r === void 0 ? void 0 : _r.id : undefined }, indexedAccessProperties), referenceProperties), conditionalProperties), { firstDeclaration: firstDeclaration && {
3074                         path: firstFile.path,
3075                         start: indexFromOne(ts.getLineAndCharacterOfPosition(firstFile, firstDeclaration.pos)),
3076                         end: indexFromOne(ts.getLineAndCharacterOfPosition(ts.getSourceFileOfNode(firstDeclaration), firstDeclaration.end)),
3077                     }, flags: ts.Debug.formatTypeFlags(type.flags).split("|"), display: display });
3078                 fs.writeSync(typesFd, JSON.stringify(descriptor));
3079                 if (i < numTypes - 1) {
3080                     fs.writeSync(typesFd, ",\n");
3081                 }
3082             }
3083             fs.writeSync(typesFd, "]\n");
3084             fs.closeSync(typesFd);
3085             ts.performance.mark("endDumpTypes");
3086             ts.performance.measure("Dump types", "beginDumpTypes", "endDumpTypes");
3087         }
3088         function dumpLegend() {
3089             if (!legendPath) {
3090                 return;
3091             }
3092             ts.Debug.assert(fs);
3093             fs.writeFileSync(legendPath, JSON.stringify(legend));
3094         }
3095         tracing.dumpLegend = dumpLegend;
3096     })(tracing = ts.tracing || (ts.tracing = {}));
3097 })(ts || (ts = {}));
3098 var ts;
3099 (function (ts) {
3100     var OperationCanceledException = (function () {
3101         function OperationCanceledException() {
3102         }
3103         return OperationCanceledException;
3104     }());
3105     ts.OperationCanceledException = OperationCanceledException;
3106     var RefFileKind;
3107     (function (RefFileKind) {
3108         RefFileKind[RefFileKind["Import"] = 0] = "Import";
3109         RefFileKind[RefFileKind["ReferenceFile"] = 1] = "ReferenceFile";
3110         RefFileKind[RefFileKind["TypeReferenceDirective"] = 2] = "TypeReferenceDirective";
3111     })(RefFileKind = ts.RefFileKind || (ts.RefFileKind = {}));
3112     var ExitStatus;
3113     (function (ExitStatus) {
3114         ExitStatus[ExitStatus["Success"] = 0] = "Success";
3115         ExitStatus[ExitStatus["DiagnosticsPresent_OutputsSkipped"] = 1] = "DiagnosticsPresent_OutputsSkipped";
3116         ExitStatus[ExitStatus["DiagnosticsPresent_OutputsGenerated"] = 2] = "DiagnosticsPresent_OutputsGenerated";
3117         ExitStatus[ExitStatus["InvalidProject_OutputsSkipped"] = 3] = "InvalidProject_OutputsSkipped";
3118         ExitStatus[ExitStatus["ProjectReferenceCycle_OutputsSkipped"] = 4] = "ProjectReferenceCycle_OutputsSkipped";
3119         ExitStatus[ExitStatus["ProjectReferenceCycle_OutputsSkupped"] = 4] = "ProjectReferenceCycle_OutputsSkupped";
3120     })(ExitStatus = ts.ExitStatus || (ts.ExitStatus = {}));
3121     var TypeReferenceSerializationKind;
3122     (function (TypeReferenceSerializationKind) {
3123         TypeReferenceSerializationKind[TypeReferenceSerializationKind["Unknown"] = 0] = "Unknown";
3124         TypeReferenceSerializationKind[TypeReferenceSerializationKind["TypeWithConstructSignatureAndValue"] = 1] = "TypeWithConstructSignatureAndValue";
3125         TypeReferenceSerializationKind[TypeReferenceSerializationKind["VoidNullableOrNeverType"] = 2] = "VoidNullableOrNeverType";
3126         TypeReferenceSerializationKind[TypeReferenceSerializationKind["NumberLikeType"] = 3] = "NumberLikeType";
3127         TypeReferenceSerializationKind[TypeReferenceSerializationKind["BigIntLikeType"] = 4] = "BigIntLikeType";
3128         TypeReferenceSerializationKind[TypeReferenceSerializationKind["StringLikeType"] = 5] = "StringLikeType";
3129         TypeReferenceSerializationKind[TypeReferenceSerializationKind["BooleanType"] = 6] = "BooleanType";
3130         TypeReferenceSerializationKind[TypeReferenceSerializationKind["ArrayLikeType"] = 7] = "ArrayLikeType";
3131         TypeReferenceSerializationKind[TypeReferenceSerializationKind["ESSymbolType"] = 8] = "ESSymbolType";
3132         TypeReferenceSerializationKind[TypeReferenceSerializationKind["Promise"] = 9] = "Promise";
3133         TypeReferenceSerializationKind[TypeReferenceSerializationKind["TypeWithCallSignature"] = 10] = "TypeWithCallSignature";
3134         TypeReferenceSerializationKind[TypeReferenceSerializationKind["ObjectType"] = 11] = "ObjectType";
3135     })(TypeReferenceSerializationKind = ts.TypeReferenceSerializationKind || (ts.TypeReferenceSerializationKind = {}));
3136     var DiagnosticCategory;
3137     (function (DiagnosticCategory) {
3138         DiagnosticCategory[DiagnosticCategory["Warning"] = 0] = "Warning";
3139         DiagnosticCategory[DiagnosticCategory["Error"] = 1] = "Error";
3140         DiagnosticCategory[DiagnosticCategory["Suggestion"] = 2] = "Suggestion";
3141         DiagnosticCategory[DiagnosticCategory["Message"] = 3] = "Message";
3142     })(DiagnosticCategory = ts.DiagnosticCategory || (ts.DiagnosticCategory = {}));
3143     function diagnosticCategoryName(d, lowerCase) {
3144         if (lowerCase === void 0) { lowerCase = true; }
3145         var name = DiagnosticCategory[d.category];
3146         return lowerCase ? name.toLowerCase() : name;
3147     }
3148     ts.diagnosticCategoryName = diagnosticCategoryName;
3149     var ModuleResolutionKind;
3150     (function (ModuleResolutionKind) {
3151         ModuleResolutionKind[ModuleResolutionKind["Classic"] = 1] = "Classic";
3152         ModuleResolutionKind[ModuleResolutionKind["NodeJs"] = 2] = "NodeJs";
3153     })(ModuleResolutionKind = ts.ModuleResolutionKind || (ts.ModuleResolutionKind = {}));
3154     var WatchFileKind;
3155     (function (WatchFileKind) {
3156         WatchFileKind[WatchFileKind["FixedPollingInterval"] = 0] = "FixedPollingInterval";
3157         WatchFileKind[WatchFileKind["PriorityPollingInterval"] = 1] = "PriorityPollingInterval";
3158         WatchFileKind[WatchFileKind["DynamicPriorityPolling"] = 2] = "DynamicPriorityPolling";
3159         WatchFileKind[WatchFileKind["UseFsEvents"] = 3] = "UseFsEvents";
3160         WatchFileKind[WatchFileKind["UseFsEventsOnParentDirectory"] = 4] = "UseFsEventsOnParentDirectory";
3161     })(WatchFileKind = ts.WatchFileKind || (ts.WatchFileKind = {}));
3162     var WatchDirectoryKind;
3163     (function (WatchDirectoryKind) {
3164         WatchDirectoryKind[WatchDirectoryKind["UseFsEvents"] = 0] = "UseFsEvents";
3165         WatchDirectoryKind[WatchDirectoryKind["FixedPollingInterval"] = 1] = "FixedPollingInterval";
3166         WatchDirectoryKind[WatchDirectoryKind["DynamicPriorityPolling"] = 2] = "DynamicPriorityPolling";
3167     })(WatchDirectoryKind = ts.WatchDirectoryKind || (ts.WatchDirectoryKind = {}));
3168     var PollingWatchKind;
3169     (function (PollingWatchKind) {
3170         PollingWatchKind[PollingWatchKind["FixedInterval"] = 0] = "FixedInterval";
3171         PollingWatchKind[PollingWatchKind["PriorityInterval"] = 1] = "PriorityInterval";
3172         PollingWatchKind[PollingWatchKind["DynamicPriority"] = 2] = "DynamicPriority";
3173     })(PollingWatchKind = ts.PollingWatchKind || (ts.PollingWatchKind = {}));
3174     var ModuleKind;
3175     (function (ModuleKind) {
3176         ModuleKind[ModuleKind["None"] = 0] = "None";
3177         ModuleKind[ModuleKind["CommonJS"] = 1] = "CommonJS";
3178         ModuleKind[ModuleKind["AMD"] = 2] = "AMD";
3179         ModuleKind[ModuleKind["UMD"] = 3] = "UMD";
3180         ModuleKind[ModuleKind["System"] = 4] = "System";
3181         ModuleKind[ModuleKind["ES2015"] = 5] = "ES2015";
3182         ModuleKind[ModuleKind["ES2020"] = 6] = "ES2020";
3183         ModuleKind[ModuleKind["ESNext"] = 99] = "ESNext";
3184     })(ModuleKind = ts.ModuleKind || (ts.ModuleKind = {}));
3185     ts.commentPragmas = {
3186         "reference": {
3187             args: [
3188                 { name: "types", optional: true, captureSpan: true },
3189                 { name: "lib", optional: true, captureSpan: true },
3190                 { name: "path", optional: true, captureSpan: true },
3191                 { name: "no-default-lib", optional: true }
3192             ],
3193             kind: 1
3194         },
3195         "amd-dependency": {
3196             args: [{ name: "path" }, { name: "name", optional: true }],
3197             kind: 1
3198         },
3199         "amd-module": {
3200             args: [{ name: "name" }],
3201             kind: 1
3202         },
3203         "ts-check": {
3204             kind: 2
3205         },
3206         "ts-nocheck": {
3207             kind: 2
3208         },
3209         "jsx": {
3210             args: [{ name: "factory" }],
3211             kind: 4
3212         },
3213         "jsxfrag": {
3214             args: [{ name: "factory" }],
3215             kind: 4
3216         },
3217         "jsximportsource": {
3218             args: [{ name: "factory" }],
3219             kind: 4
3220         },
3221         "jsxruntime": {
3222             args: [{ name: "factory" }],
3223             kind: 4
3224         },
3225     };
3226 })(ts || (ts = {}));
3227 var ts;
3228 (function (ts) {
3229     ts.directorySeparator = "/";
3230     var altDirectorySeparator = "\\";
3231     var urlSchemeSeparator = "://";
3232     var backslashRegExp = /\\/g;
3233     function isAnyDirectorySeparator(charCode) {
3234         return charCode === 47 || charCode === 92;
3235     }
3236     ts.isAnyDirectorySeparator = isAnyDirectorySeparator;
3237     function isUrl(path) {
3238         return getEncodedRootLength(path) < 0;
3239     }
3240     ts.isUrl = isUrl;
3241     function isRootedDiskPath(path) {
3242         return getEncodedRootLength(path) > 0;
3243     }
3244     ts.isRootedDiskPath = isRootedDiskPath;
3245     function isDiskPathRoot(path) {
3246         var rootLength = getEncodedRootLength(path);
3247         return rootLength > 0 && rootLength === path.length;
3248     }
3249     ts.isDiskPathRoot = isDiskPathRoot;
3250     function pathIsAbsolute(path) {
3251         return getEncodedRootLength(path) !== 0;
3252     }
3253     ts.pathIsAbsolute = pathIsAbsolute;
3254     function pathIsRelative(path) {
3255         return /^\.\.?($|[\\/])/.test(path);
3256     }
3257     ts.pathIsRelative = pathIsRelative;
3258     function pathIsBareSpecifier(path) {
3259         return !pathIsAbsolute(path) && !pathIsRelative(path);
3260     }
3261     ts.pathIsBareSpecifier = pathIsBareSpecifier;
3262     function hasExtension(fileName) {
3263         return ts.stringContains(getBaseFileName(fileName), ".");
3264     }
3265     ts.hasExtension = hasExtension;
3266     function fileExtensionIs(path, extension) {
3267         return path.length > extension.length && ts.endsWith(path, extension);
3268     }
3269     ts.fileExtensionIs = fileExtensionIs;
3270     function fileExtensionIsOneOf(path, extensions) {
3271         for (var _i = 0, extensions_1 = extensions; _i < extensions_1.length; _i++) {
3272             var extension = extensions_1[_i];
3273             if (fileExtensionIs(path, extension)) {
3274                 return true;
3275             }
3276         }
3277         return false;
3278     }
3279     ts.fileExtensionIsOneOf = fileExtensionIsOneOf;
3280     function hasTrailingDirectorySeparator(path) {
3281         return path.length > 0 && isAnyDirectorySeparator(path.charCodeAt(path.length - 1));
3282     }
3283     ts.hasTrailingDirectorySeparator = hasTrailingDirectorySeparator;
3284     function isVolumeCharacter(charCode) {
3285         return (charCode >= 97 && charCode <= 122) ||
3286             (charCode >= 65 && charCode <= 90);
3287     }
3288     function getFileUrlVolumeSeparatorEnd(url, start) {
3289         var ch0 = url.charCodeAt(start);
3290         if (ch0 === 58)
3291             return start + 1;
3292         if (ch0 === 37 && url.charCodeAt(start + 1) === 51) {
3293             var ch2 = url.charCodeAt(start + 2);
3294             if (ch2 === 97 || ch2 === 65)
3295                 return start + 3;
3296         }
3297         return -1;
3298     }
3299     function getEncodedRootLength(path) {
3300         if (!path)
3301             return 0;
3302         var ch0 = path.charCodeAt(0);
3303         if (ch0 === 47 || ch0 === 92) {
3304             if (path.charCodeAt(1) !== ch0)
3305                 return 1;
3306             var p1 = path.indexOf(ch0 === 47 ? ts.directorySeparator : altDirectorySeparator, 2);
3307             if (p1 < 0)
3308                 return path.length;
3309             return p1 + 1;
3310         }
3311         if (isVolumeCharacter(ch0) && path.charCodeAt(1) === 58) {
3312             var ch2 = path.charCodeAt(2);
3313             if (ch2 === 47 || ch2 === 92)
3314                 return 3;
3315             if (path.length === 2)
3316                 return 2;
3317         }
3318         var schemeEnd = path.indexOf(urlSchemeSeparator);
3319         if (schemeEnd !== -1) {
3320             var authorityStart = schemeEnd + urlSchemeSeparator.length;
3321             var authorityEnd = path.indexOf(ts.directorySeparator, authorityStart);
3322             if (authorityEnd !== -1) {
3323                 var scheme = path.slice(0, schemeEnd);
3324                 var authority = path.slice(authorityStart, authorityEnd);
3325                 if (scheme === "file" && (authority === "" || authority === "localhost") &&
3326                     isVolumeCharacter(path.charCodeAt(authorityEnd + 1))) {
3327                     var volumeSeparatorEnd = getFileUrlVolumeSeparatorEnd(path, authorityEnd + 2);
3328                     if (volumeSeparatorEnd !== -1) {
3329                         if (path.charCodeAt(volumeSeparatorEnd) === 47) {
3330                             return ~(volumeSeparatorEnd + 1);
3331                         }
3332                         if (volumeSeparatorEnd === path.length) {
3333                             return ~volumeSeparatorEnd;
3334                         }
3335                     }
3336                 }
3337                 return ~(authorityEnd + 1);
3338             }
3339             return ~path.length;
3340         }
3341         return 0;
3342     }
3343     function getRootLength(path) {
3344         var rootLength = getEncodedRootLength(path);
3345         return rootLength < 0 ? ~rootLength : rootLength;
3346     }
3347     ts.getRootLength = getRootLength;
3348     function getDirectoryPath(path) {
3349         path = normalizeSlashes(path);
3350         var rootLength = getRootLength(path);
3351         if (rootLength === path.length)
3352             return path;
3353         path = removeTrailingDirectorySeparator(path);
3354         return path.slice(0, Math.max(rootLength, path.lastIndexOf(ts.directorySeparator)));
3355     }
3356     ts.getDirectoryPath = getDirectoryPath;
3357     function getBaseFileName(path, extensions, ignoreCase) {
3358         path = normalizeSlashes(path);
3359         var rootLength = getRootLength(path);
3360         if (rootLength === path.length)
3361             return "";
3362         path = removeTrailingDirectorySeparator(path);
3363         var name = path.slice(Math.max(getRootLength(path), path.lastIndexOf(ts.directorySeparator) + 1));
3364         var extension = extensions !== undefined && ignoreCase !== undefined ? getAnyExtensionFromPath(name, extensions, ignoreCase) : undefined;
3365         return extension ? name.slice(0, name.length - extension.length) : name;
3366     }
3367     ts.getBaseFileName = getBaseFileName;
3368     function tryGetExtensionFromPath(path, extension, stringEqualityComparer) {
3369         if (!ts.startsWith(extension, "."))
3370             extension = "." + extension;
3371         if (path.length >= extension.length && path.charCodeAt(path.length - extension.length) === 46) {
3372             var pathExtension = path.slice(path.length - extension.length);
3373             if (stringEqualityComparer(pathExtension, extension)) {
3374                 return pathExtension;
3375             }
3376         }
3377     }
3378     function getAnyExtensionFromPathWorker(path, extensions, stringEqualityComparer) {
3379         if (typeof extensions === "string") {
3380             return tryGetExtensionFromPath(path, extensions, stringEqualityComparer) || "";
3381         }
3382         for (var _i = 0, extensions_2 = extensions; _i < extensions_2.length; _i++) {
3383             var extension = extensions_2[_i];
3384             var result = tryGetExtensionFromPath(path, extension, stringEqualityComparer);
3385             if (result)
3386                 return result;
3387         }
3388         return "";
3389     }
3390     function getAnyExtensionFromPath(path, extensions, ignoreCase) {
3391         if (extensions) {
3392             return getAnyExtensionFromPathWorker(removeTrailingDirectorySeparator(path), extensions, ignoreCase ? ts.equateStringsCaseInsensitive : ts.equateStringsCaseSensitive);
3393         }
3394         var baseFileName = getBaseFileName(path);
3395         var extensionIndex = baseFileName.lastIndexOf(".");
3396         if (extensionIndex >= 0) {
3397             return baseFileName.substring(extensionIndex);
3398         }
3399         return "";
3400     }
3401     ts.getAnyExtensionFromPath = getAnyExtensionFromPath;
3402     function pathComponents(path, rootLength) {
3403         var root = path.substring(0, rootLength);
3404         var rest = path.substring(rootLength).split(ts.directorySeparator);
3405         if (rest.length && !ts.lastOrUndefined(rest))
3406             rest.pop();
3407         return __spreadArrays([root], rest);
3408     }
3409     function getPathComponents(path, currentDirectory) {
3410         if (currentDirectory === void 0) { currentDirectory = ""; }
3411         path = combinePaths(currentDirectory, path);
3412         return pathComponents(path, getRootLength(path));
3413     }
3414     ts.getPathComponents = getPathComponents;
3415     function getPathFromPathComponents(pathComponents) {
3416         if (pathComponents.length === 0)
3417             return "";
3418         var root = pathComponents[0] && ensureTrailingDirectorySeparator(pathComponents[0]);
3419         return root + pathComponents.slice(1).join(ts.directorySeparator);
3420     }
3421     ts.getPathFromPathComponents = getPathFromPathComponents;
3422     function normalizeSlashes(path) {
3423         return path.replace(backslashRegExp, ts.directorySeparator);
3424     }
3425     ts.normalizeSlashes = normalizeSlashes;
3426     function reducePathComponents(components) {
3427         if (!ts.some(components))
3428             return [];
3429         var reduced = [components[0]];
3430         for (var i = 1; i < components.length; i++) {
3431             var component = components[i];
3432             if (!component)
3433                 continue;
3434             if (component === ".")
3435                 continue;
3436             if (component === "..") {
3437                 if (reduced.length > 1) {
3438                     if (reduced[reduced.length - 1] !== "..") {
3439                         reduced.pop();
3440                         continue;
3441                     }
3442                 }
3443                 else if (reduced[0])
3444                     continue;
3445             }
3446             reduced.push(component);
3447         }
3448         return reduced;
3449     }
3450     ts.reducePathComponents = reducePathComponents;
3451     function combinePaths(path) {
3452         var paths = [];
3453         for (var _i = 1; _i < arguments.length; _i++) {
3454             paths[_i - 1] = arguments[_i];
3455         }
3456         if (path)
3457             path = normalizeSlashes(path);
3458         for (var _a = 0, paths_1 = paths; _a < paths_1.length; _a++) {
3459             var relativePath = paths_1[_a];
3460             if (!relativePath)
3461                 continue;
3462             relativePath = normalizeSlashes(relativePath);
3463             if (!path || getRootLength(relativePath) !== 0) {
3464                 path = relativePath;
3465             }
3466             else {
3467                 path = ensureTrailingDirectorySeparator(path) + relativePath;
3468             }
3469         }
3470         return path;
3471     }
3472     ts.combinePaths = combinePaths;
3473     function resolvePath(path) {
3474         var paths = [];
3475         for (var _i = 1; _i < arguments.length; _i++) {
3476             paths[_i - 1] = arguments[_i];
3477         }
3478         return normalizePath(ts.some(paths) ? combinePaths.apply(void 0, __spreadArrays([path], paths)) : normalizeSlashes(path));
3479     }
3480     ts.resolvePath = resolvePath;
3481     function getNormalizedPathComponents(path, currentDirectory) {
3482         return reducePathComponents(getPathComponents(path, currentDirectory));
3483     }
3484     ts.getNormalizedPathComponents = getNormalizedPathComponents;
3485     function getNormalizedAbsolutePath(fileName, currentDirectory) {
3486         return getPathFromPathComponents(getNormalizedPathComponents(fileName, currentDirectory));
3487     }
3488     ts.getNormalizedAbsolutePath = getNormalizedAbsolutePath;
3489     function normalizePath(path) {
3490         path = normalizeSlashes(path);
3491         var normalized = getPathFromPathComponents(reducePathComponents(getPathComponents(path)));
3492         return normalized && hasTrailingDirectorySeparator(path) ? ensureTrailingDirectorySeparator(normalized) : normalized;
3493     }
3494     ts.normalizePath = normalizePath;
3495     function getPathWithoutRoot(pathComponents) {
3496         if (pathComponents.length === 0)
3497             return "";
3498         return pathComponents.slice(1).join(ts.directorySeparator);
3499     }
3500     function getNormalizedAbsolutePathWithoutRoot(fileName, currentDirectory) {
3501         return getPathWithoutRoot(getNormalizedPathComponents(fileName, currentDirectory));
3502     }
3503     ts.getNormalizedAbsolutePathWithoutRoot = getNormalizedAbsolutePathWithoutRoot;
3504     function toPath(fileName, basePath, getCanonicalFileName) {
3505         var nonCanonicalizedPath = isRootedDiskPath(fileName)
3506             ? normalizePath(fileName)
3507             : getNormalizedAbsolutePath(fileName, basePath);
3508         return getCanonicalFileName(nonCanonicalizedPath);
3509     }
3510     ts.toPath = toPath;
3511     function normalizePathAndParts(path) {
3512         path = normalizeSlashes(path);
3513         var _a = reducePathComponents(getPathComponents(path)), root = _a[0], parts = _a.slice(1);
3514         if (parts.length) {
3515             var joinedParts = root + parts.join(ts.directorySeparator);
3516             return { path: hasTrailingDirectorySeparator(path) ? ensureTrailingDirectorySeparator(joinedParts) : joinedParts, parts: parts };
3517         }
3518         else {
3519             return { path: root, parts: parts };
3520         }
3521     }
3522     ts.normalizePathAndParts = normalizePathAndParts;
3523     function removeTrailingDirectorySeparator(path) {
3524         if (hasTrailingDirectorySeparator(path)) {
3525             return path.substr(0, path.length - 1);
3526         }
3527         return path;
3528     }
3529     ts.removeTrailingDirectorySeparator = removeTrailingDirectorySeparator;
3530     function ensureTrailingDirectorySeparator(path) {
3531         if (!hasTrailingDirectorySeparator(path)) {
3532             return path + ts.directorySeparator;
3533         }
3534         return path;
3535     }
3536     ts.ensureTrailingDirectorySeparator = ensureTrailingDirectorySeparator;
3537     function ensurePathIsNonModuleName(path) {
3538         return !pathIsAbsolute(path) && !pathIsRelative(path) ? "./" + path : path;
3539     }
3540     ts.ensurePathIsNonModuleName = ensurePathIsNonModuleName;
3541     function changeAnyExtension(path, ext, extensions, ignoreCase) {
3542         var pathext = extensions !== undefined && ignoreCase !== undefined ? getAnyExtensionFromPath(path, extensions, ignoreCase) : getAnyExtensionFromPath(path);
3543         return pathext ? path.slice(0, path.length - pathext.length) + (ts.startsWith(ext, ".") ? ext : "." + ext) : path;
3544     }
3545     ts.changeAnyExtension = changeAnyExtension;
3546     var relativePathSegmentRegExp = /(^|\/)\.{0,2}($|\/)/;
3547     function comparePathsWorker(a, b, componentComparer) {
3548         if (a === b)
3549             return 0;
3550         if (a === undefined)
3551             return -1;
3552         if (b === undefined)
3553             return 1;
3554         var aRoot = a.substring(0, getRootLength(a));
3555         var bRoot = b.substring(0, getRootLength(b));
3556         var result = ts.compareStringsCaseInsensitive(aRoot, bRoot);
3557         if (result !== 0) {
3558             return result;
3559         }
3560         var aRest = a.substring(aRoot.length);
3561         var bRest = b.substring(bRoot.length);
3562         if (!relativePathSegmentRegExp.test(aRest) && !relativePathSegmentRegExp.test(bRest)) {
3563             return componentComparer(aRest, bRest);
3564         }
3565         var aComponents = reducePathComponents(getPathComponents(a));
3566         var bComponents = reducePathComponents(getPathComponents(b));
3567         var sharedLength = Math.min(aComponents.length, bComponents.length);
3568         for (var i = 1; i < sharedLength; i++) {
3569             var result_2 = componentComparer(aComponents[i], bComponents[i]);
3570             if (result_2 !== 0) {
3571                 return result_2;
3572             }
3573         }
3574         return ts.compareValues(aComponents.length, bComponents.length);
3575     }
3576     function comparePathsCaseSensitive(a, b) {
3577         return comparePathsWorker(a, b, ts.compareStringsCaseSensitive);
3578     }
3579     ts.comparePathsCaseSensitive = comparePathsCaseSensitive;
3580     function comparePathsCaseInsensitive(a, b) {
3581         return comparePathsWorker(a, b, ts.compareStringsCaseInsensitive);
3582     }
3583     ts.comparePathsCaseInsensitive = comparePathsCaseInsensitive;
3584     function comparePaths(a, b, currentDirectory, ignoreCase) {
3585         if (typeof currentDirectory === "string") {
3586             a = combinePaths(currentDirectory, a);
3587             b = combinePaths(currentDirectory, b);
3588         }
3589         else if (typeof currentDirectory === "boolean") {
3590             ignoreCase = currentDirectory;
3591         }
3592         return comparePathsWorker(a, b, ts.getStringComparer(ignoreCase));
3593     }
3594     ts.comparePaths = comparePaths;
3595     function containsPath(parent, child, currentDirectory, ignoreCase) {
3596         if (typeof currentDirectory === "string") {
3597             parent = combinePaths(currentDirectory, parent);
3598             child = combinePaths(currentDirectory, child);
3599         }
3600         else if (typeof currentDirectory === "boolean") {
3601             ignoreCase = currentDirectory;
3602         }
3603         if (parent === undefined || child === undefined)
3604             return false;
3605         if (parent === child)
3606             return true;
3607         var parentComponents = reducePathComponents(getPathComponents(parent));
3608         var childComponents = reducePathComponents(getPathComponents(child));
3609         if (childComponents.length < parentComponents.length) {
3610             return false;
3611         }
3612         var componentEqualityComparer = ignoreCase ? ts.equateStringsCaseInsensitive : ts.equateStringsCaseSensitive;
3613         for (var i = 0; i < parentComponents.length; i++) {
3614             var equalityComparer = i === 0 ? ts.equateStringsCaseInsensitive : componentEqualityComparer;
3615             if (!equalityComparer(parentComponents[i], childComponents[i])) {
3616                 return false;
3617             }
3618         }
3619         return true;
3620     }
3621     ts.containsPath = containsPath;
3622     function startsWithDirectory(fileName, directoryName, getCanonicalFileName) {
3623         var canonicalFileName = getCanonicalFileName(fileName);
3624         var canonicalDirectoryName = getCanonicalFileName(directoryName);
3625         return ts.startsWith(canonicalFileName, canonicalDirectoryName + "/") || ts.startsWith(canonicalFileName, canonicalDirectoryName + "\\");
3626     }
3627     ts.startsWithDirectory = startsWithDirectory;
3628     function getPathComponentsRelativeTo(from, to, stringEqualityComparer, getCanonicalFileName) {
3629         var fromComponents = reducePathComponents(getPathComponents(from));
3630         var toComponents = reducePathComponents(getPathComponents(to));
3631         var start;
3632         for (start = 0; start < fromComponents.length && start < toComponents.length; start++) {
3633             var fromComponent = getCanonicalFileName(fromComponents[start]);
3634             var toComponent = getCanonicalFileName(toComponents[start]);
3635             var comparer = start === 0 ? ts.equateStringsCaseInsensitive : stringEqualityComparer;
3636             if (!comparer(fromComponent, toComponent))
3637                 break;
3638         }
3639         if (start === 0) {
3640             return toComponents;
3641         }
3642         var components = toComponents.slice(start);
3643         var relative = [];
3644         for (; start < fromComponents.length; start++) {
3645             relative.push("..");
3646         }
3647         return __spreadArrays([""], relative, components);
3648     }
3649     ts.getPathComponentsRelativeTo = getPathComponentsRelativeTo;
3650     function getRelativePathFromDirectory(fromDirectory, to, getCanonicalFileNameOrIgnoreCase) {
3651         ts.Debug.assert((getRootLength(fromDirectory) > 0) === (getRootLength(to) > 0), "Paths must either both be absolute or both be relative");
3652         var getCanonicalFileName = typeof getCanonicalFileNameOrIgnoreCase === "function" ? getCanonicalFileNameOrIgnoreCase : ts.identity;
3653         var ignoreCase = typeof getCanonicalFileNameOrIgnoreCase === "boolean" ? getCanonicalFileNameOrIgnoreCase : false;
3654         var pathComponents = getPathComponentsRelativeTo(fromDirectory, to, ignoreCase ? ts.equateStringsCaseInsensitive : ts.equateStringsCaseSensitive, getCanonicalFileName);
3655         return getPathFromPathComponents(pathComponents);
3656     }
3657     ts.getRelativePathFromDirectory = getRelativePathFromDirectory;
3658     function convertToRelativePath(absoluteOrRelativePath, basePath, getCanonicalFileName) {
3659         return !isRootedDiskPath(absoluteOrRelativePath)
3660             ? absoluteOrRelativePath
3661             : getRelativePathToDirectoryOrUrl(basePath, absoluteOrRelativePath, basePath, getCanonicalFileName, false);
3662     }
3663     ts.convertToRelativePath = convertToRelativePath;
3664     function getRelativePathFromFile(from, to, getCanonicalFileName) {
3665         return ensurePathIsNonModuleName(getRelativePathFromDirectory(getDirectoryPath(from), to, getCanonicalFileName));
3666     }
3667     ts.getRelativePathFromFile = getRelativePathFromFile;
3668     function getRelativePathToDirectoryOrUrl(directoryPathOrUrl, relativeOrAbsolutePath, currentDirectory, getCanonicalFileName, isAbsolutePathAnUrl) {
3669         var pathComponents = getPathComponentsRelativeTo(resolvePath(currentDirectory, directoryPathOrUrl), resolvePath(currentDirectory, relativeOrAbsolutePath), ts.equateStringsCaseSensitive, getCanonicalFileName);
3670         var firstComponent = pathComponents[0];
3671         if (isAbsolutePathAnUrl && isRootedDiskPath(firstComponent)) {
3672             var prefix = firstComponent.charAt(0) === ts.directorySeparator ? "file://" : "file:///";
3673             pathComponents[0] = prefix + firstComponent;
3674         }
3675         return getPathFromPathComponents(pathComponents);
3676     }
3677     ts.getRelativePathToDirectoryOrUrl = getRelativePathToDirectoryOrUrl;
3678     function forEachAncestorDirectory(directory, callback) {
3679         while (true) {
3680             var result = callback(directory);
3681             if (result !== undefined) {
3682                 return result;
3683             }
3684             var parentPath = getDirectoryPath(directory);
3685             if (parentPath === directory) {
3686                 return undefined;
3687             }
3688             directory = parentPath;
3689         }
3690     }
3691     ts.forEachAncestorDirectory = forEachAncestorDirectory;
3692     function isNodeModulesDirectory(dirPath) {
3693         return ts.endsWith(dirPath, "/node_modules");
3694     }
3695     ts.isNodeModulesDirectory = isNodeModulesDirectory;
3696 })(ts || (ts = {}));
3697 var ts;
3698 (function (ts) {
3699     function generateDjb2Hash(data) {
3700         var acc = 5381;
3701         for (var i = 0; i < data.length; i++) {
3702             acc = ((acc << 5) + acc) + data.charCodeAt(i);
3703         }
3704         return acc.toString();
3705     }
3706     ts.generateDjb2Hash = generateDjb2Hash;
3707     function setStackTraceLimit() {
3708         if (Error.stackTraceLimit < 100) {
3709             Error.stackTraceLimit = 100;
3710         }
3711     }
3712     ts.setStackTraceLimit = setStackTraceLimit;
3713     var FileWatcherEventKind;
3714     (function (FileWatcherEventKind) {
3715         FileWatcherEventKind[FileWatcherEventKind["Created"] = 0] = "Created";
3716         FileWatcherEventKind[FileWatcherEventKind["Changed"] = 1] = "Changed";
3717         FileWatcherEventKind[FileWatcherEventKind["Deleted"] = 2] = "Deleted";
3718     })(FileWatcherEventKind = ts.FileWatcherEventKind || (ts.FileWatcherEventKind = {}));
3719     var PollingInterval;
3720     (function (PollingInterval) {
3721         PollingInterval[PollingInterval["High"] = 2000] = "High";
3722         PollingInterval[PollingInterval["Medium"] = 500] = "Medium";
3723         PollingInterval[PollingInterval["Low"] = 250] = "Low";
3724     })(PollingInterval = ts.PollingInterval || (ts.PollingInterval = {}));
3725     ts.missingFileModifiedTime = new Date(0);
3726     function createPollingIntervalBasedLevels(levels) {
3727         var _a;
3728         return _a = {},
3729             _a[PollingInterval.Low] = levels.Low,
3730             _a[PollingInterval.Medium] = levels.Medium,
3731             _a[PollingInterval.High] = levels.High,
3732             _a;
3733     }
3734     var defaultChunkLevels = { Low: 32, Medium: 64, High: 256 };
3735     var pollingChunkSize = createPollingIntervalBasedLevels(defaultChunkLevels);
3736     ts.unchangedPollThresholds = createPollingIntervalBasedLevels(defaultChunkLevels);
3737     function setCustomPollingValues(system) {
3738         if (!system.getEnvironmentVariable) {
3739             return;
3740         }
3741         var pollingIntervalChanged = setCustomLevels("TSC_WATCH_POLLINGINTERVAL", PollingInterval);
3742         pollingChunkSize = getCustomPollingBasedLevels("TSC_WATCH_POLLINGCHUNKSIZE", defaultChunkLevels) || pollingChunkSize;
3743         ts.unchangedPollThresholds = getCustomPollingBasedLevels("TSC_WATCH_UNCHANGEDPOLLTHRESHOLDS", defaultChunkLevels) || ts.unchangedPollThresholds;
3744         function getLevel(envVar, level) {
3745             return system.getEnvironmentVariable(envVar + "_" + level.toUpperCase());
3746         }
3747         function getCustomLevels(baseVariable) {
3748             var customLevels;
3749             setCustomLevel("Low");
3750             setCustomLevel("Medium");
3751             setCustomLevel("High");
3752             return customLevels;
3753             function setCustomLevel(level) {
3754                 var customLevel = getLevel(baseVariable, level);
3755                 if (customLevel) {
3756                     (customLevels || (customLevels = {}))[level] = Number(customLevel);
3757                 }
3758             }
3759         }
3760         function setCustomLevels(baseVariable, levels) {
3761             var customLevels = getCustomLevels(baseVariable);
3762             if (customLevels) {
3763                 setLevel("Low");
3764                 setLevel("Medium");
3765                 setLevel("High");
3766                 return true;
3767             }
3768             return false;
3769             function setLevel(level) {
3770                 levels[level] = customLevels[level] || levels[level];
3771             }
3772         }
3773         function getCustomPollingBasedLevels(baseVariable, defaultLevels) {
3774             var customLevels = getCustomLevels(baseVariable);
3775             return (pollingIntervalChanged || customLevels) &&
3776                 createPollingIntervalBasedLevels(customLevels ? __assign(__assign({}, defaultLevels), customLevels) : defaultLevels);
3777         }
3778     }
3779     ts.setCustomPollingValues = setCustomPollingValues;
3780     function createDynamicPriorityPollingWatchFile(host) {
3781         var watchedFiles = [];
3782         var changedFilesInLastPoll = [];
3783         var lowPollingIntervalQueue = createPollingIntervalQueue(PollingInterval.Low);
3784         var mediumPollingIntervalQueue = createPollingIntervalQueue(PollingInterval.Medium);
3785         var highPollingIntervalQueue = createPollingIntervalQueue(PollingInterval.High);
3786         return watchFile;
3787         function watchFile(fileName, callback, defaultPollingInterval) {
3788             var file = {
3789                 fileName: fileName,
3790                 callback: callback,
3791                 unchangedPolls: 0,
3792                 mtime: getModifiedTime(fileName)
3793             };
3794             watchedFiles.push(file);
3795             addToPollingIntervalQueue(file, defaultPollingInterval);
3796             return {
3797                 close: function () {
3798                     file.isClosed = true;
3799                     ts.unorderedRemoveItem(watchedFiles, file);
3800                 }
3801             };
3802         }
3803         function createPollingIntervalQueue(pollingInterval) {
3804             var queue = [];
3805             queue.pollingInterval = pollingInterval;
3806             queue.pollIndex = 0;
3807             queue.pollScheduled = false;
3808             return queue;
3809         }
3810         function pollPollingIntervalQueue(queue) {
3811             queue.pollIndex = pollQueue(queue, queue.pollingInterval, queue.pollIndex, pollingChunkSize[queue.pollingInterval]);
3812             if (queue.length) {
3813                 scheduleNextPoll(queue.pollingInterval);
3814             }
3815             else {
3816                 ts.Debug.assert(queue.pollIndex === 0);
3817                 queue.pollScheduled = false;
3818             }
3819         }
3820         function pollLowPollingIntervalQueue(queue) {
3821             pollQueue(changedFilesInLastPoll, PollingInterval.Low, 0, changedFilesInLastPoll.length);
3822             pollPollingIntervalQueue(queue);
3823             if (!queue.pollScheduled && changedFilesInLastPoll.length) {
3824                 scheduleNextPoll(PollingInterval.Low);
3825             }
3826         }
3827         function pollQueue(queue, pollingInterval, pollIndex, chunkSize) {
3828             var needsVisit = queue.length;
3829             var definedValueCopyToIndex = pollIndex;
3830             for (var polled = 0; polled < chunkSize && needsVisit > 0; nextPollIndex(), needsVisit--) {
3831                 var watchedFile = queue[pollIndex];
3832                 if (!watchedFile) {
3833                     continue;
3834                 }
3835                 else if (watchedFile.isClosed) {
3836                     queue[pollIndex] = undefined;
3837                     continue;
3838                 }
3839                 polled++;
3840                 var fileChanged = onWatchedFileStat(watchedFile, getModifiedTime(watchedFile.fileName));
3841                 if (watchedFile.isClosed) {
3842                     queue[pollIndex] = undefined;
3843                 }
3844                 else if (fileChanged) {
3845                     watchedFile.unchangedPolls = 0;
3846                     if (queue !== changedFilesInLastPoll) {
3847                         queue[pollIndex] = undefined;
3848                         addChangedFileToLowPollingIntervalQueue(watchedFile);
3849                     }
3850                 }
3851                 else if (watchedFile.unchangedPolls !== ts.unchangedPollThresholds[pollingInterval]) {
3852                     watchedFile.unchangedPolls++;
3853                 }
3854                 else if (queue === changedFilesInLastPoll) {
3855                     watchedFile.unchangedPolls = 1;
3856                     queue[pollIndex] = undefined;
3857                     addToPollingIntervalQueue(watchedFile, PollingInterval.Low);
3858                 }
3859                 else if (pollingInterval !== PollingInterval.High) {
3860                     watchedFile.unchangedPolls++;
3861                     queue[pollIndex] = undefined;
3862                     addToPollingIntervalQueue(watchedFile, pollingInterval === PollingInterval.Low ? PollingInterval.Medium : PollingInterval.High);
3863                 }
3864                 if (queue[pollIndex]) {
3865                     if (definedValueCopyToIndex < pollIndex) {
3866                         queue[definedValueCopyToIndex] = watchedFile;
3867                         queue[pollIndex] = undefined;
3868                     }
3869                     definedValueCopyToIndex++;
3870                 }
3871             }
3872             return pollIndex;
3873             function nextPollIndex() {
3874                 pollIndex++;
3875                 if (pollIndex === queue.length) {
3876                     if (definedValueCopyToIndex < pollIndex) {
3877                         queue.length = definedValueCopyToIndex;
3878                     }
3879                     pollIndex = 0;
3880                     definedValueCopyToIndex = 0;
3881                 }
3882             }
3883         }
3884         function pollingIntervalQueue(pollingInterval) {
3885             switch (pollingInterval) {
3886                 case PollingInterval.Low:
3887                     return lowPollingIntervalQueue;
3888                 case PollingInterval.Medium:
3889                     return mediumPollingIntervalQueue;
3890                 case PollingInterval.High:
3891                     return highPollingIntervalQueue;
3892             }
3893         }
3894         function addToPollingIntervalQueue(file, pollingInterval) {
3895             pollingIntervalQueue(pollingInterval).push(file);
3896             scheduleNextPollIfNotAlreadyScheduled(pollingInterval);
3897         }
3898         function addChangedFileToLowPollingIntervalQueue(file) {
3899             changedFilesInLastPoll.push(file);
3900             scheduleNextPollIfNotAlreadyScheduled(PollingInterval.Low);
3901         }
3902         function scheduleNextPollIfNotAlreadyScheduled(pollingInterval) {
3903             if (!pollingIntervalQueue(pollingInterval).pollScheduled) {
3904                 scheduleNextPoll(pollingInterval);
3905             }
3906         }
3907         function scheduleNextPoll(pollingInterval) {
3908             pollingIntervalQueue(pollingInterval).pollScheduled = host.setTimeout(pollingInterval === PollingInterval.Low ? pollLowPollingIntervalQueue : pollPollingIntervalQueue, pollingInterval, pollingIntervalQueue(pollingInterval));
3909         }
3910         function getModifiedTime(fileName) {
3911             return host.getModifiedTime(fileName) || ts.missingFileModifiedTime;
3912         }
3913     }
3914     ts.createDynamicPriorityPollingWatchFile = createDynamicPriorityPollingWatchFile;
3915     function createUseFsEventsOnParentDirectoryWatchFile(fsWatch, useCaseSensitiveFileNames) {
3916         var fileWatcherCallbacks = ts.createMultiMap();
3917         var dirWatchers = new ts.Map();
3918         var toCanonicalName = ts.createGetCanonicalFileName(useCaseSensitiveFileNames);
3919         return nonPollingWatchFile;
3920         function nonPollingWatchFile(fileName, callback, _pollingInterval, fallbackOptions) {
3921             var filePath = toCanonicalName(fileName);
3922             fileWatcherCallbacks.add(filePath, callback);
3923             var dirPath = ts.getDirectoryPath(filePath) || ".";
3924             var watcher = dirWatchers.get(dirPath) ||
3925                 createDirectoryWatcher(ts.getDirectoryPath(fileName) || ".", dirPath, fallbackOptions);
3926             watcher.referenceCount++;
3927             return {
3928                 close: function () {
3929                     if (watcher.referenceCount === 1) {
3930                         watcher.close();
3931                         dirWatchers.delete(dirPath);
3932                     }
3933                     else {
3934                         watcher.referenceCount--;
3935                     }
3936                     fileWatcherCallbacks.remove(filePath, callback);
3937                 }
3938             };
3939         }
3940         function createDirectoryWatcher(dirName, dirPath, fallbackOptions) {
3941             var watcher = fsWatch(dirName, 1, function (_eventName, relativeFileName) {
3942                 if (!ts.isString(relativeFileName)) {
3943                     return;
3944                 }
3945                 var fileName = ts.getNormalizedAbsolutePath(relativeFileName, dirName);
3946                 var callbacks = fileName && fileWatcherCallbacks.get(toCanonicalName(fileName));
3947                 if (callbacks) {
3948                     for (var _i = 0, callbacks_1 = callbacks; _i < callbacks_1.length; _i++) {
3949                         var fileCallback = callbacks_1[_i];
3950                         fileCallback(fileName, FileWatcherEventKind.Changed);
3951                     }
3952                 }
3953             }, false, PollingInterval.Medium, fallbackOptions);
3954             watcher.referenceCount = 0;
3955             dirWatchers.set(dirPath, watcher);
3956             return watcher;
3957         }
3958     }
3959     function createSingleFileWatcherPerName(watchFile, useCaseSensitiveFileNames) {
3960         var cache = new ts.Map();
3961         var callbacksCache = ts.createMultiMap();
3962         var toCanonicalFileName = ts.createGetCanonicalFileName(useCaseSensitiveFileNames);
3963         return function (fileName, callback, pollingInterval, options) {
3964             var path = toCanonicalFileName(fileName);
3965             var existing = cache.get(path);
3966             if (existing) {
3967                 existing.refCount++;
3968             }
3969             else {
3970                 cache.set(path, {
3971                     watcher: watchFile(fileName, function (fileName, eventKind) { return ts.forEach(callbacksCache.get(path), function (cb) { return cb(fileName, eventKind); }); }, pollingInterval, options),
3972                     refCount: 1
3973                 });
3974             }
3975             callbacksCache.add(path, callback);
3976             return {
3977                 close: function () {
3978                     var watcher = ts.Debug.checkDefined(cache.get(path));
3979                     callbacksCache.remove(path, callback);
3980                     watcher.refCount--;
3981                     if (watcher.refCount)
3982                         return;
3983                     cache.delete(path);
3984                     ts.closeFileWatcherOf(watcher);
3985                 }
3986             };
3987         };
3988     }
3989     ts.createSingleFileWatcherPerName = createSingleFileWatcherPerName;
3990     function onWatchedFileStat(watchedFile, modifiedTime) {
3991         var oldTime = watchedFile.mtime.getTime();
3992         var newTime = modifiedTime.getTime();
3993         if (oldTime !== newTime) {
3994             watchedFile.mtime = modifiedTime;
3995             watchedFile.callback(watchedFile.fileName, getFileWatcherEventKind(oldTime, newTime));
3996             return true;
3997         }
3998         return false;
3999     }
4000     ts.onWatchedFileStat = onWatchedFileStat;
4001     function getFileWatcherEventKind(oldTime, newTime) {
4002         return oldTime === 0
4003             ? FileWatcherEventKind.Created
4004             : newTime === 0
4005                 ? FileWatcherEventKind.Deleted
4006                 : FileWatcherEventKind.Changed;
4007     }
4008     ts.getFileWatcherEventKind = getFileWatcherEventKind;
4009     ts.ignoredPaths = ["/node_modules/.", "/.git", "/.#"];
4010     ts.sysLog = ts.noop;
4011     function setSysLog(logger) {
4012         ts.sysLog = logger;
4013     }
4014     ts.setSysLog = setSysLog;
4015     function createDirectoryWatcherSupportingRecursive(host) {
4016         var cache = new ts.Map();
4017         var callbackCache = ts.createMultiMap();
4018         var cacheToUpdateChildWatches = new ts.Map();
4019         var timerToUpdateChildWatches;
4020         var filePathComparer = ts.getStringComparer(!host.useCaseSensitiveFileNames);
4021         var toCanonicalFilePath = ts.createGetCanonicalFileName(host.useCaseSensitiveFileNames);
4022         return function (dirName, callback, recursive, options) { return recursive ?
4023             createDirectoryWatcher(dirName, options, callback) :
4024             host.watchDirectory(dirName, callback, recursive, options); };
4025         function createDirectoryWatcher(dirName, options, callback) {
4026             var dirPath = toCanonicalFilePath(dirName);
4027             var directoryWatcher = cache.get(dirPath);
4028             if (directoryWatcher) {
4029                 directoryWatcher.refCount++;
4030             }
4031             else {
4032                 directoryWatcher = {
4033                     watcher: host.watchDirectory(dirName, function (fileName) {
4034                         if (isIgnoredPath(fileName))
4035                             return;
4036                         if (options === null || options === void 0 ? void 0 : options.synchronousWatchDirectory) {
4037                             invokeCallbacks(dirPath, fileName);
4038                             updateChildWatches(dirName, dirPath, options);
4039                         }
4040                         else {
4041                             nonSyncUpdateChildWatches(dirName, dirPath, fileName, options);
4042                         }
4043                     }, false, options),
4044                     refCount: 1,
4045                     childWatches: ts.emptyArray
4046                 };
4047                 cache.set(dirPath, directoryWatcher);
4048                 updateChildWatches(dirName, dirPath, options);
4049             }
4050             var callbackToAdd = callback && { dirName: dirName, callback: callback };
4051             if (callbackToAdd) {
4052                 callbackCache.add(dirPath, callbackToAdd);
4053             }
4054             return {
4055                 dirName: dirName,
4056                 close: function () {
4057                     var directoryWatcher = ts.Debug.checkDefined(cache.get(dirPath));
4058                     if (callbackToAdd)
4059                         callbackCache.remove(dirPath, callbackToAdd);
4060                     directoryWatcher.refCount--;
4061                     if (directoryWatcher.refCount)
4062                         return;
4063                     cache.delete(dirPath);
4064                     ts.closeFileWatcherOf(directoryWatcher);
4065                     directoryWatcher.childWatches.forEach(ts.closeFileWatcher);
4066                 }
4067             };
4068         }
4069         function invokeCallbacks(dirPath, fileNameOrInvokeMap, fileNames) {
4070             var fileName;
4071             var invokeMap;
4072             if (ts.isString(fileNameOrInvokeMap)) {
4073                 fileName = fileNameOrInvokeMap;
4074             }
4075             else {
4076                 invokeMap = fileNameOrInvokeMap;
4077             }
4078             callbackCache.forEach(function (callbacks, rootDirName) {
4079                 var _a;
4080                 if (invokeMap && invokeMap.get(rootDirName) === true)
4081                     return;
4082                 if (rootDirName === dirPath || (ts.startsWith(dirPath, rootDirName) && dirPath[rootDirName.length] === ts.directorySeparator)) {
4083                     if (invokeMap) {
4084                         if (fileNames) {
4085                             var existing = invokeMap.get(rootDirName);
4086                             if (existing) {
4087                                 (_a = existing).push.apply(_a, fileNames);
4088                             }
4089                             else {
4090                                 invokeMap.set(rootDirName, fileNames.slice());
4091                             }
4092                         }
4093                         else {
4094                             invokeMap.set(rootDirName, true);
4095                         }
4096                     }
4097                     else {
4098                         callbacks.forEach(function (_a) {
4099                             var callback = _a.callback;
4100                             return callback(fileName);
4101                         });
4102                     }
4103                 }
4104             });
4105         }
4106         function nonSyncUpdateChildWatches(dirName, dirPath, fileName, options) {
4107             var parentWatcher = cache.get(dirPath);
4108             if (parentWatcher && host.directoryExists(dirName)) {
4109                 scheduleUpdateChildWatches(dirName, dirPath, fileName, options);
4110                 return;
4111             }
4112             invokeCallbacks(dirPath, fileName);
4113             removeChildWatches(parentWatcher);
4114         }
4115         function scheduleUpdateChildWatches(dirName, dirPath, fileName, options) {
4116             var existing = cacheToUpdateChildWatches.get(dirPath);
4117             if (existing) {
4118                 existing.fileNames.push(fileName);
4119             }
4120             else {
4121                 cacheToUpdateChildWatches.set(dirPath, { dirName: dirName, options: options, fileNames: [fileName] });
4122             }
4123             if (timerToUpdateChildWatches) {
4124                 host.clearTimeout(timerToUpdateChildWatches);
4125                 timerToUpdateChildWatches = undefined;
4126             }
4127             timerToUpdateChildWatches = host.setTimeout(onTimerToUpdateChildWatches, 1000);
4128         }
4129         function onTimerToUpdateChildWatches() {
4130             timerToUpdateChildWatches = undefined;
4131             ts.sysLog("sysLog:: onTimerToUpdateChildWatches:: " + cacheToUpdateChildWatches.size);
4132             var start = ts.timestamp();
4133             var invokeMap = new ts.Map();
4134             while (!timerToUpdateChildWatches && cacheToUpdateChildWatches.size) {
4135                 var _a = cacheToUpdateChildWatches.entries().next(), _b = _a.value, dirPath = _b[0], _c = _b[1], dirName = _c.dirName, options = _c.options, fileNames = _c.fileNames, done = _a.done;
4136                 ts.Debug.assert(!done);
4137                 cacheToUpdateChildWatches.delete(dirPath);
4138                 var hasChanges = updateChildWatches(dirName, dirPath, options);
4139                 invokeCallbacks(dirPath, invokeMap, hasChanges ? undefined : fileNames);
4140             }
4141             ts.sysLog("sysLog:: invokingWatchers:: " + (ts.timestamp() - start) + "ms:: " + cacheToUpdateChildWatches.size);
4142             callbackCache.forEach(function (callbacks, rootDirName) {
4143                 var existing = invokeMap.get(rootDirName);
4144                 if (existing) {
4145                     callbacks.forEach(function (_a) {
4146                         var callback = _a.callback, dirName = _a.dirName;
4147                         if (ts.isArray(existing)) {
4148                             existing.forEach(callback);
4149                         }
4150                         else {
4151                             callback(dirName);
4152                         }
4153                     });
4154                 }
4155             });
4156             var elapsed = ts.timestamp() - start;
4157             ts.sysLog("sysLog:: Elapsed " + elapsed + "ms:: onTimerToUpdateChildWatches:: " + cacheToUpdateChildWatches.size + " " + timerToUpdateChildWatches);
4158         }
4159         function removeChildWatches(parentWatcher) {
4160             if (!parentWatcher)
4161                 return;
4162             var existingChildWatches = parentWatcher.childWatches;
4163             parentWatcher.childWatches = ts.emptyArray;
4164             for (var _i = 0, existingChildWatches_1 = existingChildWatches; _i < existingChildWatches_1.length; _i++) {
4165                 var childWatcher = existingChildWatches_1[_i];
4166                 childWatcher.close();
4167                 removeChildWatches(cache.get(toCanonicalFilePath(childWatcher.dirName)));
4168             }
4169         }
4170         function updateChildWatches(parentDir, parentDirPath, options) {
4171             var parentWatcher = cache.get(parentDirPath);
4172             if (!parentWatcher)
4173                 return false;
4174             var newChildWatches;
4175             var hasChanges = ts.enumerateInsertsAndDeletes(host.directoryExists(parentDir) ? ts.mapDefined(host.getAccessibleSortedChildDirectories(parentDir), function (child) {
4176                 var childFullName = ts.getNormalizedAbsolutePath(child, parentDir);
4177                 return !isIgnoredPath(childFullName) && filePathComparer(childFullName, ts.normalizePath(host.realpath(childFullName))) === 0 ? childFullName : undefined;
4178             }) : ts.emptyArray, parentWatcher.childWatches, function (child, childWatcher) { return filePathComparer(child, childWatcher.dirName); }, createAndAddChildDirectoryWatcher, ts.closeFileWatcher, addChildDirectoryWatcher);
4179             parentWatcher.childWatches = newChildWatches || ts.emptyArray;
4180             return hasChanges;
4181             function createAndAddChildDirectoryWatcher(childName) {
4182                 var result = createDirectoryWatcher(childName, options);
4183                 addChildDirectoryWatcher(result);
4184             }
4185             function addChildDirectoryWatcher(childWatcher) {
4186                 (newChildWatches || (newChildWatches = [])).push(childWatcher);
4187             }
4188         }
4189         function isIgnoredPath(path) {
4190             return ts.some(ts.ignoredPaths, function (searchPath) { return isInPath(path, searchPath); });
4191         }
4192         function isInPath(path, searchPath) {
4193             if (ts.stringContains(path, searchPath))
4194                 return true;
4195             if (host.useCaseSensitiveFileNames)
4196                 return false;
4197             return ts.stringContains(toCanonicalFilePath(path), searchPath);
4198         }
4199     }
4200     ts.createDirectoryWatcherSupportingRecursive = createDirectoryWatcherSupportingRecursive;
4201     function createFileWatcherCallback(callback) {
4202         return function (_fileName, eventKind) { return callback(eventKind === FileWatcherEventKind.Changed ? "change" : "rename", ""); };
4203     }
4204     ts.createFileWatcherCallback = createFileWatcherCallback;
4205     function createFsWatchCallbackForFileWatcherCallback(fileName, callback, fileExists) {
4206         return function (eventName) {
4207             if (eventName === "rename") {
4208                 callback(fileName, fileExists(fileName) ? FileWatcherEventKind.Created : FileWatcherEventKind.Deleted);
4209             }
4210             else {
4211                 callback(fileName, FileWatcherEventKind.Changed);
4212             }
4213         };
4214     }
4215     function createFsWatchCallbackForDirectoryWatcherCallback(directoryName, callback) {
4216         return function (eventName, relativeFileName) {
4217             if (eventName === "rename") {
4218                 callback(!relativeFileName ? directoryName : ts.normalizePath(ts.combinePaths(directoryName, relativeFileName)));
4219             }
4220         };
4221     }
4222     function createSystemWatchFunctions(_a) {
4223         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;
4224         var dynamicPollingWatchFile;
4225         var nonPollingWatchFile;
4226         var hostRecursiveDirectoryWatcher;
4227         return {
4228             watchFile: watchFile,
4229             watchDirectory: watchDirectory
4230         };
4231         function watchFile(fileName, callback, pollingInterval, options) {
4232             options = updateOptionsForWatchFile(options, useNonPollingWatchers);
4233             var watchFileKind = ts.Debug.checkDefined(options.watchFile);
4234             switch (watchFileKind) {
4235                 case ts.WatchFileKind.FixedPollingInterval:
4236                     return pollingWatchFile(fileName, callback, PollingInterval.Low, undefined);
4237                 case ts.WatchFileKind.PriorityPollingInterval:
4238                     return pollingWatchFile(fileName, callback, pollingInterval, undefined);
4239                 case ts.WatchFileKind.DynamicPriorityPolling:
4240                     return ensureDynamicPollingWatchFile()(fileName, callback, pollingInterval, undefined);
4241                 case ts.WatchFileKind.UseFsEvents:
4242                     return fsWatch(fileName, 0, createFsWatchCallbackForFileWatcherCallback(fileName, callback, fileExists), false, pollingInterval, ts.getFallbackOptions(options));
4243                 case ts.WatchFileKind.UseFsEventsOnParentDirectory:
4244                     if (!nonPollingWatchFile) {
4245                         nonPollingWatchFile = createUseFsEventsOnParentDirectoryWatchFile(fsWatch, useCaseSensitiveFileNames);
4246                     }
4247                     return nonPollingWatchFile(fileName, callback, pollingInterval, ts.getFallbackOptions(options));
4248                 default:
4249                     ts.Debug.assertNever(watchFileKind);
4250             }
4251         }
4252         function ensureDynamicPollingWatchFile() {
4253             return dynamicPollingWatchFile ||
4254                 (dynamicPollingWatchFile = createDynamicPriorityPollingWatchFile({ getModifiedTime: getModifiedTime, setTimeout: setTimeout }));
4255         }
4256         function updateOptionsForWatchFile(options, useNonPollingWatchers) {
4257             if (options && options.watchFile !== undefined)
4258                 return options;
4259             switch (tscWatchFile) {
4260                 case "PriorityPollingInterval":
4261                     return { watchFile: ts.WatchFileKind.PriorityPollingInterval };
4262                 case "DynamicPriorityPolling":
4263                     return { watchFile: ts.WatchFileKind.DynamicPriorityPolling };
4264                 case "UseFsEvents":
4265                     return generateWatchFileOptions(ts.WatchFileKind.UseFsEvents, ts.PollingWatchKind.PriorityInterval, options);
4266                 case "UseFsEventsWithFallbackDynamicPolling":
4267                     return generateWatchFileOptions(ts.WatchFileKind.UseFsEvents, ts.PollingWatchKind.DynamicPriority, options);
4268                 case "UseFsEventsOnParentDirectory":
4269                     useNonPollingWatchers = true;
4270                 default:
4271                     return useNonPollingWatchers ?
4272                         generateWatchFileOptions(ts.WatchFileKind.UseFsEventsOnParentDirectory, ts.PollingWatchKind.PriorityInterval, options) :
4273                         { watchFile: ts.WatchFileKind.FixedPollingInterval };
4274             }
4275         }
4276         function generateWatchFileOptions(watchFile, fallbackPolling, options) {
4277             var defaultFallbackPolling = options === null || options === void 0 ? void 0 : options.fallbackPolling;
4278             return {
4279                 watchFile: watchFile,
4280                 fallbackPolling: defaultFallbackPolling === undefined ?
4281                     fallbackPolling :
4282                     defaultFallbackPolling
4283             };
4284         }
4285         function watchDirectory(directoryName, callback, recursive, options) {
4286             if (fsSupportsRecursiveFsWatch) {
4287                 return fsWatch(directoryName, 1, createFsWatchCallbackForDirectoryWatcherCallback(directoryName, callback), recursive, PollingInterval.Medium, ts.getFallbackOptions(options));
4288             }
4289             if (!hostRecursiveDirectoryWatcher) {
4290                 hostRecursiveDirectoryWatcher = createDirectoryWatcherSupportingRecursive({
4291                     useCaseSensitiveFileNames: useCaseSensitiveFileNames,
4292                     directoryExists: directoryExists,
4293                     getAccessibleSortedChildDirectories: getAccessibleSortedChildDirectories,
4294                     watchDirectory: nonRecursiveWatchDirectory,
4295                     realpath: realpath,
4296                     setTimeout: setTimeout,
4297                     clearTimeout: clearTimeout
4298                 });
4299             }
4300             return hostRecursiveDirectoryWatcher(directoryName, callback, recursive, options);
4301         }
4302         function nonRecursiveWatchDirectory(directoryName, callback, recursive, options) {
4303             ts.Debug.assert(!recursive);
4304             options = updateOptionsForWatchDirectory(options);
4305             var watchDirectoryKind = ts.Debug.checkDefined(options.watchDirectory);
4306             switch (watchDirectoryKind) {
4307                 case ts.WatchDirectoryKind.FixedPollingInterval:
4308                     return pollingWatchFile(directoryName, function () { return callback(directoryName); }, PollingInterval.Medium, undefined);
4309                 case ts.WatchDirectoryKind.DynamicPriorityPolling:
4310                     return ensureDynamicPollingWatchFile()(directoryName, function () { return callback(directoryName); }, PollingInterval.Medium, undefined);
4311                 case ts.WatchDirectoryKind.UseFsEvents:
4312                     return fsWatch(directoryName, 1, createFsWatchCallbackForDirectoryWatcherCallback(directoryName, callback), recursive, PollingInterval.Medium, ts.getFallbackOptions(options));
4313                 default:
4314                     ts.Debug.assertNever(watchDirectoryKind);
4315             }
4316         }
4317         function updateOptionsForWatchDirectory(options) {
4318             if (options && options.watchDirectory !== undefined)
4319                 return options;
4320             switch (tscWatchDirectory) {
4321                 case "RecursiveDirectoryUsingFsWatchFile":
4322                     return { watchDirectory: ts.WatchDirectoryKind.FixedPollingInterval };
4323                 case "RecursiveDirectoryUsingDynamicPriorityPolling":
4324                     return { watchDirectory: ts.WatchDirectoryKind.DynamicPriorityPolling };
4325                 default:
4326                     var defaultFallbackPolling = options === null || options === void 0 ? void 0 : options.fallbackPolling;
4327                     return {
4328                         watchDirectory: ts.WatchDirectoryKind.UseFsEvents,
4329                         fallbackPolling: defaultFallbackPolling !== undefined ?
4330                             defaultFallbackPolling :
4331                             undefined
4332                     };
4333             }
4334         }
4335     }
4336     ts.createSystemWatchFunctions = createSystemWatchFunctions;
4337     function patchWriteFileEnsuringDirectory(sys) {
4338         var originalWriteFile = sys.writeFile;
4339         sys.writeFile = function (path, data, writeBom) {
4340             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); });
4341         };
4342     }
4343     ts.patchWriteFileEnsuringDirectory = patchWriteFileEnsuringDirectory;
4344     function getNodeMajorVersion() {
4345         if (typeof process === "undefined") {
4346             return undefined;
4347         }
4348         var version = process.version;
4349         if (!version) {
4350             return undefined;
4351         }
4352         var dot = version.indexOf(".");
4353         if (dot === -1) {
4354             return undefined;
4355         }
4356         return parseInt(version.substring(1, dot));
4357     }
4358     ts.getNodeMajorVersion = getNodeMajorVersion;
4359     ts.sys = (function () {
4360         var byteOrderMarkIndicator = "\uFEFF";
4361         function getNodeSystem() {
4362             var nativePattern = /^native |^\([^)]+\)$|^(internal[\\/]|[a-zA-Z0-9_\s]+(\.js)?$)/;
4363             var _fs = require("fs");
4364             var _path = require("path");
4365             var _os = require("os");
4366             var _crypto;
4367             try {
4368                 _crypto = require("crypto");
4369             }
4370             catch (_a) {
4371                 _crypto = undefined;
4372             }
4373             var activeSession;
4374             var profilePath = "./profile.cpuprofile";
4375             var Buffer = require("buffer").Buffer;
4376             var nodeVersion = getNodeMajorVersion();
4377             var isNode4OrLater = nodeVersion >= 4;
4378             var isLinuxOrMacOs = process.platform === "linux" || process.platform === "darwin";
4379             var platform = _os.platform();
4380             var useCaseSensitiveFileNames = isFileSystemCaseSensitive();
4381             var fsSupportsRecursiveFsWatch = isNode4OrLater && (process.platform === "win32" || process.platform === "darwin");
4382             var _b = createSystemWatchFunctions({
4383                 pollingWatchFile: createSingleFileWatcherPerName(fsWatchFileWorker, useCaseSensitiveFileNames),
4384                 getModifiedTime: getModifiedTime,
4385                 setTimeout: setTimeout,
4386                 clearTimeout: clearTimeout,
4387                 fsWatch: fsWatch,
4388                 useCaseSensitiveFileNames: useCaseSensitiveFileNames,
4389                 fileExists: fileExists,
4390                 fsSupportsRecursiveFsWatch: fsSupportsRecursiveFsWatch,
4391                 directoryExists: directoryExists,
4392                 getAccessibleSortedChildDirectories: function (path) { return getAccessibleFileSystemEntries(path).directories; },
4393                 realpath: realpath,
4394                 tscWatchFile: process.env.TSC_WATCHFILE,
4395                 useNonPollingWatchers: process.env.TSC_NONPOLLING_WATCHER,
4396                 tscWatchDirectory: process.env.TSC_WATCHDIRECTORY,
4397             }), watchFile = _b.watchFile, watchDirectory = _b.watchDirectory;
4398             var nodeSystem = {
4399                 args: process.argv.slice(2),
4400                 newLine: _os.EOL,
4401                 useCaseSensitiveFileNames: useCaseSensitiveFileNames,
4402                 write: function (s) {
4403                     process.stdout.write(s);
4404                 },
4405                 writeOutputIsTTY: function () {
4406                     return process.stdout.isTTY;
4407                 },
4408                 readFile: readFile,
4409                 writeFile: writeFile,
4410                 watchFile: watchFile,
4411                 watchDirectory: watchDirectory,
4412                 resolvePath: function (path) { return _path.resolve(path); },
4413                 fileExists: fileExists,
4414                 directoryExists: directoryExists,
4415                 createDirectory: function (directoryName) {
4416                     if (!nodeSystem.directoryExists(directoryName)) {
4417                         try {
4418                             _fs.mkdirSync(directoryName);
4419                         }
4420                         catch (e) {
4421                             if (e.code !== "EEXIST") {
4422                                 throw e;
4423                             }
4424                         }
4425                     }
4426                 },
4427                 getExecutingFilePath: function () {
4428                     return __filename;
4429                 },
4430                 getCurrentDirectory: function () {
4431                     return process.cwd();
4432                 },
4433                 getDirectories: getDirectories,
4434                 getEnvironmentVariable: function (name) {
4435                     return process.env[name] || "";
4436                 },
4437                 readDirectory: readDirectory,
4438                 getModifiedTime: getModifiedTime,
4439                 setModifiedTime: setModifiedTime,
4440                 deleteFile: deleteFile,
4441                 createHash: _crypto ? createSHA256Hash : generateDjb2Hash,
4442                 createSHA256Hash: _crypto ? createSHA256Hash : undefined,
4443                 getMemoryUsage: function () {
4444                     if (global.gc) {
4445                         global.gc();
4446                     }
4447                     return process.memoryUsage().heapUsed;
4448                 },
4449                 getFileSize: function (path) {
4450                     try {
4451                         var stat = _fs.statSync(path);
4452                         if (stat.isFile()) {
4453                             return stat.size;
4454                         }
4455                     }
4456                     catch (_a) { }
4457                     return 0;
4458                 },
4459                 exit: function (exitCode) {
4460                     disableCPUProfiler(function () { return process.exit(exitCode); });
4461                 },
4462                 enableCPUProfiler: enableCPUProfiler,
4463                 disableCPUProfiler: disableCPUProfiler,
4464                 realpath: realpath,
4465                 debugMode: !!process.env.NODE_INSPECTOR_IPC || !!process.env.VSCODE_INSPECTOR_OPTIONS || ts.some(process.execArgv, function (arg) { return /^--(inspect|debug)(-brk)?(=\d+)?$/i.test(arg); }),
4466                 tryEnableSourceMapsForHost: function () {
4467                     try {
4468                         require("source-map-support").install();
4469                     }
4470                     catch (_a) {
4471                     }
4472                 },
4473                 setTimeout: setTimeout,
4474                 clearTimeout: clearTimeout,
4475                 clearScreen: function () {
4476                     process.stdout.write("\x1Bc");
4477                 },
4478                 setBlocking: function () {
4479                     if (process.stdout && process.stdout._handle && process.stdout._handle.setBlocking) {
4480                         process.stdout._handle.setBlocking(true);
4481                     }
4482                 },
4483                 bufferFrom: bufferFrom,
4484                 base64decode: function (input) { return bufferFrom(input, "base64").toString("utf8"); },
4485                 base64encode: function (input) { return bufferFrom(input).toString("base64"); },
4486                 require: function (baseDir, moduleName) {
4487                     try {
4488                         var modulePath = ts.resolveJSModule(moduleName, baseDir, nodeSystem);
4489                         return { module: require(modulePath), modulePath: modulePath, error: undefined };
4490                     }
4491                     catch (error) {
4492                         return { module: undefined, modulePath: undefined, error: error };
4493                     }
4494                 }
4495             };
4496             return nodeSystem;
4497             function enableCPUProfiler(path, cb) {
4498                 if (activeSession) {
4499                     cb();
4500                     return false;
4501                 }
4502                 var inspector = require("inspector");
4503                 if (!inspector || !inspector.Session) {
4504                     cb();
4505                     return false;
4506                 }
4507                 var session = new inspector.Session();
4508                 session.connect();
4509                 session.post("Profiler.enable", function () {
4510                     session.post("Profiler.start", function () {
4511                         activeSession = session;
4512                         profilePath = path;
4513                         cb();
4514                     });
4515                 });
4516                 return true;
4517             }
4518             function cleanupPaths(profile) {
4519                 var externalFileCounter = 0;
4520                 var remappedPaths = new ts.Map();
4521                 var normalizedDir = ts.normalizeSlashes(__dirname);
4522                 var fileUrlRoot = "file://" + (ts.getRootLength(normalizedDir) === 1 ? "" : "/") + normalizedDir;
4523                 for (var _i = 0, _a = profile.nodes; _i < _a.length; _i++) {
4524                     var node = _a[_i];
4525                     if (node.callFrame.url) {
4526                         var url = ts.normalizeSlashes(node.callFrame.url);
4527                         if (ts.containsPath(fileUrlRoot, url, useCaseSensitiveFileNames)) {
4528                             node.callFrame.url = ts.getRelativePathToDirectoryOrUrl(fileUrlRoot, url, fileUrlRoot, ts.createGetCanonicalFileName(useCaseSensitiveFileNames), true);
4529                         }
4530                         else if (!nativePattern.test(url)) {
4531                             node.callFrame.url = (remappedPaths.has(url) ? remappedPaths : remappedPaths.set(url, "external" + externalFileCounter + ".js")).get(url);
4532                             externalFileCounter++;
4533                         }
4534                     }
4535                 }
4536                 return profile;
4537             }
4538             function disableCPUProfiler(cb) {
4539                 if (activeSession && activeSession !== "stopping") {
4540                     var s_1 = activeSession;
4541                     activeSession.post("Profiler.stop", function (err, _a) {
4542                         var profile = _a.profile;
4543                         if (!err) {
4544                             try {
4545                                 if (_fs.statSync(profilePath).isDirectory()) {
4546                                     profilePath = _path.join(profilePath, (new Date()).toISOString().replace(/:/g, "-") + "+P" + process.pid + ".cpuprofile");
4547                                 }
4548                             }
4549                             catch (_b) {
4550                             }
4551                             try {
4552                                 _fs.mkdirSync(_path.dirname(profilePath), { recursive: true });
4553                             }
4554                             catch (_c) {
4555                             }
4556                             _fs.writeFileSync(profilePath, JSON.stringify(cleanupPaths(profile)));
4557                         }
4558                         activeSession = undefined;
4559                         s_1.disconnect();
4560                         cb();
4561                     });
4562                     activeSession = "stopping";
4563                     return true;
4564                 }
4565                 else {
4566                     cb();
4567                     return false;
4568                 }
4569             }
4570             function bufferFrom(input, encoding) {
4571                 return Buffer.from && Buffer.from !== Int8Array.from
4572                     ? Buffer.from(input, encoding)
4573                     : new Buffer(input, encoding);
4574             }
4575             function isFileSystemCaseSensitive() {
4576                 if (platform === "win32" || platform === "win64") {
4577                     return false;
4578                 }
4579                 return !fileExists(swapCase(__filename));
4580             }
4581             function swapCase(s) {
4582                 return s.replace(/\w/g, function (ch) {
4583                     var up = ch.toUpperCase();
4584                     return ch === up ? ch.toLowerCase() : up;
4585                 });
4586             }
4587             function fsWatchFileWorker(fileName, callback, pollingInterval) {
4588                 _fs.watchFile(fileName, { persistent: true, interval: pollingInterval }, fileChanged);
4589                 var eventKind;
4590                 return {
4591                     close: function () { return _fs.unwatchFile(fileName, fileChanged); }
4592                 };
4593                 function fileChanged(curr, prev) {
4594                     var isPreviouslyDeleted = +prev.mtime === 0 || eventKind === FileWatcherEventKind.Deleted;
4595                     if (+curr.mtime === 0) {
4596                         if (isPreviouslyDeleted) {
4597                             return;
4598                         }
4599                         eventKind = FileWatcherEventKind.Deleted;
4600                     }
4601                     else if (isPreviouslyDeleted) {
4602                         eventKind = FileWatcherEventKind.Created;
4603                     }
4604                     else if (+curr.mtime === +prev.mtime) {
4605                         return;
4606                     }
4607                     else {
4608                         eventKind = FileWatcherEventKind.Changed;
4609                     }
4610                     callback(fileName, eventKind);
4611                 }
4612             }
4613             function fsWatch(fileOrDirectory, entryKind, callback, recursive, fallbackPollingInterval, fallbackOptions) {
4614                 var options;
4615                 var lastDirectoryPartWithDirectorySeparator;
4616                 var lastDirectoryPart;
4617                 if (isLinuxOrMacOs) {
4618                     lastDirectoryPartWithDirectorySeparator = fileOrDirectory.substr(fileOrDirectory.lastIndexOf(ts.directorySeparator));
4619                     lastDirectoryPart = lastDirectoryPartWithDirectorySeparator.slice(ts.directorySeparator.length);
4620                 }
4621                 var watcher = !fileSystemEntryExists(fileOrDirectory, entryKind) ?
4622                     watchMissingFileSystemEntry() :
4623                     watchPresentFileSystemEntry();
4624                 return {
4625                     close: function () {
4626                         watcher.close();
4627                         watcher = undefined;
4628                     }
4629                 };
4630                 function invokeCallbackAndUpdateWatcher(createWatcher) {
4631                     ts.sysLog("sysLog:: " + fileOrDirectory + ":: Changing watcher to " + (createWatcher === watchPresentFileSystemEntry ? "Present" : "Missing") + "FileSystemEntryWatcher");
4632                     callback("rename", "");
4633                     if (watcher) {
4634                         watcher.close();
4635                         watcher = createWatcher();
4636                     }
4637                 }
4638                 function watchPresentFileSystemEntry() {
4639                     if (options === undefined) {
4640                         if (fsSupportsRecursiveFsWatch) {
4641                             options = { persistent: true, recursive: !!recursive };
4642                         }
4643                         else {
4644                             options = { persistent: true };
4645                         }
4646                     }
4647                     try {
4648                         var presentWatcher = _fs.watch(fileOrDirectory, options, isLinuxOrMacOs ?
4649                             callbackChangingToMissingFileSystemEntry :
4650                             callback);
4651                         presentWatcher.on("error", function () { return invokeCallbackAndUpdateWatcher(watchMissingFileSystemEntry); });
4652                         return presentWatcher;
4653                     }
4654                     catch (e) {
4655                         return watchPresentFileSystemEntryWithFsWatchFile();
4656                     }
4657                 }
4658                 function callbackChangingToMissingFileSystemEntry(event, relativeName) {
4659                     return event === "rename" &&
4660                         (!relativeName ||
4661                             relativeName === lastDirectoryPart ||
4662                             relativeName.lastIndexOf(lastDirectoryPartWithDirectorySeparator) === relativeName.length - lastDirectoryPartWithDirectorySeparator.length) &&
4663                         !fileSystemEntryExists(fileOrDirectory, entryKind) ?
4664                         invokeCallbackAndUpdateWatcher(watchMissingFileSystemEntry) :
4665                         callback(event, relativeName);
4666                 }
4667                 function watchPresentFileSystemEntryWithFsWatchFile() {
4668                     ts.sysLog("sysLog:: " + fileOrDirectory + ":: Changing to fsWatchFile");
4669                     return watchFile(fileOrDirectory, createFileWatcherCallback(callback), fallbackPollingInterval, fallbackOptions);
4670                 }
4671                 function watchMissingFileSystemEntry() {
4672                     return watchFile(fileOrDirectory, function (_fileName, eventKind) {
4673                         if (eventKind === FileWatcherEventKind.Created && fileSystemEntryExists(fileOrDirectory, entryKind)) {
4674                             invokeCallbackAndUpdateWatcher(watchPresentFileSystemEntry);
4675                         }
4676                     }, fallbackPollingInterval, fallbackOptions);
4677                 }
4678             }
4679             function readFileWorker(fileName, _encoding) {
4680                 var buffer;
4681                 try {
4682                     buffer = _fs.readFileSync(fileName);
4683                 }
4684                 catch (e) {
4685                     return undefined;
4686                 }
4687                 var len = buffer.length;
4688                 if (len >= 2 && buffer[0] === 0xFE && buffer[1] === 0xFF) {
4689                     len &= ~1;
4690                     for (var i = 0; i < len; i += 2) {
4691                         var temp = buffer[i];
4692                         buffer[i] = buffer[i + 1];
4693                         buffer[i + 1] = temp;
4694                     }
4695                     return buffer.toString("utf16le", 2);
4696                 }
4697                 if (len >= 2 && buffer[0] === 0xFF && buffer[1] === 0xFE) {
4698                     return buffer.toString("utf16le", 2);
4699                 }
4700                 if (len >= 3 && buffer[0] === 0xEF && buffer[1] === 0xBB && buffer[2] === 0xBF) {
4701                     return buffer.toString("utf8", 3);
4702                 }
4703                 return buffer.toString("utf8");
4704             }
4705             function readFile(fileName, _encoding) {
4706                 ts.perfLogger.logStartReadFile(fileName);
4707                 var file = readFileWorker(fileName, _encoding);
4708                 ts.perfLogger.logStopReadFile();
4709                 return file;
4710             }
4711             function writeFile(fileName, data, writeByteOrderMark) {
4712                 ts.perfLogger.logEvent("WriteFile: " + fileName);
4713                 if (writeByteOrderMark) {
4714                     data = byteOrderMarkIndicator + data;
4715                 }
4716                 var fd;
4717                 try {
4718                     fd = _fs.openSync(fileName, "w");
4719                     _fs.writeSync(fd, data, undefined, "utf8");
4720                 }
4721                 finally {
4722                     if (fd !== undefined) {
4723                         _fs.closeSync(fd);
4724                     }
4725                 }
4726             }
4727             function getAccessibleFileSystemEntries(path) {
4728                 ts.perfLogger.logEvent("ReadDir: " + (path || "."));
4729                 try {
4730                     var entries = _fs.readdirSync(path || ".", { withFileTypes: true });
4731                     var files = [];
4732                     var directories = [];
4733                     for (var _i = 0, entries_1 = entries; _i < entries_1.length; _i++) {
4734                         var dirent = entries_1[_i];
4735                         var entry = typeof dirent === "string" ? dirent : dirent.name;
4736                         if (entry === "." || entry === "..") {
4737                             continue;
4738                         }
4739                         var stat = void 0;
4740                         if (typeof dirent === "string" || dirent.isSymbolicLink()) {
4741                             var name = ts.combinePaths(path, entry);
4742                             try {
4743                                 stat = _fs.statSync(name);
4744                             }
4745                             catch (e) {
4746                                 continue;
4747                             }
4748                         }
4749                         else {
4750                             stat = dirent;
4751                         }
4752                         if (stat.isFile()) {
4753                             files.push(entry);
4754                         }
4755                         else if (stat.isDirectory()) {
4756                             directories.push(entry);
4757                         }
4758                     }
4759                     files.sort();
4760                     directories.sort();
4761                     return { files: files, directories: directories };
4762                 }
4763                 catch (e) {
4764                     return ts.emptyFileSystemEntries;
4765                 }
4766             }
4767             function readDirectory(path, extensions, excludes, includes, depth) {
4768                 return ts.matchFiles(path, extensions, excludes, includes, useCaseSensitiveFileNames, process.cwd(), depth, getAccessibleFileSystemEntries, realpath);
4769             }
4770             function fileSystemEntryExists(path, entryKind) {
4771                 var originalStackTraceLimit = Error.stackTraceLimit;
4772                 Error.stackTraceLimit = 0;
4773                 try {
4774                     var stat = _fs.statSync(path);
4775                     switch (entryKind) {
4776                         case 0: return stat.isFile();
4777                         case 1: return stat.isDirectory();
4778                         default: return false;
4779                     }
4780                 }
4781                 catch (e) {
4782                     return false;
4783                 }
4784                 finally {
4785                     Error.stackTraceLimit = originalStackTraceLimit;
4786                 }
4787             }
4788             function fileExists(path) {
4789                 return fileSystemEntryExists(path, 0);
4790             }
4791             function directoryExists(path) {
4792                 return fileSystemEntryExists(path, 1);
4793             }
4794             function getDirectories(path) {
4795                 return getAccessibleFileSystemEntries(path).directories.slice();
4796             }
4797             function realpath(path) {
4798                 try {
4799                     return _fs.realpathSync(path);
4800                 }
4801                 catch (_a) {
4802                     return path;
4803                 }
4804             }
4805             function getModifiedTime(path) {
4806                 try {
4807                     return _fs.statSync(path).mtime;
4808                 }
4809                 catch (e) {
4810                     return undefined;
4811                 }
4812             }
4813             function setModifiedTime(path, time) {
4814                 try {
4815                     _fs.utimesSync(path, time, time);
4816                 }
4817                 catch (e) {
4818                     return;
4819                 }
4820             }
4821             function deleteFile(path) {
4822                 try {
4823                     return _fs.unlinkSync(path);
4824                 }
4825                 catch (e) {
4826                     return;
4827                 }
4828             }
4829             function createSHA256Hash(data) {
4830                 var hash = _crypto.createHash("sha256");
4831                 hash.update(data);
4832                 return hash.digest("hex");
4833             }
4834         }
4835         var sys;
4836         if (typeof process !== "undefined" && process.nextTick && !process.browser && typeof require !== "undefined") {
4837             sys = getNodeSystem();
4838         }
4839         if (sys) {
4840             patchWriteFileEnsuringDirectory(sys);
4841         }
4842         return sys;
4843     })();
4844     if (ts.sys && ts.sys.getEnvironmentVariable) {
4845         setCustomPollingValues(ts.sys);
4846         ts.Debug.setAssertionLevel(/^development$/i.test(ts.sys.getEnvironmentVariable("NODE_ENV"))
4847             ? 1
4848             : 0);
4849     }
4850     if (ts.sys && ts.sys.debugMode) {
4851         ts.Debug.isDebugging = true;
4852     }
4853 })(ts || (ts = {}));
4854 var ts;
4855 (function (ts) {
4856     function diag(code, category, key, message, reportsUnnecessary, elidedInCompatabilityPyramid, reportsDeprecated) {
4857         return { code: code, category: category, key: key, message: message, reportsUnnecessary: reportsUnnecessary, elidedInCompatabilityPyramid: elidedInCompatabilityPyramid, reportsDeprecated: reportsDeprecated };
4858     }
4859     ts.Diagnostics = {
4860         Unterminated_string_literal: diag(1002, ts.DiagnosticCategory.Error, "Unterminated_string_literal_1002", "Unterminated string literal."),
4861         Identifier_expected: diag(1003, ts.DiagnosticCategory.Error, "Identifier_expected_1003", "Identifier expected."),
4862         _0_expected: diag(1005, ts.DiagnosticCategory.Error, "_0_expected_1005", "'{0}' expected."),
4863         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."),
4864         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."),
4865         Trailing_comma_not_allowed: diag(1009, ts.DiagnosticCategory.Error, "Trailing_comma_not_allowed_1009", "Trailing comma not allowed."),
4866         Asterisk_Slash_expected: diag(1010, ts.DiagnosticCategory.Error, "Asterisk_Slash_expected_1010", "'*/' expected."),
4867         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."),
4868         Unexpected_token: diag(1012, ts.DiagnosticCategory.Error, "Unexpected_token_1012", "Unexpected token."),
4869         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."),
4870         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."),
4871         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."),
4872         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."),
4873         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."),
4874         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."),
4875         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."),
4876         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."),
4877         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."),
4878         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."),
4879         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'."),
4880         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."),
4881         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."),
4882         Accessibility_modifier_already_seen: diag(1028, ts.DiagnosticCategory.Error, "Accessibility_modifier_already_seen_1028", "Accessibility modifier already seen."),
4883         _0_modifier_must_precede_1_modifier: diag(1029, ts.DiagnosticCategory.Error, "_0_modifier_must_precede_1_modifier_1029", "'{0}' modifier must precede '{1}' modifier."),
4884         _0_modifier_already_seen: diag(1030, ts.DiagnosticCategory.Error, "_0_modifier_already_seen_1030", "'{0}' modifier already seen."),
4885         _0_modifier_cannot_appear_on_class_elements_of_this_kind: diag(1031, ts.DiagnosticCategory.Error, "_0_modifier_cannot_appear_on_class_elements_of_this_kind_1031", "'{0}' modifier cannot appear on class elements of this kind."),
4886         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."),
4887         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."),
4888         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."),
4889         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."),
4890         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."),
4891         _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."),
4892         _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."),
4893         _0_modifier_cannot_be_used_here: diag(1042, ts.DiagnosticCategory.Error, "_0_modifier_cannot_be_used_here_1042", "'{0}' modifier cannot be used here."),
4894         _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."),
4895         _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."),
4896         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."),
4897         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."),
4898         A_rest_parameter_cannot_be_optional: diag(1047, ts.DiagnosticCategory.Error, "A_rest_parameter_cannot_be_optional_1047", "A rest parameter cannot be optional."),
4899         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."),
4900         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."),
4901         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."),
4902         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."),
4903         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."),
4904         A_get_accessor_cannot_have_parameters: diag(1054, ts.DiagnosticCategory.Error, "A_get_accessor_cannot_have_parameters_1054", "A 'get' accessor cannot have parameters."),
4905         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."),
4906         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."),
4907         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."),
4908         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."),
4909         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."),
4910         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."),
4911         Enum_member_must_have_initializer: diag(1061, ts.DiagnosticCategory.Error, "Enum_member_must_have_initializer_1061", "Enum member must have initializer."),
4912         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."),
4913         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."),
4914         The_return_type_of_an_async_function_or_method_must_be_the_global_Promise_T_type_Did_you_mean_to_write_Promise_0: diag(1064, ts.DiagnosticCategory.Error, "The_return_type_of_an_async_function_or_method_must_be_the_global_Promise_T_type_Did_you_mean_to_wri_1064", "The return type of an async function or method must be the global Promise<T> type. Did you mean to write 'Promise<{0}>'?"),
4915         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."),
4916         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."),
4917         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."),
4918         _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."),
4919         _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."),
4920         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."),
4921         Invalid_reference_directive_syntax: diag(1084, ts.DiagnosticCategory.Error, "Invalid_reference_directive_syntax_1084", "Invalid 'reference' directive syntax."),
4922         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}'."),
4923         _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."),
4924         _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."),
4925         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."),
4926         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."),
4927         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."),
4928         An_accessor_cannot_have_type_parameters: diag(1094, ts.DiagnosticCategory.Error, "An_accessor_cannot_have_type_parameters_1094", "An accessor cannot have type parameters."),
4929         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."),
4930         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."),
4931         _0_list_cannot_be_empty: diag(1097, ts.DiagnosticCategory.Error, "_0_list_cannot_be_empty_1097", "'{0}' list cannot be empty."),
4932         Type_parameter_list_cannot_be_empty: diag(1098, ts.DiagnosticCategory.Error, "Type_parameter_list_cannot_be_empty_1098", "Type parameter list cannot be empty."),
4933         Type_argument_list_cannot_be_empty: diag(1099, ts.DiagnosticCategory.Error, "Type_argument_list_cannot_be_empty_1099", "Type argument list cannot be empty."),
4934         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."),
4935         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."),
4936         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."),
4937         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."),
4938         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."),
4939         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."),
4940         Jump_target_cannot_cross_function_boundary: diag(1107, ts.DiagnosticCategory.Error, "Jump_target_cannot_cross_function_boundary_1107", "Jump target cannot cross function boundary."),
4941         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."),
4942         Expression_expected: diag(1109, ts.DiagnosticCategory.Error, "Expression_expected_1109", "Expression expected."),
4943         Type_expected: diag(1110, ts.DiagnosticCategory.Error, "Type_expected_1110", "Type expected."),
4944         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."),
4945         Duplicate_label_0: diag(1114, ts.DiagnosticCategory.Error, "Duplicate_label_0_1114", "Duplicate label '{0}'."),
4946         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."),
4947         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."),
4948         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."),
4949         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."),
4950         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."),
4951         An_export_assignment_cannot_have_modifiers: diag(1120, ts.DiagnosticCategory.Error, "An_export_assignment_cannot_have_modifiers_1120", "An export assignment cannot have modifiers."),
4952         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."),
4953         Variable_declaration_list_cannot_be_empty: diag(1123, ts.DiagnosticCategory.Error, "Variable_declaration_list_cannot_be_empty_1123", "Variable declaration list cannot be empty."),
4954         Digit_expected: diag(1124, ts.DiagnosticCategory.Error, "Digit_expected_1124", "Digit expected."),
4955         Hexadecimal_digit_expected: diag(1125, ts.DiagnosticCategory.Error, "Hexadecimal_digit_expected_1125", "Hexadecimal digit expected."),
4956         Unexpected_end_of_text: diag(1126, ts.DiagnosticCategory.Error, "Unexpected_end_of_text_1126", "Unexpected end of text."),
4957         Invalid_character: diag(1127, ts.DiagnosticCategory.Error, "Invalid_character_1127", "Invalid character."),
4958         Declaration_or_statement_expected: diag(1128, ts.DiagnosticCategory.Error, "Declaration_or_statement_expected_1128", "Declaration or statement expected."),
4959         Statement_expected: diag(1129, ts.DiagnosticCategory.Error, "Statement_expected_1129", "Statement expected."),
4960         case_or_default_expected: diag(1130, ts.DiagnosticCategory.Error, "case_or_default_expected_1130", "'case' or 'default' expected."),
4961         Property_or_signature_expected: diag(1131, ts.DiagnosticCategory.Error, "Property_or_signature_expected_1131", "Property or signature expected."),
4962         Enum_member_expected: diag(1132, ts.DiagnosticCategory.Error, "Enum_member_expected_1132", "Enum member expected."),
4963         Variable_declaration_expected: diag(1134, ts.DiagnosticCategory.Error, "Variable_declaration_expected_1134", "Variable declaration expected."),
4964         Argument_expression_expected: diag(1135, ts.DiagnosticCategory.Error, "Argument_expression_expected_1135", "Argument expression expected."),
4965         Property_assignment_expected: diag(1136, ts.DiagnosticCategory.Error, "Property_assignment_expected_1136", "Property assignment expected."),
4966         Expression_or_comma_expected: diag(1137, ts.DiagnosticCategory.Error, "Expression_or_comma_expected_1137", "Expression or comma expected."),
4967         Parameter_declaration_expected: diag(1138, ts.DiagnosticCategory.Error, "Parameter_declaration_expected_1138", "Parameter declaration expected."),
4968         Type_parameter_declaration_expected: diag(1139, ts.DiagnosticCategory.Error, "Type_parameter_declaration_expected_1139", "Type parameter declaration expected."),
4969         Type_argument_expected: diag(1140, ts.DiagnosticCategory.Error, "Type_argument_expected_1140", "Type argument expected."),
4970         String_literal_expected: diag(1141, ts.DiagnosticCategory.Error, "String_literal_expected_1141", "String literal expected."),
4971         Line_break_not_permitted_here: diag(1142, ts.DiagnosticCategory.Error, "Line_break_not_permitted_here_1142", "Line break not permitted here."),
4972         or_expected: diag(1144, ts.DiagnosticCategory.Error, "or_expected_1144", "'{' or ';' expected."),
4973         Declaration_expected: diag(1146, ts.DiagnosticCategory.Error, "Declaration_expected_1146", "Declaration expected."),
4974         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."),
4975         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'."),
4976         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."),
4977         const_declarations_must_be_initialized: diag(1155, ts.DiagnosticCategory.Error, "const_declarations_must_be_initialized_1155", "'const' declarations must be initialized."),
4978         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."),
4979         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."),
4980         Unterminated_template_literal: diag(1160, ts.DiagnosticCategory.Error, "Unterminated_template_literal_1160", "Unterminated template literal."),
4981         Unterminated_regular_expression_literal: diag(1161, ts.DiagnosticCategory.Error, "Unterminated_regular_expression_literal_1161", "Unterminated regular expression literal."),
4982         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."),
4983         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."),
4984         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."),
4985         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."),
4986         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."),
4987         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."),
4988         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."),
4989         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."),
4990         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."),
4991         extends_clause_already_seen: diag(1172, ts.DiagnosticCategory.Error, "extends_clause_already_seen_1172", "'extends' clause already seen."),
4992         extends_clause_must_precede_implements_clause: diag(1173, ts.DiagnosticCategory.Error, "extends_clause_must_precede_implements_clause_1173", "'extends' clause must precede 'implements' clause."),
4993         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."),
4994         implements_clause_already_seen: diag(1175, ts.DiagnosticCategory.Error, "implements_clause_already_seen_1175", "'implements' clause already seen."),
4995         Interface_declaration_cannot_have_implements_clause: diag(1176, ts.DiagnosticCategory.Error, "Interface_declaration_cannot_have_implements_clause_1176", "Interface declaration cannot have 'implements' clause."),
4996         Binary_digit_expected: diag(1177, ts.DiagnosticCategory.Error, "Binary_digit_expected_1177", "Binary digit expected."),
4997         Octal_digit_expected: diag(1178, ts.DiagnosticCategory.Error, "Octal_digit_expected_1178", "Octal digit expected."),
4998         Unexpected_token_expected: diag(1179, ts.DiagnosticCategory.Error, "Unexpected_token_expected_1179", "Unexpected token. '{' expected."),
4999         Property_destructuring_pattern_expected: diag(1180, ts.DiagnosticCategory.Error, "Property_destructuring_pattern_expected_1180", "Property destructuring pattern expected."),
5000         Array_element_destructuring_pattern_expected: diag(1181, ts.DiagnosticCategory.Error, "Array_element_destructuring_pattern_expected_1181", "Array element destructuring pattern expected."),
5001         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."),
5002         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."),
5003         Modifiers_cannot_appear_here: diag(1184, ts.DiagnosticCategory.Error, "Modifiers_cannot_appear_here_1184", "Modifiers cannot appear here."),
5004         Merge_conflict_marker_encountered: diag(1185, ts.DiagnosticCategory.Error, "Merge_conflict_marker_encountered_1185", "Merge conflict marker encountered."),
5005         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."),
5006         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."),
5007         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."),
5008         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."),
5009         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."),
5010         An_import_declaration_cannot_have_modifiers: diag(1191, ts.DiagnosticCategory.Error, "An_import_declaration_cannot_have_modifiers_1191", "An import declaration cannot have modifiers."),
5011         Module_0_has_no_default_export: diag(1192, ts.DiagnosticCategory.Error, "Module_0_has_no_default_export_1192", "Module '{0}' has no default export."),
5012         An_export_declaration_cannot_have_modifiers: diag(1193, ts.DiagnosticCategory.Error, "An_export_declaration_cannot_have_modifiers_1193", "An export declaration cannot have modifiers."),
5013         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."),
5014         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."),
5015         Catch_clause_variable_type_annotation_must_be_any_or_unknown_if_specified: diag(1196, ts.DiagnosticCategory.Error, "Catch_clause_variable_type_annotation_must_be_any_or_unknown_if_specified_1196", "Catch clause variable type annotation must be 'any' or 'unknown' if specified."),
5016         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."),
5017         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."),
5018         Unterminated_Unicode_escape_sequence: diag(1199, ts.DiagnosticCategory.Error, "Unterminated_Unicode_escape_sequence_1199", "Unterminated Unicode escape sequence."),
5019         Line_terminator_not_permitted_before_arrow: diag(1200, ts.DiagnosticCategory.Error, "Line_terminator_not_permitted_before_arrow_1200", "Line terminator not permitted before arrow."),
5020         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."),
5021         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."),
5022         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'."),
5023         Decorators_are_not_valid_here: diag(1206, ts.DiagnosticCategory.Error, "Decorators_are_not_valid_here_1206", "Decorators are not valid here."),
5024         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."),
5025         _0_cannot_be_compiled_under_isolatedModules_because_it_is_considered_a_global_script_file_Add_an_import_export_or_an_empty_export_statement_to_make_it_a_module: diag(1208, ts.DiagnosticCategory.Error, "_0_cannot_be_compiled_under_isolatedModules_because_it_is_considered_a_global_script_file_Add_an_imp_1208", "'{0}' cannot be compiled under '--isolatedModules' because it is considered a global script file. Add an import, export, or an empty 'export {}' statement to make it a module."),
5026         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."),
5027         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."),
5028         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."),
5029         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."),
5030         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."),
5031         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."),
5032         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."),
5033         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'."),
5034         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."),
5035         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."),
5036         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."),
5037         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."),
5038         _0_tag_already_specified: diag(1223, ts.DiagnosticCategory.Error, "_0_tag_already_specified_1223", "'{0}' tag already specified."),
5039         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."),
5040         Cannot_find_parameter_0: diag(1225, ts.DiagnosticCategory.Error, "Cannot_find_parameter_0_1225", "Cannot find parameter '{0}'."),
5041         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}'."),
5042         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}'."),
5043         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."),
5044         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."),
5045         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."),
5046         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."),
5047         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."),
5048         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."),
5049         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."),
5050         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."),
5051         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'."),
5052         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'."),
5053         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."),
5054         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."),
5055         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."),
5056         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."),
5057         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."),
5058         _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."),
5059         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."),
5060         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."),
5061         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."),
5062         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."),
5063         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."),
5064         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."),
5065         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'."),
5066         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."),
5067         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."),
5068         _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."),
5069         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."),
5070         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."),
5071         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."),
5072         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."),
5073         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"),
5074         Keywords_cannot_contain_escape_characters: diag(1260, ts.DiagnosticCategory.Error, "Keywords_cannot_contain_escape_characters_1260", "Keywords cannot contain escape characters."),
5075         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."),
5076         Identifier_expected_0_is_a_reserved_word_at_the_top_level_of_a_module: diag(1262, ts.DiagnosticCategory.Error, "Identifier_expected_0_is_a_reserved_word_at_the_top_level_of_a_module_1262", "Identifier expected. '{0}' is a reserved word at the top-level of a module."),
5077         Declarations_with_initializers_cannot_also_have_definite_assignment_assertions: diag(1263, ts.DiagnosticCategory.Error, "Declarations_with_initializers_cannot_also_have_definite_assignment_assertions_1263", "Declarations with initializers cannot also have definite assignment assertions."),
5078         Declarations_with_definite_assignment_assertions_must_also_have_type_annotations: diag(1264, ts.DiagnosticCategory.Error, "Declarations_with_definite_assignment_assertions_must_also_have_type_annotations_1264", "Declarations with definite assignment assertions must also have type annotations."),
5079         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."),
5080         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."),
5081         Did_you_mean_to_use_a_Colon_An_can_only_follow_a_property_name_when_the_containing_object_literal_is_part_of_a_destructuring_pattern: diag(1312, ts.DiagnosticCategory.Error, "Did_you_mean_to_use_a_Colon_An_can_only_follow_a_property_name_when_the_containing_object_literal_is_1312", "Did you mean to use a ':'? An '=' can only follow a property name when the containing object literal is part of a destructuring pattern."),
5082         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."),
5083         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."),
5084         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."),
5085         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."),
5086         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."),
5087         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."),
5088         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."),
5089         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."),
5090         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."),
5091         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."),
5092         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'."),
5093         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."),
5094         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."),
5095         Dynamic_import_cannot_have_type_arguments: diag(1326, ts.DiagnosticCategory.Error, "Dynamic_import_cannot_have_type_arguments_1326", "Dynamic import cannot have type arguments."),
5096         String_literal_with_double_quotes_expected: diag(1327, ts.DiagnosticCategory.Error, "String_literal_with_double_quotes_expected_1327", "String literal with double quotes expected."),
5097         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."),
5098         _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}()'?"),
5099         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'."),
5100         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'."),
5101         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'."),
5102         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."),
5103         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."),
5104         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."),
5105         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."),
5106         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."),
5107         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."),
5108         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."),
5109         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}')'?"),
5110         Type_arguments_cannot_be_used_here: diag(1342, ts.DiagnosticCategory.Error, "Type_arguments_cannot_be_used_here_1342", "Type arguments cannot be used here."),
5111         The_import_meta_meta_property_is_only_allowed_when_the_module_option_is_es2020_esnext_or_system: diag(1343, ts.DiagnosticCategory.Error, "The_import_meta_meta_property_is_only_allowed_when_the_module_option_is_es2020_esnext_or_system_1343", "The 'import.meta' meta-property is only allowed when the '--module' option is 'es2020', 'esnext', or 'system'."),
5112         A_label_is_not_allowed_here: diag(1344, ts.DiagnosticCategory.Error, "A_label_is_not_allowed_here_1344", "'A label is not allowed here."),
5113         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."),
5114         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."),
5115         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."),
5116         Non_simple_parameter_declared_here: diag(1348, ts.DiagnosticCategory.Error, "Non_simple_parameter_declared_here_1348", "Non-simple parameter declared here."),
5117         use_strict_directive_used_here: diag(1349, ts.DiagnosticCategory.Error, "use_strict_directive_used_here_1349", "'use strict' directive used here."),
5118         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."),
5119         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."),
5120         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."),
5121         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."),
5122         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."),
5123         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."),
5124         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'?"),
5125         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 '}'."),
5126         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."),
5127         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."),
5128         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?"),
5129         _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'."),
5130         _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'."),
5131         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."),
5132         Convert_to_type_only_export: diag(1364, ts.DiagnosticCategory.Message, "Convert_to_type_only_export_1364", "Convert to type-only export"),
5133         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"),
5134         Split_into_two_separate_import_declarations: diag(1366, ts.DiagnosticCategory.Message, "Split_into_two_separate_import_declarations_1366", "Split into two separate import declarations"),
5135         Split_all_invalid_type_only_imports: diag(1367, ts.DiagnosticCategory.Message, "Split_all_invalid_type_only_imports_1367", "Split all invalid type-only imports"),
5136         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"),
5137         Did_you_mean_0: diag(1369, ts.DiagnosticCategory.Message, "Did_you_mean_0_1369", "Did you mean '{0}'?"),
5138         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'."),
5139         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'."),
5140         Convert_to_type_only_import: diag(1373, ts.DiagnosticCategory.Message, "Convert_to_type_only_import_1373", "Convert to type-only import"),
5141         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"),
5142         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."),
5143         _0_was_imported_here: diag(1376, ts.DiagnosticCategory.Message, "_0_was_imported_here_1376", "'{0}' was imported here."),
5144         _0_was_exported_here: diag(1377, ts.DiagnosticCategory.Message, "_0_was_exported_here_1377", "'{0}' was exported here."),
5145         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."),
5146         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'."),
5147         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'."),
5148         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;`?"),
5149         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;`?"),
5150         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'."),
5151         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."),
5152         Function_type_notation_must_be_parenthesized_when_used_in_a_union_type: diag(1385, ts.DiagnosticCategory.Error, "Function_type_notation_must_be_parenthesized_when_used_in_a_union_type_1385", "Function type notation must be parenthesized when used in a union type."),
5153         Constructor_type_notation_must_be_parenthesized_when_used_in_a_union_type: diag(1386, ts.DiagnosticCategory.Error, "Constructor_type_notation_must_be_parenthesized_when_used_in_a_union_type_1386", "Constructor type notation must be parenthesized when used in a union type."),
5154         Function_type_notation_must_be_parenthesized_when_used_in_an_intersection_type: diag(1387, ts.DiagnosticCategory.Error, "Function_type_notation_must_be_parenthesized_when_used_in_an_intersection_type_1387", "Function type notation must be parenthesized when used in an intersection type."),
5155         Constructor_type_notation_must_be_parenthesized_when_used_in_an_intersection_type: diag(1388, ts.DiagnosticCategory.Error, "Constructor_type_notation_must_be_parenthesized_when_used_in_an_intersection_type_1388", "Constructor type notation must be parenthesized when used in an intersection type."),
5156         _0_is_not_allowed_as_a_variable_declaration_name: diag(1389, ts.DiagnosticCategory.Error, "_0_is_not_allowed_as_a_variable_declaration_name_1389", "'{0}' is not allowed as a variable declaration name."),
5157         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."),
5158         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."),
5159         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),
5160         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),
5161         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),
5162         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),
5163         Duplicate_identifier_0: diag(2300, ts.DiagnosticCategory.Error, "Duplicate_identifier_0_2300", "Duplicate identifier '{0}'."),
5164         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."),
5165         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."),
5166         Circular_definition_of_import_alias_0: diag(2303, ts.DiagnosticCategory.Error, "Circular_definition_of_import_alias_0_2303", "Circular definition of import alias '{0}'."),
5167         Cannot_find_name_0: diag(2304, ts.DiagnosticCategory.Error, "Cannot_find_name_0_2304", "Cannot find name '{0}'."),
5168         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}'."),
5169         File_0_is_not_a_module: diag(2306, ts.DiagnosticCategory.Error, "File_0_is_not_a_module_2306", "File '{0}' is not a module."),
5170         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."),
5171         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."),
5172         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."),
5173         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."),
5174         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."),
5175         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."),
5176         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."),
5177         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)."),
5178         Type_0_is_not_generic: diag(2315, ts.DiagnosticCategory.Error, "Type_0_is_not_generic_2315", "Type '{0}' is not generic."),
5179         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."),
5180         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)."),
5181         Cannot_find_global_type_0: diag(2318, ts.DiagnosticCategory.Error, "Cannot_find_global_type_0_2318", "Cannot find global type '{0}'."),
5182         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."),
5183         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}'."),
5184         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}'."),
5185         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}'."),
5186         Cannot_redeclare_exported_variable_0: diag(2323, ts.DiagnosticCategory.Error, "Cannot_redeclare_exported_variable_0_2323", "Cannot redeclare exported variable '{0}'."),
5187         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}'."),
5188         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}'."),
5189         Types_of_property_0_are_incompatible: diag(2326, ts.DiagnosticCategory.Error, "Types_of_property_0_are_incompatible_2326", "Types of property '{0}' are incompatible."),
5190         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}'."),
5191         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."),
5192         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}'."),
5193         Index_signatures_are_incompatible: diag(2330, ts.DiagnosticCategory.Error, "Index_signatures_are_incompatible_2330", "Index signatures are incompatible."),
5194         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."),
5195         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."),
5196         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."),
5197         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."),
5198         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."),
5199         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."),
5200         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."),
5201         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."),
5202         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}'."),
5203         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."),
5204         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}'."),
5205         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'."),
5206         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}'."),
5207         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}'."),
5208         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}'."),
5209         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."),
5210         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."),
5211         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'?"),
5212         This_expression_is_not_callable: diag(2349, ts.DiagnosticCategory.Error, "This_expression_is_not_callable_2349", "This expression is not callable."),
5213         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."),
5214         This_expression_is_not_constructable: diag(2351, ts.DiagnosticCategory.Error, "This_expression_is_not_constructable_2351", "This expression is not constructable."),
5215         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."),
5216         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}'."),
5217         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."),
5218         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."),
5219         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."),
5220         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."),
5221         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."),
5222         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."),
5223         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'."),
5224         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."),
5225         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."),
5226         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."),
5227         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."),
5228         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}'."),
5229         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'."),
5230         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."),
5231         Type_parameter_name_cannot_be_0: diag(2368, ts.DiagnosticCategory.Error, "Type_parameter_name_cannot_be_0_2368", "Type parameter name cannot be '{0}'."),
5232         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."),
5233         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."),
5234         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."),
5235         Parameter_0_cannot_reference_itself: diag(2372, ts.DiagnosticCategory.Error, "Parameter_0_cannot_reference_itself_2372", "Parameter '{0}' cannot reference itself."),
5236         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."),
5237         Duplicate_string_index_signature: diag(2374, ts.DiagnosticCategory.Error, "Duplicate_string_index_signature_2374", "Duplicate string index signature."),
5238         Duplicate_number_index_signature: diag(2375, ts.DiagnosticCategory.Error, "Duplicate_number_index_signature_2375", "Duplicate number index signature."),
5239         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."),
5240         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."),
5241         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."),
5242         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."),
5243         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."),
5244         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."),
5245         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."),
5246         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."),
5247         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."),
5248         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."),
5249         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."),
5250         Function_overload_must_be_static: diag(2387, ts.DiagnosticCategory.Error, "Function_overload_must_be_static_2387", "Function overload must be static."),
5251         Function_overload_must_not_be_static: diag(2388, ts.DiagnosticCategory.Error, "Function_overload_must_not_be_static_2388", "Function overload must not be static."),
5252         Function_implementation_name_must_be_0: diag(2389, ts.DiagnosticCategory.Error, "Function_implementation_name_must_be_0_2389", "Function implementation name must be '{0}'."),
5253         Constructor_implementation_is_missing: diag(2390, ts.DiagnosticCategory.Error, "Constructor_implementation_is_missing_2390", "Constructor implementation is missing."),
5254         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."),
5255         Multiple_constructor_implementations_are_not_allowed: diag(2392, ts.DiagnosticCategory.Error, "Multiple_constructor_implementations_are_not_allowed_2392", "Multiple constructor implementations are not allowed."),
5256         Duplicate_function_implementation: diag(2393, ts.DiagnosticCategory.Error, "Duplicate_function_implementation_2393", "Duplicate function implementation."),
5257         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."),
5258         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."),
5259         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."),
5260         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}'."),
5261         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."),
5262         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."),
5263         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."),
5264         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."),
5265         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."),
5266         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}'."),
5267         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."),
5268         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'."),
5269         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."),
5270         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}'."),
5271         Setters_cannot_return_a_value: diag(2408, ts.DiagnosticCategory.Error, "Setters_cannot_return_a_value_2408", "Setters cannot return a value."),
5272         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."),
5273         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'."),
5274         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}'."),
5275         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}'."),
5276         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}'."),
5277         Class_name_cannot_be_0: diag(2414, ts.DiagnosticCategory.Error, "Class_name_cannot_be_0_2414", "Class name cannot be '{0}'."),
5278         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}'."),
5279         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}'."),
5280         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}'."),
5281         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}'."),
5282         Types_of_construct_signatures_are_incompatible: diag(2419, ts.DiagnosticCategory.Error, "Types_of_construct_signatures_are_incompatible_2419", "Types of construct signatures are incompatible."),
5283         Class_0_incorrectly_implements_interface_1: diag(2420, ts.DiagnosticCategory.Error, "Class_0_incorrectly_implements_interface_1_2420", "Class '{0}' incorrectly implements interface '{1}'."),
5284         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."),
5285         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."),
5286         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."),
5287         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."),
5288         Interface_name_cannot_be_0: diag(2427, ts.DiagnosticCategory.Error, "Interface_name_cannot_be_0_2427", "Interface name cannot be '{0}'."),
5289         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."),
5290         Interface_0_incorrectly_extends_interface_1: diag(2430, ts.DiagnosticCategory.Error, "Interface_0_incorrectly_extends_interface_1_2430", "Interface '{0}' incorrectly extends interface '{1}'."),
5291         Enum_name_cannot_be_0: diag(2431, ts.DiagnosticCategory.Error, "Enum_name_cannot_be_0_2431", "Enum name cannot be '{0}'."),
5292         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."),
5293         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."),
5294         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."),
5295         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."),
5296         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."),
5297         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."),
5298         Import_name_cannot_be_0: diag(2438, ts.DiagnosticCategory.Error, "Import_name_cannot_be_0_2438", "Import name cannot be '{0}'."),
5299         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."),
5300         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}'."),
5301         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."),
5302         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}'."),
5303         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}'."),
5304         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}'."),
5305         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."),
5306         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}'."),
5307         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."),
5308         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."),
5309         Class_0_used_before_its_declaration: diag(2449, ts.DiagnosticCategory.Error, "Class_0_used_before_its_declaration_2449", "Class '{0}' used before its declaration."),
5310         Enum_0_used_before_its_declaration: diag(2450, ts.DiagnosticCategory.Error, "Enum_0_used_before_its_declaration_2450", "Enum '{0}' used before its declaration."),
5311         Cannot_redeclare_block_scoped_variable_0: diag(2451, ts.DiagnosticCategory.Error, "Cannot_redeclare_block_scoped_variable_0_2451", "Cannot redeclare block-scoped variable '{0}'."),
5312         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."),
5313         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."),
5314         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."),
5315         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}'."),
5316         Type_alias_0_circularly_references_itself: diag(2456, ts.DiagnosticCategory.Error, "Type_alias_0_circularly_references_itself_2456", "Type alias '{0}' circularly references itself."),
5317         Type_alias_name_cannot_be_0: diag(2457, ts.DiagnosticCategory.Error, "Type_alias_name_cannot_be_0_2457", "Type alias name cannot be '{0}'."),
5318         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."),
5319         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."),
5320         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}'."),
5321         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."),
5322         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."),
5323         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."),
5324         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'."),
5325         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."),
5326         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."),
5327         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."),
5328         Cannot_find_global_value_0: diag(2468, ts.DiagnosticCategory.Error, "Cannot_find_global_value_0_2468", "Cannot find global value '{0}'."),
5329         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'."),
5330         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."),
5331         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'."),
5332         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."),
5333         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."),
5334         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."),
5335         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."),
5336         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."),
5337         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."),
5338         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'."),
5339         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}'."),
5340         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."),
5341         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}'."),
5342         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."),
5343         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}'."),
5344         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."),
5345         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."),
5346         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."),
5347         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."),
5348         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."),
5349         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."),
5350         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}'."),
5351         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."),
5352         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."),
5353         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."),
5354         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."),
5355         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 *'."),
5356         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."),
5357         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."),
5358         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."),
5359         _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."),
5360         Cannot_find_namespace_0: diag(2503, ts.DiagnosticCategory.Error, "Cannot_find_namespace_0_2503", "Cannot find namespace '{0}'."),
5361         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."),
5362         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."),
5363         _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."),
5364         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."),
5365         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."),
5366         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."),
5367         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."),
5368         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."),
5369         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."),
5370         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."),
5371         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."),
5372         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}'."),
5373         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."),
5374         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."),
5375         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."),
5376         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."),
5377         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."),
5378         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."),
5379         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."),
5380         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."),
5381         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."),
5382         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."),
5383         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."),
5384         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."),
5385         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."),
5386         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."),
5387         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."),
5388         Object_is_possibly_null: diag(2531, ts.DiagnosticCategory.Error, "Object_is_possibly_null_2531", "Object is possibly 'null'."),
5389         Object_is_possibly_undefined: diag(2532, ts.DiagnosticCategory.Error, "Object_is_possibly_undefined_2532", "Object is possibly 'undefined'."),
5390         Object_is_possibly_null_or_undefined: diag(2533, ts.DiagnosticCategory.Error, "Object_is_possibly_null_or_undefined_2533", "Object is possibly 'null' or 'undefined'."),
5391         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."),
5392         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."),
5393         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}'."),
5394         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}'."),
5395         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."),
5396         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."),
5397         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."),
5398         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."),
5399         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."),
5400         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."),
5401         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."),
5402         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[]'."),
5403         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."),
5404         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."),
5405         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."),
5406         Property_0_does_not_exist_on_type_1_Do_you_need_to_change_your_target_library_Try_changing_the_lib_compiler_option_to_2_or_later: diag(2550, ts.DiagnosticCategory.Error, "Property_0_does_not_exist_on_type_1_Do_you_need_to_change_your_target_library_Try_changing_the_lib_c_2550", "Property '{0}' does not exist on type '{1}'. Do you need to change your target library? Try changing the `lib` compiler option to '{2}' or later."),
5407         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}'?"),
5408         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}'?"),
5409         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."),
5410         Expected_0_arguments_but_got_1: diag(2554, ts.DiagnosticCategory.Error, "Expected_0_arguments_but_got_1_2554", "Expected {0} arguments, but got {1}."),
5411         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}."),
5412         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."),
5413         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."),
5414         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}."),
5415         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}'."),
5416         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?"),
5417         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}'?"),
5418         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."),
5419         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."),
5420         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."),
5421         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."),
5422         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."),
5423         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."),
5424         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."),
5425         Object_is_of_type_unknown: diag(2571, ts.DiagnosticCategory.Error, "Object_is_of_type_unknown_2571", "Object is of type 'unknown'."),
5426         Rest_signatures_are_incompatible: diag(2572, ts.DiagnosticCategory.Error, "Rest_signatures_are_incompatible_2572", "Rest signatures are incompatible."),
5427         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."),
5428         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."),
5429         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."),
5430         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}'."),
5431         Return_type_annotation_circularly_references_itself: diag(2577, ts.DiagnosticCategory.Error, "Return_type_annotation_circularly_references_itself_2577", "Return type annotation circularly references itself."),
5432         Unused_ts_expect_error_directive: diag(2578, ts.DiagnosticCategory.Error, "Unused_ts_expect_error_directive_2578", "Unused '@ts-expect-error' directive."),
5433         Cannot_find_name_0_Do_you_need_to_install_type_definitions_for_node_Try_npm_i_save_dev_types_Slashnode: diag(2580, ts.DiagnosticCategory.Error, "Cannot_find_name_0_Do_you_need_to_install_type_definitions_for_node_Try_npm_i_save_dev_types_Slashno_2580", "Cannot find name '{0}'. Do you need to install type definitions for node? Try `npm i --save-dev @types/node`."),
5434         Cannot_find_name_0_Do_you_need_to_install_type_definitions_for_jQuery_Try_npm_i_save_dev_types_Slashjquery: diag(2581, ts.DiagnosticCategory.Error, "Cannot_find_name_0_Do_you_need_to_install_type_definitions_for_jQuery_Try_npm_i_save_dev_types_Slash_2581", "Cannot find name '{0}'. Do you need to install type definitions for jQuery? Try `npm i --save-dev @types/jquery`."),
5435         Cannot_find_name_0_Do_you_need_to_install_type_definitions_for_a_test_runner_Try_npm_i_save_dev_types_Slashjest_or_npm_i_save_dev_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_save_dev_type_2582", "Cannot find name '{0}'. Do you need to install type definitions for a test runner? Try `npm i --save-dev @types/jest` or `npm i --save-dev @types/mocha`."),
5436         Cannot_find_name_0_Do_you_need_to_change_your_target_library_Try_changing_the_lib_compiler_option_to_1_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 '{1}' or later."),
5437         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'."),
5438         _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."),
5439         Enum_type_0_circularly_references_itself: diag(2586, ts.DiagnosticCategory.Error, "Enum_type_0_circularly_references_itself_2586", "Enum type '{0}' circularly references itself."),
5440         JSDoc_type_0_circularly_references_itself: diag(2587, ts.DiagnosticCategory.Error, "JSDoc_type_0_circularly_references_itself_2587", "JSDoc type '{0}' circularly references itself."),
5441         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."),
5442         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."),
5443         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."),
5444         Cannot_find_name_0_Do_you_need_to_install_type_definitions_for_node_Try_npm_i_save_dev_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_save_dev_types_Slashno_2591", "Cannot find name '{0}'. Do you need to install type definitions for node? Try `npm i --save-dev @types/node` and then add `node` to the types field in your tsconfig."),
5445         Cannot_find_name_0_Do_you_need_to_install_type_definitions_for_jQuery_Try_npm_i_save_dev_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_save_dev_types_Slash_2592", "Cannot find name '{0}'. Do you need to install type definitions for jQuery? Try `npm i --save-dev @types/jquery` and then add `jquery` to the types field in your tsconfig."),
5446         Cannot_find_name_0_Do_you_need_to_install_type_definitions_for_a_test_runner_Try_npm_i_save_dev_types_Slashjest_or_npm_i_save_dev_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_save_dev_type_2593", "Cannot find name '{0}'. Do you need to install type definitions for a test runner? Try `npm i --save-dev @types/jest` or `npm i --save-dev @types/mocha` and then add `jest` or `mocha` to the types field in your tsconfig."),
5447         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."),
5448         _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."),
5449         _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."),
5450         _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."),
5451         _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."),
5452         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."),
5453         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."),
5454         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."),
5455         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}'."),
5456         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."),
5457         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."),
5458         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."),
5459         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."),
5460         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."),
5461         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."),
5462         _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."),
5463         _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."),
5464         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."),
5465         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?"),
5466         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?"),
5467         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}'."),
5468         _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."),
5469         _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."),
5470         Source_has_0_element_s_but_target_requires_1: diag(2618, ts.DiagnosticCategory.Error, "Source_has_0_element_s_but_target_requires_1_2618", "Source has {0} element(s) but target requires {1}."),
5471         Source_has_0_element_s_but_target_allows_only_1: diag(2619, ts.DiagnosticCategory.Error, "Source_has_0_element_s_but_target_allows_only_1_2619", "Source has {0} element(s) but target allows only {1}."),
5472         Target_requires_0_element_s_but_source_may_have_fewer: diag(2620, ts.DiagnosticCategory.Error, "Target_requires_0_element_s_but_source_may_have_fewer_2620", "Target requires {0} element(s) but source may have fewer."),
5473         Target_allows_only_0_element_s_but_source_may_have_more: diag(2621, ts.DiagnosticCategory.Error, "Target_allows_only_0_element_s_but_source_may_have_more_2621", "Target allows only {0} element(s) but source may have more."),
5474         Element_at_index_0_is_variadic_in_one_type_but_not_in_the_other: diag(2622, ts.DiagnosticCategory.Error, "Element_at_index_0_is_variadic_in_one_type_but_not_in_the_other_2622", "Element at index {0} is variadic in one type but not in the other."),
5475         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."),
5476         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."),
5477         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."),
5478         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}'."),
5479         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."),
5480         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."),
5481         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."),
5482         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}'."),
5483         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."),
5484         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."),
5485         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."),
5486         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}'?"),
5487         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}'?"),
5488         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."),
5489         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."),
5490         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."),
5491         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."),
5492         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."),
5493         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."),
5494         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."),
5495         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."),
5496         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."),
5497         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."),
5498         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."),
5499         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."),
5500         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."),
5501         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."),
5502         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}'."),
5503         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'."),
5504         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."),
5505         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."),
5506         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."),
5507         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."),
5508         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}'."),
5509         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."),
5510         _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."),
5511         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."),
5512         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}'."),
5513         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'?"),
5514         _0_only_refers_to_a_type_but_is_being_used_as_a_value_here_Did_you_mean_to_use_1_in_0: diag(2690, ts.DiagnosticCategory.Error, "_0_only_refers_to_a_type_but_is_being_used_as_a_value_here_Did_you_mean_to_use_1_in_0_2690", "'{0}' only refers to a type, but is being used as a value here. Did you mean to use '{1} in {0}'?"),
5515         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."),
5516         _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."),
5517         _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."),
5518         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}'."),
5519         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),
5520         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?"),
5521         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."),
5522         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."),
5523         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}'."),
5524         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."),
5525         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."),
5526         _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."),
5527         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."),
5528         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."),
5529         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."),
5530         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."),
5531         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."),
5532         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."),
5533         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."),
5534         _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."),
5535         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."),
5536         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."),
5537         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}\"]'?"),
5538         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."),
5539         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."),
5540         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."),
5541         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}'."),
5542         Duplicate_property_0: diag(2718, ts.DiagnosticCategory.Error, "Duplicate_property_0_2718", "Duplicate property '{0}'."),
5543         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."),
5544         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?"),
5545         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'."),
5546         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'."),
5547         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'."),
5548         _0_has_no_exported_member_named_1_Did_you_mean_2: diag(2724, ts.DiagnosticCategory.Error, "_0_has_no_exported_member_named_1_Did_you_mean_2_2724", "'{0}' has no exported member named '{1}'. Did you mean '{2}'?"),
5549         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}."),
5550         Cannot_find_lib_definition_for_0: diag(2726, ts.DiagnosticCategory.Error, "Cannot_find_lib_definition_for_0_2726", "Cannot find lib definition for '{0}'."),
5551         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}'?"),
5552         _0_is_declared_here: diag(2728, ts.DiagnosticCategory.Message, "_0_is_declared_here_2728", "'{0}' is declared here."),
5553         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."),
5554         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."),
5555         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(...)'."),
5556         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."),
5557         Property_0_was_also_declared_here: diag(2733, ts.DiagnosticCategory.Error, "Property_0_was_also_declared_here_2733", "Property '{0}' was also declared here."),
5558         Are_you_missing_a_semicolon: diag(2734, ts.DiagnosticCategory.Error, "Are_you_missing_a_semicolon_2734", "Are you missing a semicolon?"),
5559         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}'?"),
5560         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}'."),
5561         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."),
5562         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."),
5563         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}"),
5564         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."),
5565         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}'."),
5566         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."),
5567         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."),
5568         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."),
5569         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."),
5570         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."),
5571         _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}'."),
5572         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."),
5573         _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}'?"),
5574         The_implementation_signature_is_declared_here: diag(2750, ts.DiagnosticCategory.Error, "The_implementation_signature_is_declared_here_2750", "The implementation signature is declared here."),
5575         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."),
5576         The_first_export_default_is_here: diag(2752, ts.DiagnosticCategory.Error, "The_first_export_default_is_here_2752", "The first export default is here."),
5577         Another_export_default_is_here: diag(2753, ts.DiagnosticCategory.Error, "Another_export_default_is_here_2753", "Another export default is here."),
5578         super_may_not_use_type_arguments: diag(2754, ts.DiagnosticCategory.Error, "super_may_not_use_type_arguments_2754", "'super' may not use type arguments."),
5579         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."),
5580         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."),
5581         Type_0_has_no_call_signatures: diag(2757, ts.DiagnosticCategory.Error, "Type_0_has_no_call_signatures_2757", "Type '{0}' has no call signatures."),
5582         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."),
5583         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."),
5584         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."),
5585         Type_0_has_no_construct_signatures: diag(2761, ts.DiagnosticCategory.Error, "Type_0_has_no_construct_signatures_2761", "Type '{0}' has no construct signatures."),
5586         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."),
5587         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}'."),
5588         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}'."),
5589         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}'."),
5590         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}'."),
5591         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."),
5592         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."),
5593         No_overload_matches_this_call: diag(2769, ts.DiagnosticCategory.Error, "No_overload_matches_this_call_2769", "No overload matches this call."),
5594         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."),
5595         The_last_overload_is_declared_here: diag(2771, ts.DiagnosticCategory.Error, "The_last_overload_is_declared_here_2771", "The last overload is declared here."),
5596         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."),
5597         Did_you_forget_to_use_await: diag(2773, ts.DiagnosticCategory.Error, "Did_you_forget_to_use_await_2773", "Did you forget to use 'await'?"),
5598         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?"),
5599         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."),
5600         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."),
5601         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."),
5602         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."),
5603         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."),
5604         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."),
5605         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."),
5606         _0_needs_an_explicit_type_annotation: diag(2782, ts.DiagnosticCategory.Message, "_0_needs_an_explicit_type_annotation_2782", "'{0}' needs an explicit type annotation."),
5607         _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."),
5608         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."),
5609         This_spread_always_overwrites_this_property: diag(2785, ts.DiagnosticCategory.Error, "This_spread_always_overwrites_this_property_2785", "This spread always overwrites this property."),
5610         _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."),
5611         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."),
5612         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."),
5613         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."),
5614         The_operand_of_a_delete_operator_must_be_optional: diag(2790, ts.DiagnosticCategory.Error, "The_operand_of_a_delete_operator_must_be_optional_2790", "The operand of a 'delete' operator must be optional."),
5615         Exponentiation_cannot_be_performed_on_bigint_values_unless_the_target_option_is_set_to_es2016_or_later: diag(2791, ts.DiagnosticCategory.Error, "Exponentiation_cannot_be_performed_on_bigint_values_unless_the_target_option_is_set_to_es2016_or_lat_2791", "Exponentiation cannot be performed on 'bigint' values unless the 'target' option is set to 'es2016' or later."),
5616         Cannot_find_module_0_Did_you_mean_to_set_the_moduleResolution_option_to_node_or_to_add_aliases_to_the_paths_option: diag(2792, ts.DiagnosticCategory.Error, "Cannot_find_module_0_Did_you_mean_to_set_the_moduleResolution_option_to_node_or_to_add_aliases_to_th_2792", "Cannot find module '{0}'. Did you mean to set the 'moduleResolution' option to 'node', or to add aliases to the 'paths' option?"),
5617         The_call_would_have_succeeded_against_this_implementation_but_implementation_signatures_of_overloads_are_not_externally_visible: diag(2793, ts.DiagnosticCategory.Error, "The_call_would_have_succeeded_against_this_implementation_but_implementation_signatures_of_overloads_2793", "The call would have succeeded against this implementation, but implementation signatures of overloads are not externally visible."),
5618         Expected_0_arguments_but_got_1_Did_you_forget_to_include_void_in_your_type_argument_to_Promise: diag(2794, ts.DiagnosticCategory.Error, "Expected_0_arguments_but_got_1_Did_you_forget_to_include_void_in_your_type_argument_to_Promise_2794", "Expected {0} arguments, but got {1}. Did you forget to include 'void' in your type argument to 'Promise'?"),
5619         The_intrinsic_keyword_can_only_be_used_to_declare_compiler_provided_intrinsic_types: diag(2795, ts.DiagnosticCategory.Error, "The_intrinsic_keyword_can_only_be_used_to_declare_compiler_provided_intrinsic_types_2795", "The 'intrinsic' keyword can only be used to declare compiler provided intrinsic types."),
5620         It_is_likely_that_you_are_missing_a_comma_to_separate_these_two_template_expressions_They_form_a_tagged_template_expression_which_cannot_be_invoked: diag(2796, ts.DiagnosticCategory.Error, "It_is_likely_that_you_are_missing_a_comma_to_separate_these_two_template_expressions_They_form_a_tag_2796", "It is likely that you are missing a comma to separate these two template expressions. They form a tagged template expression which cannot be invoked."),
5621         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}'."),
5622         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}'."),
5623         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}'."),
5624         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}'."),
5625         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}'."),
5626         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}'."),
5627         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}'."),
5628         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}'."),
5629         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}'."),
5630         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}'."),
5631         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}'."),
5632         extends_clause_of_exported_class_has_or_is_using_private_name_0: diag(4021, ts.DiagnosticCategory.Error, "extends_clause_of_exported_class_has_or_is_using_private_name_0_4021", "'extends' clause of exported class has or is using private name '{0}'."),
5633         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}'."),
5634         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."),
5635         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}'."),
5636         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}'."),
5637         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."),
5638         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}'."),
5639         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}'."),
5640         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."),
5641         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}'."),
5642         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}'."),
5643         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}'."),
5644         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}'."),
5645         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}'."),
5646         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}'."),
5647         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}'."),
5648         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}'."),
5649         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."),
5650         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}'."),
5651         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}'."),
5652         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."),
5653         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}'."),
5654         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}'."),
5655         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}'."),
5656         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}'."),
5657         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}'."),
5658         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}'."),
5659         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}'."),
5660         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}'."),
5661         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."),
5662         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}'."),
5663         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}'."),
5664         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."),
5665         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}'."),
5666         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}'."),
5667         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}'."),
5668         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}'."),
5669         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."),
5670         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}'."),
5671         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}'."),
5672         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."),
5673         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}'."),
5674         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}'."),
5675         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}'."),
5676         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}'."),
5677         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}'."),
5678         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}'."),
5679         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."),
5680         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}'."),
5681         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}'."),
5682         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."),
5683         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}'."),
5684         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}'."),
5685         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}'."),
5686         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}'."),
5687         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."),
5688         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}'."),
5689         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}'."),
5690         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}'."),
5691         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}'."),
5692         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}'."),
5693         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."),
5694         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}'."),
5695         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}'."),
5696         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."),
5697         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."),
5698         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}'."),
5699         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}'."),
5700         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."),
5701         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}'."),
5702         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}'."),
5703         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}'."),
5704         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}'."),
5705         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}'."),
5706         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}'."),
5707         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."),
5708         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}'."),
5709         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}'."),
5710         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."),
5711         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."),
5712         Tuple_type_arguments_circularly_reference_themselves: diag(4110, ts.DiagnosticCategory.Error, "Tuple_type_arguments_circularly_reference_themselves_4110", "Tuple type arguments circularly reference themselves."),
5713         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."),
5714         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."),
5715         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}'."),
5716         Cannot_read_file_0_Colon_1: diag(5012, ts.DiagnosticCategory.Error, "Cannot_read_file_0_Colon_1_5012", "Cannot read file '{0}': {1}."),
5717         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}."),
5718         Unknown_compiler_option_0: diag(5023, ts.DiagnosticCategory.Error, "Unknown_compiler_option_0_5023", "Unknown compiler option '{0}'."),
5719         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}."),
5720         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}'?"),
5721         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}."),
5722         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."),
5723         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."),
5724         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'."),
5725         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."),
5726         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}'."),
5727         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}'."),
5728         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}'."),
5729         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."),
5730         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."),
5731         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}'."),
5732         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}'."),
5733         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."),
5734         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."),
5735         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."),
5736         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."),
5737         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}'."),
5738         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}'."),
5739         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."),
5740         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."),
5741         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."),
5742         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}'."),
5743         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."),
5744         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'."),
5745         Unknown_build_option_0: diag(5072, ts.DiagnosticCategory.Error, "Unknown_build_option_0_5072", "Unknown build option '{0}'."),
5746         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}."),
5747         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."),
5748         _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}'."),
5749         _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."),
5750         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}'?"),
5751         Unknown_watch_option_0: diag(5078, ts.DiagnosticCategory.Error, "Unknown_watch_option_0_5078", "Unknown watch option '{0}'."),
5752         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}'?"),
5753         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}."),
5754         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}."),
5755         _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}'."),
5756         Cannot_read_file_0: diag(5083, ts.DiagnosticCategory.Error, "Cannot_read_file_0_5083", "Cannot read file '{0}'."),
5757         Tuple_members_must_all_have_names_or_all_not_have_names: diag(5084, ts.DiagnosticCategory.Error, "Tuple_members_must_all_have_names_or_all_not_have_names_5084", "Tuple members must all have names or all not have names."),
5758         A_tuple_member_cannot_be_both_optional_and_rest: diag(5085, ts.DiagnosticCategory.Error, "A_tuple_member_cannot_be_both_optional_and_rest_5085", "A tuple member cannot be both optional and rest."),
5759         A_labeled_tuple_element_is_declared_as_optional_with_a_question_mark_after_the_name_and_before_the_colon_rather_than_after_the_type: diag(5086, ts.DiagnosticCategory.Error, "A_labeled_tuple_element_is_declared_as_optional_with_a_question_mark_after_the_name_and_before_the_c_5086", "A labeled tuple element is declared as optional with a question mark after the name and before the colon, rather than after the type."),
5760         A_labeled_tuple_element_is_declared_as_rest_with_a_before_the_name_rather_than_before_the_type: diag(5087, ts.DiagnosticCategory.Error, "A_labeled_tuple_element_is_declared_as_rest_with_a_before_the_name_rather_than_before_the_type_5087", "A labeled tuple element is declared as rest with a `...` before the name, rather than before the type."),
5761         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."),
5762         Option_0_cannot_be_specified_when_option_jsx_is_1: diag(5089, ts.DiagnosticCategory.Error, "Option_0_cannot_be_specified_when_option_jsx_is_1_5089", "Option '{0}' cannot be specified when option 'jsx' is '{1}'."),
5763         Non_relative_paths_are_not_allowed_when_baseUrl_is_not_set_Did_you_forget_a_leading_Slash: diag(5090, ts.DiagnosticCategory.Error, "Non_relative_paths_are_not_allowed_when_baseUrl_is_not_set_Did_you_forget_a_leading_Slash_5090", "Non-relative paths are not allowed when 'baseUrl' is not set. Did you forget a leading './'?"),
5764         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."),
5765         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."),
5766         Generates_corresponding_d_ts_file: diag(6002, ts.DiagnosticCategory.Message, "Generates_corresponding_d_ts_file_6002", "Generates corresponding '.d.ts' file."),
5767         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."),
5768         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."),
5769         Watch_input_files: diag(6005, ts.DiagnosticCategory.Message, "Watch_input_files_6005", "Watch input files."),
5770         Redirect_output_structure_to_the_directory: diag(6006, ts.DiagnosticCategory.Message, "Redirect_output_structure_to_the_directory_6006", "Redirect output structure to the directory."),
5771         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."),
5772         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."),
5773         Do_not_emit_comments_to_output: diag(6009, ts.DiagnosticCategory.Message, "Do_not_emit_comments_to_output_6009", "Do not emit comments to output."),
5774         Do_not_emit_outputs: diag(6010, ts.DiagnosticCategory.Message, "Do_not_emit_outputs_6010", "Do not emit outputs."),
5775         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."),
5776         Skip_type_checking_of_declaration_files: diag(6012, ts.DiagnosticCategory.Message, "Skip_type_checking_of_declaration_files_6012", "Skip type checking of declaration files."),
5777         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."),
5778         Only_emit_d_ts_declaration_files: diag(6014, ts.DiagnosticCategory.Message, "Only_emit_d_ts_declaration_files_6014", "Only emit '.d.ts' declaration files."),
5779         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'."),
5780         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'."),
5781         Print_this_message: diag(6017, ts.DiagnosticCategory.Message, "Print_this_message_6017", "Print this message."),
5782         Print_the_compiler_s_version: diag(6019, ts.DiagnosticCategory.Message, "Print_the_compiler_s_version_6019", "Print the compiler's version."),
5783         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'."),
5784         Syntax_Colon_0: diag(6023, ts.DiagnosticCategory.Message, "Syntax_Colon_0_6023", "Syntax: {0}"),
5785         options: diag(6024, ts.DiagnosticCategory.Message, "options_6024", "options"),
5786         file: diag(6025, ts.DiagnosticCategory.Message, "file_6025", "file"),
5787         Examples_Colon_0: diag(6026, ts.DiagnosticCategory.Message, "Examples_Colon_0_6026", "Examples: {0}"),
5788         Options_Colon: diag(6027, ts.DiagnosticCategory.Message, "Options_Colon_6027", "Options:"),
5789         Version_0: diag(6029, ts.DiagnosticCategory.Message, "Version_0_6029", "Version {0}"),
5790         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."),
5791         Starting_compilation_in_watch_mode: diag(6031, ts.DiagnosticCategory.Message, "Starting_compilation_in_watch_mode_6031", "Starting compilation in watch mode..."),
5792         File_change_detected_Starting_incremental_compilation: diag(6032, ts.DiagnosticCategory.Message, "File_change_detected_Starting_incremental_compilation_6032", "File change detected. Starting incremental compilation..."),
5793         KIND: diag(6034, ts.DiagnosticCategory.Message, "KIND_6034", "KIND"),
5794         FILE: diag(6035, ts.DiagnosticCategory.Message, "FILE_6035", "FILE"),
5795         VERSION: diag(6036, ts.DiagnosticCategory.Message, "VERSION_6036", "VERSION"),
5796         LOCATION: diag(6037, ts.DiagnosticCategory.Message, "LOCATION_6037", "LOCATION"),
5797         DIRECTORY: diag(6038, ts.DiagnosticCategory.Message, "DIRECTORY_6038", "DIRECTORY"),
5798         STRATEGY: diag(6039, ts.DiagnosticCategory.Message, "STRATEGY_6039", "STRATEGY"),
5799         FILE_OR_DIRECTORY: diag(6040, ts.DiagnosticCategory.Message, "FILE_OR_DIRECTORY_6040", "FILE OR DIRECTORY"),
5800         Generates_corresponding_map_file: diag(6043, ts.DiagnosticCategory.Message, "Generates_corresponding_map_file_6043", "Generates corresponding '.map' file."),
5801         Compiler_option_0_expects_an_argument: diag(6044, ts.DiagnosticCategory.Error, "Compiler_option_0_expects_an_argument_6044", "Compiler option '{0}' expects an argument."),
5802         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}'."),
5803         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}."),
5804         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}'."),
5805         Unsupported_locale_0: diag(6049, ts.DiagnosticCategory.Error, "Unsupported_locale_0_6049", "Unsupported locale '{0}'."),
5806         Unable_to_open_file_0: diag(6050, ts.DiagnosticCategory.Error, "Unable_to_open_file_0_6050", "Unable to open file '{0}'."),
5807         Corrupted_locale_file_0: diag(6051, ts.DiagnosticCategory.Error, "Corrupted_locale_file_0_6051", "Corrupted locale file {0}."),
5808         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."),
5809         File_0_not_found: diag(6053, ts.DiagnosticCategory.Error, "File_0_not_found_6053", "File '{0}' not found."),
5810         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}."),
5811         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."),
5812         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."),
5813         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."),
5814         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."),
5815         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)."),
5816         NEWLINE: diag(6061, ts.DiagnosticCategory.Message, "NEWLINE_6061", "NEWLINE"),
5817         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."),
5818         Enables_experimental_support_for_ES7_decorators: diag(6065, ts.DiagnosticCategory.Message, "Enables_experimental_support_for_ES7_decorators_6065", "Enables experimental support for ES7 decorators."),
5819         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."),
5820         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."),
5821         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)."),
5822         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."),
5823         Successfully_created_a_tsconfig_json_file: diag(6071, ts.DiagnosticCategory.Message, "Successfully_created_a_tsconfig_json_file_6071", "Successfully created a tsconfig.json file."),
5824         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."),
5825         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)."),
5826         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."),
5827         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."),
5828         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."),
5829         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."),
5830         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."),
5831         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."),
5832         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'."),
5833         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."),
5834         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}."),
5835         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."),
5836         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"),
5837         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."),
5838         Resolving_module_0_from_1: diag(6086, ts.DiagnosticCategory.Message, "Resolving_module_0_from_1_6086", "======== Resolving module '{0}' from '{1}'. ========"),
5839         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}'."),
5840         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}'."),
5841         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}'. ========"),
5842         Module_name_0_was_not_resolved: diag(6090, ts.DiagnosticCategory.Message, "Module_name_0_was_not_resolved_6090", "======== Module name '{0}' was not resolved. ========"),
5843         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}'."),
5844         Module_name_0_matched_pattern_1: diag(6092, ts.DiagnosticCategory.Message, "Module_name_0_matched_pattern_1_6092", "Module name '{0}', matched pattern '{1}'."),
5845         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}'."),
5846         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}'."),
5847         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}'."),
5848         File_0_does_not_exist: diag(6096, ts.DiagnosticCategory.Message, "File_0_does_not_exist_6096", "File '{0}' does not exist."),
5849         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."),
5850         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}'."),
5851         Found_package_json_at_0: diag(6099, ts.DiagnosticCategory.Message, "Found_package_json_at_0_6099", "Found 'package.json' at '{0}'."),
5852         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."),
5853         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}'."),
5854         Allow_javascript_files_to_be_compiled: diag(6102, ts.DiagnosticCategory.Message, "Allow_javascript_files_to_be_compiled_6102", "Allow javascript files to be compiled."),
5855         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."),
5856         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}'."),
5857         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}'."),
5858         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}'."),
5859         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}'."),
5860         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}'."),
5861         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}'."),
5862         Trying_other_entries_in_rootDirs: diag(6110, ts.DiagnosticCategory.Message, "Trying_other_entries_in_rootDirs_6110", "Trying other entries in 'rootDirs'."),
5863         Module_resolution_using_rootDirs_has_failed: diag(6111, ts.DiagnosticCategory.Message, "Module_resolution_using_rootDirs_has_failed_6111", "Module resolution using 'rootDirs' has failed."),
5864         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."),
5865         Enable_strict_null_checks: diag(6113, ts.DiagnosticCategory.Message, "Enable_strict_null_checks_6113", "Enable strict null checks."),
5866         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'?"),
5867         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."),
5868         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}'. ========"),
5869         Resolving_using_primary_search_paths: diag(6117, ts.DiagnosticCategory.Message, "Resolving_using_primary_search_paths_6117", "Resolving using primary search paths..."),
5870         Resolving_from_node_modules_folder: diag(6118, ts.DiagnosticCategory.Message, "Resolving_from_node_modules_folder_6118", "Resolving from node_modules folder..."),
5871         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}. ========"),
5872         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. ========"),
5873         Resolving_with_primary_search_path_0: diag(6121, ts.DiagnosticCategory.Message, "Resolving_with_primary_search_path_0_6121", "Resolving with primary search path '{0}'."),
5874         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."),
5875         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. ========"),
5876         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."),
5877         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}'."),
5878         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."),
5879         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}'. ========"),
5880         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. ========"),
5881         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}'."),
5882         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'."),
5883         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."),
5884         _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),
5885         Report_errors_on_unused_locals: diag(6134, ts.DiagnosticCategory.Message, "Report_errors_on_unused_locals_6134", "Report errors on unused locals."),
5886         Report_errors_on_unused_parameters: diag(6135, ts.DiagnosticCategory.Message, "Report_errors_on_unused_parameters_6135", "Report errors on unused parameters."),
5887         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."),
5888         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}'."),
5889         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),
5890         Import_emit_helpers_from_tslib: diag(6139, ts.DiagnosticCategory.Message, "Import_emit_helpers_from_tslib_6139", "Import emit helpers from 'tslib'."),
5891         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}'."),
5892         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."),
5893         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."),
5894         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}'."),
5895         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."),
5896         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'."),
5897         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}'."),
5898         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."),
5899         Show_diagnostic_information: diag(6149, ts.DiagnosticCategory.Message, "Show_diagnostic_information_6149", "Show diagnostic information."),
5900         Show_verbose_diagnostic_information: diag(6150, ts.DiagnosticCategory.Message, "Show_verbose_diagnostic_information_6150", "Show verbose diagnostic information."),
5901         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."),
5902         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."),
5903         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')."),
5904         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."),
5905         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."),
5906         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')"),
5907         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."),
5908         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)."),
5909         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."),
5910         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."),
5911         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."),
5912         Disable_size_limitations_on_JavaScript_projects: diag(6162, ts.DiagnosticCategory.Message, "Disable_size_limitations_on_JavaScript_projects_6162", "Disable size limitations on JavaScript projects."),
5913         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."),
5914         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."),
5915         Do_not_truncate_error_messages: diag(6165, ts.DiagnosticCategory.Message, "Do_not_truncate_error_messages_6165", "Do not truncate error messages."),
5916         Output_directory_for_generated_declaration_files: diag(6166, ts.DiagnosticCategory.Message, "Output_directory_for_generated_declaration_files_6166", "Output directory for generated declaration files."),
5917         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'."),
5918         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."),
5919         Show_all_compiler_options: diag(6169, ts.DiagnosticCategory.Message, "Show_all_compiler_options_6169", "Show all compiler options."),
5920         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"),
5921         Command_line_Options: diag(6171, ts.DiagnosticCategory.Message, "Command_line_Options_6171", "Command-line Options"),
5922         Basic_Options: diag(6172, ts.DiagnosticCategory.Message, "Basic_Options_6172", "Basic Options"),
5923         Strict_Type_Checking_Options: diag(6173, ts.DiagnosticCategory.Message, "Strict_Type_Checking_Options_6173", "Strict Type-Checking Options"),
5924         Module_Resolution_Options: diag(6174, ts.DiagnosticCategory.Message, "Module_Resolution_Options_6174", "Module Resolution Options"),
5925         Source_Map_Options: diag(6175, ts.DiagnosticCategory.Message, "Source_Map_Options_6175", "Source Map Options"),
5926         Additional_Checks: diag(6176, ts.DiagnosticCategory.Message, "Additional_Checks_6176", "Additional Checks"),
5927         Experimental_Options: diag(6177, ts.DiagnosticCategory.Message, "Experimental_Options_6177", "Experimental Options"),
5928         Advanced_Options: diag(6178, ts.DiagnosticCategory.Message, "Advanced_Options_6178", "Advanced Options"),
5929         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'."),
5930         Enable_all_strict_type_checking_options: diag(6180, ts.DiagnosticCategory.Message, "Enable_all_strict_type_checking_options_6180", "Enable all strict type-checking options."),
5931         List_of_language_service_plugins: diag(6181, ts.DiagnosticCategory.Message, "List_of_language_service_plugins_6181", "List of language service plugins."),
5932         Scoped_package_detected_looking_in_0: diag(6182, ts.DiagnosticCategory.Message, "Scoped_package_detected_looking_in_0_6182", "Scoped package detected, looking in '{0}'"),
5933         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."),
5934         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."),
5935         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."),
5936         Enable_strict_checking_of_function_types: diag(6186, ts.DiagnosticCategory.Message, "Enable_strict_checking_of_function_types_6186", "Enable strict checking of function types."),
5937         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."),
5938         Numeric_separators_are_not_allowed_here: diag(6188, ts.DiagnosticCategory.Error, "Numeric_separators_are_not_allowed_here_6188", "Numeric separators are not allowed here."),
5939         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."),
5940         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."),
5941         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),
5942         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."),
5943         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."),
5944         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)."),
5945         _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),
5946         Include_modules_imported_with_json_extension: diag(6197, ts.DiagnosticCategory.Message, "Include_modules_imported_with_json_extension_6197", "Include modules imported with '.json' extension"),
5947         All_destructured_elements_are_unused: diag(6198, ts.DiagnosticCategory.Error, "All_destructured_elements_are_unused_6198", "All destructured elements are unused.", true),
5948         All_variables_are_unused: diag(6199, ts.DiagnosticCategory.Error, "All_variables_are_unused_6199", "All variables are unused.", true),
5949         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}"),
5950         Conflicts_are_in_this_file: diag(6201, ts.DiagnosticCategory.Message, "Conflicts_are_in_this_file_6201", "Conflicts are in this file."),
5951         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}"),
5952         _0_was_also_declared_here: diag(6203, ts.DiagnosticCategory.Message, "_0_was_also_declared_here_6203", "'{0}' was also declared here."),
5953         and_here: diag(6204, ts.DiagnosticCategory.Message, "and_here_6204", "and here."),
5954         All_type_parameters_are_unused: diag(6205, ts.DiagnosticCategory.Error, "All_type_parameters_are_unused_6205", "All type parameters are unused."),
5955         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."),
5956         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}'."),
5957         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}'."),
5958         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."),
5959         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."),
5960         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."),
5961         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?"),
5962         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?"),
5963         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."),
5964         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}'."),
5965         Found_1_error: diag(6216, ts.DiagnosticCategory.Message, "Found_1_error_6216", "Found 1 error."),
5966         Found_0_errors: diag(6217, ts.DiagnosticCategory.Message, "Found_0_errors_6217", "Found {0} errors."),
5967         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}'. ========"),
5968         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}. ========"),
5969         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."),
5970         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."),
5971         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."),
5972         Generates_a_CPU_profile: diag(6223, ts.DiagnosticCategory.Message, "Generates_a_CPU_profile_6223", "Generates a CPU profile."),
5973         Disable_solution_searching_for_this_project: diag(6224, ts.DiagnosticCategory.Message, "Disable_solution_searching_for_this_project_6224", "Disable solution searching for this project."),
5974         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'."),
5975         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'."),
5976         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'."),
5977         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."),
5978         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}'."),
5979         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."),
5980         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}."),
5981         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."),
5982         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."),
5983         This_expression_is_not_callable_because_it_is_a_get_accessor_Did_you_mean_to_use_it_without: diag(6234, ts.DiagnosticCategory.Error, "This_expression_is_not_callable_because_it_is_a_get_accessor_Did_you_mean_to_use_it_without_6234", "This expression is not callable because it is a 'get' accessor. Did you mean to use it without '()'?"),
5984         Disable_loading_referenced_projects: diag(6235, ts.DiagnosticCategory.Message, "Disable_loading_referenced_projects_6235", "Disable loading referenced projects."),
5985         Arguments_for_the_rest_parameter_0_were_not_provided: diag(6236, ts.DiagnosticCategory.Error, "Arguments_for_the_rest_parameter_0_were_not_provided_6236", "Arguments for the rest parameter '{0}' were not provided."),
5986         Generates_an_event_trace_and_a_list_of_types: diag(6237, ts.DiagnosticCategory.Message, "Generates_an_event_trace_and_a_list_of_types_6237", "Generates an event trace and a list of types."),
5987         Specify_the_module_specifier_to_be_used_to_import_the_jsx_and_jsxs_factory_functions_from_eg_react: diag(6238, ts.DiagnosticCategory.Error, "Specify_the_module_specifier_to_be_used_to_import_the_jsx_and_jsxs_factory_functions_from_eg_react_6238", "Specify the module specifier to be used to import the `jsx` and `jsxs` factory functions from. eg, react"),
5988         Projects_to_reference: diag(6300, ts.DiagnosticCategory.Message, "Projects_to_reference_6300", "Projects to reference"),
5989         Enable_project_compilation: diag(6302, ts.DiagnosticCategory.Message, "Enable_project_compilation_6302", "Enable project compilation"),
5990         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."),
5991         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}'."),
5992         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."),
5993         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."),
5994         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"),
5995         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"),
5996         Referenced_project_0_may_not_disable_emit: diag(6310, ts.DiagnosticCategory.Error, "Referenced_project_0_may_not_disable_emit_6310", "Referenced project '{0}' may not disable emit."),
5997         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}'"),
5998         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}'"),
5999         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"),
6000         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"),
6001         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"),
6002         Projects_in_this_build_Colon_0: diag(6355, ts.DiagnosticCategory.Message, "Projects_in_this_build_Colon_0_6355", "Projects in this build: {0}"),
6003         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}"),
6004         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}'"),
6005         Building_project_0: diag(6358, ts.DiagnosticCategory.Message, "Building_project_0_6358", "Building project '{0}'..."),
6006         Updating_output_timestamps_of_project_0: diag(6359, ts.DiagnosticCategory.Message, "Updating_output_timestamps_of_project_0_6359", "Updating output timestamps of project '{0}'..."),
6007         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"),
6008         Project_0_is_up_to_date: diag(6361, ts.DiagnosticCategory.Message, "Project_0_is_up_to_date_6361", "Project '{0}' is up to date"),
6009         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"),
6010         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"),
6011         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"),
6012         Delete_the_outputs_of_all_projects: diag(6365, ts.DiagnosticCategory.Message, "Delete_the_outputs_of_all_projects_6365", "Delete the outputs of all projects"),
6013         Enable_verbose_logging: diag(6366, ts.DiagnosticCategory.Message, "Enable_verbose_logging_6366", "Enable verbose logging"),
6014         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')"),
6015         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"),
6016         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."),
6017         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."),
6018         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}'..."),
6019         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"),
6020         Updating_output_of_project_0: diag(6373, ts.DiagnosticCategory.Message, "Updating_output_of_project_0_6373", "Updating output of project '{0}'..."),
6021         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}'"),
6022         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}'"),
6023         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}'"),
6024         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}'"),
6025         Enable_incremental_compilation: diag(6378, ts.DiagnosticCategory.Message, "Enable_incremental_compilation_6378", "Enable incremental compilation"),
6026         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."),
6027         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"),
6028         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}'"),
6029         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"),
6030         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"),
6031         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."),
6032         _0_is_deprecated: diag(6385, ts.DiagnosticCategory.Suggestion, "_0_is_deprecated_6385", "'{0}' is deprecated", undefined, undefined, true),
6033         Performance_timings_for_diagnostics_or_extendedDiagnostics_are_not_available_in_this_session_A_native_implementation_of_the_Web_Performance_API_could_not_be_found: diag(6386, ts.DiagnosticCategory.Message, "Performance_timings_for_diagnostics_or_extendedDiagnostics_are_not_available_in_this_session_A_nativ_6386", "Performance timings for '--diagnostics' or '--extendedDiagnostics' are not available in this session. A native implementation of the Web Performance API could not be found."),
6034         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}'"),
6035         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."),
6036         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."),
6037         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."),
6038         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?"),
6039         Include_undefined_in_index_signature_results: diag(6800, ts.DiagnosticCategory.Message, "Include_undefined_in_index_signature_results_6800", "Include 'undefined' in index signature results"),
6040         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."),
6041         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."),
6042         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."),
6043         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."),
6044         _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."),
6045         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."),
6046         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."),
6047         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."),
6048         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'."),
6049         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."),
6050         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."),
6051         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."),
6052         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."),
6053         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."),
6054         _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."),
6055         _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."),
6056         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."),
6057         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."),
6058         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."),
6059         Unreachable_code_detected: diag(7027, ts.DiagnosticCategory.Error, "Unreachable_code_detected_7027", "Unreachable code detected.", true),
6060         Unused_label: diag(7028, ts.DiagnosticCategory.Error, "Unused_label_7028", "Unused label.", true),
6061         Fallthrough_case_in_switch: diag(7029, ts.DiagnosticCategory.Error, "Fallthrough_case_in_switch_7029", "Fallthrough case in switch."),
6062         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."),
6063         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."),
6064         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."),
6065         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."),
6066         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."),
6067         Try_npm_i_save_dev_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_i_save_dev_types_Slash_1_if_it_exists_or_add_a_new_declaration_d_ts_file_containing_declare__7035", "Try `npm i --save-dev @types/{1}` if it exists or add a new declaration (.d.ts) file containing `declare module '{0}';`"),
6068         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}'."),
6069         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'."),
6070         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."),
6071         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."),
6072         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}`"),
6073         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'."),
6074         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."),
6075         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."),
6076         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."),
6077         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."),
6078         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."),
6079         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."),
6080         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."),
6081         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."),
6082         _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."),
6083         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}'?"),
6084         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}'?"),
6085         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}'."),
6086         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}'."),
6087         _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."),
6088         The_inferred_type_of_this_node_exceeds_the_maximum_length_the_compiler_will_serialize_An_explicit_type_annotation_is_needed: diag(7056, ts.DiagnosticCategory.Error, "The_inferred_type_of_this_node_exceeds_the_maximum_length_the_compiler_will_serialize_An_explicit_ty_7056", "The inferred type of this node exceeds the maximum length the compiler will serialize. An explicit type annotation is needed."),
6089         You_cannot_rename_this_element: diag(8000, ts.DiagnosticCategory.Error, "You_cannot_rename_this_element_8000", "You cannot rename this element."),
6090         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."),
6091         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."),
6092         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."),
6093         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."),
6094         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."),
6095         _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."),
6096         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."),
6097         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."),
6098         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."),
6099         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."),
6100         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."),
6101         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."),
6102         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."),
6103         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}'."),
6104         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}'."),
6105         Report_errors_in_js_files: diag(8019, ts.DiagnosticCategory.Message, "Report_errors_in_js_files_8019", "Report errors in .js files."),
6106         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."),
6107         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."),
6108         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."),
6109         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."),
6110         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."),
6111         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."),
6112         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."),
6113         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."),
6114         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."),
6115         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."),
6116         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."),
6117         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."),
6118         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}'."),
6119         A_JSDoc_typedef_comment_may_not_contain_multiple_type_tags: diag(8033, ts.DiagnosticCategory.Error, "A_JSDoc_typedef_comment_may_not_contain_multiple_type_tags_8033", "A JSDoc '@typedef' comment may not contain multiple '@type' tags."),
6120         The_tag_was_first_specified_here: diag(8034, ts.DiagnosticCategory.Error, "The_tag_was_first_specified_here_8034", "The tag was first specified here."),
6121         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."),
6122         class_expressions_are_not_currently_supported: diag(9003, ts.DiagnosticCategory.Error, "class_expressions_are_not_currently_supported_9003", "'class' expressions are not currently supported."),
6123         Language_service_is_disabled: diag(9004, ts.DiagnosticCategory.Error, "Language_service_is_disabled_9004", "Language service is disabled."),
6124         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."),
6125         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."),
6126         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'."),
6127         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."),
6128         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}'."),
6129         JSX_attribute_expected: diag(17003, ts.DiagnosticCategory.Error, "JSX_attribute_expected_17003", "JSX attribute expected."),
6130         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."),
6131         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'."),
6132         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."),
6133         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."),
6134         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."),
6135         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."),
6136         Unknown_type_acquisition_option_0: diag(17010, ts.DiagnosticCategory.Error, "Unknown_type_acquisition_option_0_17010", "Unknown type acquisition option '{0}'."),
6137         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."),
6138         _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}'?"),
6139         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."),
6140         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."),
6141         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."),
6142         The_jsxFragmentFactory_compiler_option_must_be_provided_to_use_JSX_fragments_with_the_jsxFactory_compiler_option: diag(17016, ts.DiagnosticCategory.Error, "The_jsxFragmentFactory_compiler_option_must_be_provided_to_use_JSX_fragments_with_the_jsxFactory_com_17016", "The 'jsxFragmentFactory' compiler option must be provided to use JSX fragments with the 'jsxFactory' compiler option."),
6143         An_jsxFrag_pragma_is_required_when_using_an_jsx_pragma_with_JSX_fragments: diag(17017, ts.DiagnosticCategory.Error, "An_jsxFrag_pragma_is_required_when_using_an_jsx_pragma_with_JSX_fragments_17017", "An @jsxFrag pragma is required when using an @jsx pragma with JSX fragments."),
6144         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}'?"),
6145         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}"),
6146         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."),
6147         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."),
6148         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}'."),
6149         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."),
6150         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."),
6151         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."),
6152         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."),
6153         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."),
6154         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."),
6155         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."),
6156         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."),
6157         Add_missing_super_call: diag(90001, ts.DiagnosticCategory.Message, "Add_missing_super_call_90001", "Add missing 'super()' call"),
6158         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"),
6159         Change_extends_to_implements: diag(90003, ts.DiagnosticCategory.Message, "Change_extends_to_implements_90003", "Change 'extends' to 'implements'"),
6160         Remove_unused_declaration_for_Colon_0: diag(90004, ts.DiagnosticCategory.Message, "Remove_unused_declaration_for_Colon_0_90004", "Remove unused declaration for: '{0}'"),
6161         Remove_import_from_0: diag(90005, ts.DiagnosticCategory.Message, "Remove_import_from_0_90005", "Remove import from '{0}'"),
6162         Implement_interface_0: diag(90006, ts.DiagnosticCategory.Message, "Implement_interface_0_90006", "Implement interface '{0}'"),
6163         Implement_inherited_abstract_class: diag(90007, ts.DiagnosticCategory.Message, "Implement_inherited_abstract_class_90007", "Implement inherited abstract class"),
6164         Add_0_to_unresolved_variable: diag(90008, ts.DiagnosticCategory.Message, "Add_0_to_unresolved_variable_90008", "Add '{0}.' to unresolved variable"),
6165         Remove_variable_statement: diag(90010, ts.DiagnosticCategory.Message, "Remove_variable_statement_90010", "Remove variable statement"),
6166         Remove_template_tag: diag(90011, ts.DiagnosticCategory.Message, "Remove_template_tag_90011", "Remove template tag"),
6167         Remove_type_parameters: diag(90012, ts.DiagnosticCategory.Message, "Remove_type_parameters_90012", "Remove type parameters"),
6168         Import_0_from_module_1: diag(90013, ts.DiagnosticCategory.Message, "Import_0_from_module_1_90013", "Import '{0}' from module \"{1}\""),
6169         Change_0_to_1: diag(90014, ts.DiagnosticCategory.Message, "Change_0_to_1_90014", "Change '{0}' to '{1}'"),
6170         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}\""),
6171         Declare_property_0: diag(90016, ts.DiagnosticCategory.Message, "Declare_property_0_90016", "Declare property '{0}'"),
6172         Add_index_signature_for_property_0: diag(90017, ts.DiagnosticCategory.Message, "Add_index_signature_for_property_0_90017", "Add index signature for property '{0}'"),
6173         Disable_checking_for_this_file: diag(90018, ts.DiagnosticCategory.Message, "Disable_checking_for_this_file_90018", "Disable checking for this file"),
6174         Ignore_this_error_message: diag(90019, ts.DiagnosticCategory.Message, "Ignore_this_error_message_90019", "Ignore this error message"),
6175         Initialize_property_0_in_the_constructor: diag(90020, ts.DiagnosticCategory.Message, "Initialize_property_0_in_the_constructor_90020", "Initialize property '{0}' in the constructor"),
6176         Initialize_static_property_0: diag(90021, ts.DiagnosticCategory.Message, "Initialize_static_property_0_90021", "Initialize static property '{0}'"),
6177         Change_spelling_to_0: diag(90022, ts.DiagnosticCategory.Message, "Change_spelling_to_0_90022", "Change spelling to '{0}'"),
6178         Declare_method_0: diag(90023, ts.DiagnosticCategory.Message, "Declare_method_0_90023", "Declare method '{0}'"),
6179         Declare_static_method_0: diag(90024, ts.DiagnosticCategory.Message, "Declare_static_method_0_90024", "Declare static method '{0}'"),
6180         Prefix_0_with_an_underscore: diag(90025, ts.DiagnosticCategory.Message, "Prefix_0_with_an_underscore_90025", "Prefix '{0}' with an underscore"),
6181         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}'"),
6182         Declare_static_property_0: diag(90027, ts.DiagnosticCategory.Message, "Declare_static_property_0_90027", "Declare static property '{0}'"),
6183         Call_decorator_expression: diag(90028, ts.DiagnosticCategory.Message, "Call_decorator_expression_90028", "Call decorator expression"),
6184         Add_async_modifier_to_containing_function: diag(90029, ts.DiagnosticCategory.Message, "Add_async_modifier_to_containing_function_90029", "Add async modifier to containing function"),
6185         Replace_infer_0_with_unknown: diag(90030, ts.DiagnosticCategory.Message, "Replace_infer_0_with_unknown_90030", "Replace 'infer {0}' with 'unknown'"),
6186         Replace_all_unused_infer_with_unknown: diag(90031, ts.DiagnosticCategory.Message, "Replace_all_unused_infer_with_unknown_90031", "Replace all unused 'infer' with 'unknown'"),
6187         Import_default_0_from_module_1: diag(90032, ts.DiagnosticCategory.Message, "Import_default_0_from_module_1_90032", "Import default '{0}' from module \"{1}\""),
6188         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}\""),
6189         Add_parameter_name: diag(90034, ts.DiagnosticCategory.Message, "Add_parameter_name_90034", "Add parameter name"),
6190         Declare_private_property_0: diag(90035, ts.DiagnosticCategory.Message, "Declare_private_property_0_90035", "Declare private property '{0}'"),
6191         Replace_0_with_Promise_1: diag(90036, ts.DiagnosticCategory.Message, "Replace_0_with_Promise_1_90036", "Replace '{0}' with 'Promise<{1}>'"),
6192         Fix_all_incorrect_return_type_of_an_async_functions: diag(90037, ts.DiagnosticCategory.Message, "Fix_all_incorrect_return_type_of_an_async_functions_90037", "Fix all incorrect return type of an async functions"),
6193         Declare_private_method_0: diag(90038, ts.DiagnosticCategory.Message, "Declare_private_method_0_90038", "Declare private method '{0}'"),
6194         Remove_unused_destructuring_declaration: diag(90039, ts.DiagnosticCategory.Message, "Remove_unused_destructuring_declaration_90039", "Remove unused destructuring declaration"),
6195         Remove_unused_declarations_for_Colon_0: diag(90041, ts.DiagnosticCategory.Message, "Remove_unused_declarations_for_Colon_0_90041", "Remove unused declarations for: '{0}'"),
6196         Declare_a_private_field_named_0: diag(90053, ts.DiagnosticCategory.Message, "Declare_a_private_field_named_0_90053", "Declare a private field named '{0}'."),
6197         Convert_function_to_an_ES2015_class: diag(95001, ts.DiagnosticCategory.Message, "Convert_function_to_an_ES2015_class_95001", "Convert function to an ES2015 class"),
6198         Convert_function_0_to_class: diag(95002, ts.DiagnosticCategory.Message, "Convert_function_0_to_class_95002", "Convert function '{0}' to class"),
6199         Convert_0_to_1_in_0: diag(95003, ts.DiagnosticCategory.Message, "Convert_0_to_1_in_0_95003", "Convert '{0}' to '{1} in {0}'"),
6200         Extract_to_0_in_1: diag(95004, ts.DiagnosticCategory.Message, "Extract_to_0_in_1_95004", "Extract to {0} in {1}"),
6201         Extract_function: diag(95005, ts.DiagnosticCategory.Message, "Extract_function_95005", "Extract function"),
6202         Extract_constant: diag(95006, ts.DiagnosticCategory.Message, "Extract_constant_95006", "Extract constant"),
6203         Extract_to_0_in_enclosing_scope: diag(95007, ts.DiagnosticCategory.Message, "Extract_to_0_in_enclosing_scope_95007", "Extract to {0} in enclosing scope"),
6204         Extract_to_0_in_1_scope: diag(95008, ts.DiagnosticCategory.Message, "Extract_to_0_in_1_scope_95008", "Extract to {0} in {1} scope"),
6205         Annotate_with_type_from_JSDoc: diag(95009, ts.DiagnosticCategory.Message, "Annotate_with_type_from_JSDoc_95009", "Annotate with type from JSDoc"),
6206         Annotate_with_types_from_JSDoc: diag(95010, ts.DiagnosticCategory.Message, "Annotate_with_types_from_JSDoc_95010", "Annotate with types from JSDoc"),
6207         Infer_type_of_0_from_usage: diag(95011, ts.DiagnosticCategory.Message, "Infer_type_of_0_from_usage_95011", "Infer type of '{0}' from usage"),
6208         Infer_parameter_types_from_usage: diag(95012, ts.DiagnosticCategory.Message, "Infer_parameter_types_from_usage_95012", "Infer parameter types from usage"),
6209         Convert_to_default_import: diag(95013, ts.DiagnosticCategory.Message, "Convert_to_default_import_95013", "Convert to default import"),
6210         Install_0: diag(95014, ts.DiagnosticCategory.Message, "Install_0_95014", "Install '{0}'"),
6211         Replace_import_with_0: diag(95015, ts.DiagnosticCategory.Message, "Replace_import_with_0_95015", "Replace import with '{0}'."),
6212         Use_synthetic_default_member: diag(95016, ts.DiagnosticCategory.Message, "Use_synthetic_default_member_95016", "Use synthetic 'default' member."),
6213         Convert_to_ES6_module: diag(95017, ts.DiagnosticCategory.Message, "Convert_to_ES6_module_95017", "Convert to ES6 module"),
6214         Add_undefined_type_to_property_0: diag(95018, ts.DiagnosticCategory.Message, "Add_undefined_type_to_property_0_95018", "Add 'undefined' type to property '{0}'"),
6215         Add_initializer_to_property_0: diag(95019, ts.DiagnosticCategory.Message, "Add_initializer_to_property_0_95019", "Add initializer to property '{0}'"),
6216         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}'"),
6217         Convert_all_type_literals_to_mapped_type: diag(95021, ts.DiagnosticCategory.Message, "Convert_all_type_literals_to_mapped_type_95021", "Convert all type literals to mapped type"),
6218         Add_all_missing_members: diag(95022, ts.DiagnosticCategory.Message, "Add_all_missing_members_95022", "Add all missing members"),
6219         Infer_all_types_from_usage: diag(95023, ts.DiagnosticCategory.Message, "Infer_all_types_from_usage_95023", "Infer all types from usage"),
6220         Delete_all_unused_declarations: diag(95024, ts.DiagnosticCategory.Message, "Delete_all_unused_declarations_95024", "Delete all unused declarations"),
6221         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"),
6222         Fix_all_detected_spelling_errors: diag(95026, ts.DiagnosticCategory.Message, "Fix_all_detected_spelling_errors_95026", "Fix all detected spelling errors"),
6223         Add_initializers_to_all_uninitialized_properties: diag(95027, ts.DiagnosticCategory.Message, "Add_initializers_to_all_uninitialized_properties_95027", "Add initializers to all uninitialized properties"),
6224         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"),
6225         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"),
6226         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"),
6227         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)"),
6228         Implement_all_unimplemented_interfaces: diag(95032, ts.DiagnosticCategory.Message, "Implement_all_unimplemented_interfaces_95032", "Implement all unimplemented interfaces"),
6229         Install_all_missing_types_packages: diag(95033, ts.DiagnosticCategory.Message, "Install_all_missing_types_packages_95033", "Install all missing types packages"),
6230         Rewrite_all_as_indexed_access_types: diag(95034, ts.DiagnosticCategory.Message, "Rewrite_all_as_indexed_access_types_95034", "Rewrite all as indexed access types"),
6231         Convert_all_to_default_imports: diag(95035, ts.DiagnosticCategory.Message, "Convert_all_to_default_imports_95035", "Convert all to default imports"),
6232         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"),
6233         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"),
6234         Change_all_extended_interfaces_to_implements: diag(95038, ts.DiagnosticCategory.Message, "Change_all_extended_interfaces_to_implements_95038", "Change all extended interfaces to 'implements'"),
6235         Add_all_missing_super_calls: diag(95039, ts.DiagnosticCategory.Message, "Add_all_missing_super_calls_95039", "Add all missing super calls"),
6236         Implement_all_inherited_abstract_classes: diag(95040, ts.DiagnosticCategory.Message, "Implement_all_inherited_abstract_classes_95040", "Implement all inherited abstract classes"),
6237         Add_all_missing_async_modifiers: diag(95041, ts.DiagnosticCategory.Message, "Add_all_missing_async_modifiers_95041", "Add all missing 'async' modifiers"),
6238         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"),
6239         Annotate_everything_with_types_from_JSDoc: diag(95043, ts.DiagnosticCategory.Message, "Annotate_everything_with_types_from_JSDoc_95043", "Annotate everything with types from JSDoc"),
6240         Add_to_all_uncalled_decorators: diag(95044, ts.DiagnosticCategory.Message, "Add_to_all_uncalled_decorators_95044", "Add '()' to all uncalled decorators"),
6241         Convert_all_constructor_functions_to_classes: diag(95045, ts.DiagnosticCategory.Message, "Convert_all_constructor_functions_to_classes_95045", "Convert all constructor functions to classes"),
6242         Generate_get_and_set_accessors: diag(95046, ts.DiagnosticCategory.Message, "Generate_get_and_set_accessors_95046", "Generate 'get' and 'set' accessors"),
6243         Convert_require_to_import: diag(95047, ts.DiagnosticCategory.Message, "Convert_require_to_import_95047", "Convert 'require' to 'import'"),
6244         Convert_all_require_to_import: diag(95048, ts.DiagnosticCategory.Message, "Convert_all_require_to_import_95048", "Convert all 'require' to 'import'"),
6245         Move_to_a_new_file: diag(95049, ts.DiagnosticCategory.Message, "Move_to_a_new_file_95049", "Move to a new file"),
6246         Remove_unreachable_code: diag(95050, ts.DiagnosticCategory.Message, "Remove_unreachable_code_95050", "Remove unreachable code"),
6247         Remove_all_unreachable_code: diag(95051, ts.DiagnosticCategory.Message, "Remove_all_unreachable_code_95051", "Remove all unreachable code"),
6248         Add_missing_typeof: diag(95052, ts.DiagnosticCategory.Message, "Add_missing_typeof_95052", "Add missing 'typeof'"),
6249         Remove_unused_label: diag(95053, ts.DiagnosticCategory.Message, "Remove_unused_label_95053", "Remove unused label"),
6250         Remove_all_unused_labels: diag(95054, ts.DiagnosticCategory.Message, "Remove_all_unused_labels_95054", "Remove all unused labels"),
6251         Convert_0_to_mapped_object_type: diag(95055, ts.DiagnosticCategory.Message, "Convert_0_to_mapped_object_type_95055", "Convert '{0}' to mapped object type"),
6252         Convert_namespace_import_to_named_imports: diag(95056, ts.DiagnosticCategory.Message, "Convert_namespace_import_to_named_imports_95056", "Convert namespace import to named imports"),
6253         Convert_named_imports_to_namespace_import: diag(95057, ts.DiagnosticCategory.Message, "Convert_named_imports_to_namespace_import_95057", "Convert named imports to namespace import"),
6254         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"),
6255         Add_braces_to_arrow_function: diag(95059, ts.DiagnosticCategory.Message, "Add_braces_to_arrow_function_95059", "Add braces to arrow function"),
6256         Remove_braces_from_arrow_function: diag(95060, ts.DiagnosticCategory.Message, "Remove_braces_from_arrow_function_95060", "Remove braces from arrow function"),
6257         Convert_default_export_to_named_export: diag(95061, ts.DiagnosticCategory.Message, "Convert_default_export_to_named_export_95061", "Convert default export to named export"),
6258         Convert_named_export_to_default_export: diag(95062, ts.DiagnosticCategory.Message, "Convert_named_export_to_default_export_95062", "Convert named export to default export"),
6259         Add_missing_enum_member_0: diag(95063, ts.DiagnosticCategory.Message, "Add_missing_enum_member_0_95063", "Add missing enum member '{0}'"),
6260         Add_all_missing_imports: diag(95064, ts.DiagnosticCategory.Message, "Add_all_missing_imports_95064", "Add all missing imports"),
6261         Convert_to_async_function: diag(95065, ts.DiagnosticCategory.Message, "Convert_to_async_function_95065", "Convert to async function"),
6262         Convert_all_to_async_functions: diag(95066, ts.DiagnosticCategory.Message, "Convert_all_to_async_functions_95066", "Convert all to async functions"),
6263         Add_missing_call_parentheses: diag(95067, ts.DiagnosticCategory.Message, "Add_missing_call_parentheses_95067", "Add missing call parentheses"),
6264         Add_all_missing_call_parentheses: diag(95068, ts.DiagnosticCategory.Message, "Add_all_missing_call_parentheses_95068", "Add all missing call parentheses"),
6265         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"),
6266         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"),
6267         Add_missing_new_operator_to_call: diag(95071, ts.DiagnosticCategory.Message, "Add_missing_new_operator_to_call_95071", "Add missing 'new' operator to call"),
6268         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"),
6269         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"),
6270         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"),
6271         Convert_parameters_to_destructured_object: diag(95075, ts.DiagnosticCategory.Message, "Convert_parameters_to_destructured_object_95075", "Convert parameters to destructured object"),
6272         Allow_accessing_UMD_globals_from_modules: diag(95076, ts.DiagnosticCategory.Message, "Allow_accessing_UMD_globals_from_modules_95076", "Allow accessing UMD globals from modules."),
6273         Extract_type: diag(95077, ts.DiagnosticCategory.Message, "Extract_type_95077", "Extract type"),
6274         Extract_to_type_alias: diag(95078, ts.DiagnosticCategory.Message, "Extract_to_type_alias_95078", "Extract to type alias"),
6275         Extract_to_typedef: diag(95079, ts.DiagnosticCategory.Message, "Extract_to_typedef_95079", "Extract to typedef"),
6276         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"),
6277         Add_const_to_unresolved_variable: diag(95081, ts.DiagnosticCategory.Message, "Add_const_to_unresolved_variable_95081", "Add 'const' to unresolved variable"),
6278         Add_const_to_all_unresolved_variables: diag(95082, ts.DiagnosticCategory.Message, "Add_const_to_all_unresolved_variables_95082", "Add 'const' to all unresolved variables"),
6279         Add_await: diag(95083, ts.DiagnosticCategory.Message, "Add_await_95083", "Add 'await'"),
6280         Add_await_to_initializer_for_0: diag(95084, ts.DiagnosticCategory.Message, "Add_await_to_initializer_for_0_95084", "Add 'await' to initializer for '{0}'"),
6281         Fix_all_expressions_possibly_missing_await: diag(95085, ts.DiagnosticCategory.Message, "Fix_all_expressions_possibly_missing_await_95085", "Fix all expressions possibly missing 'await'"),
6282         Remove_unnecessary_await: diag(95086, ts.DiagnosticCategory.Message, "Remove_unnecessary_await_95086", "Remove unnecessary 'await'"),
6283         Remove_all_unnecessary_uses_of_await: diag(95087, ts.DiagnosticCategory.Message, "Remove_all_unnecessary_uses_of_await_95087", "Remove all unnecessary uses of 'await'"),
6284         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"),
6285         Add_await_to_initializers: diag(95089, ts.DiagnosticCategory.Message, "Add_await_to_initializers_95089", "Add 'await' to initializers"),
6286         Extract_to_interface: diag(95090, ts.DiagnosticCategory.Message, "Extract_to_interface_95090", "Extract to interface"),
6287         Convert_to_a_bigint_numeric_literal: diag(95091, ts.DiagnosticCategory.Message, "Convert_to_a_bigint_numeric_literal_95091", "Convert to a bigint numeric literal"),
6288         Convert_all_to_bigint_numeric_literals: diag(95092, ts.DiagnosticCategory.Message, "Convert_all_to_bigint_numeric_literals_95092", "Convert all to bigint numeric literals"),
6289         Convert_const_to_let: diag(95093, ts.DiagnosticCategory.Message, "Convert_const_to_let_95093", "Convert 'const' to 'let'"),
6290         Prefix_with_declare: diag(95094, ts.DiagnosticCategory.Message, "Prefix_with_declare_95094", "Prefix with 'declare'"),
6291         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'"),
6292         Convert_to_template_string: diag(95096, ts.DiagnosticCategory.Message, "Convert_to_template_string_95096", "Convert to template string"),
6293         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"),
6294         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}'"),
6295         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}'"),
6296         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"),
6297         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"),
6298         Add_class_tag: diag(95102, ts.DiagnosticCategory.Message, "Add_class_tag_95102", "Add '@class' tag"),
6299         Add_this_tag: diag(95103, ts.DiagnosticCategory.Message, "Add_this_tag_95103", "Add '@this' tag"),
6300         Add_this_parameter: diag(95104, ts.DiagnosticCategory.Message, "Add_this_parameter_95104", "Add 'this' parameter."),
6301         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"),
6302         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"),
6303         Fix_all_implicit_this_errors: diag(95107, ts.DiagnosticCategory.Message, "Fix_all_implicit_this_errors_95107", "Fix all implicit-'this' errors"),
6304         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"),
6305         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"),
6306         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"),
6307         Add_a_return_statement: diag(95111, ts.DiagnosticCategory.Message, "Add_a_return_statement_95111", "Add a return statement"),
6308         Remove_braces_from_arrow_function_body: diag(95112, ts.DiagnosticCategory.Message, "Remove_braces_from_arrow_function_body_95112", "Remove braces from arrow function body"),
6309         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"),
6310         Add_all_missing_return_statement: diag(95114, ts.DiagnosticCategory.Message, "Add_all_missing_return_statement_95114", "Add all missing return statement"),
6311         Remove_braces_from_all_arrow_function_bodies_with_relevant_issues: diag(95115, ts.DiagnosticCategory.Message, "Remove_braces_from_all_arrow_function_bodies_with_relevant_issues_95115", "Remove braces from all arrow function bodies with relevant issues"),
6312         Wrap_all_object_literal_with_parentheses: diag(95116, ts.DiagnosticCategory.Message, "Wrap_all_object_literal_with_parentheses_95116", "Wrap all object literal with parentheses"),
6313         Move_labeled_tuple_element_modifiers_to_labels: diag(95117, ts.DiagnosticCategory.Message, "Move_labeled_tuple_element_modifiers_to_labels_95117", "Move labeled tuple element modifiers to labels"),
6314         Convert_overload_list_to_single_signature: diag(95118, ts.DiagnosticCategory.Message, "Convert_overload_list_to_single_signature_95118", "Convert overload list to single signature"),
6315         Generate_get_and_set_accessors_for_all_overriding_properties: diag(95119, ts.DiagnosticCategory.Message, "Generate_get_and_set_accessors_for_all_overriding_properties_95119", "Generate 'get' and 'set' accessors for all overriding properties"),
6316         Wrap_in_JSX_fragment: diag(95120, ts.DiagnosticCategory.Message, "Wrap_in_JSX_fragment_95120", "Wrap in JSX fragment"),
6317         Wrap_all_unparented_JSX_in_JSX_fragment: diag(95121, ts.DiagnosticCategory.Message, "Wrap_all_unparented_JSX_in_JSX_fragment_95121", "Wrap all unparented JSX in JSX fragment"),
6318         Convert_arrow_function_or_function_expression: diag(95122, ts.DiagnosticCategory.Message, "Convert_arrow_function_or_function_expression_95122", "Convert arrow function or function expression"),
6319         Convert_to_anonymous_function: diag(95123, ts.DiagnosticCategory.Message, "Convert_to_anonymous_function_95123", "Convert to anonymous function"),
6320         Convert_to_named_function: diag(95124, ts.DiagnosticCategory.Message, "Convert_to_named_function_95124", "Convert to named function"),
6321         Convert_to_arrow_function: diag(95125, ts.DiagnosticCategory.Message, "Convert_to_arrow_function_95125", "Convert to arrow function"),
6322         Remove_parentheses: diag(95126, ts.DiagnosticCategory.Message, "Remove_parentheses_95126", "Remove parentheses"),
6323         Could_not_find_a_containing_arrow_function: diag(95127, ts.DiagnosticCategory.Message, "Could_not_find_a_containing_arrow_function_95127", "Could not find a containing arrow function"),
6324         Containing_function_is_not_an_arrow_function: diag(95128, ts.DiagnosticCategory.Message, "Containing_function_is_not_an_arrow_function_95128", "Containing function is not an arrow function"),
6325         Could_not_find_export_statement: diag(95129, ts.DiagnosticCategory.Message, "Could_not_find_export_statement_95129", "Could not find export statement"),
6326         This_file_already_has_a_default_export: diag(95130, ts.DiagnosticCategory.Message, "This_file_already_has_a_default_export_95130", "This file already has a default export"),
6327         Could_not_find_import_clause: diag(95131, ts.DiagnosticCategory.Message, "Could_not_find_import_clause_95131", "Could not find import clause"),
6328         Could_not_find_namespace_import_or_named_imports: diag(95132, ts.DiagnosticCategory.Message, "Could_not_find_namespace_import_or_named_imports_95132", "Could not find namespace import or named imports"),
6329         Selection_is_not_a_valid_type_node: diag(95133, ts.DiagnosticCategory.Message, "Selection_is_not_a_valid_type_node_95133", "Selection is not a valid type node"),
6330         No_type_could_be_extracted_from_this_type_node: diag(95134, ts.DiagnosticCategory.Message, "No_type_could_be_extracted_from_this_type_node_95134", "No type could be extracted from this type node"),
6331         Could_not_find_property_for_which_to_generate_accessor: diag(95135, ts.DiagnosticCategory.Message, "Could_not_find_property_for_which_to_generate_accessor_95135", "Could not find property for which to generate accessor"),
6332         Name_is_not_valid: diag(95136, ts.DiagnosticCategory.Message, "Name_is_not_valid_95136", "Name is not valid"),
6333         Can_only_convert_property_with_modifier: diag(95137, ts.DiagnosticCategory.Message, "Can_only_convert_property_with_modifier_95137", "Can only convert property with modifier"),
6334         Switch_each_misused_0_to_1: diag(95138, ts.DiagnosticCategory.Message, "Switch_each_misused_0_to_1_95138", "Switch each misused '{0}' to '{1}'"),
6335         Convert_to_optional_chain_expression: diag(95139, ts.DiagnosticCategory.Message, "Convert_to_optional_chain_expression_95139", "Convert to optional chain expression"),
6336         Could_not_find_convertible_access_expression: diag(95140, ts.DiagnosticCategory.Message, "Could_not_find_convertible_access_expression_95140", "Could not find convertible access expression"),
6337         Could_not_find_matching_access_expressions: diag(95141, ts.DiagnosticCategory.Message, "Could_not_find_matching_access_expressions_95141", "Could not find matching access expressions"),
6338         Can_only_convert_logical_AND_access_chains: diag(95142, ts.DiagnosticCategory.Message, "Can_only_convert_logical_AND_access_chains_95142", "Can only convert logical AND access chains"),
6339         Add_void_to_Promise_resolved_without_a_value: diag(95143, ts.DiagnosticCategory.Message, "Add_void_to_Promise_resolved_without_a_value_95143", "Add 'void' to Promise resolved without a value"),
6340         Add_void_to_all_Promises_resolved_without_a_value: diag(95144, ts.DiagnosticCategory.Message, "Add_void_to_all_Promises_resolved_without_a_value_95144", "Add 'void' to all Promises resolved without a value"),
6341         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."),
6342         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'."),
6343         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?"),
6344         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."),
6345         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."),
6346         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."),
6347         constructor_is_a_reserved_word: diag(18012, ts.DiagnosticCategory.Error, "constructor_is_a_reserved_word_18012", "'#constructor' is a reserved word."),
6348         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."),
6349         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."),
6350         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}'."),
6351         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."),
6352         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"),
6353         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"),
6354         _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."),
6355         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."),
6356         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."),
6357         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."),
6358         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."),
6359         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."),
6360         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."),
6361         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."),
6362         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."),
6363         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."),
6364         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."),
6365         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."),
6366         Specify_the_JSX_fragment_factory_function_to_use_when_targeting_react_JSX_emit_with_jsxFactory_compiler_option_is_specified_e_g_Fragment: diag(18034, ts.DiagnosticCategory.Message, "Specify_the_JSX_fragment_factory_function_to_use_when_targeting_react_JSX_emit_with_jsxFactory_compi_18034", "Specify the JSX fragment factory function to use when targeting 'react' JSX emit with 'jsxFactory' compiler option is specified, e.g. 'Fragment'."),
6367         Invalid_value_for_jsxFragmentFactory_0_is_not_a_valid_identifier_or_qualified_name: diag(18035, ts.DiagnosticCategory.Error, "Invalid_value_for_jsxFragmentFactory_0_is_not_a_valid_identifier_or_qualified_name_18035", "Invalid value for 'jsxFragmentFactory'. '{0}' is not a valid identifier or qualified-name."),
6368     };
6369 })(ts || (ts = {}));
6370 var ts;
6371 (function (ts) {
6372     var _a;
6373     function tokenIsIdentifierOrKeyword(token) {
6374         return token >= 78;
6375     }
6376     ts.tokenIsIdentifierOrKeyword = tokenIsIdentifierOrKeyword;
6377     function tokenIsIdentifierOrKeywordOrGreaterThan(token) {
6378         return token === 31 || tokenIsIdentifierOrKeyword(token);
6379     }
6380     ts.tokenIsIdentifierOrKeywordOrGreaterThan = tokenIsIdentifierOrKeywordOrGreaterThan;
6381     var textToKeywordObj = (_a = {
6382             abstract: 125,
6383             any: 128,
6384             as: 126,
6385             asserts: 127,
6386             bigint: 155,
6387             boolean: 131,
6388             break: 80,
6389             case: 81,
6390             catch: 82,
6391             class: 83,
6392             continue: 85,
6393             const: 84
6394         },
6395         _a["" + "constructor"] = 132,
6396         _a.debugger = 86,
6397         _a.declare = 133,
6398         _a.default = 87,
6399         _a.delete = 88,
6400         _a.do = 89,
6401         _a.else = 90,
6402         _a.enum = 91,
6403         _a.export = 92,
6404         _a.extends = 93,
6405         _a.false = 94,
6406         _a.finally = 95,
6407         _a.for = 96,
6408         _a.from = 153,
6409         _a.function = 97,
6410         _a.get = 134,
6411         _a.if = 98,
6412         _a.implements = 116,
6413         _a.import = 99,
6414         _a.in = 100,
6415         _a.infer = 135,
6416         _a.instanceof = 101,
6417         _a.interface = 117,
6418         _a.intrinsic = 136,
6419         _a.is = 137,
6420         _a.keyof = 138,
6421         _a.let = 118,
6422         _a.module = 139,
6423         _a.namespace = 140,
6424         _a.never = 141,
6425         _a.new = 102,
6426         _a.null = 103,
6427         _a.number = 144,
6428         _a.object = 145,
6429         _a.package = 119,
6430         _a.private = 120,
6431         _a.protected = 121,
6432         _a.public = 122,
6433         _a.readonly = 142,
6434         _a.require = 143,
6435         _a.global = 154,
6436         _a.return = 104,
6437         _a.set = 146,
6438         _a.static = 123,
6439         _a.string = 147,
6440         _a.super = 105,
6441         _a.switch = 106,
6442         _a.symbol = 148,
6443         _a.this = 107,
6444         _a.throw = 108,
6445         _a.true = 109,
6446         _a.try = 110,
6447         _a.type = 149,
6448         _a.typeof = 111,
6449         _a.undefined = 150,
6450         _a.unique = 151,
6451         _a.unknown = 152,
6452         _a.var = 112,
6453         _a.void = 113,
6454         _a.while = 114,
6455         _a.with = 115,
6456         _a.yield = 124,
6457         _a.async = 129,
6458         _a.await = 130,
6459         _a.of = 156,
6460         _a);
6461     var textToKeyword = new ts.Map(ts.getEntries(textToKeywordObj));
6462     var textToToken = new ts.Map(ts.getEntries(__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, "^=": 77, "||=": 74, "&&=": 75, "??=": 76, "@": 59, "`": 61 })));
6463     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,];
6464     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,];
6465     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,];
6466     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,];
6467     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];
6468     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];
6469     var commentDirectiveRegExSingleLine = /^\s*\/\/\/?\s*@(ts-expect-error|ts-ignore)/;
6470     var commentDirectiveRegExMultiLine = /^\s*(?:\/|\*)*\s*@(ts-expect-error|ts-ignore)/;
6471     function lookupInUnicodeMap(code, map) {
6472         if (code < map[0]) {
6473             return false;
6474         }
6475         var lo = 0;
6476         var hi = map.length;
6477         var mid;
6478         while (lo + 1 < hi) {
6479             mid = lo + (hi - lo) / 2;
6480             mid -= mid % 2;
6481             if (map[mid] <= code && code <= map[mid + 1]) {
6482                 return true;
6483             }
6484             if (code < map[mid]) {
6485                 hi = mid;
6486             }
6487             else {
6488                 lo = mid + 2;
6489             }
6490         }
6491         return false;
6492     }
6493     function isUnicodeIdentifierStart(code, languageVersion) {
6494         return languageVersion >= 2 ?
6495             lookupInUnicodeMap(code, unicodeESNextIdentifierStart) :
6496             languageVersion === 1 ? lookupInUnicodeMap(code, unicodeES5IdentifierStart) :
6497                 lookupInUnicodeMap(code, unicodeES3IdentifierStart);
6498     }
6499     ts.isUnicodeIdentifierStart = isUnicodeIdentifierStart;
6500     function isUnicodeIdentifierPart(code, languageVersion) {
6501         return languageVersion >= 2 ?
6502             lookupInUnicodeMap(code, unicodeESNextIdentifierPart) :
6503             languageVersion === 1 ? lookupInUnicodeMap(code, unicodeES5IdentifierPart) :
6504                 lookupInUnicodeMap(code, unicodeES3IdentifierPart);
6505     }
6506     function makeReverseMap(source) {
6507         var result = [];
6508         source.forEach(function (value, name) {
6509             result[value] = name;
6510         });
6511         return result;
6512     }
6513     var tokenStrings = makeReverseMap(textToToken);
6514     function tokenToString(t) {
6515         return tokenStrings[t];
6516     }
6517     ts.tokenToString = tokenToString;
6518     function stringToToken(s) {
6519         return textToToken.get(s);
6520     }
6521     ts.stringToToken = stringToToken;
6522     function computeLineStarts(text) {
6523         var result = new Array();
6524         var pos = 0;
6525         var lineStart = 0;
6526         while (pos < text.length) {
6527             var ch = text.charCodeAt(pos);
6528             pos++;
6529             switch (ch) {
6530                 case 13:
6531                     if (text.charCodeAt(pos) === 10) {
6532                         pos++;
6533                     }
6534                 case 10:
6535                     result.push(lineStart);
6536                     lineStart = pos;
6537                     break;
6538                 default:
6539                     if (ch > 127 && isLineBreak(ch)) {
6540                         result.push(lineStart);
6541                         lineStart = pos;
6542                     }
6543                     break;
6544             }
6545         }
6546         result.push(lineStart);
6547         return result;
6548     }
6549     ts.computeLineStarts = computeLineStarts;
6550     function getPositionOfLineAndCharacter(sourceFile, line, character, allowEdits) {
6551         return sourceFile.getPositionOfLineAndCharacter ?
6552             sourceFile.getPositionOfLineAndCharacter(line, character, allowEdits) :
6553             computePositionOfLineAndCharacter(getLineStarts(sourceFile), line, character, sourceFile.text, allowEdits);
6554     }
6555     ts.getPositionOfLineAndCharacter = getPositionOfLineAndCharacter;
6556     function computePositionOfLineAndCharacter(lineStarts, line, character, debugText, allowEdits) {
6557         if (line < 0 || line >= lineStarts.length) {
6558             if (allowEdits) {
6559                 line = line < 0 ? 0 : line >= lineStarts.length ? lineStarts.length - 1 : line;
6560             }
6561             else {
6562                 ts.Debug.fail("Bad line number. Line: " + line + ", lineStarts.length: " + lineStarts.length + " , line map is correct? " + (debugText !== undefined ? ts.arraysEqual(lineStarts, computeLineStarts(debugText)) : "unknown"));
6563             }
6564         }
6565         var res = lineStarts[line] + character;
6566         if (allowEdits) {
6567             return res > lineStarts[line + 1] ? lineStarts[line + 1] : typeof debugText === "string" && res > debugText.length ? debugText.length : res;
6568         }
6569         if (line < lineStarts.length - 1) {
6570             ts.Debug.assert(res < lineStarts[line + 1]);
6571         }
6572         else if (debugText !== undefined) {
6573             ts.Debug.assert(res <= debugText.length);
6574         }
6575         return res;
6576     }
6577     ts.computePositionOfLineAndCharacter = computePositionOfLineAndCharacter;
6578     function getLineStarts(sourceFile) {
6579         return sourceFile.lineMap || (sourceFile.lineMap = computeLineStarts(sourceFile.text));
6580     }
6581     ts.getLineStarts = getLineStarts;
6582     function computeLineAndCharacterOfPosition(lineStarts, position) {
6583         var lineNumber = computeLineOfPosition(lineStarts, position);
6584         return {
6585             line: lineNumber,
6586             character: position - lineStarts[lineNumber]
6587         };
6588     }
6589     ts.computeLineAndCharacterOfPosition = computeLineAndCharacterOfPosition;
6590     function computeLineOfPosition(lineStarts, position, lowerBound) {
6591         var lineNumber = ts.binarySearch(lineStarts, position, ts.identity, ts.compareValues, lowerBound);
6592         if (lineNumber < 0) {
6593             lineNumber = ~lineNumber - 1;
6594             ts.Debug.assert(lineNumber !== -1, "position cannot precede the beginning of the file");
6595         }
6596         return lineNumber;
6597     }
6598     ts.computeLineOfPosition = computeLineOfPosition;
6599     function getLinesBetweenPositions(sourceFile, pos1, pos2) {
6600         if (pos1 === pos2)
6601             return 0;
6602         var lineStarts = getLineStarts(sourceFile);
6603         var lower = Math.min(pos1, pos2);
6604         var isNegative = lower === pos2;
6605         var upper = isNegative ? pos1 : pos2;
6606         var lowerLine = computeLineOfPosition(lineStarts, lower);
6607         var upperLine = computeLineOfPosition(lineStarts, upper, lowerLine);
6608         return isNegative ? lowerLine - upperLine : upperLine - lowerLine;
6609     }
6610     ts.getLinesBetweenPositions = getLinesBetweenPositions;
6611     function getLineAndCharacterOfPosition(sourceFile, position) {
6612         return computeLineAndCharacterOfPosition(getLineStarts(sourceFile), position);
6613     }
6614     ts.getLineAndCharacterOfPosition = getLineAndCharacterOfPosition;
6615     function isWhiteSpaceLike(ch) {
6616         return isWhiteSpaceSingleLine(ch) || isLineBreak(ch);
6617     }
6618     ts.isWhiteSpaceLike = isWhiteSpaceLike;
6619     function isWhiteSpaceSingleLine(ch) {
6620         return ch === 32 ||
6621             ch === 9 ||
6622             ch === 11 ||
6623             ch === 12 ||
6624             ch === 160 ||
6625             ch === 133 ||
6626             ch === 5760 ||
6627             ch >= 8192 && ch <= 8203 ||
6628             ch === 8239 ||
6629             ch === 8287 ||
6630             ch === 12288 ||
6631             ch === 65279;
6632     }
6633     ts.isWhiteSpaceSingleLine = isWhiteSpaceSingleLine;
6634     function isLineBreak(ch) {
6635         return ch === 10 ||
6636             ch === 13 ||
6637             ch === 8232 ||
6638             ch === 8233;
6639     }
6640     ts.isLineBreak = isLineBreak;
6641     function isDigit(ch) {
6642         return ch >= 48 && ch <= 57;
6643     }
6644     function isHexDigit(ch) {
6645         return isDigit(ch) || ch >= 65 && ch <= 70 || ch >= 97 && ch <= 102;
6646     }
6647     function isCodePoint(code) {
6648         return code <= 0x10FFFF;
6649     }
6650     function isOctalDigit(ch) {
6651         return ch >= 48 && ch <= 55;
6652     }
6653     ts.isOctalDigit = isOctalDigit;
6654     function couldStartTrivia(text, pos) {
6655         var ch = text.charCodeAt(pos);
6656         switch (ch) {
6657             case 13:
6658             case 10:
6659             case 9:
6660             case 11:
6661             case 12:
6662             case 32:
6663             case 47:
6664             case 60:
6665             case 124:
6666             case 61:
6667             case 62:
6668                 return true;
6669             case 35:
6670                 return pos === 0;
6671             default:
6672                 return ch > 127;
6673         }
6674     }
6675     ts.couldStartTrivia = couldStartTrivia;
6676     function skipTrivia(text, pos, stopAfterLineBreak, stopAtComments) {
6677         if (stopAtComments === void 0) { stopAtComments = false; }
6678         if (ts.positionIsSynthesized(pos)) {
6679             return pos;
6680         }
6681         while (true) {
6682             var ch = text.charCodeAt(pos);
6683             switch (ch) {
6684                 case 13:
6685                     if (text.charCodeAt(pos + 1) === 10) {
6686                         pos++;
6687                     }
6688                 case 10:
6689                     pos++;
6690                     if (stopAfterLineBreak) {
6691                         return pos;
6692                     }
6693                     continue;
6694                 case 9:
6695                 case 11:
6696                 case 12:
6697                 case 32:
6698                     pos++;
6699                     continue;
6700                 case 47:
6701                     if (stopAtComments) {
6702                         break;
6703                     }
6704                     if (text.charCodeAt(pos + 1) === 47) {
6705                         pos += 2;
6706                         while (pos < text.length) {
6707                             if (isLineBreak(text.charCodeAt(pos))) {
6708                                 break;
6709                             }
6710                             pos++;
6711                         }
6712                         continue;
6713                     }
6714                     if (text.charCodeAt(pos + 1) === 42) {
6715                         pos += 2;
6716                         while (pos < text.length) {
6717                             if (text.charCodeAt(pos) === 42 && text.charCodeAt(pos + 1) === 47) {
6718                                 pos += 2;
6719                                 break;
6720                             }
6721                             pos++;
6722                         }
6723                         continue;
6724                     }
6725                     break;
6726                 case 60:
6727                 case 124:
6728                 case 61:
6729                 case 62:
6730                     if (isConflictMarkerTrivia(text, pos)) {
6731                         pos = scanConflictMarkerTrivia(text, pos);
6732                         continue;
6733                     }
6734                     break;
6735                 case 35:
6736                     if (pos === 0 && isShebangTrivia(text, pos)) {
6737                         pos = scanShebangTrivia(text, pos);
6738                         continue;
6739                     }
6740                     break;
6741                 default:
6742                     if (ch > 127 && (isWhiteSpaceLike(ch))) {
6743                         pos++;
6744                         continue;
6745                     }
6746                     break;
6747             }
6748             return pos;
6749         }
6750     }
6751     ts.skipTrivia = skipTrivia;
6752     var mergeConflictMarkerLength = "<<<<<<<".length;
6753     function isConflictMarkerTrivia(text, pos) {
6754         ts.Debug.assert(pos >= 0);
6755         if (pos === 0 || isLineBreak(text.charCodeAt(pos - 1))) {
6756             var ch = text.charCodeAt(pos);
6757             if ((pos + mergeConflictMarkerLength) < text.length) {
6758                 for (var i = 0; i < mergeConflictMarkerLength; i++) {
6759                     if (text.charCodeAt(pos + i) !== ch) {
6760                         return false;
6761                     }
6762                 }
6763                 return ch === 61 ||
6764                     text.charCodeAt(pos + mergeConflictMarkerLength) === 32;
6765             }
6766         }
6767         return false;
6768     }
6769     function scanConflictMarkerTrivia(text, pos, error) {
6770         if (error) {
6771             error(ts.Diagnostics.Merge_conflict_marker_encountered, pos, mergeConflictMarkerLength);
6772         }
6773         var ch = text.charCodeAt(pos);
6774         var len = text.length;
6775         if (ch === 60 || ch === 62) {
6776             while (pos < len && !isLineBreak(text.charCodeAt(pos))) {
6777                 pos++;
6778             }
6779         }
6780         else {
6781             ts.Debug.assert(ch === 124 || ch === 61);
6782             while (pos < len) {
6783                 var currentChar = text.charCodeAt(pos);
6784                 if ((currentChar === 61 || currentChar === 62) && currentChar !== ch && isConflictMarkerTrivia(text, pos)) {
6785                     break;
6786                 }
6787                 pos++;
6788             }
6789         }
6790         return pos;
6791     }
6792     var shebangTriviaRegex = /^#!.*/;
6793     function isShebangTrivia(text, pos) {
6794         ts.Debug.assert(pos === 0);
6795         return shebangTriviaRegex.test(text);
6796     }
6797     ts.isShebangTrivia = isShebangTrivia;
6798     function scanShebangTrivia(text, pos) {
6799         var shebang = shebangTriviaRegex.exec(text)[0];
6800         pos = pos + shebang.length;
6801         return pos;
6802     }
6803     ts.scanShebangTrivia = scanShebangTrivia;
6804     function iterateCommentRanges(reduce, text, pos, trailing, cb, state, initial) {
6805         var pendingPos;
6806         var pendingEnd;
6807         var pendingKind;
6808         var pendingHasTrailingNewLine;
6809         var hasPendingCommentRange = false;
6810         var collecting = trailing;
6811         var accumulator = initial;
6812         if (pos === 0) {
6813             collecting = true;
6814             var shebang = getShebang(text);
6815             if (shebang) {
6816                 pos = shebang.length;
6817             }
6818         }
6819         scan: while (pos >= 0 && pos < text.length) {
6820             var ch = text.charCodeAt(pos);
6821             switch (ch) {
6822                 case 13:
6823                     if (text.charCodeAt(pos + 1) === 10) {
6824                         pos++;
6825                     }
6826                 case 10:
6827                     pos++;
6828                     if (trailing) {
6829                         break scan;
6830                     }
6831                     collecting = true;
6832                     if (hasPendingCommentRange) {
6833                         pendingHasTrailingNewLine = true;
6834                     }
6835                     continue;
6836                 case 9:
6837                 case 11:
6838                 case 12:
6839                 case 32:
6840                     pos++;
6841                     continue;
6842                 case 47:
6843                     var nextChar = text.charCodeAt(pos + 1);
6844                     var hasTrailingNewLine = false;
6845                     if (nextChar === 47 || nextChar === 42) {
6846                         var kind = nextChar === 47 ? 2 : 3;
6847                         var startPos = pos;
6848                         pos += 2;
6849                         if (nextChar === 47) {
6850                             while (pos < text.length) {
6851                                 if (isLineBreak(text.charCodeAt(pos))) {
6852                                     hasTrailingNewLine = true;
6853                                     break;
6854                                 }
6855                                 pos++;
6856                             }
6857                         }
6858                         else {
6859                             while (pos < text.length) {
6860                                 if (text.charCodeAt(pos) === 42 && text.charCodeAt(pos + 1) === 47) {
6861                                     pos += 2;
6862                                     break;
6863                                 }
6864                                 pos++;
6865                             }
6866                         }
6867                         if (collecting) {
6868                             if (hasPendingCommentRange) {
6869                                 accumulator = cb(pendingPos, pendingEnd, pendingKind, pendingHasTrailingNewLine, state, accumulator);
6870                                 if (!reduce && accumulator) {
6871                                     return accumulator;
6872                                 }
6873                             }
6874                             pendingPos = startPos;
6875                             pendingEnd = pos;
6876                             pendingKind = kind;
6877                             pendingHasTrailingNewLine = hasTrailingNewLine;
6878                             hasPendingCommentRange = true;
6879                         }
6880                         continue;
6881                     }
6882                     break scan;
6883                 default:
6884                     if (ch > 127 && (isWhiteSpaceLike(ch))) {
6885                         if (hasPendingCommentRange && isLineBreak(ch)) {
6886                             pendingHasTrailingNewLine = true;
6887                         }
6888                         pos++;
6889                         continue;
6890                     }
6891                     break scan;
6892             }
6893         }
6894         if (hasPendingCommentRange) {
6895             accumulator = cb(pendingPos, pendingEnd, pendingKind, pendingHasTrailingNewLine, state, accumulator);
6896         }
6897         return accumulator;
6898     }
6899     function forEachLeadingCommentRange(text, pos, cb, state) {
6900         return iterateCommentRanges(false, text, pos, false, cb, state);
6901     }
6902     ts.forEachLeadingCommentRange = forEachLeadingCommentRange;
6903     function forEachTrailingCommentRange(text, pos, cb, state) {
6904         return iterateCommentRanges(false, text, pos, true, cb, state);
6905     }
6906     ts.forEachTrailingCommentRange = forEachTrailingCommentRange;
6907     function reduceEachLeadingCommentRange(text, pos, cb, state, initial) {
6908         return iterateCommentRanges(true, text, pos, false, cb, state, initial);
6909     }
6910     ts.reduceEachLeadingCommentRange = reduceEachLeadingCommentRange;
6911     function reduceEachTrailingCommentRange(text, pos, cb, state, initial) {
6912         return iterateCommentRanges(true, text, pos, true, cb, state, initial);
6913     }
6914     ts.reduceEachTrailingCommentRange = reduceEachTrailingCommentRange;
6915     function appendCommentRange(pos, end, kind, hasTrailingNewLine, _state, comments) {
6916         if (!comments) {
6917             comments = [];
6918         }
6919         comments.push({ kind: kind, pos: pos, end: end, hasTrailingNewLine: hasTrailingNewLine });
6920         return comments;
6921     }
6922     function getLeadingCommentRanges(text, pos) {
6923         return reduceEachLeadingCommentRange(text, pos, appendCommentRange, undefined, undefined);
6924     }
6925     ts.getLeadingCommentRanges = getLeadingCommentRanges;
6926     function getTrailingCommentRanges(text, pos) {
6927         return reduceEachTrailingCommentRange(text, pos, appendCommentRange, undefined, undefined);
6928     }
6929     ts.getTrailingCommentRanges = getTrailingCommentRanges;
6930     function getShebang(text) {
6931         var match = shebangTriviaRegex.exec(text);
6932         if (match) {
6933             return match[0];
6934         }
6935     }
6936     ts.getShebang = getShebang;
6937     function isIdentifierStart(ch, languageVersion) {
6938         return ch >= 65 && ch <= 90 || ch >= 97 && ch <= 122 ||
6939             ch === 36 || ch === 95 ||
6940             ch > 127 && isUnicodeIdentifierStart(ch, languageVersion);
6941     }
6942     ts.isIdentifierStart = isIdentifierStart;
6943     function isIdentifierPart(ch, languageVersion, identifierVariant) {
6944         return ch >= 65 && ch <= 90 || ch >= 97 && ch <= 122 ||
6945             ch >= 48 && ch <= 57 || ch === 36 || ch === 95 ||
6946             (identifierVariant === 1 ? (ch === 45 || ch === 58) : false) ||
6947             ch > 127 && isUnicodeIdentifierPart(ch, languageVersion);
6948     }
6949     ts.isIdentifierPart = isIdentifierPart;
6950     function isIdentifierText(name, languageVersion, identifierVariant) {
6951         var ch = codePointAt(name, 0);
6952         if (!isIdentifierStart(ch, languageVersion)) {
6953             return false;
6954         }
6955         for (var i = charSize(ch); i < name.length; i += charSize(ch)) {
6956             if (!isIdentifierPart(ch = codePointAt(name, i), languageVersion, identifierVariant)) {
6957                 return false;
6958             }
6959         }
6960         return true;
6961     }
6962     ts.isIdentifierText = isIdentifierText;
6963     function createScanner(languageVersion, skipTrivia, languageVariant, textInitial, onError, start, length) {
6964         if (languageVariant === void 0) { languageVariant = 0; }
6965         var text = textInitial;
6966         var pos;
6967         var end;
6968         var startPos;
6969         var tokenPos;
6970         var token;
6971         var tokenValue;
6972         var tokenFlags;
6973         var commentDirectives;
6974         var inJSDocType = 0;
6975         setText(text, start, length);
6976         var scanner = {
6977             getStartPos: function () { return startPos; },
6978             getTextPos: function () { return pos; },
6979             getToken: function () { return token; },
6980             getTokenPos: function () { return tokenPos; },
6981             getTokenText: function () { return text.substring(tokenPos, pos); },
6982             getTokenValue: function () { return tokenValue; },
6983             hasUnicodeEscape: function () { return (tokenFlags & 1024) !== 0; },
6984             hasExtendedUnicodeEscape: function () { return (tokenFlags & 8) !== 0; },
6985             hasPrecedingLineBreak: function () { return (tokenFlags & 1) !== 0; },
6986             hasPrecedingJSDocComment: function () { return (tokenFlags & 2) !== 0; },
6987             isIdentifier: function () { return token === 78 || token > 115; },
6988             isReservedWord: function () { return token >= 80 && token <= 115; },
6989             isUnterminated: function () { return (tokenFlags & 4) !== 0; },
6990             getCommentDirectives: function () { return commentDirectives; },
6991             getNumericLiteralFlags: function () { return tokenFlags & 1008; },
6992             getTokenFlags: function () { return tokenFlags; },
6993             reScanGreaterToken: reScanGreaterToken,
6994             reScanAsteriskEqualsToken: reScanAsteriskEqualsToken,
6995             reScanSlashToken: reScanSlashToken,
6996             reScanTemplateToken: reScanTemplateToken,
6997             reScanTemplateHeadOrNoSubstitutionTemplate: reScanTemplateHeadOrNoSubstitutionTemplate,
6998             scanJsxIdentifier: scanJsxIdentifier,
6999             scanJsxAttributeValue: scanJsxAttributeValue,
7000             reScanJsxAttributeValue: reScanJsxAttributeValue,
7001             reScanJsxToken: reScanJsxToken,
7002             reScanLessThanToken: reScanLessThanToken,
7003             reScanQuestionToken: reScanQuestionToken,
7004             scanJsxToken: scanJsxToken,
7005             scanJsDocToken: scanJsDocToken,
7006             scan: scan,
7007             getText: getText,
7008             clearCommentDirectives: clearCommentDirectives,
7009             setText: setText,
7010             setScriptTarget: setScriptTarget,
7011             setLanguageVariant: setLanguageVariant,
7012             setOnError: setOnError,
7013             setTextPos: setTextPos,
7014             setInJSDocType: setInJSDocType,
7015             tryScan: tryScan,
7016             lookAhead: lookAhead,
7017             scanRange: scanRange,
7018         };
7019         if (ts.Debug.isDebugging) {
7020             Object.defineProperty(scanner, "__debugShowCurrentPositionInText", {
7021                 get: function () {
7022                     var text = scanner.getText();
7023                     return text.slice(0, scanner.getStartPos()) + "â•‘" + text.slice(scanner.getStartPos());
7024                 },
7025             });
7026         }
7027         return scanner;
7028         function error(message, errPos, length) {
7029             if (errPos === void 0) { errPos = pos; }
7030             if (onError) {
7031                 var oldPos = pos;
7032                 pos = errPos;
7033                 onError(message, length || 0);
7034                 pos = oldPos;
7035             }
7036         }
7037         function scanNumberFragment() {
7038             var start = pos;
7039             var allowSeparator = false;
7040             var isPreviousTokenSeparator = false;
7041             var result = "";
7042             while (true) {
7043                 var ch = text.charCodeAt(pos);
7044                 if (ch === 95) {
7045                     tokenFlags |= 512;
7046                     if (allowSeparator) {
7047                         allowSeparator = false;
7048                         isPreviousTokenSeparator = true;
7049                         result += text.substring(start, pos);
7050                     }
7051                     else if (isPreviousTokenSeparator) {
7052                         error(ts.Diagnostics.Multiple_consecutive_numeric_separators_are_not_permitted, pos, 1);
7053                     }
7054                     else {
7055                         error(ts.Diagnostics.Numeric_separators_are_not_allowed_here, pos, 1);
7056                     }
7057                     pos++;
7058                     start = pos;
7059                     continue;
7060                 }
7061                 if (isDigit(ch)) {
7062                     allowSeparator = true;
7063                     isPreviousTokenSeparator = false;
7064                     pos++;
7065                     continue;
7066                 }
7067                 break;
7068             }
7069             if (text.charCodeAt(pos - 1) === 95) {
7070                 error(ts.Diagnostics.Numeric_separators_are_not_allowed_here, pos - 1, 1);
7071             }
7072             return result + text.substring(start, pos);
7073         }
7074         function scanNumber() {
7075             var start = pos;
7076             var mainFragment = scanNumberFragment();
7077             var decimalFragment;
7078             var scientificFragment;
7079             if (text.charCodeAt(pos) === 46) {
7080                 pos++;
7081                 decimalFragment = scanNumberFragment();
7082             }
7083             var end = pos;
7084             if (text.charCodeAt(pos) === 69 || text.charCodeAt(pos) === 101) {
7085                 pos++;
7086                 tokenFlags |= 16;
7087                 if (text.charCodeAt(pos) === 43 || text.charCodeAt(pos) === 45)
7088                     pos++;
7089                 var preNumericPart = pos;
7090                 var finalFragment = scanNumberFragment();
7091                 if (!finalFragment) {
7092                     error(ts.Diagnostics.Digit_expected);
7093                 }
7094                 else {
7095                     scientificFragment = text.substring(end, preNumericPart) + finalFragment;
7096                     end = pos;
7097                 }
7098             }
7099             var result;
7100             if (tokenFlags & 512) {
7101                 result = mainFragment;
7102                 if (decimalFragment) {
7103                     result += "." + decimalFragment;
7104                 }
7105                 if (scientificFragment) {
7106                     result += scientificFragment;
7107                 }
7108             }
7109             else {
7110                 result = text.substring(start, end);
7111             }
7112             if (decimalFragment !== undefined || tokenFlags & 16) {
7113                 checkForIdentifierStartAfterNumericLiteral(start, decimalFragment === undefined && !!(tokenFlags & 16));
7114                 return {
7115                     type: 8,
7116                     value: "" + +result
7117                 };
7118             }
7119             else {
7120                 tokenValue = result;
7121                 var type = checkBigIntSuffix();
7122                 checkForIdentifierStartAfterNumericLiteral(start);
7123                 return { type: type, value: tokenValue };
7124             }
7125         }
7126         function checkForIdentifierStartAfterNumericLiteral(numericStart, isScientific) {
7127             if (!isIdentifierStart(codePointAt(text, pos), languageVersion)) {
7128                 return;
7129             }
7130             var identifierStart = pos;
7131             var length = scanIdentifierParts().length;
7132             if (length === 1 && text[identifierStart] === "n") {
7133                 if (isScientific) {
7134                     error(ts.Diagnostics.A_bigint_literal_cannot_use_exponential_notation, numericStart, identifierStart - numericStart + 1);
7135                 }
7136                 else {
7137                     error(ts.Diagnostics.A_bigint_literal_must_be_an_integer, numericStart, identifierStart - numericStart + 1);
7138                 }
7139             }
7140             else {
7141                 error(ts.Diagnostics.An_identifier_or_keyword_cannot_immediately_follow_a_numeric_literal, identifierStart, length);
7142                 pos = identifierStart;
7143             }
7144         }
7145         function scanOctalDigits() {
7146             var start = pos;
7147             while (isOctalDigit(text.charCodeAt(pos))) {
7148                 pos++;
7149             }
7150             return +(text.substring(start, pos));
7151         }
7152         function scanExactNumberOfHexDigits(count, canHaveSeparators) {
7153             var valueString = scanHexDigits(count, false, canHaveSeparators);
7154             return valueString ? parseInt(valueString, 16) : -1;
7155         }
7156         function scanMinimumNumberOfHexDigits(count, canHaveSeparators) {
7157             return scanHexDigits(count, true, canHaveSeparators);
7158         }
7159         function scanHexDigits(minCount, scanAsManyAsPossible, canHaveSeparators) {
7160             var valueChars = [];
7161             var allowSeparator = false;
7162             var isPreviousTokenSeparator = false;
7163             while (valueChars.length < minCount || scanAsManyAsPossible) {
7164                 var ch = text.charCodeAt(pos);
7165                 if (canHaveSeparators && ch === 95) {
7166                     tokenFlags |= 512;
7167                     if (allowSeparator) {
7168                         allowSeparator = false;
7169                         isPreviousTokenSeparator = true;
7170                     }
7171                     else if (isPreviousTokenSeparator) {
7172                         error(ts.Diagnostics.Multiple_consecutive_numeric_separators_are_not_permitted, pos, 1);
7173                     }
7174                     else {
7175                         error(ts.Diagnostics.Numeric_separators_are_not_allowed_here, pos, 1);
7176                     }
7177                     pos++;
7178                     continue;
7179                 }
7180                 allowSeparator = canHaveSeparators;
7181                 if (ch >= 65 && ch <= 70) {
7182                     ch += 97 - 65;
7183                 }
7184                 else if (!((ch >= 48 && ch <= 57) ||
7185                     (ch >= 97 && ch <= 102))) {
7186                     break;
7187                 }
7188                 valueChars.push(ch);
7189                 pos++;
7190                 isPreviousTokenSeparator = false;
7191             }
7192             if (valueChars.length < minCount) {
7193                 valueChars = [];
7194             }
7195             if (text.charCodeAt(pos - 1) === 95) {
7196                 error(ts.Diagnostics.Numeric_separators_are_not_allowed_here, pos - 1, 1);
7197             }
7198             return String.fromCharCode.apply(String, valueChars);
7199         }
7200         function scanString(jsxAttributeString) {
7201             if (jsxAttributeString === void 0) { jsxAttributeString = false; }
7202             var quote = text.charCodeAt(pos);
7203             pos++;
7204             var result = "";
7205             var start = pos;
7206             while (true) {
7207                 if (pos >= end) {
7208                     result += text.substring(start, pos);
7209                     tokenFlags |= 4;
7210                     error(ts.Diagnostics.Unterminated_string_literal);
7211                     break;
7212                 }
7213                 var ch = text.charCodeAt(pos);
7214                 if (ch === quote) {
7215                     result += text.substring(start, pos);
7216                     pos++;
7217                     break;
7218                 }
7219                 if (ch === 92 && !jsxAttributeString) {
7220                     result += text.substring(start, pos);
7221                     result += scanEscapeSequence();
7222                     start = pos;
7223                     continue;
7224                 }
7225                 if (isLineBreak(ch) && !jsxAttributeString) {
7226                     result += text.substring(start, pos);
7227                     tokenFlags |= 4;
7228                     error(ts.Diagnostics.Unterminated_string_literal);
7229                     break;
7230                 }
7231                 pos++;
7232             }
7233             return result;
7234         }
7235         function scanTemplateAndSetTokenValue(isTaggedTemplate) {
7236             var startedWithBacktick = text.charCodeAt(pos) === 96;
7237             pos++;
7238             var start = pos;
7239             var contents = "";
7240             var resultingToken;
7241             while (true) {
7242                 if (pos >= end) {
7243                     contents += text.substring(start, pos);
7244                     tokenFlags |= 4;
7245                     error(ts.Diagnostics.Unterminated_template_literal);
7246                     resultingToken = startedWithBacktick ? 14 : 17;
7247                     break;
7248                 }
7249                 var currChar = text.charCodeAt(pos);
7250                 if (currChar === 96) {
7251                     contents += text.substring(start, pos);
7252                     pos++;
7253                     resultingToken = startedWithBacktick ? 14 : 17;
7254                     break;
7255                 }
7256                 if (currChar === 36 && pos + 1 < end && text.charCodeAt(pos + 1) === 123) {
7257                     contents += text.substring(start, pos);
7258                     pos += 2;
7259                     resultingToken = startedWithBacktick ? 15 : 16;
7260                     break;
7261                 }
7262                 if (currChar === 92) {
7263                     contents += text.substring(start, pos);
7264                     contents += scanEscapeSequence(isTaggedTemplate);
7265                     start = pos;
7266                     continue;
7267                 }
7268                 if (currChar === 13) {
7269                     contents += text.substring(start, pos);
7270                     pos++;
7271                     if (pos < end && text.charCodeAt(pos) === 10) {
7272                         pos++;
7273                     }
7274                     contents += "\n";
7275                     start = pos;
7276                     continue;
7277                 }
7278                 pos++;
7279             }
7280             ts.Debug.assert(resultingToken !== undefined);
7281             tokenValue = contents;
7282             return resultingToken;
7283         }
7284         function scanEscapeSequence(isTaggedTemplate) {
7285             var start = pos;
7286             pos++;
7287             if (pos >= end) {
7288                 error(ts.Diagnostics.Unexpected_end_of_text);
7289                 return "";
7290             }
7291             var ch = text.charCodeAt(pos);
7292             pos++;
7293             switch (ch) {
7294                 case 48:
7295                     if (isTaggedTemplate && pos < end && isDigit(text.charCodeAt(pos))) {
7296                         pos++;
7297                         tokenFlags |= 2048;
7298                         return text.substring(start, pos);
7299                     }
7300                     return "\0";
7301                 case 98:
7302                     return "\b";
7303                 case 116:
7304                     return "\t";
7305                 case 110:
7306                     return "\n";
7307                 case 118:
7308                     return "\v";
7309                 case 102:
7310                     return "\f";
7311                 case 114:
7312                     return "\r";
7313                 case 39:
7314                     return "\'";
7315                 case 34:
7316                     return "\"";
7317                 case 117:
7318                     if (isTaggedTemplate) {
7319                         for (var escapePos = pos; escapePos < pos + 4; escapePos++) {
7320                             if (escapePos < end && !isHexDigit(text.charCodeAt(escapePos)) && text.charCodeAt(escapePos) !== 123) {
7321                                 pos = escapePos;
7322                                 tokenFlags |= 2048;
7323                                 return text.substring(start, pos);
7324                             }
7325                         }
7326                     }
7327                     if (pos < end && text.charCodeAt(pos) === 123) {
7328                         pos++;
7329                         if (isTaggedTemplate && !isHexDigit(text.charCodeAt(pos))) {
7330                             tokenFlags |= 2048;
7331                             return text.substring(start, pos);
7332                         }
7333                         if (isTaggedTemplate) {
7334                             var savePos = pos;
7335                             var escapedValueString = scanMinimumNumberOfHexDigits(1, false);
7336                             var escapedValue = escapedValueString ? parseInt(escapedValueString, 16) : -1;
7337                             if (!isCodePoint(escapedValue) || text.charCodeAt(pos) !== 125) {
7338                                 tokenFlags |= 2048;
7339                                 return text.substring(start, pos);
7340                             }
7341                             else {
7342                                 pos = savePos;
7343                             }
7344                         }
7345                         tokenFlags |= 8;
7346                         return scanExtendedUnicodeEscape();
7347                     }
7348                     tokenFlags |= 1024;
7349                     return scanHexadecimalEscape(4);
7350                 case 120:
7351                     if (isTaggedTemplate) {
7352                         if (!isHexDigit(text.charCodeAt(pos))) {
7353                             tokenFlags |= 2048;
7354                             return text.substring(start, pos);
7355                         }
7356                         else if (!isHexDigit(text.charCodeAt(pos + 1))) {
7357                             pos++;
7358                             tokenFlags |= 2048;
7359                             return text.substring(start, pos);
7360                         }
7361                     }
7362                     return scanHexadecimalEscape(2);
7363                 case 13:
7364                     if (pos < end && text.charCodeAt(pos) === 10) {
7365                         pos++;
7366                     }
7367                 case 10:
7368                 case 8232:
7369                 case 8233:
7370                     return "";
7371                 default:
7372                     return String.fromCharCode(ch);
7373             }
7374         }
7375         function scanHexadecimalEscape(numDigits) {
7376             var escapedValue = scanExactNumberOfHexDigits(numDigits, false);
7377             if (escapedValue >= 0) {
7378                 return String.fromCharCode(escapedValue);
7379             }
7380             else {
7381                 error(ts.Diagnostics.Hexadecimal_digit_expected);
7382                 return "";
7383             }
7384         }
7385         function scanExtendedUnicodeEscape() {
7386             var escapedValueString = scanMinimumNumberOfHexDigits(1, false);
7387             var escapedValue = escapedValueString ? parseInt(escapedValueString, 16) : -1;
7388             var isInvalidExtendedEscape = false;
7389             if (escapedValue < 0) {
7390                 error(ts.Diagnostics.Hexadecimal_digit_expected);
7391                 isInvalidExtendedEscape = true;
7392             }
7393             else if (escapedValue > 0x10FFFF) {
7394                 error(ts.Diagnostics.An_extended_Unicode_escape_value_must_be_between_0x0_and_0x10FFFF_inclusive);
7395                 isInvalidExtendedEscape = true;
7396             }
7397             if (pos >= end) {
7398                 error(ts.Diagnostics.Unexpected_end_of_text);
7399                 isInvalidExtendedEscape = true;
7400             }
7401             else if (text.charCodeAt(pos) === 125) {
7402                 pos++;
7403             }
7404             else {
7405                 error(ts.Diagnostics.Unterminated_Unicode_escape_sequence);
7406                 isInvalidExtendedEscape = true;
7407             }
7408             if (isInvalidExtendedEscape) {
7409                 return "";
7410             }
7411             return utf16EncodeAsString(escapedValue);
7412         }
7413         function peekUnicodeEscape() {
7414             if (pos + 5 < end && text.charCodeAt(pos + 1) === 117) {
7415                 var start_1 = pos;
7416                 pos += 2;
7417                 var value = scanExactNumberOfHexDigits(4, false);
7418                 pos = start_1;
7419                 return value;
7420             }
7421             return -1;
7422         }
7423         function peekExtendedUnicodeEscape() {
7424             if (languageVersion >= 2 && codePointAt(text, pos + 1) === 117 && codePointAt(text, pos + 2) === 123) {
7425                 var start_2 = pos;
7426                 pos += 3;
7427                 var escapedValueString = scanMinimumNumberOfHexDigits(1, false);
7428                 var escapedValue = escapedValueString ? parseInt(escapedValueString, 16) : -1;
7429                 pos = start_2;
7430                 return escapedValue;
7431             }
7432             return -1;
7433         }
7434         function scanIdentifierParts() {
7435             var result = "";
7436             var start = pos;
7437             while (pos < end) {
7438                 var ch = codePointAt(text, pos);
7439                 if (isIdentifierPart(ch, languageVersion)) {
7440                     pos += charSize(ch);
7441                 }
7442                 else if (ch === 92) {
7443                     ch = peekExtendedUnicodeEscape();
7444                     if (ch >= 0 && isIdentifierPart(ch, languageVersion)) {
7445                         pos += 3;
7446                         tokenFlags |= 8;
7447                         result += scanExtendedUnicodeEscape();
7448                         start = pos;
7449                         continue;
7450                     }
7451                     ch = peekUnicodeEscape();
7452                     if (!(ch >= 0 && isIdentifierPart(ch, languageVersion))) {
7453                         break;
7454                     }
7455                     tokenFlags |= 1024;
7456                     result += text.substring(start, pos);
7457                     result += utf16EncodeAsString(ch);
7458                     pos += 6;
7459                     start = pos;
7460                 }
7461                 else {
7462                     break;
7463                 }
7464             }
7465             result += text.substring(start, pos);
7466             return result;
7467         }
7468         function getIdentifierToken() {
7469             var len = tokenValue.length;
7470             if (len >= 2 && len <= 12) {
7471                 var ch = tokenValue.charCodeAt(0);
7472                 if (ch >= 97 && ch <= 122) {
7473                     var keyword = textToKeyword.get(tokenValue);
7474                     if (keyword !== undefined) {
7475                         return token = keyword;
7476                     }
7477                 }
7478             }
7479             return token = 78;
7480         }
7481         function scanBinaryOrOctalDigits(base) {
7482             var value = "";
7483             var separatorAllowed = false;
7484             var isPreviousTokenSeparator = false;
7485             while (true) {
7486                 var ch = text.charCodeAt(pos);
7487                 if (ch === 95) {
7488                     tokenFlags |= 512;
7489                     if (separatorAllowed) {
7490                         separatorAllowed = false;
7491                         isPreviousTokenSeparator = true;
7492                     }
7493                     else if (isPreviousTokenSeparator) {
7494                         error(ts.Diagnostics.Multiple_consecutive_numeric_separators_are_not_permitted, pos, 1);
7495                     }
7496                     else {
7497                         error(ts.Diagnostics.Numeric_separators_are_not_allowed_here, pos, 1);
7498                     }
7499                     pos++;
7500                     continue;
7501                 }
7502                 separatorAllowed = true;
7503                 if (!isDigit(ch) || ch - 48 >= base) {
7504                     break;
7505                 }
7506                 value += text[pos];
7507                 pos++;
7508                 isPreviousTokenSeparator = false;
7509             }
7510             if (text.charCodeAt(pos - 1) === 95) {
7511                 error(ts.Diagnostics.Numeric_separators_are_not_allowed_here, pos - 1, 1);
7512             }
7513             return value;
7514         }
7515         function checkBigIntSuffix() {
7516             if (text.charCodeAt(pos) === 110) {
7517                 tokenValue += "n";
7518                 if (tokenFlags & 384) {
7519                     tokenValue = ts.parsePseudoBigInt(tokenValue) + "n";
7520                 }
7521                 pos++;
7522                 return 9;
7523             }
7524             else {
7525                 var numericValue = tokenFlags & 128
7526                     ? parseInt(tokenValue.slice(2), 2)
7527                     : tokenFlags & 256
7528                         ? parseInt(tokenValue.slice(2), 8)
7529                         : +tokenValue;
7530                 tokenValue = "" + numericValue;
7531                 return 8;
7532             }
7533         }
7534         function scan() {
7535             var _a;
7536             startPos = pos;
7537             tokenFlags = 0;
7538             var asteriskSeen = false;
7539             while (true) {
7540                 tokenPos = pos;
7541                 if (pos >= end) {
7542                     return token = 1;
7543                 }
7544                 var ch = codePointAt(text, pos);
7545                 if (ch === 35 && pos === 0 && isShebangTrivia(text, pos)) {
7546                     pos = scanShebangTrivia(text, pos);
7547                     if (skipTrivia) {
7548                         continue;
7549                     }
7550                     else {
7551                         return token = 6;
7552                     }
7553                 }
7554                 switch (ch) {
7555                     case 10:
7556                     case 13:
7557                         tokenFlags |= 1;
7558                         if (skipTrivia) {
7559                             pos++;
7560                             continue;
7561                         }
7562                         else {
7563                             if (ch === 13 && pos + 1 < end && text.charCodeAt(pos + 1) === 10) {
7564                                 pos += 2;
7565                             }
7566                             else {
7567                                 pos++;
7568                             }
7569                             return token = 4;
7570                         }
7571                     case 9:
7572                     case 11:
7573                     case 12:
7574                     case 32:
7575                     case 160:
7576                     case 5760:
7577                     case 8192:
7578                     case 8193:
7579                     case 8194:
7580                     case 8195:
7581                     case 8196:
7582                     case 8197:
7583                     case 8198:
7584                     case 8199:
7585                     case 8200:
7586                     case 8201:
7587                     case 8202:
7588                     case 8203:
7589                     case 8239:
7590                     case 8287:
7591                     case 12288:
7592                     case 65279:
7593                         if (skipTrivia) {
7594                             pos++;
7595                             continue;
7596                         }
7597                         else {
7598                             while (pos < end && isWhiteSpaceSingleLine(text.charCodeAt(pos))) {
7599                                 pos++;
7600                             }
7601                             return token = 5;
7602                         }
7603                     case 33:
7604                         if (text.charCodeAt(pos + 1) === 61) {
7605                             if (text.charCodeAt(pos + 2) === 61) {
7606                                 return pos += 3, token = 37;
7607                             }
7608                             return pos += 2, token = 35;
7609                         }
7610                         pos++;
7611                         return token = 53;
7612                     case 34:
7613                     case 39:
7614                         tokenValue = scanString();
7615                         return token = 10;
7616                     case 96:
7617                         return token = scanTemplateAndSetTokenValue(false);
7618                     case 37:
7619                         if (text.charCodeAt(pos + 1) === 61) {
7620                             return pos += 2, token = 68;
7621                         }
7622                         pos++;
7623                         return token = 44;
7624                     case 38:
7625                         if (text.charCodeAt(pos + 1) === 38) {
7626                             if (text.charCodeAt(pos + 2) === 61) {
7627                                 return pos += 3, token = 75;
7628                             }
7629                             return pos += 2, token = 55;
7630                         }
7631                         if (text.charCodeAt(pos + 1) === 61) {
7632                             return pos += 2, token = 72;
7633                         }
7634                         pos++;
7635                         return token = 50;
7636                     case 40:
7637                         pos++;
7638                         return token = 20;
7639                     case 41:
7640                         pos++;
7641                         return token = 21;
7642                     case 42:
7643                         if (text.charCodeAt(pos + 1) === 61) {
7644                             return pos += 2, token = 65;
7645                         }
7646                         if (text.charCodeAt(pos + 1) === 42) {
7647                             if (text.charCodeAt(pos + 2) === 61) {
7648                                 return pos += 3, token = 66;
7649                             }
7650                             return pos += 2, token = 42;
7651                         }
7652                         pos++;
7653                         if (inJSDocType && !asteriskSeen && (tokenFlags & 1)) {
7654                             asteriskSeen = true;
7655                             continue;
7656                         }
7657                         return token = 41;
7658                     case 43:
7659                         if (text.charCodeAt(pos + 1) === 43) {
7660                             return pos += 2, token = 45;
7661                         }
7662                         if (text.charCodeAt(pos + 1) === 61) {
7663                             return pos += 2, token = 63;
7664                         }
7665                         pos++;
7666                         return token = 39;
7667                     case 44:
7668                         pos++;
7669                         return token = 27;
7670                     case 45:
7671                         if (text.charCodeAt(pos + 1) === 45) {
7672                             return pos += 2, token = 46;
7673                         }
7674                         if (text.charCodeAt(pos + 1) === 61) {
7675                             return pos += 2, token = 64;
7676                         }
7677                         pos++;
7678                         return token = 40;
7679                     case 46:
7680                         if (isDigit(text.charCodeAt(pos + 1))) {
7681                             tokenValue = scanNumber().value;
7682                             return token = 8;
7683                         }
7684                         if (text.charCodeAt(pos + 1) === 46 && text.charCodeAt(pos + 2) === 46) {
7685                             return pos += 3, token = 25;
7686                         }
7687                         pos++;
7688                         return token = 24;
7689                     case 47:
7690                         if (text.charCodeAt(pos + 1) === 47) {
7691                             pos += 2;
7692                             while (pos < end) {
7693                                 if (isLineBreak(text.charCodeAt(pos))) {
7694                                     break;
7695                                 }
7696                                 pos++;
7697                             }
7698                             commentDirectives = appendIfCommentDirective(commentDirectives, text.slice(tokenPos, pos), commentDirectiveRegExSingleLine, tokenPos);
7699                             if (skipTrivia) {
7700                                 continue;
7701                             }
7702                             else {
7703                                 return token = 2;
7704                             }
7705                         }
7706                         if (text.charCodeAt(pos + 1) === 42) {
7707                             pos += 2;
7708                             if (text.charCodeAt(pos) === 42 && text.charCodeAt(pos + 1) !== 47) {
7709                                 tokenFlags |= 2;
7710                             }
7711                             var commentClosed = false;
7712                             var lastLineStart = tokenPos;
7713                             while (pos < end) {
7714                                 var ch_1 = text.charCodeAt(pos);
7715                                 if (ch_1 === 42 && text.charCodeAt(pos + 1) === 47) {
7716                                     pos += 2;
7717                                     commentClosed = true;
7718                                     break;
7719                                 }
7720                                 pos++;
7721                                 if (isLineBreak(ch_1)) {
7722                                     lastLineStart = pos;
7723                                     tokenFlags |= 1;
7724                                 }
7725                             }
7726                             commentDirectives = appendIfCommentDirective(commentDirectives, text.slice(lastLineStart, pos), commentDirectiveRegExMultiLine, lastLineStart);
7727                             if (!commentClosed) {
7728                                 error(ts.Diagnostics.Asterisk_Slash_expected);
7729                             }
7730                             if (skipTrivia) {
7731                                 continue;
7732                             }
7733                             else {
7734                                 if (!commentClosed) {
7735                                     tokenFlags |= 4;
7736                                 }
7737                                 return token = 3;
7738                             }
7739                         }
7740                         if (text.charCodeAt(pos + 1) === 61) {
7741                             return pos += 2, token = 67;
7742                         }
7743                         pos++;
7744                         return token = 43;
7745                     case 48:
7746                         if (pos + 2 < end && (text.charCodeAt(pos + 1) === 88 || text.charCodeAt(pos + 1) === 120)) {
7747                             pos += 2;
7748                             tokenValue = scanMinimumNumberOfHexDigits(1, true);
7749                             if (!tokenValue) {
7750                                 error(ts.Diagnostics.Hexadecimal_digit_expected);
7751                                 tokenValue = "0";
7752                             }
7753                             tokenValue = "0x" + tokenValue;
7754                             tokenFlags |= 64;
7755                             return token = checkBigIntSuffix();
7756                         }
7757                         else if (pos + 2 < end && (text.charCodeAt(pos + 1) === 66 || text.charCodeAt(pos + 1) === 98)) {
7758                             pos += 2;
7759                             tokenValue = scanBinaryOrOctalDigits(2);
7760                             if (!tokenValue) {
7761                                 error(ts.Diagnostics.Binary_digit_expected);
7762                                 tokenValue = "0";
7763                             }
7764                             tokenValue = "0b" + tokenValue;
7765                             tokenFlags |= 128;
7766                             return token = checkBigIntSuffix();
7767                         }
7768                         else if (pos + 2 < end && (text.charCodeAt(pos + 1) === 79 || text.charCodeAt(pos + 1) === 111)) {
7769                             pos += 2;
7770                             tokenValue = scanBinaryOrOctalDigits(8);
7771                             if (!tokenValue) {
7772                                 error(ts.Diagnostics.Octal_digit_expected);
7773                                 tokenValue = "0";
7774                             }
7775                             tokenValue = "0o" + tokenValue;
7776                             tokenFlags |= 256;
7777                             return token = checkBigIntSuffix();
7778                         }
7779                         if (pos + 1 < end && isOctalDigit(text.charCodeAt(pos + 1))) {
7780                             tokenValue = "" + scanOctalDigits();
7781                             tokenFlags |= 32;
7782                             return token = 8;
7783                         }
7784                     case 49:
7785                     case 50:
7786                     case 51:
7787                     case 52:
7788                     case 53:
7789                     case 54:
7790                     case 55:
7791                     case 56:
7792                     case 57:
7793                         (_a = scanNumber(), token = _a.type, tokenValue = _a.value);
7794                         return token;
7795                     case 58:
7796                         pos++;
7797                         return token = 58;
7798                     case 59:
7799                         pos++;
7800                         return token = 26;
7801                     case 60:
7802                         if (isConflictMarkerTrivia(text, pos)) {
7803                             pos = scanConflictMarkerTrivia(text, pos, error);
7804                             if (skipTrivia) {
7805                                 continue;
7806                             }
7807                             else {
7808                                 return token = 7;
7809                             }
7810                         }
7811                         if (text.charCodeAt(pos + 1) === 60) {
7812                             if (text.charCodeAt(pos + 2) === 61) {
7813                                 return pos += 3, token = 69;
7814                             }
7815                             return pos += 2, token = 47;
7816                         }
7817                         if (text.charCodeAt(pos + 1) === 61) {
7818                             return pos += 2, token = 32;
7819                         }
7820                         if (languageVariant === 1 &&
7821                             text.charCodeAt(pos + 1) === 47 &&
7822                             text.charCodeAt(pos + 2) !== 42) {
7823                             return pos += 2, token = 30;
7824                         }
7825                         pos++;
7826                         return token = 29;
7827                     case 61:
7828                         if (isConflictMarkerTrivia(text, pos)) {
7829                             pos = scanConflictMarkerTrivia(text, pos, error);
7830                             if (skipTrivia) {
7831                                 continue;
7832                             }
7833                             else {
7834                                 return token = 7;
7835                             }
7836                         }
7837                         if (text.charCodeAt(pos + 1) === 61) {
7838                             if (text.charCodeAt(pos + 2) === 61) {
7839                                 return pos += 3, token = 36;
7840                             }
7841                             return pos += 2, token = 34;
7842                         }
7843                         if (text.charCodeAt(pos + 1) === 62) {
7844                             return pos += 2, token = 38;
7845                         }
7846                         pos++;
7847                         return token = 62;
7848                     case 62:
7849                         if (isConflictMarkerTrivia(text, pos)) {
7850                             pos = scanConflictMarkerTrivia(text, pos, error);
7851                             if (skipTrivia) {
7852                                 continue;
7853                             }
7854                             else {
7855                                 return token = 7;
7856                             }
7857                         }
7858                         pos++;
7859                         return token = 31;
7860                     case 63:
7861                         if (text.charCodeAt(pos + 1) === 46 && !isDigit(text.charCodeAt(pos + 2))) {
7862                             return pos += 2, token = 28;
7863                         }
7864                         if (text.charCodeAt(pos + 1) === 63) {
7865                             if (text.charCodeAt(pos + 2) === 61) {
7866                                 return pos += 3, token = 76;
7867                             }
7868                             return pos += 2, token = 60;
7869                         }
7870                         pos++;
7871                         return token = 57;
7872                     case 91:
7873                         pos++;
7874                         return token = 22;
7875                     case 93:
7876                         pos++;
7877                         return token = 23;
7878                     case 94:
7879                         if (text.charCodeAt(pos + 1) === 61) {
7880                             return pos += 2, token = 77;
7881                         }
7882                         pos++;
7883                         return token = 52;
7884                     case 123:
7885                         pos++;
7886                         return token = 18;
7887                     case 124:
7888                         if (isConflictMarkerTrivia(text, pos)) {
7889                             pos = scanConflictMarkerTrivia(text, pos, error);
7890                             if (skipTrivia) {
7891                                 continue;
7892                             }
7893                             else {
7894                                 return token = 7;
7895                             }
7896                         }
7897                         if (text.charCodeAt(pos + 1) === 124) {
7898                             if (text.charCodeAt(pos + 2) === 61) {
7899                                 return pos += 3, token = 74;
7900                             }
7901                             return pos += 2, token = 56;
7902                         }
7903                         if (text.charCodeAt(pos + 1) === 61) {
7904                             return pos += 2, token = 73;
7905                         }
7906                         pos++;
7907                         return token = 51;
7908                     case 125:
7909                         pos++;
7910                         return token = 19;
7911                     case 126:
7912                         pos++;
7913                         return token = 54;
7914                     case 64:
7915                         pos++;
7916                         return token = 59;
7917                     case 92:
7918                         var extendedCookedChar = peekExtendedUnicodeEscape();
7919                         if (extendedCookedChar >= 0 && isIdentifierStart(extendedCookedChar, languageVersion)) {
7920                             pos += 3;
7921                             tokenFlags |= 8;
7922                             tokenValue = scanExtendedUnicodeEscape() + scanIdentifierParts();
7923                             return token = getIdentifierToken();
7924                         }
7925                         var cookedChar = peekUnicodeEscape();
7926                         if (cookedChar >= 0 && isIdentifierStart(cookedChar, languageVersion)) {
7927                             pos += 6;
7928                             tokenFlags |= 1024;
7929                             tokenValue = String.fromCharCode(cookedChar) + scanIdentifierParts();
7930                             return token = getIdentifierToken();
7931                         }
7932                         error(ts.Diagnostics.Invalid_character);
7933                         pos++;
7934                         return token = 0;
7935                     case 35:
7936                         if (pos !== 0 && text[pos + 1] === "!") {
7937                             error(ts.Diagnostics.can_only_be_used_at_the_start_of_a_file);
7938                             pos++;
7939                             return token = 0;
7940                         }
7941                         pos++;
7942                         if (isIdentifierStart(ch = text.charCodeAt(pos), languageVersion)) {
7943                             pos++;
7944                             while (pos < end && isIdentifierPart(ch = text.charCodeAt(pos), languageVersion))
7945                                 pos++;
7946                             tokenValue = text.substring(tokenPos, pos);
7947                             if (ch === 92) {
7948                                 tokenValue += scanIdentifierParts();
7949                             }
7950                         }
7951                         else {
7952                             tokenValue = "#";
7953                             error(ts.Diagnostics.Invalid_character);
7954                         }
7955                         return token = 79;
7956                     default:
7957                         if (isIdentifierStart(ch, languageVersion)) {
7958                             pos += charSize(ch);
7959                             while (pos < end && isIdentifierPart(ch = codePointAt(text, pos), languageVersion))
7960                                 pos += charSize(ch);
7961                             tokenValue = text.substring(tokenPos, pos);
7962                             if (ch === 92) {
7963                                 tokenValue += scanIdentifierParts();
7964                             }
7965                             return token = getIdentifierToken();
7966                         }
7967                         else if (isWhiteSpaceSingleLine(ch)) {
7968                             pos += charSize(ch);
7969                             continue;
7970                         }
7971                         else if (isLineBreak(ch)) {
7972                             tokenFlags |= 1;
7973                             pos += charSize(ch);
7974                             continue;
7975                         }
7976                         error(ts.Diagnostics.Invalid_character);
7977                         pos += charSize(ch);
7978                         return token = 0;
7979                 }
7980             }
7981         }
7982         function reScanGreaterToken() {
7983             if (token === 31) {
7984                 if (text.charCodeAt(pos) === 62) {
7985                     if (text.charCodeAt(pos + 1) === 62) {
7986                         if (text.charCodeAt(pos + 2) === 61) {
7987                             return pos += 3, token = 71;
7988                         }
7989                         return pos += 2, token = 49;
7990                     }
7991                     if (text.charCodeAt(pos + 1) === 61) {
7992                         return pos += 2, token = 70;
7993                     }
7994                     pos++;
7995                     return token = 48;
7996                 }
7997                 if (text.charCodeAt(pos) === 61) {
7998                     pos++;
7999                     return token = 33;
8000                 }
8001             }
8002             return token;
8003         }
8004         function reScanAsteriskEqualsToken() {
8005             ts.Debug.assert(token === 65, "'reScanAsteriskEqualsToken' should only be called on a '*='");
8006             pos = tokenPos + 1;
8007             return token = 62;
8008         }
8009         function reScanSlashToken() {
8010             if (token === 43 || token === 67) {
8011                 var p = tokenPos + 1;
8012                 var inEscape = false;
8013                 var inCharacterClass = false;
8014                 while (true) {
8015                     if (p >= end) {
8016                         tokenFlags |= 4;
8017                         error(ts.Diagnostics.Unterminated_regular_expression_literal);
8018                         break;
8019                     }
8020                     var ch = text.charCodeAt(p);
8021                     if (isLineBreak(ch)) {
8022                         tokenFlags |= 4;
8023                         error(ts.Diagnostics.Unterminated_regular_expression_literal);
8024                         break;
8025                     }
8026                     if (inEscape) {
8027                         inEscape = false;
8028                     }
8029                     else if (ch === 47 && !inCharacterClass) {
8030                         p++;
8031                         break;
8032                     }
8033                     else if (ch === 91) {
8034                         inCharacterClass = true;
8035                     }
8036                     else if (ch === 92) {
8037                         inEscape = true;
8038                     }
8039                     else if (ch === 93) {
8040                         inCharacterClass = false;
8041                     }
8042                     p++;
8043                 }
8044                 while (p < end && isIdentifierPart(text.charCodeAt(p), languageVersion)) {
8045                     p++;
8046                 }
8047                 pos = p;
8048                 tokenValue = text.substring(tokenPos, pos);
8049                 token = 13;
8050             }
8051             return token;
8052         }
8053         function appendIfCommentDirective(commentDirectives, text, commentDirectiveRegEx, lineStart) {
8054             var type = getDirectiveFromComment(text, commentDirectiveRegEx);
8055             if (type === undefined) {
8056                 return commentDirectives;
8057             }
8058             return ts.append(commentDirectives, {
8059                 range: { pos: lineStart, end: pos },
8060                 type: type,
8061             });
8062         }
8063         function getDirectiveFromComment(text, commentDirectiveRegEx) {
8064             var match = commentDirectiveRegEx.exec(text);
8065             if (!match) {
8066                 return undefined;
8067             }
8068             switch (match[1]) {
8069                 case "ts-expect-error":
8070                     return 0;
8071                 case "ts-ignore":
8072                     return 1;
8073             }
8074             return undefined;
8075         }
8076         function reScanTemplateToken(isTaggedTemplate) {
8077             ts.Debug.assert(token === 19, "'reScanTemplateToken' should only be called on a '}'");
8078             pos = tokenPos;
8079             return token = scanTemplateAndSetTokenValue(isTaggedTemplate);
8080         }
8081         function reScanTemplateHeadOrNoSubstitutionTemplate() {
8082             pos = tokenPos;
8083             return token = scanTemplateAndSetTokenValue(true);
8084         }
8085         function reScanJsxToken() {
8086             pos = tokenPos = startPos;
8087             return token = scanJsxToken();
8088         }
8089         function reScanLessThanToken() {
8090             if (token === 47) {
8091                 pos = tokenPos + 1;
8092                 return token = 29;
8093             }
8094             return token;
8095         }
8096         function reScanQuestionToken() {
8097             ts.Debug.assert(token === 60, "'reScanQuestionToken' should only be called on a '??'");
8098             pos = tokenPos + 1;
8099             return token = 57;
8100         }
8101         function scanJsxToken() {
8102             startPos = tokenPos = pos;
8103             if (pos >= end) {
8104                 return token = 1;
8105             }
8106             var char = text.charCodeAt(pos);
8107             if (char === 60) {
8108                 if (text.charCodeAt(pos + 1) === 47) {
8109                     pos += 2;
8110                     return token = 30;
8111                 }
8112                 pos++;
8113                 return token = 29;
8114             }
8115             if (char === 123) {
8116                 pos++;
8117                 return token = 18;
8118             }
8119             var firstNonWhitespace = 0;
8120             var lastNonWhitespace = -1;
8121             while (pos < end) {
8122                 if (!isWhiteSpaceSingleLine(char)) {
8123                     lastNonWhitespace = pos;
8124                 }
8125                 char = text.charCodeAt(pos);
8126                 if (char === 123) {
8127                     break;
8128                 }
8129                 if (char === 60) {
8130                     if (isConflictMarkerTrivia(text, pos)) {
8131                         pos = scanConflictMarkerTrivia(text, pos, error);
8132                         return token = 7;
8133                     }
8134                     break;
8135                 }
8136                 if (char === 62) {
8137                     error(ts.Diagnostics.Unexpected_token_Did_you_mean_or_gt, pos, 1);
8138                 }
8139                 if (char === 125) {
8140                     error(ts.Diagnostics.Unexpected_token_Did_you_mean_or_rbrace, pos, 1);
8141                 }
8142                 if (lastNonWhitespace > 0)
8143                     lastNonWhitespace++;
8144                 if (isLineBreak(char) && firstNonWhitespace === 0) {
8145                     firstNonWhitespace = -1;
8146                 }
8147                 else if (!isWhiteSpaceLike(char)) {
8148                     firstNonWhitespace = pos;
8149                 }
8150                 pos++;
8151             }
8152             var endPosition = lastNonWhitespace === -1 ? pos : lastNonWhitespace;
8153             tokenValue = text.substring(startPos, endPosition);
8154             return firstNonWhitespace === -1 ? 12 : 11;
8155         }
8156         function scanJsxIdentifier() {
8157             if (tokenIsIdentifierOrKeyword(token)) {
8158                 while (pos < end) {
8159                     var ch = text.charCodeAt(pos);
8160                     if (ch === 45) {
8161                         tokenValue += "-";
8162                         pos++;
8163                         continue;
8164                     }
8165                     var oldPos = pos;
8166                     tokenValue += scanIdentifierParts();
8167                     if (pos === oldPos) {
8168                         break;
8169                     }
8170                 }
8171             }
8172             return token;
8173         }
8174         function scanJsxAttributeValue() {
8175             startPos = pos;
8176             switch (text.charCodeAt(pos)) {
8177                 case 34:
8178                 case 39:
8179                     tokenValue = scanString(true);
8180                     return token = 10;
8181                 default:
8182                     return scan();
8183             }
8184         }
8185         function reScanJsxAttributeValue() {
8186             pos = tokenPos = startPos;
8187             return scanJsxAttributeValue();
8188         }
8189         function scanJsDocToken() {
8190             startPos = tokenPos = pos;
8191             tokenFlags = 0;
8192             if (pos >= end) {
8193                 return token = 1;
8194             }
8195             var ch = codePointAt(text, pos);
8196             pos += charSize(ch);
8197             switch (ch) {
8198                 case 9:
8199                 case 11:
8200                 case 12:
8201                 case 32:
8202                     while (pos < end && isWhiteSpaceSingleLine(text.charCodeAt(pos))) {
8203                         pos++;
8204                     }
8205                     return token = 5;
8206                 case 64:
8207                     return token = 59;
8208                 case 13:
8209                     if (text.charCodeAt(pos) === 10) {
8210                         pos++;
8211                     }
8212                 case 10:
8213                     tokenFlags |= 1;
8214                     return token = 4;
8215                 case 42:
8216                     return token = 41;
8217                 case 123:
8218                     return token = 18;
8219                 case 125:
8220                     return token = 19;
8221                 case 91:
8222                     return token = 22;
8223                 case 93:
8224                     return token = 23;
8225                 case 60:
8226                     return token = 29;
8227                 case 62:
8228                     return token = 31;
8229                 case 61:
8230                     return token = 62;
8231                 case 44:
8232                     return token = 27;
8233                 case 46:
8234                     return token = 24;
8235                 case 96:
8236                     return token = 61;
8237                 case 92:
8238                     pos--;
8239                     var extendedCookedChar = peekExtendedUnicodeEscape();
8240                     if (extendedCookedChar >= 0 && isIdentifierStart(extendedCookedChar, languageVersion)) {
8241                         pos += 3;
8242                         tokenFlags |= 8;
8243                         tokenValue = scanExtendedUnicodeEscape() + scanIdentifierParts();
8244                         return token = getIdentifierToken();
8245                     }
8246                     var cookedChar = peekUnicodeEscape();
8247                     if (cookedChar >= 0 && isIdentifierStart(cookedChar, languageVersion)) {
8248                         pos += 6;
8249                         tokenFlags |= 1024;
8250                         tokenValue = String.fromCharCode(cookedChar) + scanIdentifierParts();
8251                         return token = getIdentifierToken();
8252                     }
8253                     pos++;
8254                     return token = 0;
8255             }
8256             if (isIdentifierStart(ch, languageVersion)) {
8257                 var char = ch;
8258                 while (pos < end && isIdentifierPart(char = codePointAt(text, pos), languageVersion) || text.charCodeAt(pos) === 45)
8259                     pos += charSize(char);
8260                 tokenValue = text.substring(tokenPos, pos);
8261                 if (char === 92) {
8262                     tokenValue += scanIdentifierParts();
8263                 }
8264                 return token = getIdentifierToken();
8265             }
8266             else {
8267                 return token = 0;
8268             }
8269         }
8270         function speculationHelper(callback, isLookahead) {
8271             var savePos = pos;
8272             var saveStartPos = startPos;
8273             var saveTokenPos = tokenPos;
8274             var saveToken = token;
8275             var saveTokenValue = tokenValue;
8276             var saveTokenFlags = tokenFlags;
8277             var result = callback();
8278             if (!result || isLookahead) {
8279                 pos = savePos;
8280                 startPos = saveStartPos;
8281                 tokenPos = saveTokenPos;
8282                 token = saveToken;
8283                 tokenValue = saveTokenValue;
8284                 tokenFlags = saveTokenFlags;
8285             }
8286             return result;
8287         }
8288         function scanRange(start, length, callback) {
8289             var saveEnd = end;
8290             var savePos = pos;
8291             var saveStartPos = startPos;
8292             var saveTokenPos = tokenPos;
8293             var saveToken = token;
8294             var saveTokenValue = tokenValue;
8295             var saveTokenFlags = tokenFlags;
8296             var saveErrorExpectations = commentDirectives;
8297             setText(text, start, length);
8298             var result = callback();
8299             end = saveEnd;
8300             pos = savePos;
8301             startPos = saveStartPos;
8302             tokenPos = saveTokenPos;
8303             token = saveToken;
8304             tokenValue = saveTokenValue;
8305             tokenFlags = saveTokenFlags;
8306             commentDirectives = saveErrorExpectations;
8307             return result;
8308         }
8309         function lookAhead(callback) {
8310             return speculationHelper(callback, true);
8311         }
8312         function tryScan(callback) {
8313             return speculationHelper(callback, false);
8314         }
8315         function getText() {
8316             return text;
8317         }
8318         function clearCommentDirectives() {
8319             commentDirectives = undefined;
8320         }
8321         function setText(newText, start, length) {
8322             text = newText || "";
8323             end = length === undefined ? text.length : start + length;
8324             setTextPos(start || 0);
8325         }
8326         function setOnError(errorCallback) {
8327             onError = errorCallback;
8328         }
8329         function setScriptTarget(scriptTarget) {
8330             languageVersion = scriptTarget;
8331         }
8332         function setLanguageVariant(variant) {
8333             languageVariant = variant;
8334         }
8335         function setTextPos(textPos) {
8336             ts.Debug.assert(textPos >= 0);
8337             pos = textPos;
8338             startPos = textPos;
8339             tokenPos = textPos;
8340             token = 0;
8341             tokenValue = undefined;
8342             tokenFlags = 0;
8343         }
8344         function setInJSDocType(inType) {
8345             inJSDocType += inType ? 1 : -1;
8346         }
8347     }
8348     ts.createScanner = createScanner;
8349     var codePointAt = String.prototype.codePointAt ? function (s, i) { return s.codePointAt(i); } : function codePointAt(str, i) {
8350         var size = str.length;
8351         if (i < 0 || i >= size) {
8352             return undefined;
8353         }
8354         var first = str.charCodeAt(i);
8355         if (first >= 0xD800 && first <= 0xDBFF && size > i + 1) {
8356             var second = str.charCodeAt(i + 1);
8357             if (second >= 0xDC00 && second <= 0xDFFF) {
8358                 return (first - 0xD800) * 0x400 + second - 0xDC00 + 0x10000;
8359             }
8360         }
8361         return first;
8362     };
8363     function charSize(ch) {
8364         if (ch >= 0x10000) {
8365             return 2;
8366         }
8367         return 1;
8368     }
8369     function utf16EncodeAsStringFallback(codePoint) {
8370         ts.Debug.assert(0x0 <= codePoint && codePoint <= 0x10FFFF);
8371         if (codePoint <= 65535) {
8372             return String.fromCharCode(codePoint);
8373         }
8374         var codeUnit1 = Math.floor((codePoint - 65536) / 1024) + 0xD800;
8375         var codeUnit2 = ((codePoint - 65536) % 1024) + 0xDC00;
8376         return String.fromCharCode(codeUnit1, codeUnit2);
8377     }
8378     var utf16EncodeAsStringWorker = String.fromCodePoint ? function (codePoint) { return String.fromCodePoint(codePoint); } : utf16EncodeAsStringFallback;
8379     function utf16EncodeAsString(codePoint) {
8380         return utf16EncodeAsStringWorker(codePoint);
8381     }
8382     ts.utf16EncodeAsString = utf16EncodeAsString;
8383 })(ts || (ts = {}));
8384 var ts;
8385 (function (ts) {
8386     function isExternalModuleNameRelative(moduleName) {
8387         return ts.pathIsRelative(moduleName) || ts.isRootedDiskPath(moduleName);
8388     }
8389     ts.isExternalModuleNameRelative = isExternalModuleNameRelative;
8390     function sortAndDeduplicateDiagnostics(diagnostics) {
8391         return ts.sortAndDeduplicate(diagnostics, ts.compareDiagnostics);
8392     }
8393     ts.sortAndDeduplicateDiagnostics = sortAndDeduplicateDiagnostics;
8394     function getDefaultLibFileName(options) {
8395         switch (options.target) {
8396             case 99:
8397                 return "lib.esnext.full.d.ts";
8398             case 7:
8399                 return "lib.es2020.full.d.ts";
8400             case 6:
8401                 return "lib.es2019.full.d.ts";
8402             case 5:
8403                 return "lib.es2018.full.d.ts";
8404             case 4:
8405                 return "lib.es2017.full.d.ts";
8406             case 3:
8407                 return "lib.es2016.full.d.ts";
8408             case 2:
8409                 return "lib.es6.d.ts";
8410             default:
8411                 return "lib.d.ts";
8412         }
8413     }
8414     ts.getDefaultLibFileName = getDefaultLibFileName;
8415     function textSpanEnd(span) {
8416         return span.start + span.length;
8417     }
8418     ts.textSpanEnd = textSpanEnd;
8419     function textSpanIsEmpty(span) {
8420         return span.length === 0;
8421     }
8422     ts.textSpanIsEmpty = textSpanIsEmpty;
8423     function textSpanContainsPosition(span, position) {
8424         return position >= span.start && position < textSpanEnd(span);
8425     }
8426     ts.textSpanContainsPosition = textSpanContainsPosition;
8427     function textRangeContainsPositionInclusive(span, position) {
8428         return position >= span.pos && position <= span.end;
8429     }
8430     ts.textRangeContainsPositionInclusive = textRangeContainsPositionInclusive;
8431     function textSpanContainsTextSpan(span, other) {
8432         return other.start >= span.start && textSpanEnd(other) <= textSpanEnd(span);
8433     }
8434     ts.textSpanContainsTextSpan = textSpanContainsTextSpan;
8435     function textSpanOverlapsWith(span, other) {
8436         return textSpanOverlap(span, other) !== undefined;
8437     }
8438     ts.textSpanOverlapsWith = textSpanOverlapsWith;
8439     function textSpanOverlap(span1, span2) {
8440         var overlap = textSpanIntersection(span1, span2);
8441         return overlap && overlap.length === 0 ? undefined : overlap;
8442     }
8443     ts.textSpanOverlap = textSpanOverlap;
8444     function textSpanIntersectsWithTextSpan(span, other) {
8445         return decodedTextSpanIntersectsWith(span.start, span.length, other.start, other.length);
8446     }
8447     ts.textSpanIntersectsWithTextSpan = textSpanIntersectsWithTextSpan;
8448     function textSpanIntersectsWith(span, start, length) {
8449         return decodedTextSpanIntersectsWith(span.start, span.length, start, length);
8450     }
8451     ts.textSpanIntersectsWith = textSpanIntersectsWith;
8452     function decodedTextSpanIntersectsWith(start1, length1, start2, length2) {
8453         var end1 = start1 + length1;
8454         var end2 = start2 + length2;
8455         return start2 <= end1 && end2 >= start1;
8456     }
8457     ts.decodedTextSpanIntersectsWith = decodedTextSpanIntersectsWith;
8458     function textSpanIntersectsWithPosition(span, position) {
8459         return position <= textSpanEnd(span) && position >= span.start;
8460     }
8461     ts.textSpanIntersectsWithPosition = textSpanIntersectsWithPosition;
8462     function textSpanIntersection(span1, span2) {
8463         var start = Math.max(span1.start, span2.start);
8464         var end = Math.min(textSpanEnd(span1), textSpanEnd(span2));
8465         return start <= end ? createTextSpanFromBounds(start, end) : undefined;
8466     }
8467     ts.textSpanIntersection = textSpanIntersection;
8468     function createTextSpan(start, length) {
8469         if (start < 0) {
8470             throw new Error("start < 0");
8471         }
8472         if (length < 0) {
8473             throw new Error("length < 0");
8474         }
8475         return { start: start, length: length };
8476     }
8477     ts.createTextSpan = createTextSpan;
8478     function createTextSpanFromBounds(start, end) {
8479         return createTextSpan(start, end - start);
8480     }
8481     ts.createTextSpanFromBounds = createTextSpanFromBounds;
8482     function textChangeRangeNewSpan(range) {
8483         return createTextSpan(range.span.start, range.newLength);
8484     }
8485     ts.textChangeRangeNewSpan = textChangeRangeNewSpan;
8486     function textChangeRangeIsUnchanged(range) {
8487         return textSpanIsEmpty(range.span) && range.newLength === 0;
8488     }
8489     ts.textChangeRangeIsUnchanged = textChangeRangeIsUnchanged;
8490     function createTextChangeRange(span, newLength) {
8491         if (newLength < 0) {
8492             throw new Error("newLength < 0");
8493         }
8494         return { span: span, newLength: newLength };
8495     }
8496     ts.createTextChangeRange = createTextChangeRange;
8497     ts.unchangedTextChangeRange = createTextChangeRange(createTextSpan(0, 0), 0);
8498     function collapseTextChangeRangesAcrossMultipleVersions(changes) {
8499         if (changes.length === 0) {
8500             return ts.unchangedTextChangeRange;
8501         }
8502         if (changes.length === 1) {
8503             return changes[0];
8504         }
8505         var change0 = changes[0];
8506         var oldStartN = change0.span.start;
8507         var oldEndN = textSpanEnd(change0.span);
8508         var newEndN = oldStartN + change0.newLength;
8509         for (var i = 1; i < changes.length; i++) {
8510             var nextChange = changes[i];
8511             var oldStart1 = oldStartN;
8512             var oldEnd1 = oldEndN;
8513             var newEnd1 = newEndN;
8514             var oldStart2 = nextChange.span.start;
8515             var oldEnd2 = textSpanEnd(nextChange.span);
8516             var newEnd2 = oldStart2 + nextChange.newLength;
8517             oldStartN = Math.min(oldStart1, oldStart2);
8518             oldEndN = Math.max(oldEnd1, oldEnd1 + (oldEnd2 - newEnd1));
8519             newEndN = Math.max(newEnd2, newEnd2 + (newEnd1 - oldEnd2));
8520         }
8521         return createTextChangeRange(createTextSpanFromBounds(oldStartN, oldEndN), newEndN - oldStartN);
8522     }
8523     ts.collapseTextChangeRangesAcrossMultipleVersions = collapseTextChangeRangesAcrossMultipleVersions;
8524     function getTypeParameterOwner(d) {
8525         if (d && d.kind === 159) {
8526             for (var current = d; current; current = current.parent) {
8527                 if (isFunctionLike(current) || isClassLike(current) || current.kind === 253) {
8528                     return current;
8529                 }
8530             }
8531         }
8532     }
8533     ts.getTypeParameterOwner = getTypeParameterOwner;
8534     function isParameterPropertyDeclaration(node, parent) {
8535         return ts.hasSyntacticModifier(node, 92) && parent.kind === 166;
8536     }
8537     ts.isParameterPropertyDeclaration = isParameterPropertyDeclaration;
8538     function isEmptyBindingPattern(node) {
8539         if (isBindingPattern(node)) {
8540             return ts.every(node.elements, isEmptyBindingElement);
8541         }
8542         return false;
8543     }
8544     ts.isEmptyBindingPattern = isEmptyBindingPattern;
8545     function isEmptyBindingElement(node) {
8546         if (ts.isOmittedExpression(node)) {
8547             return true;
8548         }
8549         return isEmptyBindingPattern(node.name);
8550     }
8551     ts.isEmptyBindingElement = isEmptyBindingElement;
8552     function walkUpBindingElementsAndPatterns(binding) {
8553         var node = binding.parent;
8554         while (ts.isBindingElement(node.parent)) {
8555             node = node.parent.parent;
8556         }
8557         return node.parent;
8558     }
8559     ts.walkUpBindingElementsAndPatterns = walkUpBindingElementsAndPatterns;
8560     function getCombinedFlags(node, getFlags) {
8561         if (ts.isBindingElement(node)) {
8562             node = walkUpBindingElementsAndPatterns(node);
8563         }
8564         var flags = getFlags(node);
8565         if (node.kind === 249) {
8566             node = node.parent;
8567         }
8568         if (node && node.kind === 250) {
8569             flags |= getFlags(node);
8570             node = node.parent;
8571         }
8572         if (node && node.kind === 232) {
8573             flags |= getFlags(node);
8574         }
8575         return flags;
8576     }
8577     function getCombinedModifierFlags(node) {
8578         return getCombinedFlags(node, ts.getEffectiveModifierFlags);
8579     }
8580     ts.getCombinedModifierFlags = getCombinedModifierFlags;
8581     function getCombinedNodeFlagsAlwaysIncludeJSDoc(node) {
8582         return getCombinedFlags(node, ts.getEffectiveModifierFlagsAlwaysIncludeJSDoc);
8583     }
8584     ts.getCombinedNodeFlagsAlwaysIncludeJSDoc = getCombinedNodeFlagsAlwaysIncludeJSDoc;
8585     function getCombinedNodeFlags(node) {
8586         return getCombinedFlags(node, function (n) { return n.flags; });
8587     }
8588     ts.getCombinedNodeFlags = getCombinedNodeFlags;
8589     function validateLocaleAndSetLanguage(locale, sys, errors) {
8590         var matchResult = /^([a-z]+)([_\-]([a-z]+))?$/.exec(locale.toLowerCase());
8591         if (!matchResult) {
8592             if (errors) {
8593                 errors.push(ts.createCompilerDiagnostic(ts.Diagnostics.Locale_must_be_of_the_form_language_or_language_territory_For_example_0_or_1, "en", "ja-jp"));
8594             }
8595             return;
8596         }
8597         var language = matchResult[1];
8598         var territory = matchResult[3];
8599         if (!trySetLanguageAndTerritory(language, territory, errors)) {
8600             trySetLanguageAndTerritory(language, undefined, errors);
8601         }
8602         ts.setUILocale(locale);
8603         function trySetLanguageAndTerritory(language, territory, errors) {
8604             var compilerFilePath = ts.normalizePath(sys.getExecutingFilePath());
8605             var containingDirectoryPath = ts.getDirectoryPath(compilerFilePath);
8606             var filePath = ts.combinePaths(containingDirectoryPath, language);
8607             if (territory) {
8608                 filePath = filePath + "-" + territory;
8609             }
8610             filePath = sys.resolvePath(ts.combinePaths(filePath, "diagnosticMessages.generated.json"));
8611             if (!sys.fileExists(filePath)) {
8612                 return false;
8613             }
8614             var fileContents = "";
8615             try {
8616                 fileContents = sys.readFile(filePath);
8617             }
8618             catch (e) {
8619                 if (errors) {
8620                     errors.push(ts.createCompilerDiagnostic(ts.Diagnostics.Unable_to_open_file_0, filePath));
8621                 }
8622                 return false;
8623             }
8624             try {
8625                 ts.setLocalizedDiagnosticMessages(JSON.parse(fileContents));
8626             }
8627             catch (_a) {
8628                 if (errors) {
8629                     errors.push(ts.createCompilerDiagnostic(ts.Diagnostics.Corrupted_locale_file_0, filePath));
8630                 }
8631                 return false;
8632             }
8633             return true;
8634         }
8635     }
8636     ts.validateLocaleAndSetLanguage = validateLocaleAndSetLanguage;
8637     function getOriginalNode(node, nodeTest) {
8638         if (node) {
8639             while (node.original !== undefined) {
8640                 node = node.original;
8641             }
8642         }
8643         return !nodeTest || nodeTest(node) ? node : undefined;
8644     }
8645     ts.getOriginalNode = getOriginalNode;
8646     function findAncestor(node, callback) {
8647         while (node) {
8648             var result = callback(node);
8649             if (result === "quit") {
8650                 return undefined;
8651             }
8652             else if (result) {
8653                 return node;
8654             }
8655             node = node.parent;
8656         }
8657         return undefined;
8658     }
8659     ts.findAncestor = findAncestor;
8660     function isParseTreeNode(node) {
8661         return (node.flags & 8) === 0;
8662     }
8663     ts.isParseTreeNode = isParseTreeNode;
8664     function getParseTreeNode(node, nodeTest) {
8665         if (node === undefined || isParseTreeNode(node)) {
8666             return node;
8667         }
8668         node = node.original;
8669         while (node) {
8670             if (isParseTreeNode(node)) {
8671                 return !nodeTest || nodeTest(node) ? node : undefined;
8672             }
8673             node = node.original;
8674         }
8675     }
8676     ts.getParseTreeNode = getParseTreeNode;
8677     function escapeLeadingUnderscores(identifier) {
8678         return (identifier.length >= 2 && identifier.charCodeAt(0) === 95 && identifier.charCodeAt(1) === 95 ? "_" + identifier : identifier);
8679     }
8680     ts.escapeLeadingUnderscores = escapeLeadingUnderscores;
8681     function unescapeLeadingUnderscores(identifier) {
8682         var id = identifier;
8683         return id.length >= 3 && id.charCodeAt(0) === 95 && id.charCodeAt(1) === 95 && id.charCodeAt(2) === 95 ? id.substr(1) : id;
8684     }
8685     ts.unescapeLeadingUnderscores = unescapeLeadingUnderscores;
8686     function idText(identifierOrPrivateName) {
8687         return unescapeLeadingUnderscores(identifierOrPrivateName.escapedText);
8688     }
8689     ts.idText = idText;
8690     function symbolName(symbol) {
8691         if (symbol.valueDeclaration && isPrivateIdentifierPropertyDeclaration(symbol.valueDeclaration)) {
8692             return idText(symbol.valueDeclaration.name);
8693         }
8694         return unescapeLeadingUnderscores(symbol.escapedName);
8695     }
8696     ts.symbolName = symbolName;
8697     function nameForNamelessJSDocTypedef(declaration) {
8698         var hostNode = declaration.parent.parent;
8699         if (!hostNode) {
8700             return undefined;
8701         }
8702         if (isDeclaration(hostNode)) {
8703             return getDeclarationIdentifier(hostNode);
8704         }
8705         switch (hostNode.kind) {
8706             case 232:
8707                 if (hostNode.declarationList && hostNode.declarationList.declarations[0]) {
8708                     return getDeclarationIdentifier(hostNode.declarationList.declarations[0]);
8709                 }
8710                 break;
8711             case 233:
8712                 var expr = hostNode.expression;
8713                 if (expr.kind === 216 && expr.operatorToken.kind === 62) {
8714                     expr = expr.left;
8715                 }
8716                 switch (expr.kind) {
8717                     case 201:
8718                         return expr.name;
8719                     case 202:
8720                         var arg = expr.argumentExpression;
8721                         if (ts.isIdentifier(arg)) {
8722                             return arg;
8723                         }
8724                 }
8725                 break;
8726             case 207: {
8727                 return getDeclarationIdentifier(hostNode.expression);
8728             }
8729             case 245: {
8730                 if (isDeclaration(hostNode.statement) || isExpression(hostNode.statement)) {
8731                     return getDeclarationIdentifier(hostNode.statement);
8732                 }
8733                 break;
8734             }
8735         }
8736     }
8737     function getDeclarationIdentifier(node) {
8738         var name = getNameOfDeclaration(node);
8739         return name && ts.isIdentifier(name) ? name : undefined;
8740     }
8741     function nodeHasName(statement, name) {
8742         if (isNamedDeclaration(statement) && ts.isIdentifier(statement.name) && idText(statement.name) === idText(name)) {
8743             return true;
8744         }
8745         if (ts.isVariableStatement(statement) && ts.some(statement.declarationList.declarations, function (d) { return nodeHasName(d, name); })) {
8746             return true;
8747         }
8748         return false;
8749     }
8750     ts.nodeHasName = nodeHasName;
8751     function getNameOfJSDocTypedef(declaration) {
8752         return declaration.name || nameForNamelessJSDocTypedef(declaration);
8753     }
8754     ts.getNameOfJSDocTypedef = getNameOfJSDocTypedef;
8755     function isNamedDeclaration(node) {
8756         return !!node.name;
8757     }
8758     ts.isNamedDeclaration = isNamedDeclaration;
8759     function getNonAssignedNameOfDeclaration(declaration) {
8760         switch (declaration.kind) {
8761             case 78:
8762                 return declaration;
8763             case 333:
8764             case 326: {
8765                 var name = declaration.name;
8766                 if (name.kind === 157) {
8767                     return name.right;
8768                 }
8769                 break;
8770             }
8771             case 203:
8772             case 216: {
8773                 var expr_1 = declaration;
8774                 switch (ts.getAssignmentDeclarationKind(expr_1)) {
8775                     case 1:
8776                     case 4:
8777                     case 5:
8778                     case 3:
8779                         return ts.getElementOrPropertyAccessArgumentExpressionOrName(expr_1.left);
8780                     case 7:
8781                     case 8:
8782                     case 9:
8783                         return expr_1.arguments[1];
8784                     default:
8785                         return undefined;
8786                 }
8787             }
8788             case 331:
8789                 return getNameOfJSDocTypedef(declaration);
8790             case 325:
8791                 return nameForNamelessJSDocTypedef(declaration);
8792             case 266: {
8793                 var expression = declaration.expression;
8794                 return ts.isIdentifier(expression) ? expression : undefined;
8795             }
8796             case 202:
8797                 var expr = declaration;
8798                 if (ts.isBindableStaticElementAccessExpression(expr)) {
8799                     return expr.argumentExpression;
8800                 }
8801         }
8802         return declaration.name;
8803     }
8804     ts.getNonAssignedNameOfDeclaration = getNonAssignedNameOfDeclaration;
8805     function getNameOfDeclaration(declaration) {
8806         if (declaration === undefined)
8807             return undefined;
8808         return getNonAssignedNameOfDeclaration(declaration) ||
8809             (ts.isFunctionExpression(declaration) || ts.isClassExpression(declaration) ? getAssignedName(declaration) : undefined);
8810     }
8811     ts.getNameOfDeclaration = getNameOfDeclaration;
8812     function getAssignedName(node) {
8813         if (!node.parent) {
8814             return undefined;
8815         }
8816         else if (ts.isPropertyAssignment(node.parent) || ts.isBindingElement(node.parent)) {
8817             return node.parent.name;
8818         }
8819         else if (ts.isBinaryExpression(node.parent) && node === node.parent.right) {
8820             if (ts.isIdentifier(node.parent.left)) {
8821                 return node.parent.left;
8822             }
8823             else if (ts.isAccessExpression(node.parent.left)) {
8824                 return ts.getElementOrPropertyAccessArgumentExpressionOrName(node.parent.left);
8825             }
8826         }
8827         else if (ts.isVariableDeclaration(node.parent) && ts.isIdentifier(node.parent.name)) {
8828             return node.parent.name;
8829         }
8830     }
8831     ts.getAssignedName = getAssignedName;
8832     function getJSDocParameterTagsWorker(param, noCache) {
8833         if (param.name) {
8834             if (ts.isIdentifier(param.name)) {
8835                 var name_1 = param.name.escapedText;
8836                 return getJSDocTagsWorker(param.parent, noCache).filter(function (tag) { return ts.isJSDocParameterTag(tag) && ts.isIdentifier(tag.name) && tag.name.escapedText === name_1; });
8837             }
8838             else {
8839                 var i = param.parent.parameters.indexOf(param);
8840                 ts.Debug.assert(i > -1, "Parameters should always be in their parents' parameter list");
8841                 var paramTags = getJSDocTagsWorker(param.parent, noCache).filter(ts.isJSDocParameterTag);
8842                 if (i < paramTags.length) {
8843                     return [paramTags[i]];
8844                 }
8845             }
8846         }
8847         return ts.emptyArray;
8848     }
8849     function getJSDocParameterTags(param) {
8850         return getJSDocParameterTagsWorker(param, false);
8851     }
8852     ts.getJSDocParameterTags = getJSDocParameterTags;
8853     function getJSDocParameterTagsNoCache(param) {
8854         return getJSDocParameterTagsWorker(param, true);
8855     }
8856     ts.getJSDocParameterTagsNoCache = getJSDocParameterTagsNoCache;
8857     function getJSDocTypeParameterTagsWorker(param, noCache) {
8858         var name = param.name.escapedText;
8859         return getJSDocTagsWorker(param.parent, noCache).filter(function (tag) {
8860             return ts.isJSDocTemplateTag(tag) && tag.typeParameters.some(function (tp) { return tp.name.escapedText === name; });
8861         });
8862     }
8863     function getJSDocTypeParameterTags(param) {
8864         return getJSDocTypeParameterTagsWorker(param, false);
8865     }
8866     ts.getJSDocTypeParameterTags = getJSDocTypeParameterTags;
8867     function getJSDocTypeParameterTagsNoCache(param) {
8868         return getJSDocTypeParameterTagsWorker(param, true);
8869     }
8870     ts.getJSDocTypeParameterTagsNoCache = getJSDocTypeParameterTagsNoCache;
8871     function hasJSDocParameterTags(node) {
8872         return !!getFirstJSDocTag(node, ts.isJSDocParameterTag);
8873     }
8874     ts.hasJSDocParameterTags = hasJSDocParameterTags;
8875     function getJSDocAugmentsTag(node) {
8876         return getFirstJSDocTag(node, ts.isJSDocAugmentsTag);
8877     }
8878     ts.getJSDocAugmentsTag = getJSDocAugmentsTag;
8879     function getJSDocImplementsTags(node) {
8880         return getAllJSDocTags(node, ts.isJSDocImplementsTag);
8881     }
8882     ts.getJSDocImplementsTags = getJSDocImplementsTags;
8883     function getJSDocClassTag(node) {
8884         return getFirstJSDocTag(node, ts.isJSDocClassTag);
8885     }
8886     ts.getJSDocClassTag = getJSDocClassTag;
8887     function getJSDocPublicTag(node) {
8888         return getFirstJSDocTag(node, ts.isJSDocPublicTag);
8889     }
8890     ts.getJSDocPublicTag = getJSDocPublicTag;
8891     function getJSDocPublicTagNoCache(node) {
8892         return getFirstJSDocTag(node, ts.isJSDocPublicTag, true);
8893     }
8894     ts.getJSDocPublicTagNoCache = getJSDocPublicTagNoCache;
8895     function getJSDocPrivateTag(node) {
8896         return getFirstJSDocTag(node, ts.isJSDocPrivateTag);
8897     }
8898     ts.getJSDocPrivateTag = getJSDocPrivateTag;
8899     function getJSDocPrivateTagNoCache(node) {
8900         return getFirstJSDocTag(node, ts.isJSDocPrivateTag, true);
8901     }
8902     ts.getJSDocPrivateTagNoCache = getJSDocPrivateTagNoCache;
8903     function getJSDocProtectedTag(node) {
8904         return getFirstJSDocTag(node, ts.isJSDocProtectedTag);
8905     }
8906     ts.getJSDocProtectedTag = getJSDocProtectedTag;
8907     function getJSDocProtectedTagNoCache(node) {
8908         return getFirstJSDocTag(node, ts.isJSDocProtectedTag, true);
8909     }
8910     ts.getJSDocProtectedTagNoCache = getJSDocProtectedTagNoCache;
8911     function getJSDocReadonlyTag(node) {
8912         return getFirstJSDocTag(node, ts.isJSDocReadonlyTag);
8913     }
8914     ts.getJSDocReadonlyTag = getJSDocReadonlyTag;
8915     function getJSDocReadonlyTagNoCache(node) {
8916         return getFirstJSDocTag(node, ts.isJSDocReadonlyTag, true);
8917     }
8918     ts.getJSDocReadonlyTagNoCache = getJSDocReadonlyTagNoCache;
8919     function getJSDocDeprecatedTag(node) {
8920         return getFirstJSDocTag(node, ts.isJSDocDeprecatedTag);
8921     }
8922     ts.getJSDocDeprecatedTag = getJSDocDeprecatedTag;
8923     function getJSDocDeprecatedTagNoCache(node) {
8924         return getFirstJSDocTag(node, ts.isJSDocDeprecatedTag, true);
8925     }
8926     ts.getJSDocDeprecatedTagNoCache = getJSDocDeprecatedTagNoCache;
8927     function getJSDocEnumTag(node) {
8928         return getFirstJSDocTag(node, ts.isJSDocEnumTag);
8929     }
8930     ts.getJSDocEnumTag = getJSDocEnumTag;
8931     function getJSDocThisTag(node) {
8932         return getFirstJSDocTag(node, ts.isJSDocThisTag);
8933     }
8934     ts.getJSDocThisTag = getJSDocThisTag;
8935     function getJSDocReturnTag(node) {
8936         return getFirstJSDocTag(node, ts.isJSDocReturnTag);
8937     }
8938     ts.getJSDocReturnTag = getJSDocReturnTag;
8939     function getJSDocTemplateTag(node) {
8940         return getFirstJSDocTag(node, ts.isJSDocTemplateTag);
8941     }
8942     ts.getJSDocTemplateTag = getJSDocTemplateTag;
8943     function getJSDocTypeTag(node) {
8944         var tag = getFirstJSDocTag(node, ts.isJSDocTypeTag);
8945         if (tag && tag.typeExpression && tag.typeExpression.type) {
8946             return tag;
8947         }
8948         return undefined;
8949     }
8950     ts.getJSDocTypeTag = getJSDocTypeTag;
8951     function getJSDocType(node) {
8952         var tag = getFirstJSDocTag(node, ts.isJSDocTypeTag);
8953         if (!tag && ts.isParameter(node)) {
8954             tag = ts.find(getJSDocParameterTags(node), function (tag) { return !!tag.typeExpression; });
8955         }
8956         return tag && tag.typeExpression && tag.typeExpression.type;
8957     }
8958     ts.getJSDocType = getJSDocType;
8959     function getJSDocReturnType(node) {
8960         var returnTag = getJSDocReturnTag(node);
8961         if (returnTag && returnTag.typeExpression) {
8962             return returnTag.typeExpression.type;
8963         }
8964         var typeTag = getJSDocTypeTag(node);
8965         if (typeTag && typeTag.typeExpression) {
8966             var type = typeTag.typeExpression.type;
8967             if (ts.isTypeLiteralNode(type)) {
8968                 var sig = ts.find(type.members, ts.isCallSignatureDeclaration);
8969                 return sig && sig.type;
8970             }
8971             if (ts.isFunctionTypeNode(type) || ts.isJSDocFunctionType(type)) {
8972                 return type.type;
8973             }
8974         }
8975     }
8976     ts.getJSDocReturnType = getJSDocReturnType;
8977     function getJSDocTagsWorker(node, noCache) {
8978         var tags = node.jsDocCache;
8979         if (tags === undefined || noCache) {
8980             var comments = ts.getJSDocCommentsAndTags(node, noCache);
8981             ts.Debug.assert(comments.length < 2 || comments[0] !== comments[1]);
8982             tags = ts.flatMap(comments, function (j) { return ts.isJSDoc(j) ? j.tags : j; });
8983             if (!noCache) {
8984                 node.jsDocCache = tags;
8985             }
8986         }
8987         return tags;
8988     }
8989     function getJSDocTags(node) {
8990         return getJSDocTagsWorker(node, false);
8991     }
8992     ts.getJSDocTags = getJSDocTags;
8993     function getJSDocTagsNoCache(node) {
8994         return getJSDocTagsWorker(node, true);
8995     }
8996     ts.getJSDocTagsNoCache = getJSDocTagsNoCache;
8997     function getFirstJSDocTag(node, predicate, noCache) {
8998         return ts.find(getJSDocTagsWorker(node, noCache), predicate);
8999     }
9000     function getAllJSDocTags(node, predicate) {
9001         return getJSDocTags(node).filter(predicate);
9002     }
9003     ts.getAllJSDocTags = getAllJSDocTags;
9004     function getAllJSDocTagsOfKind(node, kind) {
9005         return getJSDocTags(node).filter(function (doc) { return doc.kind === kind; });
9006     }
9007     ts.getAllJSDocTagsOfKind = getAllJSDocTagsOfKind;
9008     function getEffectiveTypeParameterDeclarations(node) {
9009         if (ts.isJSDocSignature(node)) {
9010             return ts.emptyArray;
9011         }
9012         if (ts.isJSDocTypeAlias(node)) {
9013             ts.Debug.assert(node.parent.kind === 311);
9014             return ts.flatMap(node.parent.tags, function (tag) { return ts.isJSDocTemplateTag(tag) ? tag.typeParameters : undefined; });
9015         }
9016         if (node.typeParameters) {
9017             return node.typeParameters;
9018         }
9019         if (ts.isInJSFile(node)) {
9020             var decls = ts.getJSDocTypeParameterDeclarations(node);
9021             if (decls.length) {
9022                 return decls;
9023             }
9024             var typeTag = getJSDocType(node);
9025             if (typeTag && ts.isFunctionTypeNode(typeTag) && typeTag.typeParameters) {
9026                 return typeTag.typeParameters;
9027             }
9028         }
9029         return ts.emptyArray;
9030     }
9031     ts.getEffectiveTypeParameterDeclarations = getEffectiveTypeParameterDeclarations;
9032     function getEffectiveConstraintOfTypeParameter(node) {
9033         return node.constraint ? node.constraint :
9034             ts.isJSDocTemplateTag(node.parent) && node === node.parent.typeParameters[0] ? node.parent.constraint :
9035                 undefined;
9036     }
9037     ts.getEffectiveConstraintOfTypeParameter = getEffectiveConstraintOfTypeParameter;
9038     function isIdentifierOrPrivateIdentifier(node) {
9039         return node.kind === 78 || node.kind === 79;
9040     }
9041     ts.isIdentifierOrPrivateIdentifier = isIdentifierOrPrivateIdentifier;
9042     function isGetOrSetAccessorDeclaration(node) {
9043         return node.kind === 168 || node.kind === 167;
9044     }
9045     ts.isGetOrSetAccessorDeclaration = isGetOrSetAccessorDeclaration;
9046     function isPropertyAccessChain(node) {
9047         return ts.isPropertyAccessExpression(node) && !!(node.flags & 32);
9048     }
9049     ts.isPropertyAccessChain = isPropertyAccessChain;
9050     function isElementAccessChain(node) {
9051         return ts.isElementAccessExpression(node) && !!(node.flags & 32);
9052     }
9053     ts.isElementAccessChain = isElementAccessChain;
9054     function isCallChain(node) {
9055         return ts.isCallExpression(node) && !!(node.flags & 32);
9056     }
9057     ts.isCallChain = isCallChain;
9058     function isOptionalChain(node) {
9059         var kind = node.kind;
9060         return !!(node.flags & 32) &&
9061             (kind === 201
9062                 || kind === 202
9063                 || kind === 203
9064                 || kind === 225);
9065     }
9066     ts.isOptionalChain = isOptionalChain;
9067     function isOptionalChainRoot(node) {
9068         return isOptionalChain(node) && !ts.isNonNullExpression(node) && !!node.questionDotToken;
9069     }
9070     ts.isOptionalChainRoot = isOptionalChainRoot;
9071     function isExpressionOfOptionalChainRoot(node) {
9072         return isOptionalChainRoot(node.parent) && node.parent.expression === node;
9073     }
9074     ts.isExpressionOfOptionalChainRoot = isExpressionOfOptionalChainRoot;
9075     function isOutermostOptionalChain(node) {
9076         return !isOptionalChain(node.parent)
9077             || isOptionalChainRoot(node.parent)
9078             || node !== node.parent.expression;
9079     }
9080     ts.isOutermostOptionalChain = isOutermostOptionalChain;
9081     function isNullishCoalesce(node) {
9082         return node.kind === 216 && node.operatorToken.kind === 60;
9083     }
9084     ts.isNullishCoalesce = isNullishCoalesce;
9085     function isConstTypeReference(node) {
9086         return ts.isTypeReferenceNode(node) && ts.isIdentifier(node.typeName) &&
9087             node.typeName.escapedText === "const" && !node.typeArguments;
9088     }
9089     ts.isConstTypeReference = isConstTypeReference;
9090     function skipPartiallyEmittedExpressions(node) {
9091         return ts.skipOuterExpressions(node, 8);
9092     }
9093     ts.skipPartiallyEmittedExpressions = skipPartiallyEmittedExpressions;
9094     function isNonNullChain(node) {
9095         return ts.isNonNullExpression(node) && !!(node.flags & 32);
9096     }
9097     ts.isNonNullChain = isNonNullChain;
9098     function isBreakOrContinueStatement(node) {
9099         return node.kind === 241 || node.kind === 240;
9100     }
9101     ts.isBreakOrContinueStatement = isBreakOrContinueStatement;
9102     function isNamedExportBindings(node) {
9103         return node.kind === 269 || node.kind === 268;
9104     }
9105     ts.isNamedExportBindings = isNamedExportBindings;
9106     function isUnparsedTextLike(node) {
9107         switch (node.kind) {
9108             case 294:
9109             case 295:
9110                 return true;
9111             default:
9112                 return false;
9113         }
9114     }
9115     ts.isUnparsedTextLike = isUnparsedTextLike;
9116     function isUnparsedNode(node) {
9117         return isUnparsedTextLike(node) ||
9118             node.kind === 292 ||
9119             node.kind === 296;
9120     }
9121     ts.isUnparsedNode = isUnparsedNode;
9122     function isJSDocPropertyLikeTag(node) {
9123         return node.kind === 333 || node.kind === 326;
9124     }
9125     ts.isJSDocPropertyLikeTag = isJSDocPropertyLikeTag;
9126     function isNode(node) {
9127         return isNodeKind(node.kind);
9128     }
9129     ts.isNode = isNode;
9130     function isNodeKind(kind) {
9131         return kind >= 157;
9132     }
9133     ts.isNodeKind = isNodeKind;
9134     function isToken(n) {
9135         return n.kind >= 0 && n.kind <= 156;
9136     }
9137     ts.isToken = isToken;
9138     function isNodeArray(array) {
9139         return array.hasOwnProperty("pos") && array.hasOwnProperty("end");
9140     }
9141     ts.isNodeArray = isNodeArray;
9142     function isLiteralKind(kind) {
9143         return 8 <= kind && kind <= 14;
9144     }
9145     ts.isLiteralKind = isLiteralKind;
9146     function isLiteralExpression(node) {
9147         return isLiteralKind(node.kind);
9148     }
9149     ts.isLiteralExpression = isLiteralExpression;
9150     function isTemplateLiteralKind(kind) {
9151         return 14 <= kind && kind <= 17;
9152     }
9153     ts.isTemplateLiteralKind = isTemplateLiteralKind;
9154     function isTemplateLiteralToken(node) {
9155         return isTemplateLiteralKind(node.kind);
9156     }
9157     ts.isTemplateLiteralToken = isTemplateLiteralToken;
9158     function isTemplateMiddleOrTemplateTail(node) {
9159         var kind = node.kind;
9160         return kind === 16
9161             || kind === 17;
9162     }
9163     ts.isTemplateMiddleOrTemplateTail = isTemplateMiddleOrTemplateTail;
9164     function isImportOrExportSpecifier(node) {
9165         return ts.isImportSpecifier(node) || ts.isExportSpecifier(node);
9166     }
9167     ts.isImportOrExportSpecifier = isImportOrExportSpecifier;
9168     function isTypeOnlyImportOrExportDeclaration(node) {
9169         switch (node.kind) {
9170             case 265:
9171             case 270:
9172                 return node.parent.parent.isTypeOnly;
9173             case 263:
9174                 return node.parent.isTypeOnly;
9175             case 262:
9176                 return node.isTypeOnly;
9177             default:
9178                 return false;
9179         }
9180     }
9181     ts.isTypeOnlyImportOrExportDeclaration = isTypeOnlyImportOrExportDeclaration;
9182     function isStringTextContainingNode(node) {
9183         return node.kind === 10 || isTemplateLiteralKind(node.kind);
9184     }
9185     ts.isStringTextContainingNode = isStringTextContainingNode;
9186     function isGeneratedIdentifier(node) {
9187         return ts.isIdentifier(node) && (node.autoGenerateFlags & 7) > 0;
9188     }
9189     ts.isGeneratedIdentifier = isGeneratedIdentifier;
9190     function isPrivateIdentifierPropertyDeclaration(node) {
9191         return ts.isPropertyDeclaration(node) && ts.isPrivateIdentifier(node.name);
9192     }
9193     ts.isPrivateIdentifierPropertyDeclaration = isPrivateIdentifierPropertyDeclaration;
9194     function isPrivateIdentifierPropertyAccessExpression(node) {
9195         return ts.isPropertyAccessExpression(node) && ts.isPrivateIdentifier(node.name);
9196     }
9197     ts.isPrivateIdentifierPropertyAccessExpression = isPrivateIdentifierPropertyAccessExpression;
9198     function isModifierKind(token) {
9199         switch (token) {
9200             case 125:
9201             case 129:
9202             case 84:
9203             case 133:
9204             case 87:
9205             case 92:
9206             case 122:
9207             case 120:
9208             case 121:
9209             case 142:
9210             case 123:
9211                 return true;
9212         }
9213         return false;
9214     }
9215     ts.isModifierKind = isModifierKind;
9216     function isParameterPropertyModifier(kind) {
9217         return !!(ts.modifierToFlag(kind) & 92);
9218     }
9219     ts.isParameterPropertyModifier = isParameterPropertyModifier;
9220     function isClassMemberModifier(idToken) {
9221         return isParameterPropertyModifier(idToken) || idToken === 123;
9222     }
9223     ts.isClassMemberModifier = isClassMemberModifier;
9224     function isModifier(node) {
9225         return isModifierKind(node.kind);
9226     }
9227     ts.isModifier = isModifier;
9228     function isEntityName(node) {
9229         var kind = node.kind;
9230         return kind === 157
9231             || kind === 78;
9232     }
9233     ts.isEntityName = isEntityName;
9234     function isPropertyName(node) {
9235         var kind = node.kind;
9236         return kind === 78
9237             || kind === 79
9238             || kind === 10
9239             || kind === 8
9240             || kind === 158;
9241     }
9242     ts.isPropertyName = isPropertyName;
9243     function isBindingName(node) {
9244         var kind = node.kind;
9245         return kind === 78
9246             || kind === 196
9247             || kind === 197;
9248     }
9249     ts.isBindingName = isBindingName;
9250     function isFunctionLike(node) {
9251         return node && isFunctionLikeKind(node.kind);
9252     }
9253     ts.isFunctionLike = isFunctionLike;
9254     function isFunctionLikeDeclaration(node) {
9255         return node && isFunctionLikeDeclarationKind(node.kind);
9256     }
9257     ts.isFunctionLikeDeclaration = isFunctionLikeDeclaration;
9258     function isFunctionLikeDeclarationKind(kind) {
9259         switch (kind) {
9260             case 251:
9261             case 165:
9262             case 166:
9263             case 167:
9264             case 168:
9265             case 208:
9266             case 209:
9267                 return true;
9268             default:
9269                 return false;
9270         }
9271     }
9272     function isFunctionLikeKind(kind) {
9273         switch (kind) {
9274             case 164:
9275             case 169:
9276             case 313:
9277             case 170:
9278             case 171:
9279             case 174:
9280             case 308:
9281             case 175:
9282                 return true;
9283             default:
9284                 return isFunctionLikeDeclarationKind(kind);
9285         }
9286     }
9287     ts.isFunctionLikeKind = isFunctionLikeKind;
9288     function isFunctionOrModuleBlock(node) {
9289         return ts.isSourceFile(node) || ts.isModuleBlock(node) || ts.isBlock(node) && isFunctionLike(node.parent);
9290     }
9291     ts.isFunctionOrModuleBlock = isFunctionOrModuleBlock;
9292     function isClassElement(node) {
9293         var kind = node.kind;
9294         return kind === 166
9295             || kind === 163
9296             || kind === 165
9297             || kind === 167
9298             || kind === 168
9299             || kind === 171
9300             || kind === 229;
9301     }
9302     ts.isClassElement = isClassElement;
9303     function isClassLike(node) {
9304         return node && (node.kind === 252 || node.kind === 221);
9305     }
9306     ts.isClassLike = isClassLike;
9307     function isAccessor(node) {
9308         return node && (node.kind === 167 || node.kind === 168);
9309     }
9310     ts.isAccessor = isAccessor;
9311     function isMethodOrAccessor(node) {
9312         switch (node.kind) {
9313             case 165:
9314             case 167:
9315             case 168:
9316                 return true;
9317             default:
9318                 return false;
9319         }
9320     }
9321     ts.isMethodOrAccessor = isMethodOrAccessor;
9322     function isTypeElement(node) {
9323         var kind = node.kind;
9324         return kind === 170
9325             || kind === 169
9326             || kind === 162
9327             || kind === 164
9328             || kind === 171;
9329     }
9330     ts.isTypeElement = isTypeElement;
9331     function isClassOrTypeElement(node) {
9332         return isTypeElement(node) || isClassElement(node);
9333     }
9334     ts.isClassOrTypeElement = isClassOrTypeElement;
9335     function isObjectLiteralElementLike(node) {
9336         var kind = node.kind;
9337         return kind === 288
9338             || kind === 289
9339             || kind === 290
9340             || kind === 165
9341             || kind === 167
9342             || kind === 168;
9343     }
9344     ts.isObjectLiteralElementLike = isObjectLiteralElementLike;
9345     function isTypeNode(node) {
9346         return ts.isTypeNodeKind(node.kind);
9347     }
9348     ts.isTypeNode = isTypeNode;
9349     function isFunctionOrConstructorTypeNode(node) {
9350         switch (node.kind) {
9351             case 174:
9352             case 175:
9353                 return true;
9354         }
9355         return false;
9356     }
9357     ts.isFunctionOrConstructorTypeNode = isFunctionOrConstructorTypeNode;
9358     function isBindingPattern(node) {
9359         if (node) {
9360             var kind = node.kind;
9361             return kind === 197
9362                 || kind === 196;
9363         }
9364         return false;
9365     }
9366     ts.isBindingPattern = isBindingPattern;
9367     function isAssignmentPattern(node) {
9368         var kind = node.kind;
9369         return kind === 199
9370             || kind === 200;
9371     }
9372     ts.isAssignmentPattern = isAssignmentPattern;
9373     function isArrayBindingElement(node) {
9374         var kind = node.kind;
9375         return kind === 198
9376             || kind === 222;
9377     }
9378     ts.isArrayBindingElement = isArrayBindingElement;
9379     function isDeclarationBindingElement(bindingElement) {
9380         switch (bindingElement.kind) {
9381             case 249:
9382             case 160:
9383             case 198:
9384                 return true;
9385         }
9386         return false;
9387     }
9388     ts.isDeclarationBindingElement = isDeclarationBindingElement;
9389     function isBindingOrAssignmentPattern(node) {
9390         return isObjectBindingOrAssignmentPattern(node)
9391             || isArrayBindingOrAssignmentPattern(node);
9392     }
9393     ts.isBindingOrAssignmentPattern = isBindingOrAssignmentPattern;
9394     function isObjectBindingOrAssignmentPattern(node) {
9395         switch (node.kind) {
9396             case 196:
9397             case 200:
9398                 return true;
9399         }
9400         return false;
9401     }
9402     ts.isObjectBindingOrAssignmentPattern = isObjectBindingOrAssignmentPattern;
9403     function isArrayBindingOrAssignmentPattern(node) {
9404         switch (node.kind) {
9405             case 197:
9406             case 199:
9407                 return true;
9408         }
9409         return false;
9410     }
9411     ts.isArrayBindingOrAssignmentPattern = isArrayBindingOrAssignmentPattern;
9412     function isPropertyAccessOrQualifiedNameOrImportTypeNode(node) {
9413         var kind = node.kind;
9414         return kind === 201
9415             || kind === 157
9416             || kind === 195;
9417     }
9418     ts.isPropertyAccessOrQualifiedNameOrImportTypeNode = isPropertyAccessOrQualifiedNameOrImportTypeNode;
9419     function isPropertyAccessOrQualifiedName(node) {
9420         var kind = node.kind;
9421         return kind === 201
9422             || kind === 157;
9423     }
9424     ts.isPropertyAccessOrQualifiedName = isPropertyAccessOrQualifiedName;
9425     function isCallLikeExpression(node) {
9426         switch (node.kind) {
9427             case 275:
9428             case 274:
9429             case 203:
9430             case 204:
9431             case 205:
9432             case 161:
9433                 return true;
9434             default:
9435                 return false;
9436         }
9437     }
9438     ts.isCallLikeExpression = isCallLikeExpression;
9439     function isCallOrNewExpression(node) {
9440         return node.kind === 203 || node.kind === 204;
9441     }
9442     ts.isCallOrNewExpression = isCallOrNewExpression;
9443     function isTemplateLiteral(node) {
9444         var kind = node.kind;
9445         return kind === 218
9446             || kind === 14;
9447     }
9448     ts.isTemplateLiteral = isTemplateLiteral;
9449     function isLeftHandSideExpression(node) {
9450         return isLeftHandSideExpressionKind(skipPartiallyEmittedExpressions(node).kind);
9451     }
9452     ts.isLeftHandSideExpression = isLeftHandSideExpression;
9453     function isLeftHandSideExpressionKind(kind) {
9454         switch (kind) {
9455             case 201:
9456             case 202:
9457             case 204:
9458             case 203:
9459             case 273:
9460             case 274:
9461             case 277:
9462             case 205:
9463             case 199:
9464             case 207:
9465             case 200:
9466             case 221:
9467             case 208:
9468             case 78:
9469             case 13:
9470             case 8:
9471             case 9:
9472             case 10:
9473             case 14:
9474             case 218:
9475             case 94:
9476             case 103:
9477             case 107:
9478             case 109:
9479             case 105:
9480             case 225:
9481             case 226:
9482             case 99:
9483                 return true;
9484             default:
9485                 return false;
9486         }
9487     }
9488     function isUnaryExpression(node) {
9489         return isUnaryExpressionKind(skipPartiallyEmittedExpressions(node).kind);
9490     }
9491     ts.isUnaryExpression = isUnaryExpression;
9492     function isUnaryExpressionKind(kind) {
9493         switch (kind) {
9494             case 214:
9495             case 215:
9496             case 210:
9497             case 211:
9498             case 212:
9499             case 213:
9500             case 206:
9501                 return true;
9502             default:
9503                 return isLeftHandSideExpressionKind(kind);
9504         }
9505     }
9506     function isUnaryExpressionWithWrite(expr) {
9507         switch (expr.kind) {
9508             case 215:
9509                 return true;
9510             case 214:
9511                 return expr.operator === 45 ||
9512                     expr.operator === 46;
9513             default:
9514                 return false;
9515         }
9516     }
9517     ts.isUnaryExpressionWithWrite = isUnaryExpressionWithWrite;
9518     function isExpression(node) {
9519         return isExpressionKind(skipPartiallyEmittedExpressions(node).kind);
9520     }
9521     ts.isExpression = isExpression;
9522     function isExpressionKind(kind) {
9523         switch (kind) {
9524             case 217:
9525             case 219:
9526             case 209:
9527             case 216:
9528             case 220:
9529             case 224:
9530             case 222:
9531             case 337:
9532             case 336:
9533                 return true;
9534             default:
9535                 return isUnaryExpressionKind(kind);
9536         }
9537     }
9538     function isAssertionExpression(node) {
9539         var kind = node.kind;
9540         return kind === 206
9541             || kind === 224;
9542     }
9543     ts.isAssertionExpression = isAssertionExpression;
9544     function isNotEmittedOrPartiallyEmittedNode(node) {
9545         return ts.isNotEmittedStatement(node)
9546             || ts.isPartiallyEmittedExpression(node);
9547     }
9548     ts.isNotEmittedOrPartiallyEmittedNode = isNotEmittedOrPartiallyEmittedNode;
9549     function isIterationStatement(node, lookInLabeledStatements) {
9550         switch (node.kind) {
9551             case 237:
9552             case 238:
9553             case 239:
9554             case 235:
9555             case 236:
9556                 return true;
9557             case 245:
9558                 return lookInLabeledStatements && isIterationStatement(node.statement, lookInLabeledStatements);
9559         }
9560         return false;
9561     }
9562     ts.isIterationStatement = isIterationStatement;
9563     function isScopeMarker(node) {
9564         return ts.isExportAssignment(node) || ts.isExportDeclaration(node);
9565     }
9566     ts.isScopeMarker = isScopeMarker;
9567     function hasScopeMarker(statements) {
9568         return ts.some(statements, isScopeMarker);
9569     }
9570     ts.hasScopeMarker = hasScopeMarker;
9571     function needsScopeMarker(result) {
9572         return !ts.isAnyImportOrReExport(result) && !ts.isExportAssignment(result) && !ts.hasSyntacticModifier(result, 1) && !ts.isAmbientModule(result);
9573     }
9574     ts.needsScopeMarker = needsScopeMarker;
9575     function isExternalModuleIndicator(result) {
9576         return ts.isAnyImportOrReExport(result) || ts.isExportAssignment(result) || ts.hasSyntacticModifier(result, 1);
9577     }
9578     ts.isExternalModuleIndicator = isExternalModuleIndicator;
9579     function isForInOrOfStatement(node) {
9580         return node.kind === 238 || node.kind === 239;
9581     }
9582     ts.isForInOrOfStatement = isForInOrOfStatement;
9583     function isConciseBody(node) {
9584         return ts.isBlock(node)
9585             || isExpression(node);
9586     }
9587     ts.isConciseBody = isConciseBody;
9588     function isFunctionBody(node) {
9589         return ts.isBlock(node);
9590     }
9591     ts.isFunctionBody = isFunctionBody;
9592     function isForInitializer(node) {
9593         return ts.isVariableDeclarationList(node)
9594             || isExpression(node);
9595     }
9596     ts.isForInitializer = isForInitializer;
9597     function isModuleBody(node) {
9598         var kind = node.kind;
9599         return kind === 257
9600             || kind === 256
9601             || kind === 78;
9602     }
9603     ts.isModuleBody = isModuleBody;
9604     function isNamespaceBody(node) {
9605         var kind = node.kind;
9606         return kind === 257
9607             || kind === 256;
9608     }
9609     ts.isNamespaceBody = isNamespaceBody;
9610     function isJSDocNamespaceBody(node) {
9611         var kind = node.kind;
9612         return kind === 78
9613             || kind === 256;
9614     }
9615     ts.isJSDocNamespaceBody = isJSDocNamespaceBody;
9616     function isNamedImportBindings(node) {
9617         var kind = node.kind;
9618         return kind === 264
9619             || kind === 263;
9620     }
9621     ts.isNamedImportBindings = isNamedImportBindings;
9622     function isModuleOrEnumDeclaration(node) {
9623         return node.kind === 256 || node.kind === 255;
9624     }
9625     ts.isModuleOrEnumDeclaration = isModuleOrEnumDeclaration;
9626     function isDeclarationKind(kind) {
9627         return kind === 209
9628             || kind === 198
9629             || kind === 252
9630             || kind === 221
9631             || kind === 166
9632             || kind === 255
9633             || kind === 291
9634             || kind === 270
9635             || kind === 251
9636             || kind === 208
9637             || kind === 167
9638             || kind === 262
9639             || kind === 260
9640             || kind === 265
9641             || kind === 253
9642             || kind === 280
9643             || kind === 165
9644             || kind === 164
9645             || kind === 256
9646             || kind === 259
9647             || kind === 263
9648             || kind === 269
9649             || kind === 160
9650             || kind === 288
9651             || kind === 163
9652             || kind === 162
9653             || kind === 168
9654             || kind === 289
9655             || kind === 254
9656             || kind === 159
9657             || kind === 249
9658             || kind === 331
9659             || kind === 324
9660             || kind === 333;
9661     }
9662     function isDeclarationStatementKind(kind) {
9663         return kind === 251
9664             || kind === 271
9665             || kind === 252
9666             || kind === 253
9667             || kind === 254
9668             || kind === 255
9669             || kind === 256
9670             || kind === 261
9671             || kind === 260
9672             || kind === 267
9673             || kind === 266
9674             || kind === 259;
9675     }
9676     function isStatementKindButNotDeclarationKind(kind) {
9677         return kind === 241
9678             || kind === 240
9679             || kind === 248
9680             || kind === 235
9681             || kind === 233
9682             || kind === 231
9683             || kind === 238
9684             || kind === 239
9685             || kind === 237
9686             || kind === 234
9687             || kind === 245
9688             || kind === 242
9689             || kind === 244
9690             || kind === 246
9691             || kind === 247
9692             || kind === 232
9693             || kind === 236
9694             || kind === 243
9695             || kind === 335
9696             || kind === 339
9697             || kind === 338;
9698     }
9699     function isDeclaration(node) {
9700         if (node.kind === 159) {
9701             return (node.parent && node.parent.kind !== 330) || ts.isInJSFile(node);
9702         }
9703         return isDeclarationKind(node.kind);
9704     }
9705     ts.isDeclaration = isDeclaration;
9706     function isDeclarationStatement(node) {
9707         return isDeclarationStatementKind(node.kind);
9708     }
9709     ts.isDeclarationStatement = isDeclarationStatement;
9710     function isStatementButNotDeclaration(node) {
9711         return isStatementKindButNotDeclarationKind(node.kind);
9712     }
9713     ts.isStatementButNotDeclaration = isStatementButNotDeclaration;
9714     function isStatement(node) {
9715         var kind = node.kind;
9716         return isStatementKindButNotDeclarationKind(kind)
9717             || isDeclarationStatementKind(kind)
9718             || isBlockStatement(node);
9719     }
9720     ts.isStatement = isStatement;
9721     function isBlockStatement(node) {
9722         if (node.kind !== 230)
9723             return false;
9724         if (node.parent !== undefined) {
9725             if (node.parent.kind === 247 || node.parent.kind === 287) {
9726                 return false;
9727             }
9728         }
9729         return !ts.isFunctionBlock(node);
9730     }
9731     function isStatementOrBlock(node) {
9732         var kind = node.kind;
9733         return isStatementKindButNotDeclarationKind(kind)
9734             || isDeclarationStatementKind(kind)
9735             || kind === 230;
9736     }
9737     ts.isStatementOrBlock = isStatementOrBlock;
9738     function isModuleReference(node) {
9739         var kind = node.kind;
9740         return kind === 272
9741             || kind === 157
9742             || kind === 78;
9743     }
9744     ts.isModuleReference = isModuleReference;
9745     function isJsxTagNameExpression(node) {
9746         var kind = node.kind;
9747         return kind === 107
9748             || kind === 78
9749             || kind === 201;
9750     }
9751     ts.isJsxTagNameExpression = isJsxTagNameExpression;
9752     function isJsxChild(node) {
9753         var kind = node.kind;
9754         return kind === 273
9755             || kind === 283
9756             || kind === 274
9757             || kind === 11
9758             || kind === 277;
9759     }
9760     ts.isJsxChild = isJsxChild;
9761     function isJsxAttributeLike(node) {
9762         var kind = node.kind;
9763         return kind === 280
9764             || kind === 282;
9765     }
9766     ts.isJsxAttributeLike = isJsxAttributeLike;
9767     function isStringLiteralOrJsxExpression(node) {
9768         var kind = node.kind;
9769         return kind === 10
9770             || kind === 283;
9771     }
9772     ts.isStringLiteralOrJsxExpression = isStringLiteralOrJsxExpression;
9773     function isJsxOpeningLikeElement(node) {
9774         var kind = node.kind;
9775         return kind === 275
9776             || kind === 274;
9777     }
9778     ts.isJsxOpeningLikeElement = isJsxOpeningLikeElement;
9779     function isCaseOrDefaultClause(node) {
9780         var kind = node.kind;
9781         return kind === 284
9782             || kind === 285;
9783     }
9784     ts.isCaseOrDefaultClause = isCaseOrDefaultClause;
9785     function isJSDocNode(node) {
9786         return node.kind >= 301 && node.kind <= 333;
9787     }
9788     ts.isJSDocNode = isJSDocNode;
9789     function isJSDocCommentContainingNode(node) {
9790         return node.kind === 311 || node.kind === 310 || isJSDocTag(node) || ts.isJSDocTypeLiteral(node) || ts.isJSDocSignature(node);
9791     }
9792     ts.isJSDocCommentContainingNode = isJSDocCommentContainingNode;
9793     function isJSDocTag(node) {
9794         return node.kind >= 314 && node.kind <= 333;
9795     }
9796     ts.isJSDocTag = isJSDocTag;
9797     function isSetAccessor(node) {
9798         return node.kind === 168;
9799     }
9800     ts.isSetAccessor = isSetAccessor;
9801     function isGetAccessor(node) {
9802         return node.kind === 167;
9803     }
9804     ts.isGetAccessor = isGetAccessor;
9805     function hasJSDocNodes(node) {
9806         var jsDoc = node.jsDoc;
9807         return !!jsDoc && jsDoc.length > 0;
9808     }
9809     ts.hasJSDocNodes = hasJSDocNodes;
9810     function hasType(node) {
9811         return !!node.type;
9812     }
9813     ts.hasType = hasType;
9814     function hasInitializer(node) {
9815         return !!node.initializer;
9816     }
9817     ts.hasInitializer = hasInitializer;
9818     function hasOnlyExpressionInitializer(node) {
9819         switch (node.kind) {
9820             case 249:
9821             case 160:
9822             case 198:
9823             case 162:
9824             case 163:
9825             case 288:
9826             case 291:
9827                 return true;
9828             default:
9829                 return false;
9830         }
9831     }
9832     ts.hasOnlyExpressionInitializer = hasOnlyExpressionInitializer;
9833     function isObjectLiteralElement(node) {
9834         return node.kind === 280 || node.kind === 282 || isObjectLiteralElementLike(node);
9835     }
9836     ts.isObjectLiteralElement = isObjectLiteralElement;
9837     function isTypeReferenceType(node) {
9838         return node.kind === 173 || node.kind === 223;
9839     }
9840     ts.isTypeReferenceType = isTypeReferenceType;
9841     var MAX_SMI_X86 = 1073741823;
9842     function guessIndentation(lines) {
9843         var indentation = MAX_SMI_X86;
9844         for (var _i = 0, lines_1 = lines; _i < lines_1.length; _i++) {
9845             var line = lines_1[_i];
9846             if (!line.length) {
9847                 continue;
9848             }
9849             var i = 0;
9850             for (; i < line.length && i < indentation; i++) {
9851                 if (!ts.isWhiteSpaceLike(line.charCodeAt(i))) {
9852                     break;
9853                 }
9854             }
9855             if (i < indentation) {
9856                 indentation = i;
9857             }
9858             if (indentation === 0) {
9859                 return 0;
9860             }
9861         }
9862         return indentation === MAX_SMI_X86 ? undefined : indentation;
9863     }
9864     ts.guessIndentation = guessIndentation;
9865     function isStringLiteralLike(node) {
9866         return node.kind === 10 || node.kind === 14;
9867     }
9868     ts.isStringLiteralLike = isStringLiteralLike;
9869 })(ts || (ts = {}));
9870 var ts;
9871 (function (ts) {
9872     ts.resolvingEmptyArray = [];
9873     ts.externalHelpersModuleNameText = "tslib";
9874     ts.defaultMaximumTruncationLength = 160;
9875     ts.noTruncationMaximumTruncationLength = 1000000;
9876     function getDeclarationOfKind(symbol, kind) {
9877         var declarations = symbol.declarations;
9878         if (declarations) {
9879             for (var _i = 0, declarations_1 = declarations; _i < declarations_1.length; _i++) {
9880                 var declaration = declarations_1[_i];
9881                 if (declaration.kind === kind) {
9882                     return declaration;
9883                 }
9884             }
9885         }
9886         return undefined;
9887     }
9888     ts.getDeclarationOfKind = getDeclarationOfKind;
9889     function createUnderscoreEscapedMap() {
9890         return new ts.Map();
9891     }
9892     ts.createUnderscoreEscapedMap = createUnderscoreEscapedMap;
9893     function hasEntries(map) {
9894         return !!map && !!map.size;
9895     }
9896     ts.hasEntries = hasEntries;
9897     function createSymbolTable(symbols) {
9898         var result = new ts.Map();
9899         if (symbols) {
9900             for (var _i = 0, symbols_1 = symbols; _i < symbols_1.length; _i++) {
9901                 var symbol = symbols_1[_i];
9902                 result.set(symbol.escapedName, symbol);
9903             }
9904         }
9905         return result;
9906     }
9907     ts.createSymbolTable = createSymbolTable;
9908     function isTransientSymbol(symbol) {
9909         return (symbol.flags & 33554432) !== 0;
9910     }
9911     ts.isTransientSymbol = isTransientSymbol;
9912     var stringWriter = createSingleLineStringWriter();
9913     function createSingleLineStringWriter() {
9914         var str = "";
9915         var writeText = function (text) { return str += text; };
9916         return {
9917             getText: function () { return str; },
9918             write: writeText,
9919             rawWrite: writeText,
9920             writeKeyword: writeText,
9921             writeOperator: writeText,
9922             writePunctuation: writeText,
9923             writeSpace: writeText,
9924             writeStringLiteral: writeText,
9925             writeLiteral: writeText,
9926             writeParameter: writeText,
9927             writeProperty: writeText,
9928             writeSymbol: function (s, _) { return writeText(s); },
9929             writeTrailingSemicolon: writeText,
9930             writeComment: writeText,
9931             getTextPos: function () { return str.length; },
9932             getLine: function () { return 0; },
9933             getColumn: function () { return 0; },
9934             getIndent: function () { return 0; },
9935             isAtStartOfLine: function () { return false; },
9936             hasTrailingComment: function () { return false; },
9937             hasTrailingWhitespace: function () { return !!str.length && ts.isWhiteSpaceLike(str.charCodeAt(str.length - 1)); },
9938             writeLine: function () { return str += " "; },
9939             increaseIndent: ts.noop,
9940             decreaseIndent: ts.noop,
9941             clear: function () { return str = ""; },
9942             trackSymbol: ts.noop,
9943             reportInaccessibleThisError: ts.noop,
9944             reportInaccessibleUniqueSymbolError: ts.noop,
9945             reportPrivateInBaseOfClassExpression: ts.noop,
9946         };
9947     }
9948     function changesAffectModuleResolution(oldOptions, newOptions) {
9949         return oldOptions.configFilePath !== newOptions.configFilePath ||
9950             optionsHaveModuleResolutionChanges(oldOptions, newOptions);
9951     }
9952     ts.changesAffectModuleResolution = changesAffectModuleResolution;
9953     function optionsHaveModuleResolutionChanges(oldOptions, newOptions) {
9954         return ts.moduleResolutionOptionDeclarations.some(function (o) {
9955             return !isJsonEqual(getCompilerOptionValue(oldOptions, o), getCompilerOptionValue(newOptions, o));
9956         });
9957     }
9958     ts.optionsHaveModuleResolutionChanges = optionsHaveModuleResolutionChanges;
9959     function forEachAncestor(node, callback) {
9960         while (true) {
9961             var res = callback(node);
9962             if (res === "quit")
9963                 return undefined;
9964             if (res !== undefined)
9965                 return res;
9966             if (ts.isSourceFile(node))
9967                 return undefined;
9968             node = node.parent;
9969         }
9970     }
9971     ts.forEachAncestor = forEachAncestor;
9972     function forEachEntry(map, callback) {
9973         var iterator = map.entries();
9974         for (var iterResult = iterator.next(); !iterResult.done; iterResult = iterator.next()) {
9975             var _a = iterResult.value, key = _a[0], value = _a[1];
9976             var result = callback(value, key);
9977             if (result) {
9978                 return result;
9979             }
9980         }
9981         return undefined;
9982     }
9983     ts.forEachEntry = forEachEntry;
9984     function forEachKey(map, callback) {
9985         var iterator = map.keys();
9986         for (var iterResult = iterator.next(); !iterResult.done; iterResult = iterator.next()) {
9987             var result = callback(iterResult.value);
9988             if (result) {
9989                 return result;
9990             }
9991         }
9992         return undefined;
9993     }
9994     ts.forEachKey = forEachKey;
9995     function copyEntries(source, target) {
9996         source.forEach(function (value, key) {
9997             target.set(key, value);
9998         });
9999     }
10000     ts.copyEntries = copyEntries;
10001     function usingSingleLineStringWriter(action) {
10002         var oldString = stringWriter.getText();
10003         try {
10004             action(stringWriter);
10005             return stringWriter.getText();
10006         }
10007         finally {
10008             stringWriter.clear();
10009             stringWriter.writeKeyword(oldString);
10010         }
10011     }
10012     ts.usingSingleLineStringWriter = usingSingleLineStringWriter;
10013     function getFullWidth(node) {
10014         return node.end - node.pos;
10015     }
10016     ts.getFullWidth = getFullWidth;
10017     function getResolvedModule(sourceFile, moduleNameText) {
10018         return sourceFile && sourceFile.resolvedModules && sourceFile.resolvedModules.get(moduleNameText);
10019     }
10020     ts.getResolvedModule = getResolvedModule;
10021     function setResolvedModule(sourceFile, moduleNameText, resolvedModule) {
10022         if (!sourceFile.resolvedModules) {
10023             sourceFile.resolvedModules = new ts.Map();
10024         }
10025         sourceFile.resolvedModules.set(moduleNameText, resolvedModule);
10026     }
10027     ts.setResolvedModule = setResolvedModule;
10028     function setResolvedTypeReferenceDirective(sourceFile, typeReferenceDirectiveName, resolvedTypeReferenceDirective) {
10029         if (!sourceFile.resolvedTypeReferenceDirectiveNames) {
10030             sourceFile.resolvedTypeReferenceDirectiveNames = new ts.Map();
10031         }
10032         sourceFile.resolvedTypeReferenceDirectiveNames.set(typeReferenceDirectiveName, resolvedTypeReferenceDirective);
10033     }
10034     ts.setResolvedTypeReferenceDirective = setResolvedTypeReferenceDirective;
10035     function projectReferenceIsEqualTo(oldRef, newRef) {
10036         return oldRef.path === newRef.path &&
10037             !oldRef.prepend === !newRef.prepend &&
10038             !oldRef.circular === !newRef.circular;
10039     }
10040     ts.projectReferenceIsEqualTo = projectReferenceIsEqualTo;
10041     function moduleResolutionIsEqualTo(oldResolution, newResolution) {
10042         return oldResolution.isExternalLibraryImport === newResolution.isExternalLibraryImport &&
10043             oldResolution.extension === newResolution.extension &&
10044             oldResolution.resolvedFileName === newResolution.resolvedFileName &&
10045             oldResolution.originalPath === newResolution.originalPath &&
10046             packageIdIsEqual(oldResolution.packageId, newResolution.packageId);
10047     }
10048     ts.moduleResolutionIsEqualTo = moduleResolutionIsEqualTo;
10049     function packageIdIsEqual(a, b) {
10050         return a === b || !!a && !!b && a.name === b.name && a.subModuleName === b.subModuleName && a.version === b.version;
10051     }
10052     function packageIdToString(_a) {
10053         var name = _a.name, subModuleName = _a.subModuleName, version = _a.version;
10054         var fullName = subModuleName ? name + "/" + subModuleName : name;
10055         return fullName + "@" + version;
10056     }
10057     ts.packageIdToString = packageIdToString;
10058     function typeDirectiveIsEqualTo(oldResolution, newResolution) {
10059         return oldResolution.resolvedFileName === newResolution.resolvedFileName && oldResolution.primary === newResolution.primary;
10060     }
10061     ts.typeDirectiveIsEqualTo = typeDirectiveIsEqualTo;
10062     function hasChangesInResolutions(names, newResolutions, oldResolutions, comparer) {
10063         ts.Debug.assert(names.length === newResolutions.length);
10064         for (var i = 0; i < names.length; i++) {
10065             var newResolution = newResolutions[i];
10066             var oldResolution = oldResolutions && oldResolutions.get(names[i]);
10067             var changed = oldResolution
10068                 ? !newResolution || !comparer(oldResolution, newResolution)
10069                 : newResolution;
10070             if (changed) {
10071                 return true;
10072             }
10073         }
10074         return false;
10075     }
10076     ts.hasChangesInResolutions = hasChangesInResolutions;
10077     function containsParseError(node) {
10078         aggregateChildData(node);
10079         return (node.flags & 262144) !== 0;
10080     }
10081     ts.containsParseError = containsParseError;
10082     function aggregateChildData(node) {
10083         if (!(node.flags & 524288)) {
10084             var thisNodeOrAnySubNodesHasError = ((node.flags & 65536) !== 0) ||
10085                 ts.forEachChild(node, containsParseError);
10086             if (thisNodeOrAnySubNodesHasError) {
10087                 node.flags |= 262144;
10088             }
10089             node.flags |= 524288;
10090         }
10091     }
10092     function getSourceFileOfNode(node) {
10093         while (node && node.kind !== 297) {
10094             node = node.parent;
10095         }
10096         return node;
10097     }
10098     ts.getSourceFileOfNode = getSourceFileOfNode;
10099     function isStatementWithLocals(node) {
10100         switch (node.kind) {
10101             case 230:
10102             case 258:
10103             case 237:
10104             case 238:
10105             case 239:
10106                 return true;
10107         }
10108         return false;
10109     }
10110     ts.isStatementWithLocals = isStatementWithLocals;
10111     function getStartPositionOfLine(line, sourceFile) {
10112         ts.Debug.assert(line >= 0);
10113         return ts.getLineStarts(sourceFile)[line];
10114     }
10115     ts.getStartPositionOfLine = getStartPositionOfLine;
10116     function nodePosToString(node) {
10117         var file = getSourceFileOfNode(node);
10118         var loc = ts.getLineAndCharacterOfPosition(file, node.pos);
10119         return file.fileName + "(" + (loc.line + 1) + "," + (loc.character + 1) + ")";
10120     }
10121     ts.nodePosToString = nodePosToString;
10122     function getEndLinePosition(line, sourceFile) {
10123         ts.Debug.assert(line >= 0);
10124         var lineStarts = ts.getLineStarts(sourceFile);
10125         var lineIndex = line;
10126         var sourceText = sourceFile.text;
10127         if (lineIndex + 1 === lineStarts.length) {
10128             return sourceText.length - 1;
10129         }
10130         else {
10131             var start = lineStarts[lineIndex];
10132             var pos = lineStarts[lineIndex + 1] - 1;
10133             ts.Debug.assert(ts.isLineBreak(sourceText.charCodeAt(pos)));
10134             while (start <= pos && ts.isLineBreak(sourceText.charCodeAt(pos))) {
10135                 pos--;
10136             }
10137             return pos;
10138         }
10139     }
10140     ts.getEndLinePosition = getEndLinePosition;
10141     function isFileLevelUniqueName(sourceFile, name, hasGlobalName) {
10142         return !(hasGlobalName && hasGlobalName(name)) && !sourceFile.identifiers.has(name);
10143     }
10144     ts.isFileLevelUniqueName = isFileLevelUniqueName;
10145     function nodeIsMissing(node) {
10146         if (node === undefined) {
10147             return true;
10148         }
10149         return node.pos === node.end && node.pos >= 0 && node.kind !== 1;
10150     }
10151     ts.nodeIsMissing = nodeIsMissing;
10152     function nodeIsPresent(node) {
10153         return !nodeIsMissing(node);
10154     }
10155     ts.nodeIsPresent = nodeIsPresent;
10156     function insertStatementsAfterPrologue(to, from, isPrologueDirective) {
10157         if (from === undefined || from.length === 0)
10158             return to;
10159         var statementIndex = 0;
10160         for (; statementIndex < to.length; ++statementIndex) {
10161             if (!isPrologueDirective(to[statementIndex])) {
10162                 break;
10163             }
10164         }
10165         to.splice.apply(to, __spreadArrays([statementIndex, 0], from));
10166         return to;
10167     }
10168     function insertStatementAfterPrologue(to, statement, isPrologueDirective) {
10169         if (statement === undefined)
10170             return to;
10171         var statementIndex = 0;
10172         for (; statementIndex < to.length; ++statementIndex) {
10173             if (!isPrologueDirective(to[statementIndex])) {
10174                 break;
10175             }
10176         }
10177         to.splice(statementIndex, 0, statement);
10178         return to;
10179     }
10180     function isAnyPrologueDirective(node) {
10181         return isPrologueDirective(node) || !!(getEmitFlags(node) & 1048576);
10182     }
10183     function insertStatementsAfterStandardPrologue(to, from) {
10184         return insertStatementsAfterPrologue(to, from, isPrologueDirective);
10185     }
10186     ts.insertStatementsAfterStandardPrologue = insertStatementsAfterStandardPrologue;
10187     function insertStatementsAfterCustomPrologue(to, from) {
10188         return insertStatementsAfterPrologue(to, from, isAnyPrologueDirective);
10189     }
10190     ts.insertStatementsAfterCustomPrologue = insertStatementsAfterCustomPrologue;
10191     function insertStatementAfterStandardPrologue(to, statement) {
10192         return insertStatementAfterPrologue(to, statement, isPrologueDirective);
10193     }
10194     ts.insertStatementAfterStandardPrologue = insertStatementAfterStandardPrologue;
10195     function insertStatementAfterCustomPrologue(to, statement) {
10196         return insertStatementAfterPrologue(to, statement, isAnyPrologueDirective);
10197     }
10198     ts.insertStatementAfterCustomPrologue = insertStatementAfterCustomPrologue;
10199     function isRecognizedTripleSlashComment(text, commentPos, commentEnd) {
10200         if (text.charCodeAt(commentPos + 1) === 47 &&
10201             commentPos + 2 < commentEnd &&
10202             text.charCodeAt(commentPos + 2) === 47) {
10203             var textSubStr = text.substring(commentPos, commentEnd);
10204             return textSubStr.match(ts.fullTripleSlashReferencePathRegEx) ||
10205                 textSubStr.match(ts.fullTripleSlashAMDReferencePathRegEx) ||
10206                 textSubStr.match(fullTripleSlashReferenceTypeReferenceDirectiveRegEx) ||
10207                 textSubStr.match(defaultLibReferenceRegEx) ?
10208                 true : false;
10209         }
10210         return false;
10211     }
10212     ts.isRecognizedTripleSlashComment = isRecognizedTripleSlashComment;
10213     function isPinnedComment(text, start) {
10214         return text.charCodeAt(start + 1) === 42 &&
10215             text.charCodeAt(start + 2) === 33;
10216     }
10217     ts.isPinnedComment = isPinnedComment;
10218     function createCommentDirectivesMap(sourceFile, commentDirectives) {
10219         var directivesByLine = new ts.Map(commentDirectives.map(function (commentDirective) { return ([
10220             "" + ts.getLineAndCharacterOfPosition(sourceFile, commentDirective.range.end).line,
10221             commentDirective,
10222         ]); }));
10223         var usedLines = new ts.Map();
10224         return { getUnusedExpectations: getUnusedExpectations, markUsed: markUsed };
10225         function getUnusedExpectations() {
10226             return ts.arrayFrom(directivesByLine.entries())
10227                 .filter(function (_a) {
10228                 var line = _a[0], directive = _a[1];
10229                 return directive.type === 0 && !usedLines.get(line);
10230             })
10231                 .map(function (_a) {
10232                 var _ = _a[0], directive = _a[1];
10233                 return directive;
10234             });
10235         }
10236         function markUsed(line) {
10237             if (!directivesByLine.has("" + line)) {
10238                 return false;
10239             }
10240             usedLines.set("" + line, true);
10241             return true;
10242         }
10243     }
10244     ts.createCommentDirectivesMap = createCommentDirectivesMap;
10245     function getTokenPosOfNode(node, sourceFile, includeJsDoc) {
10246         if (nodeIsMissing(node)) {
10247             return node.pos;
10248         }
10249         if (ts.isJSDocNode(node) || node.kind === 11) {
10250             return ts.skipTrivia((sourceFile || getSourceFileOfNode(node)).text, node.pos, false, true);
10251         }
10252         if (includeJsDoc && ts.hasJSDocNodes(node)) {
10253             return getTokenPosOfNode(node.jsDoc[0], sourceFile);
10254         }
10255         if (node.kind === 334 && node._children.length > 0) {
10256             return getTokenPosOfNode(node._children[0], sourceFile, includeJsDoc);
10257         }
10258         return ts.skipTrivia((sourceFile || getSourceFileOfNode(node)).text, node.pos);
10259     }
10260     ts.getTokenPosOfNode = getTokenPosOfNode;
10261     function getNonDecoratorTokenPosOfNode(node, sourceFile) {
10262         if (nodeIsMissing(node) || !node.decorators) {
10263             return getTokenPosOfNode(node, sourceFile);
10264         }
10265         return ts.skipTrivia((sourceFile || getSourceFileOfNode(node)).text, node.decorators.end);
10266     }
10267     ts.getNonDecoratorTokenPosOfNode = getNonDecoratorTokenPosOfNode;
10268     function getSourceTextOfNodeFromSourceFile(sourceFile, node, includeTrivia) {
10269         if (includeTrivia === void 0) { includeTrivia = false; }
10270         return getTextOfNodeFromSourceText(sourceFile.text, node, includeTrivia);
10271     }
10272     ts.getSourceTextOfNodeFromSourceFile = getSourceTextOfNodeFromSourceFile;
10273     function isJSDocTypeExpressionOrChild(node) {
10274         return !!ts.findAncestor(node, ts.isJSDocTypeExpression);
10275     }
10276     function isExportNamespaceAsDefaultDeclaration(node) {
10277         return !!(ts.isExportDeclaration(node) && node.exportClause && ts.isNamespaceExport(node.exportClause) && node.exportClause.name.escapedText === "default");
10278     }
10279     ts.isExportNamespaceAsDefaultDeclaration = isExportNamespaceAsDefaultDeclaration;
10280     function getTextOfNodeFromSourceText(sourceText, node, includeTrivia) {
10281         if (includeTrivia === void 0) { includeTrivia = false; }
10282         if (nodeIsMissing(node)) {
10283             return "";
10284         }
10285         var text = sourceText.substring(includeTrivia ? node.pos : ts.skipTrivia(sourceText, node.pos), node.end);
10286         if (isJSDocTypeExpressionOrChild(node)) {
10287             text = text.replace(/(^|\r?\n|\r)\s*\*\s*/g, "$1");
10288         }
10289         return text;
10290     }
10291     ts.getTextOfNodeFromSourceText = getTextOfNodeFromSourceText;
10292     function getTextOfNode(node, includeTrivia) {
10293         if (includeTrivia === void 0) { includeTrivia = false; }
10294         return getSourceTextOfNodeFromSourceFile(getSourceFileOfNode(node), node, includeTrivia);
10295     }
10296     ts.getTextOfNode = getTextOfNode;
10297     function getPos(range) {
10298         return range.pos;
10299     }
10300     function indexOfNode(nodeArray, node) {
10301         return ts.binarySearch(nodeArray, node, getPos, ts.compareValues);
10302     }
10303     ts.indexOfNode = indexOfNode;
10304     function getEmitFlags(node) {
10305         var emitNode = node.emitNode;
10306         return emitNode && emitNode.flags || 0;
10307     }
10308     ts.getEmitFlags = getEmitFlags;
10309     ;
10310     function getScriptTargetFeatures() {
10311         return {
10312             es2015: {
10313                 Array: ["find", "findIndex", "fill", "copyWithin", "entries", "keys", "values"],
10314                 RegExp: ["flags", "sticky", "unicode"],
10315                 Reflect: ["apply", "construct", "defineProperty", "deleteProperty", "get", " getOwnPropertyDescriptor", "getPrototypeOf", "has", "isExtensible", "ownKeys", "preventExtensions", "set", "setPrototypeOf"],
10316                 ArrayConstructor: ["from", "of"],
10317                 ObjectConstructor: ["assign", "getOwnPropertySymbols", "keys", "is", "setPrototypeOf"],
10318                 NumberConstructor: ["isFinite", "isInteger", "isNaN", "isSafeInteger", "parseFloat", "parseInt"],
10319                 Math: ["clz32", "imul", "sign", "log10", "log2", "log1p", "expm1", "cosh", "sinh", "tanh", "acosh", "asinh", "atanh", "hypot", "trunc", "fround", "cbrt"],
10320                 Map: ["entries", "keys", "values"],
10321                 Set: ["entries", "keys", "values"],
10322                 Promise: ts.emptyArray,
10323                 PromiseConstructor: ["all", "race", "reject", "resolve"],
10324                 Symbol: ["for", "keyFor"],
10325                 WeakMap: ["entries", "keys", "values"],
10326                 WeakSet: ["entries", "keys", "values"],
10327                 Iterator: ts.emptyArray,
10328                 AsyncIterator: ts.emptyArray,
10329                 String: ["codePointAt", "includes", "endsWith", "normalize", "repeat", "startsWith", "anchor", "big", "blink", "bold", "fixed", "fontcolor", "fontsize", "italics", "link", "small", "strike", "sub", "sup"],
10330                 StringConstructor: ["fromCodePoint", "raw"]
10331             },
10332             es2016: {
10333                 Array: ["includes"]
10334             },
10335             es2017: {
10336                 Atomics: ts.emptyArray,
10337                 SharedArrayBuffer: ts.emptyArray,
10338                 String: ["padStart", "padEnd"],
10339                 ObjectConstructor: ["values", "entries", "getOwnPropertyDescriptors"],
10340                 DateTimeFormat: ["formatToParts"]
10341             },
10342             es2018: {
10343                 Promise: ["finally"],
10344                 RegExpMatchArray: ["groups"],
10345                 RegExpExecArray: ["groups"],
10346                 RegExp: ["dotAll"],
10347                 Intl: ["PluralRules"],
10348                 AsyncIterable: ts.emptyArray,
10349                 AsyncIterableIterator: ts.emptyArray,
10350                 AsyncGenerator: ts.emptyArray,
10351                 AsyncGeneratorFunction: ts.emptyArray,
10352             },
10353             es2019: {
10354                 Array: ["flat", "flatMap"],
10355                 ObjectConstructor: ["fromEntries"],
10356                 String: ["trimStart", "trimEnd", "trimLeft", "trimRight"],
10357                 Symbol: ["description"]
10358             },
10359             es2020: {
10360                 BigInt: ts.emptyArray,
10361                 BigInt64Array: ts.emptyArray,
10362                 BigUint64Array: ts.emptyArray,
10363                 PromiseConstructor: ["allSettled"],
10364                 SymbolConstructor: ["matchAll"],
10365                 String: ["matchAll"],
10366                 DataView: ["setBigInt64", "setBigUint64", "getBigInt64", "getBigUint64"],
10367                 RelativeTimeFormat: ["format", "formatToParts", "resolvedOptions"]
10368             },
10369             esnext: {
10370                 PromiseConstructor: ["any"],
10371                 String: ["replaceAll"],
10372                 NumberFormat: ["formatToParts"]
10373             }
10374         };
10375     }
10376     ts.getScriptTargetFeatures = getScriptTargetFeatures;
10377     function getLiteralText(node, sourceFile, flags) {
10378         if (!nodeIsSynthesized(node) && node.parent && !(flags & 4 && node.isUnterminated) && !((ts.isNumericLiteral(node) && node.numericLiteralFlags & 512) ||
10379             ts.isBigIntLiteral(node))) {
10380             return getSourceTextOfNodeFromSourceFile(sourceFile, node);
10381         }
10382         switch (node.kind) {
10383             case 10: {
10384                 var escapeText = flags & 2 ? escapeJsxAttributeString :
10385                     flags & 1 || (getEmitFlags(node) & 16777216) ? escapeString :
10386                         escapeNonAsciiString;
10387                 if (node.singleQuote) {
10388                     return "'" + escapeText(node.text, 39) + "'";
10389                 }
10390                 else {
10391                     return '"' + escapeText(node.text, 34) + '"';
10392                 }
10393             }
10394             case 14:
10395             case 15:
10396             case 16:
10397             case 17: {
10398                 var escapeText = flags & 1 || (getEmitFlags(node) & 16777216) ? escapeString :
10399                     escapeNonAsciiString;
10400                 var rawText = node.rawText || escapeTemplateSubstitution(escapeText(node.text, 96));
10401                 switch (node.kind) {
10402                     case 14:
10403                         return "`" + rawText + "`";
10404                     case 15:
10405                         return "`" + rawText + "${";
10406                     case 16:
10407                         return "}" + rawText + "${";
10408                     case 17:
10409                         return "}" + rawText + "`";
10410                 }
10411                 break;
10412             }
10413             case 8:
10414             case 9:
10415                 return node.text;
10416             case 13:
10417                 if (flags & 4 && node.isUnterminated) {
10418                     return node.text + (node.text.charCodeAt(node.text.length - 1) === 92 ? " /" : "/");
10419                 }
10420                 return node.text;
10421         }
10422         return ts.Debug.fail("Literal kind '" + node.kind + "' not accounted for.");
10423     }
10424     ts.getLiteralText = getLiteralText;
10425     function getTextOfConstantValue(value) {
10426         return ts.isString(value) ? '"' + escapeNonAsciiString(value) + '"' : "" + value;
10427     }
10428     ts.getTextOfConstantValue = getTextOfConstantValue;
10429     function makeIdentifierFromModuleName(moduleName) {
10430         return ts.getBaseFileName(moduleName).replace(/^(\d)/, "_$1").replace(/\W/g, "_");
10431     }
10432     ts.makeIdentifierFromModuleName = makeIdentifierFromModuleName;
10433     function isBlockOrCatchScoped(declaration) {
10434         return (ts.getCombinedNodeFlags(declaration) & 3) !== 0 ||
10435             isCatchClauseVariableDeclarationOrBindingElement(declaration);
10436     }
10437     ts.isBlockOrCatchScoped = isBlockOrCatchScoped;
10438     function isCatchClauseVariableDeclarationOrBindingElement(declaration) {
10439         var node = getRootDeclaration(declaration);
10440         return node.kind === 249 && node.parent.kind === 287;
10441     }
10442     ts.isCatchClauseVariableDeclarationOrBindingElement = isCatchClauseVariableDeclarationOrBindingElement;
10443     function isAmbientModule(node) {
10444         return ts.isModuleDeclaration(node) && (node.name.kind === 10 || isGlobalScopeAugmentation(node));
10445     }
10446     ts.isAmbientModule = isAmbientModule;
10447     function isModuleWithStringLiteralName(node) {
10448         return ts.isModuleDeclaration(node) && node.name.kind === 10;
10449     }
10450     ts.isModuleWithStringLiteralName = isModuleWithStringLiteralName;
10451     function isNonGlobalAmbientModule(node) {
10452         return ts.isModuleDeclaration(node) && ts.isStringLiteral(node.name);
10453     }
10454     ts.isNonGlobalAmbientModule = isNonGlobalAmbientModule;
10455     function isEffectiveModuleDeclaration(node) {
10456         return ts.isModuleDeclaration(node) || ts.isIdentifier(node);
10457     }
10458     ts.isEffectiveModuleDeclaration = isEffectiveModuleDeclaration;
10459     function isShorthandAmbientModuleSymbol(moduleSymbol) {
10460         return isShorthandAmbientModule(moduleSymbol.valueDeclaration);
10461     }
10462     ts.isShorthandAmbientModuleSymbol = isShorthandAmbientModuleSymbol;
10463     function isShorthandAmbientModule(node) {
10464         return node && node.kind === 256 && (!node.body);
10465     }
10466     function isBlockScopedContainerTopLevel(node) {
10467         return node.kind === 297 ||
10468             node.kind === 256 ||
10469             ts.isFunctionLike(node);
10470     }
10471     ts.isBlockScopedContainerTopLevel = isBlockScopedContainerTopLevel;
10472     function isGlobalScopeAugmentation(module) {
10473         return !!(module.flags & 1024);
10474     }
10475     ts.isGlobalScopeAugmentation = isGlobalScopeAugmentation;
10476     function isExternalModuleAugmentation(node) {
10477         return isAmbientModule(node) && isModuleAugmentationExternal(node);
10478     }
10479     ts.isExternalModuleAugmentation = isExternalModuleAugmentation;
10480     function isModuleAugmentationExternal(node) {
10481         switch (node.parent.kind) {
10482             case 297:
10483                 return ts.isExternalModule(node.parent);
10484             case 257:
10485                 return isAmbientModule(node.parent.parent) && ts.isSourceFile(node.parent.parent.parent) && !ts.isExternalModule(node.parent.parent.parent);
10486         }
10487         return false;
10488     }
10489     ts.isModuleAugmentationExternal = isModuleAugmentationExternal;
10490     function getNonAugmentationDeclaration(symbol) {
10491         return ts.find(symbol.declarations, function (d) { return !isExternalModuleAugmentation(d) && !(ts.isModuleDeclaration(d) && isGlobalScopeAugmentation(d)); });
10492     }
10493     ts.getNonAugmentationDeclaration = getNonAugmentationDeclaration;
10494     function isEffectiveExternalModule(node, compilerOptions) {
10495         return ts.isExternalModule(node) || compilerOptions.isolatedModules || ((getEmitModuleKind(compilerOptions) === ts.ModuleKind.CommonJS) && !!node.commonJsModuleIndicator);
10496     }
10497     ts.isEffectiveExternalModule = isEffectiveExternalModule;
10498     function isEffectiveStrictModeSourceFile(node, compilerOptions) {
10499         switch (node.scriptKind) {
10500             case 1:
10501             case 3:
10502             case 2:
10503             case 4:
10504                 break;
10505             default:
10506                 return false;
10507         }
10508         if (node.isDeclarationFile) {
10509             return false;
10510         }
10511         if (getStrictOptionValue(compilerOptions, "alwaysStrict")) {
10512             return true;
10513         }
10514         if (ts.startsWithUseStrict(node.statements)) {
10515             return true;
10516         }
10517         if (ts.isExternalModule(node) || compilerOptions.isolatedModules) {
10518             if (getEmitModuleKind(compilerOptions) >= ts.ModuleKind.ES2015) {
10519                 return true;
10520             }
10521             return !compilerOptions.noImplicitUseStrict;
10522         }
10523         return false;
10524     }
10525     ts.isEffectiveStrictModeSourceFile = isEffectiveStrictModeSourceFile;
10526     function isBlockScope(node, parentNode) {
10527         switch (node.kind) {
10528             case 297:
10529             case 258:
10530             case 287:
10531             case 256:
10532             case 237:
10533             case 238:
10534             case 239:
10535             case 166:
10536             case 165:
10537             case 167:
10538             case 168:
10539             case 251:
10540             case 208:
10541             case 209:
10542                 return true;
10543             case 230:
10544                 return !ts.isFunctionLike(parentNode);
10545         }
10546         return false;
10547     }
10548     ts.isBlockScope = isBlockScope;
10549     function isDeclarationWithTypeParameters(node) {
10550         switch (node.kind) {
10551             case 324:
10552             case 331:
10553             case 313:
10554                 return true;
10555             default:
10556                 ts.assertType(node);
10557                 return isDeclarationWithTypeParameterChildren(node);
10558         }
10559     }
10560     ts.isDeclarationWithTypeParameters = isDeclarationWithTypeParameters;
10561     function isDeclarationWithTypeParameterChildren(node) {
10562         switch (node.kind) {
10563             case 169:
10564             case 170:
10565             case 164:
10566             case 171:
10567             case 174:
10568             case 175:
10569             case 308:
10570             case 252:
10571             case 221:
10572             case 253:
10573             case 254:
10574             case 330:
10575             case 251:
10576             case 165:
10577             case 166:
10578             case 167:
10579             case 168:
10580             case 208:
10581             case 209:
10582                 return true;
10583             default:
10584                 ts.assertType(node);
10585                 return false;
10586         }
10587     }
10588     ts.isDeclarationWithTypeParameterChildren = isDeclarationWithTypeParameterChildren;
10589     function isAnyImportSyntax(node) {
10590         switch (node.kind) {
10591             case 261:
10592             case 260:
10593                 return true;
10594             default:
10595                 return false;
10596         }
10597     }
10598     ts.isAnyImportSyntax = isAnyImportSyntax;
10599     function isLateVisibilityPaintedStatement(node) {
10600         switch (node.kind) {
10601             case 261:
10602             case 260:
10603             case 232:
10604             case 252:
10605             case 251:
10606             case 256:
10607             case 254:
10608             case 253:
10609             case 255:
10610                 return true;
10611             default:
10612                 return false;
10613         }
10614     }
10615     ts.isLateVisibilityPaintedStatement = isLateVisibilityPaintedStatement;
10616     function isAnyImportOrReExport(node) {
10617         return isAnyImportSyntax(node) || ts.isExportDeclaration(node);
10618     }
10619     ts.isAnyImportOrReExport = isAnyImportOrReExport;
10620     function getEnclosingBlockScopeContainer(node) {
10621         return ts.findAncestor(node.parent, function (current) { return isBlockScope(current, current.parent); });
10622     }
10623     ts.getEnclosingBlockScopeContainer = getEnclosingBlockScopeContainer;
10624     function declarationNameToString(name) {
10625         return !name || getFullWidth(name) === 0 ? "(Missing)" : getTextOfNode(name);
10626     }
10627     ts.declarationNameToString = declarationNameToString;
10628     function getNameFromIndexInfo(info) {
10629         return info.declaration ? declarationNameToString(info.declaration.parameters[0].name) : undefined;
10630     }
10631     ts.getNameFromIndexInfo = getNameFromIndexInfo;
10632     function isComputedNonLiteralName(name) {
10633         return name.kind === 158 && !isStringOrNumericLiteralLike(name.expression);
10634     }
10635     ts.isComputedNonLiteralName = isComputedNonLiteralName;
10636     function getTextOfPropertyName(name) {
10637         switch (name.kind) {
10638             case 78:
10639             case 79:
10640                 return name.escapedText;
10641             case 10:
10642             case 8:
10643             case 14:
10644                 return ts.escapeLeadingUnderscores(name.text);
10645             case 158:
10646                 if (isStringOrNumericLiteralLike(name.expression))
10647                     return ts.escapeLeadingUnderscores(name.expression.text);
10648                 return ts.Debug.fail("Text of property name cannot be read from non-literal-valued ComputedPropertyNames");
10649             default:
10650                 return ts.Debug.assertNever(name);
10651         }
10652     }
10653     ts.getTextOfPropertyName = getTextOfPropertyName;
10654     function entityNameToString(name) {
10655         switch (name.kind) {
10656             case 107:
10657                 return "this";
10658             case 79:
10659             case 78:
10660                 return getFullWidth(name) === 0 ? ts.idText(name) : getTextOfNode(name);
10661             case 157:
10662                 return entityNameToString(name.left) + "." + entityNameToString(name.right);
10663             case 201:
10664                 if (ts.isIdentifier(name.name) || ts.isPrivateIdentifier(name.name)) {
10665                     return entityNameToString(name.expression) + "." + entityNameToString(name.name);
10666                 }
10667                 else {
10668                     return ts.Debug.assertNever(name.name);
10669                 }
10670             default:
10671                 return ts.Debug.assertNever(name);
10672         }
10673     }
10674     ts.entityNameToString = entityNameToString;
10675     function createDiagnosticForNode(node, message, arg0, arg1, arg2, arg3) {
10676         var sourceFile = getSourceFileOfNode(node);
10677         return createDiagnosticForNodeInSourceFile(sourceFile, node, message, arg0, arg1, arg2, arg3);
10678     }
10679     ts.createDiagnosticForNode = createDiagnosticForNode;
10680     function createDiagnosticForNodeArray(sourceFile, nodes, message, arg0, arg1, arg2, arg3) {
10681         var start = ts.skipTrivia(sourceFile.text, nodes.pos);
10682         return createFileDiagnostic(sourceFile, start, nodes.end - start, message, arg0, arg1, arg2, arg3);
10683     }
10684     ts.createDiagnosticForNodeArray = createDiagnosticForNodeArray;
10685     function createDiagnosticForNodeInSourceFile(sourceFile, node, message, arg0, arg1, arg2, arg3) {
10686         var span = getErrorSpanForNode(sourceFile, node);
10687         return createFileDiagnostic(sourceFile, span.start, span.length, message, arg0, arg1, arg2, arg3);
10688     }
10689     ts.createDiagnosticForNodeInSourceFile = createDiagnosticForNodeInSourceFile;
10690     function createDiagnosticForNodeFromMessageChain(node, messageChain, relatedInformation) {
10691         var sourceFile = getSourceFileOfNode(node);
10692         var span = getErrorSpanForNode(sourceFile, node);
10693         return {
10694             file: sourceFile,
10695             start: span.start,
10696             length: span.length,
10697             code: messageChain.code,
10698             category: messageChain.category,
10699             messageText: messageChain.next ? messageChain : messageChain.messageText,
10700             relatedInformation: relatedInformation
10701         };
10702     }
10703     ts.createDiagnosticForNodeFromMessageChain = createDiagnosticForNodeFromMessageChain;
10704     function createDiagnosticForFileFromMessageChain(sourceFile, messageChain, relatedInformation) {
10705         return {
10706             file: sourceFile,
10707             start: 0,
10708             length: 0,
10709             code: messageChain.code,
10710             category: messageChain.category,
10711             messageText: messageChain.next ? messageChain : messageChain.messageText,
10712             relatedInformation: relatedInformation
10713         };
10714     }
10715     ts.createDiagnosticForFileFromMessageChain = createDiagnosticForFileFromMessageChain;
10716     function createDiagnosticForRange(sourceFile, range, message) {
10717         return {
10718             file: sourceFile,
10719             start: range.pos,
10720             length: range.end - range.pos,
10721             code: message.code,
10722             category: message.category,
10723             messageText: message.message,
10724         };
10725     }
10726     ts.createDiagnosticForRange = createDiagnosticForRange;
10727     function getSpanOfTokenAtPosition(sourceFile, pos) {
10728         var scanner = ts.createScanner(sourceFile.languageVersion, true, sourceFile.languageVariant, sourceFile.text, undefined, pos);
10729         scanner.scan();
10730         var start = scanner.getTokenPos();
10731         return ts.createTextSpanFromBounds(start, scanner.getTextPos());
10732     }
10733     ts.getSpanOfTokenAtPosition = getSpanOfTokenAtPosition;
10734     function getErrorSpanForArrowFunction(sourceFile, node) {
10735         var pos = ts.skipTrivia(sourceFile.text, node.pos);
10736         if (node.body && node.body.kind === 230) {
10737             var startLine = ts.getLineAndCharacterOfPosition(sourceFile, node.body.pos).line;
10738             var endLine = ts.getLineAndCharacterOfPosition(sourceFile, node.body.end).line;
10739             if (startLine < endLine) {
10740                 return ts.createTextSpan(pos, getEndLinePosition(startLine, sourceFile) - pos + 1);
10741             }
10742         }
10743         return ts.createTextSpanFromBounds(pos, node.end);
10744     }
10745     function getErrorSpanForNode(sourceFile, node) {
10746         var errorNode = node;
10747         switch (node.kind) {
10748             case 297:
10749                 var pos_1 = ts.skipTrivia(sourceFile.text, 0, false);
10750                 if (pos_1 === sourceFile.text.length) {
10751                     return ts.createTextSpan(0, 0);
10752                 }
10753                 return getSpanOfTokenAtPosition(sourceFile, pos_1);
10754             case 249:
10755             case 198:
10756             case 252:
10757             case 221:
10758             case 253:
10759             case 256:
10760             case 255:
10761             case 291:
10762             case 251:
10763             case 208:
10764             case 165:
10765             case 167:
10766             case 168:
10767             case 254:
10768             case 163:
10769             case 162:
10770                 errorNode = node.name;
10771                 break;
10772             case 209:
10773                 return getErrorSpanForArrowFunction(sourceFile, node);
10774             case 284:
10775             case 285:
10776                 var start = ts.skipTrivia(sourceFile.text, node.pos);
10777                 var end = node.statements.length > 0 ? node.statements[0].pos : node.end;
10778                 return ts.createTextSpanFromBounds(start, end);
10779         }
10780         if (errorNode === undefined) {
10781             return getSpanOfTokenAtPosition(sourceFile, node.pos);
10782         }
10783         ts.Debug.assert(!ts.isJSDoc(errorNode));
10784         var isMissing = nodeIsMissing(errorNode);
10785         var pos = isMissing || ts.isJsxText(node)
10786             ? errorNode.pos
10787             : ts.skipTrivia(sourceFile.text, errorNode.pos);
10788         if (isMissing) {
10789             ts.Debug.assert(pos === errorNode.pos, "This failure could trigger https://github.com/Microsoft/TypeScript/issues/20809");
10790             ts.Debug.assert(pos === errorNode.end, "This failure could trigger https://github.com/Microsoft/TypeScript/issues/20809");
10791         }
10792         else {
10793             ts.Debug.assert(pos >= errorNode.pos, "This failure could trigger https://github.com/Microsoft/TypeScript/issues/20809");
10794             ts.Debug.assert(pos <= errorNode.end, "This failure could trigger https://github.com/Microsoft/TypeScript/issues/20809");
10795         }
10796         return ts.createTextSpanFromBounds(pos, errorNode.end);
10797     }
10798     ts.getErrorSpanForNode = getErrorSpanForNode;
10799     function isExternalOrCommonJsModule(file) {
10800         return (file.externalModuleIndicator || file.commonJsModuleIndicator) !== undefined;
10801     }
10802     ts.isExternalOrCommonJsModule = isExternalOrCommonJsModule;
10803     function isJsonSourceFile(file) {
10804         return file.scriptKind === 6;
10805     }
10806     ts.isJsonSourceFile = isJsonSourceFile;
10807     function isEnumConst(node) {
10808         return !!(ts.getCombinedModifierFlags(node) & 2048);
10809     }
10810     ts.isEnumConst = isEnumConst;
10811     function isDeclarationReadonly(declaration) {
10812         return !!(ts.getCombinedModifierFlags(declaration) & 64 && !ts.isParameterPropertyDeclaration(declaration, declaration.parent));
10813     }
10814     ts.isDeclarationReadonly = isDeclarationReadonly;
10815     function isVarConst(node) {
10816         return !!(ts.getCombinedNodeFlags(node) & 2);
10817     }
10818     ts.isVarConst = isVarConst;
10819     function isLet(node) {
10820         return !!(ts.getCombinedNodeFlags(node) & 1);
10821     }
10822     ts.isLet = isLet;
10823     function isSuperCall(n) {
10824         return n.kind === 203 && n.expression.kind === 105;
10825     }
10826     ts.isSuperCall = isSuperCall;
10827     function isImportCall(n) {
10828         return n.kind === 203 && n.expression.kind === 99;
10829     }
10830     ts.isImportCall = isImportCall;
10831     function isImportMeta(n) {
10832         return ts.isMetaProperty(n)
10833             && n.keywordToken === 99
10834             && n.name.escapedText === "meta";
10835     }
10836     ts.isImportMeta = isImportMeta;
10837     function isLiteralImportTypeNode(n) {
10838         return ts.isImportTypeNode(n) && ts.isLiteralTypeNode(n.argument) && ts.isStringLiteral(n.argument.literal);
10839     }
10840     ts.isLiteralImportTypeNode = isLiteralImportTypeNode;
10841     function isPrologueDirective(node) {
10842         return node.kind === 233
10843             && node.expression.kind === 10;
10844     }
10845     ts.isPrologueDirective = isPrologueDirective;
10846     function isCustomPrologue(node) {
10847         return !!(getEmitFlags(node) & 1048576);
10848     }
10849     ts.isCustomPrologue = isCustomPrologue;
10850     function isHoistedFunction(node) {
10851         return isCustomPrologue(node)
10852             && ts.isFunctionDeclaration(node);
10853     }
10854     ts.isHoistedFunction = isHoistedFunction;
10855     function isHoistedVariable(node) {
10856         return ts.isIdentifier(node.name)
10857             && !node.initializer;
10858     }
10859     function isHoistedVariableStatement(node) {
10860         return isCustomPrologue(node)
10861             && ts.isVariableStatement(node)
10862             && ts.every(node.declarationList.declarations, isHoistedVariable);
10863     }
10864     ts.isHoistedVariableStatement = isHoistedVariableStatement;
10865     function getLeadingCommentRangesOfNode(node, sourceFileOfNode) {
10866         return node.kind !== 11 ? ts.getLeadingCommentRanges(sourceFileOfNode.text, node.pos) : undefined;
10867     }
10868     ts.getLeadingCommentRangesOfNode = getLeadingCommentRangesOfNode;
10869     function getJSDocCommentRanges(node, text) {
10870         var commentRanges = (node.kind === 160 ||
10871             node.kind === 159 ||
10872             node.kind === 208 ||
10873             node.kind === 209 ||
10874             node.kind === 207) ?
10875             ts.concatenate(ts.getTrailingCommentRanges(text, node.pos), ts.getLeadingCommentRanges(text, node.pos)) :
10876             ts.getLeadingCommentRanges(text, node.pos);
10877         return ts.filter(commentRanges, function (comment) {
10878             return text.charCodeAt(comment.pos + 1) === 42 &&
10879                 text.charCodeAt(comment.pos + 2) === 42 &&
10880                 text.charCodeAt(comment.pos + 3) !== 47;
10881         });
10882     }
10883     ts.getJSDocCommentRanges = getJSDocCommentRanges;
10884     ts.fullTripleSlashReferencePathRegEx = /^(\/\/\/\s*<reference\s+path\s*=\s*)('|")(.+?)\2.*?\/>/;
10885     var fullTripleSlashReferenceTypeReferenceDirectiveRegEx = /^(\/\/\/\s*<reference\s+types\s*=\s*)('|")(.+?)\2.*?\/>/;
10886     ts.fullTripleSlashAMDReferencePathRegEx = /^(\/\/\/\s*<amd-dependency\s+path\s*=\s*)('|")(.+?)\2.*?\/>/;
10887     var defaultLibReferenceRegEx = /^(\/\/\/\s*<reference\s+no-default-lib\s*=\s*)('|")(.+?)\2\s*\/>/;
10888     function isPartOfTypeNode(node) {
10889         if (172 <= node.kind && node.kind <= 195) {
10890             return true;
10891         }
10892         switch (node.kind) {
10893             case 128:
10894             case 152:
10895             case 144:
10896             case 155:
10897             case 147:
10898             case 131:
10899             case 148:
10900             case 145:
10901             case 150:
10902             case 141:
10903                 return true;
10904             case 113:
10905                 return node.parent.kind !== 212;
10906             case 223:
10907                 return !isExpressionWithTypeArgumentsInClassExtendsClause(node);
10908             case 159:
10909                 return node.parent.kind === 190 || node.parent.kind === 185;
10910             case 78:
10911                 if (node.parent.kind === 157 && node.parent.right === node) {
10912                     node = node.parent;
10913                 }
10914                 else if (node.parent.kind === 201 && node.parent.name === node) {
10915                     node = node.parent;
10916                 }
10917                 ts.Debug.assert(node.kind === 78 || node.kind === 157 || node.kind === 201, "'node' was expected to be a qualified name, identifier or property access in 'isPartOfTypeNode'.");
10918             case 157:
10919             case 201:
10920             case 107: {
10921                 var parent = node.parent;
10922                 if (parent.kind === 176) {
10923                     return false;
10924                 }
10925                 if (parent.kind === 195) {
10926                     return !parent.isTypeOf;
10927                 }
10928                 if (172 <= parent.kind && parent.kind <= 195) {
10929                     return true;
10930                 }
10931                 switch (parent.kind) {
10932                     case 223:
10933                         return !isExpressionWithTypeArgumentsInClassExtendsClause(parent);
10934                     case 159:
10935                         return node === parent.constraint;
10936                     case 330:
10937                         return node === parent.constraint;
10938                     case 163:
10939                     case 162:
10940                     case 160:
10941                     case 249:
10942                         return node === parent.type;
10943                     case 251:
10944                     case 208:
10945                     case 209:
10946                     case 166:
10947                     case 165:
10948                     case 164:
10949                     case 167:
10950                     case 168:
10951                         return node === parent.type;
10952                     case 169:
10953                     case 170:
10954                     case 171:
10955                         return node === parent.type;
10956                     case 206:
10957                         return node === parent.type;
10958                     case 203:
10959                     case 204:
10960                         return ts.contains(parent.typeArguments, node);
10961                     case 205:
10962                         return false;
10963                 }
10964             }
10965         }
10966         return false;
10967     }
10968     ts.isPartOfTypeNode = isPartOfTypeNode;
10969     function isChildOfNodeWithKind(node, kind) {
10970         while (node) {
10971             if (node.kind === kind) {
10972                 return true;
10973             }
10974             node = node.parent;
10975         }
10976         return false;
10977     }
10978     ts.isChildOfNodeWithKind = isChildOfNodeWithKind;
10979     function forEachReturnStatement(body, visitor) {
10980         return traverse(body);
10981         function traverse(node) {
10982             switch (node.kind) {
10983                 case 242:
10984                     return visitor(node);
10985                 case 258:
10986                 case 230:
10987                 case 234:
10988                 case 235:
10989                 case 236:
10990                 case 237:
10991                 case 238:
10992                 case 239:
10993                 case 243:
10994                 case 244:
10995                 case 284:
10996                 case 285:
10997                 case 245:
10998                 case 247:
10999                 case 287:
11000                     return ts.forEachChild(node, traverse);
11001             }
11002         }
11003     }
11004     ts.forEachReturnStatement = forEachReturnStatement;
11005     function forEachYieldExpression(body, visitor) {
11006         return traverse(body);
11007         function traverse(node) {
11008             switch (node.kind) {
11009                 case 219:
11010                     visitor(node);
11011                     var operand = node.expression;
11012                     if (operand) {
11013                         traverse(operand);
11014                     }
11015                     return;
11016                 case 255:
11017                 case 253:
11018                 case 256:
11019                 case 254:
11020                     return;
11021                 default:
11022                     if (ts.isFunctionLike(node)) {
11023                         if (node.name && node.name.kind === 158) {
11024                             traverse(node.name.expression);
11025                             return;
11026                         }
11027                     }
11028                     else if (!isPartOfTypeNode(node)) {
11029                         ts.forEachChild(node, traverse);
11030                     }
11031             }
11032         }
11033     }
11034     ts.forEachYieldExpression = forEachYieldExpression;
11035     function getRestParameterElementType(node) {
11036         if (node && node.kind === 178) {
11037             return node.elementType;
11038         }
11039         else if (node && node.kind === 173) {
11040             return ts.singleOrUndefined(node.typeArguments);
11041         }
11042         else {
11043             return undefined;
11044         }
11045     }
11046     ts.getRestParameterElementType = getRestParameterElementType;
11047     function getMembersOfDeclaration(node) {
11048         switch (node.kind) {
11049             case 253:
11050             case 252:
11051             case 221:
11052             case 177:
11053                 return node.members;
11054             case 200:
11055                 return node.properties;
11056         }
11057     }
11058     ts.getMembersOfDeclaration = getMembersOfDeclaration;
11059     function isVariableLike(node) {
11060         if (node) {
11061             switch (node.kind) {
11062                 case 198:
11063                 case 291:
11064                 case 160:
11065                 case 288:
11066                 case 163:
11067                 case 162:
11068                 case 289:
11069                 case 249:
11070                     return true;
11071             }
11072         }
11073         return false;
11074     }
11075     ts.isVariableLike = isVariableLike;
11076     function isVariableLikeOrAccessor(node) {
11077         return isVariableLike(node) || ts.isAccessor(node);
11078     }
11079     ts.isVariableLikeOrAccessor = isVariableLikeOrAccessor;
11080     function isVariableDeclarationInVariableStatement(node) {
11081         return node.parent.kind === 250
11082             && node.parent.parent.kind === 232;
11083     }
11084     ts.isVariableDeclarationInVariableStatement = isVariableDeclarationInVariableStatement;
11085     function isValidESSymbolDeclaration(node) {
11086         return ts.isVariableDeclaration(node) ? isVarConst(node) && ts.isIdentifier(node.name) && isVariableDeclarationInVariableStatement(node) :
11087             ts.isPropertyDeclaration(node) ? hasEffectiveReadonlyModifier(node) && hasStaticModifier(node) :
11088                 ts.isPropertySignature(node) && hasEffectiveReadonlyModifier(node);
11089     }
11090     ts.isValidESSymbolDeclaration = isValidESSymbolDeclaration;
11091     function introducesArgumentsExoticObject(node) {
11092         switch (node.kind) {
11093             case 165:
11094             case 164:
11095             case 166:
11096             case 167:
11097             case 168:
11098             case 251:
11099             case 208:
11100                 return true;
11101         }
11102         return false;
11103     }
11104     ts.introducesArgumentsExoticObject = introducesArgumentsExoticObject;
11105     function unwrapInnermostStatementOfLabel(node, beforeUnwrapLabelCallback) {
11106         while (true) {
11107             if (beforeUnwrapLabelCallback) {
11108                 beforeUnwrapLabelCallback(node);
11109             }
11110             if (node.statement.kind !== 245) {
11111                 return node.statement;
11112             }
11113             node = node.statement;
11114         }
11115     }
11116     ts.unwrapInnermostStatementOfLabel = unwrapInnermostStatementOfLabel;
11117     function isFunctionBlock(node) {
11118         return node && node.kind === 230 && ts.isFunctionLike(node.parent);
11119     }
11120     ts.isFunctionBlock = isFunctionBlock;
11121     function isObjectLiteralMethod(node) {
11122         return node && node.kind === 165 && node.parent.kind === 200;
11123     }
11124     ts.isObjectLiteralMethod = isObjectLiteralMethod;
11125     function isObjectLiteralOrClassExpressionMethod(node) {
11126         return node.kind === 165 &&
11127             (node.parent.kind === 200 ||
11128                 node.parent.kind === 221);
11129     }
11130     ts.isObjectLiteralOrClassExpressionMethod = isObjectLiteralOrClassExpressionMethod;
11131     function isIdentifierTypePredicate(predicate) {
11132         return predicate && predicate.kind === 1;
11133     }
11134     ts.isIdentifierTypePredicate = isIdentifierTypePredicate;
11135     function isThisTypePredicate(predicate) {
11136         return predicate && predicate.kind === 0;
11137     }
11138     ts.isThisTypePredicate = isThisTypePredicate;
11139     function getPropertyAssignment(objectLiteral, key, key2) {
11140         return objectLiteral.properties.filter(function (property) {
11141             if (property.kind === 288) {
11142                 var propName = getTextOfPropertyName(property.name);
11143                 return key === propName || (!!key2 && key2 === propName);
11144             }
11145             return false;
11146         });
11147     }
11148     ts.getPropertyAssignment = getPropertyAssignment;
11149     function getTsConfigObjectLiteralExpression(tsConfigSourceFile) {
11150         if (tsConfigSourceFile && tsConfigSourceFile.statements.length) {
11151             var expression = tsConfigSourceFile.statements[0].expression;
11152             return ts.tryCast(expression, ts.isObjectLiteralExpression);
11153         }
11154     }
11155     ts.getTsConfigObjectLiteralExpression = getTsConfigObjectLiteralExpression;
11156     function getTsConfigPropArrayElementValue(tsConfigSourceFile, propKey, elementValue) {
11157         return ts.firstDefined(getTsConfigPropArray(tsConfigSourceFile, propKey), function (property) {
11158             return ts.isArrayLiteralExpression(property.initializer) ?
11159                 ts.find(property.initializer.elements, function (element) { return ts.isStringLiteral(element) && element.text === elementValue; }) :
11160                 undefined;
11161         });
11162     }
11163     ts.getTsConfigPropArrayElementValue = getTsConfigPropArrayElementValue;
11164     function getTsConfigPropArray(tsConfigSourceFile, propKey) {
11165         var jsonObjectLiteral = getTsConfigObjectLiteralExpression(tsConfigSourceFile);
11166         return jsonObjectLiteral ? getPropertyAssignment(jsonObjectLiteral, propKey) : ts.emptyArray;
11167     }
11168     ts.getTsConfigPropArray = getTsConfigPropArray;
11169     function getContainingFunction(node) {
11170         return ts.findAncestor(node.parent, ts.isFunctionLike);
11171     }
11172     ts.getContainingFunction = getContainingFunction;
11173     function getContainingFunctionDeclaration(node) {
11174         return ts.findAncestor(node.parent, ts.isFunctionLikeDeclaration);
11175     }
11176     ts.getContainingFunctionDeclaration = getContainingFunctionDeclaration;
11177     function getContainingClass(node) {
11178         return ts.findAncestor(node.parent, ts.isClassLike);
11179     }
11180     ts.getContainingClass = getContainingClass;
11181     function getThisContainer(node, includeArrowFunctions) {
11182         ts.Debug.assert(node.kind !== 297);
11183         while (true) {
11184             node = node.parent;
11185             if (!node) {
11186                 return ts.Debug.fail();
11187             }
11188             switch (node.kind) {
11189                 case 158:
11190                     if (ts.isClassLike(node.parent.parent)) {
11191                         return node;
11192                     }
11193                     node = node.parent;
11194                     break;
11195                 case 161:
11196                     if (node.parent.kind === 160 && ts.isClassElement(node.parent.parent)) {
11197                         node = node.parent.parent;
11198                     }
11199                     else if (ts.isClassElement(node.parent)) {
11200                         node = node.parent;
11201                     }
11202                     break;
11203                 case 209:
11204                     if (!includeArrowFunctions) {
11205                         continue;
11206                     }
11207                 case 251:
11208                 case 208:
11209                 case 256:
11210                 case 163:
11211                 case 162:
11212                 case 165:
11213                 case 164:
11214                 case 166:
11215                 case 167:
11216                 case 168:
11217                 case 169:
11218                 case 170:
11219                 case 171:
11220                 case 255:
11221                 case 297:
11222                     return node;
11223             }
11224         }
11225     }
11226     ts.getThisContainer = getThisContainer;
11227     function isInTopLevelContext(node) {
11228         if (ts.isIdentifier(node) && (ts.isClassDeclaration(node.parent) || ts.isFunctionDeclaration(node.parent)) && node.parent.name === node) {
11229             node = node.parent;
11230         }
11231         var container = getThisContainer(node, true);
11232         return ts.isSourceFile(container);
11233     }
11234     ts.isInTopLevelContext = isInTopLevelContext;
11235     function getNewTargetContainer(node) {
11236         var container = getThisContainer(node, false);
11237         if (container) {
11238             switch (container.kind) {
11239                 case 166:
11240                 case 251:
11241                 case 208:
11242                     return container;
11243             }
11244         }
11245         return undefined;
11246     }
11247     ts.getNewTargetContainer = getNewTargetContainer;
11248     function getSuperContainer(node, stopOnFunctions) {
11249         while (true) {
11250             node = node.parent;
11251             if (!node) {
11252                 return node;
11253             }
11254             switch (node.kind) {
11255                 case 158:
11256                     node = node.parent;
11257                     break;
11258                 case 251:
11259                 case 208:
11260                 case 209:
11261                     if (!stopOnFunctions) {
11262                         continue;
11263                     }
11264                 case 163:
11265                 case 162:
11266                 case 165:
11267                 case 164:
11268                 case 166:
11269                 case 167:
11270                 case 168:
11271                     return node;
11272                 case 161:
11273                     if (node.parent.kind === 160 && ts.isClassElement(node.parent.parent)) {
11274                         node = node.parent.parent;
11275                     }
11276                     else if (ts.isClassElement(node.parent)) {
11277                         node = node.parent;
11278                     }
11279                     break;
11280             }
11281         }
11282     }
11283     ts.getSuperContainer = getSuperContainer;
11284     function getImmediatelyInvokedFunctionExpression(func) {
11285         if (func.kind === 208 || func.kind === 209) {
11286             var prev = func;
11287             var parent = func.parent;
11288             while (parent.kind === 207) {
11289                 prev = parent;
11290                 parent = parent.parent;
11291             }
11292             if (parent.kind === 203 && parent.expression === prev) {
11293                 return parent;
11294             }
11295         }
11296     }
11297     ts.getImmediatelyInvokedFunctionExpression = getImmediatelyInvokedFunctionExpression;
11298     function isSuperOrSuperProperty(node) {
11299         return node.kind === 105
11300             || isSuperProperty(node);
11301     }
11302     ts.isSuperOrSuperProperty = isSuperOrSuperProperty;
11303     function isSuperProperty(node) {
11304         var kind = node.kind;
11305         return (kind === 201 || kind === 202)
11306             && node.expression.kind === 105;
11307     }
11308     ts.isSuperProperty = isSuperProperty;
11309     function isThisProperty(node) {
11310         var kind = node.kind;
11311         return (kind === 201 || kind === 202)
11312             && node.expression.kind === 107;
11313     }
11314     ts.isThisProperty = isThisProperty;
11315     function isThisInitializedDeclaration(node) {
11316         var _a;
11317         return !!node && ts.isVariableDeclaration(node) && ((_a = node.initializer) === null || _a === void 0 ? void 0 : _a.kind) === 107;
11318     }
11319     ts.isThisInitializedDeclaration = isThisInitializedDeclaration;
11320     function getEntityNameFromTypeNode(node) {
11321         switch (node.kind) {
11322             case 173:
11323                 return node.typeName;
11324             case 223:
11325                 return isEntityNameExpression(node.expression)
11326                     ? node.expression
11327                     : undefined;
11328             case 78:
11329             case 157:
11330                 return node;
11331         }
11332         return undefined;
11333     }
11334     ts.getEntityNameFromTypeNode = getEntityNameFromTypeNode;
11335     function getInvokedExpression(node) {
11336         switch (node.kind) {
11337             case 205:
11338                 return node.tag;
11339             case 275:
11340             case 274:
11341                 return node.tagName;
11342             default:
11343                 return node.expression;
11344         }
11345     }
11346     ts.getInvokedExpression = getInvokedExpression;
11347     function nodeCanBeDecorated(node, parent, grandparent) {
11348         if (ts.isNamedDeclaration(node) && ts.isPrivateIdentifier(node.name)) {
11349             return false;
11350         }
11351         switch (node.kind) {
11352             case 252:
11353                 return true;
11354             case 163:
11355                 return parent.kind === 252;
11356             case 167:
11357             case 168:
11358             case 165:
11359                 return node.body !== undefined
11360                     && parent.kind === 252;
11361             case 160:
11362                 return parent.body !== undefined
11363                     && (parent.kind === 166
11364                         || parent.kind === 165
11365                         || parent.kind === 168)
11366                     && grandparent.kind === 252;
11367         }
11368         return false;
11369     }
11370     ts.nodeCanBeDecorated = nodeCanBeDecorated;
11371     function nodeIsDecorated(node, parent, grandparent) {
11372         return node.decorators !== undefined
11373             && nodeCanBeDecorated(node, parent, grandparent);
11374     }
11375     ts.nodeIsDecorated = nodeIsDecorated;
11376     function nodeOrChildIsDecorated(node, parent, grandparent) {
11377         return nodeIsDecorated(node, parent, grandparent) || childIsDecorated(node, parent);
11378     }
11379     ts.nodeOrChildIsDecorated = nodeOrChildIsDecorated;
11380     function childIsDecorated(node, parent) {
11381         switch (node.kind) {
11382             case 252:
11383                 return ts.some(node.members, function (m) { return nodeOrChildIsDecorated(m, node, parent); });
11384             case 165:
11385             case 168:
11386                 return ts.some(node.parameters, function (p) { return nodeIsDecorated(p, node, parent); });
11387             default:
11388                 return false;
11389         }
11390     }
11391     ts.childIsDecorated = childIsDecorated;
11392     function isJSXTagName(node) {
11393         var parent = node.parent;
11394         if (parent.kind === 275 ||
11395             parent.kind === 274 ||
11396             parent.kind === 276) {
11397             return parent.tagName === node;
11398         }
11399         return false;
11400     }
11401     ts.isJSXTagName = isJSXTagName;
11402     function isExpressionNode(node) {
11403         switch (node.kind) {
11404             case 105:
11405             case 103:
11406             case 109:
11407             case 94:
11408             case 13:
11409             case 199:
11410             case 200:
11411             case 201:
11412             case 202:
11413             case 203:
11414             case 204:
11415             case 205:
11416             case 224:
11417             case 206:
11418             case 225:
11419             case 207:
11420             case 208:
11421             case 221:
11422             case 209:
11423             case 212:
11424             case 210:
11425             case 211:
11426             case 214:
11427             case 215:
11428             case 216:
11429             case 217:
11430             case 220:
11431             case 218:
11432             case 222:
11433             case 273:
11434             case 274:
11435             case 277:
11436             case 219:
11437             case 213:
11438             case 226:
11439                 return true;
11440             case 157:
11441                 while (node.parent.kind === 157) {
11442                     node = node.parent;
11443                 }
11444                 return node.parent.kind === 176 || isJSXTagName(node);
11445             case 78:
11446                 if (node.parent.kind === 176 || isJSXTagName(node)) {
11447                     return true;
11448                 }
11449             case 8:
11450             case 9:
11451             case 10:
11452             case 14:
11453             case 107:
11454                 return isInExpressionContext(node);
11455             default:
11456                 return false;
11457         }
11458     }
11459     ts.isExpressionNode = isExpressionNode;
11460     function isInExpressionContext(node) {
11461         var parent = node.parent;
11462         switch (parent.kind) {
11463             case 249:
11464             case 160:
11465             case 163:
11466             case 162:
11467             case 291:
11468             case 288:
11469             case 198:
11470                 return parent.initializer === node;
11471             case 233:
11472             case 234:
11473             case 235:
11474             case 236:
11475             case 242:
11476             case 243:
11477             case 244:
11478             case 284:
11479             case 246:
11480                 return parent.expression === node;
11481             case 237:
11482                 var forStatement = parent;
11483                 return (forStatement.initializer === node && forStatement.initializer.kind !== 250) ||
11484                     forStatement.condition === node ||
11485                     forStatement.incrementor === node;
11486             case 238:
11487             case 239:
11488                 var forInStatement = parent;
11489                 return (forInStatement.initializer === node && forInStatement.initializer.kind !== 250) ||
11490                     forInStatement.expression === node;
11491             case 206:
11492             case 224:
11493                 return node === parent.expression;
11494             case 228:
11495                 return node === parent.expression;
11496             case 158:
11497                 return node === parent.expression;
11498             case 161:
11499             case 283:
11500             case 282:
11501             case 290:
11502                 return true;
11503             case 223:
11504                 return parent.expression === node && isExpressionWithTypeArgumentsInClassExtendsClause(parent);
11505             case 289:
11506                 return parent.objectAssignmentInitializer === node;
11507             default:
11508                 return isExpressionNode(parent);
11509         }
11510     }
11511     ts.isInExpressionContext = isInExpressionContext;
11512     function isPartOfTypeQuery(node) {
11513         while (node.kind === 157 || node.kind === 78) {
11514             node = node.parent;
11515         }
11516         return node.kind === 176;
11517     }
11518     ts.isPartOfTypeQuery = isPartOfTypeQuery;
11519     function isExternalModuleImportEqualsDeclaration(node) {
11520         return node.kind === 260 && node.moduleReference.kind === 272;
11521     }
11522     ts.isExternalModuleImportEqualsDeclaration = isExternalModuleImportEqualsDeclaration;
11523     function getExternalModuleImportEqualsDeclarationExpression(node) {
11524         ts.Debug.assert(isExternalModuleImportEqualsDeclaration(node));
11525         return node.moduleReference.expression;
11526     }
11527     ts.getExternalModuleImportEqualsDeclarationExpression = getExternalModuleImportEqualsDeclarationExpression;
11528     function getExternalModuleRequireArgument(node) {
11529         return isRequireVariableDeclaration(node, true)
11530             && getLeftmostAccessExpression(node.initializer).arguments[0];
11531     }
11532     ts.getExternalModuleRequireArgument = getExternalModuleRequireArgument;
11533     function isInternalModuleImportEqualsDeclaration(node) {
11534         return node.kind === 260 && node.moduleReference.kind !== 272;
11535     }
11536     ts.isInternalModuleImportEqualsDeclaration = isInternalModuleImportEqualsDeclaration;
11537     function isSourceFileJS(file) {
11538         return isInJSFile(file);
11539     }
11540     ts.isSourceFileJS = isSourceFileJS;
11541     function isSourceFileNotJS(file) {
11542         return !isInJSFile(file);
11543     }
11544     ts.isSourceFileNotJS = isSourceFileNotJS;
11545     function isInJSFile(node) {
11546         return !!node && !!(node.flags & 131072);
11547     }
11548     ts.isInJSFile = isInJSFile;
11549     function isInJsonFile(node) {
11550         return !!node && !!(node.flags & 33554432);
11551     }
11552     ts.isInJsonFile = isInJsonFile;
11553     function isSourceFileNotJson(file) {
11554         return !isJsonSourceFile(file);
11555     }
11556     ts.isSourceFileNotJson = isSourceFileNotJson;
11557     function isInJSDoc(node) {
11558         return !!node && !!(node.flags & 4194304);
11559     }
11560     ts.isInJSDoc = isInJSDoc;
11561     function isJSDocIndexSignature(node) {
11562         return ts.isTypeReferenceNode(node) &&
11563             ts.isIdentifier(node.typeName) &&
11564             node.typeName.escapedText === "Object" &&
11565             node.typeArguments && node.typeArguments.length === 2 &&
11566             (node.typeArguments[0].kind === 147 || node.typeArguments[0].kind === 144);
11567     }
11568     ts.isJSDocIndexSignature = isJSDocIndexSignature;
11569     function isRequireCall(callExpression, requireStringLiteralLikeArgument) {
11570         if (callExpression.kind !== 203) {
11571             return false;
11572         }
11573         var _a = callExpression, expression = _a.expression, args = _a.arguments;
11574         if (expression.kind !== 78 || expression.escapedText !== "require") {
11575             return false;
11576         }
11577         if (args.length !== 1) {
11578             return false;
11579         }
11580         var arg = args[0];
11581         return !requireStringLiteralLikeArgument || ts.isStringLiteralLike(arg);
11582     }
11583     ts.isRequireCall = isRequireCall;
11584     function isRequireVariableDeclaration(node, requireStringLiteralLikeArgument) {
11585         if (node.kind === 198) {
11586             node = node.parent.parent;
11587         }
11588         return ts.isVariableDeclaration(node) && !!node.initializer && isRequireCall(getLeftmostAccessExpression(node.initializer), requireStringLiteralLikeArgument);
11589     }
11590     ts.isRequireVariableDeclaration = isRequireVariableDeclaration;
11591     function isRequireVariableStatement(node, requireStringLiteralLikeArgument) {
11592         if (requireStringLiteralLikeArgument === void 0) { requireStringLiteralLikeArgument = true; }
11593         return ts.isVariableStatement(node)
11594             && node.declarationList.declarations.length > 0
11595             && ts.every(node.declarationList.declarations, function (decl) { return isRequireVariableDeclaration(decl, requireStringLiteralLikeArgument); });
11596     }
11597     ts.isRequireVariableStatement = isRequireVariableStatement;
11598     function isSingleOrDoubleQuote(charCode) {
11599         return charCode === 39 || charCode === 34;
11600     }
11601     ts.isSingleOrDoubleQuote = isSingleOrDoubleQuote;
11602     function isStringDoubleQuoted(str, sourceFile) {
11603         return getSourceTextOfNodeFromSourceFile(sourceFile, str).charCodeAt(0) === 34;
11604     }
11605     ts.isStringDoubleQuoted = isStringDoubleQuoted;
11606     function isAssignmentDeclaration(decl) {
11607         return ts.isBinaryExpression(decl) || isAccessExpression(decl) || ts.isIdentifier(decl) || ts.isCallExpression(decl);
11608     }
11609     ts.isAssignmentDeclaration = isAssignmentDeclaration;
11610     function getEffectiveInitializer(node) {
11611         if (isInJSFile(node) && node.initializer &&
11612             ts.isBinaryExpression(node.initializer) &&
11613             (node.initializer.operatorToken.kind === 56 || node.initializer.operatorToken.kind === 60) &&
11614             node.name && isEntityNameExpression(node.name) && isSameEntityName(node.name, node.initializer.left)) {
11615             return node.initializer.right;
11616         }
11617         return node.initializer;
11618     }
11619     ts.getEffectiveInitializer = getEffectiveInitializer;
11620     function getDeclaredExpandoInitializer(node) {
11621         var init = getEffectiveInitializer(node);
11622         return init && getExpandoInitializer(init, isPrototypeAccess(node.name));
11623     }
11624     ts.getDeclaredExpandoInitializer = getDeclaredExpandoInitializer;
11625     function hasExpandoValueProperty(node, isPrototypeAssignment) {
11626         return ts.forEach(node.properties, function (p) {
11627             return ts.isPropertyAssignment(p) &&
11628                 ts.isIdentifier(p.name) &&
11629                 p.name.escapedText === "value" &&
11630                 p.initializer &&
11631                 getExpandoInitializer(p.initializer, isPrototypeAssignment);
11632         });
11633     }
11634     function getAssignedExpandoInitializer(node) {
11635         if (node && node.parent && ts.isBinaryExpression(node.parent) && node.parent.operatorToken.kind === 62) {
11636             var isPrototypeAssignment = isPrototypeAccess(node.parent.left);
11637             return getExpandoInitializer(node.parent.right, isPrototypeAssignment) ||
11638                 getDefaultedExpandoInitializer(node.parent.left, node.parent.right, isPrototypeAssignment);
11639         }
11640         if (node && ts.isCallExpression(node) && isBindableObjectDefinePropertyCall(node)) {
11641             var result = hasExpandoValueProperty(node.arguments[2], node.arguments[1].text === "prototype");
11642             if (result) {
11643                 return result;
11644             }
11645         }
11646     }
11647     ts.getAssignedExpandoInitializer = getAssignedExpandoInitializer;
11648     function getExpandoInitializer(initializer, isPrototypeAssignment) {
11649         if (ts.isCallExpression(initializer)) {
11650             var e = skipParentheses(initializer.expression);
11651             return e.kind === 208 || e.kind === 209 ? initializer : undefined;
11652         }
11653         if (initializer.kind === 208 ||
11654             initializer.kind === 221 ||
11655             initializer.kind === 209) {
11656             return initializer;
11657         }
11658         if (ts.isObjectLiteralExpression(initializer) && (initializer.properties.length === 0 || isPrototypeAssignment)) {
11659             return initializer;
11660         }
11661     }
11662     ts.getExpandoInitializer = getExpandoInitializer;
11663     function getDefaultedExpandoInitializer(name, initializer, isPrototypeAssignment) {
11664         var e = ts.isBinaryExpression(initializer)
11665             && (initializer.operatorToken.kind === 56 || initializer.operatorToken.kind === 60)
11666             && getExpandoInitializer(initializer.right, isPrototypeAssignment);
11667         if (e && isSameEntityName(name, initializer.left)) {
11668             return e;
11669         }
11670     }
11671     function isDefaultedExpandoInitializer(node) {
11672         var name = ts.isVariableDeclaration(node.parent) ? node.parent.name :
11673             ts.isBinaryExpression(node.parent) && node.parent.operatorToken.kind === 62 ? node.parent.left :
11674                 undefined;
11675         return name && getExpandoInitializer(node.right, isPrototypeAccess(name)) && isEntityNameExpression(name) && isSameEntityName(name, node.left);
11676     }
11677     ts.isDefaultedExpandoInitializer = isDefaultedExpandoInitializer;
11678     function getNameOfExpando(node) {
11679         if (ts.isBinaryExpression(node.parent)) {
11680             var parent = ((node.parent.operatorToken.kind === 56 || node.parent.operatorToken.kind === 60) && ts.isBinaryExpression(node.parent.parent)) ? node.parent.parent : node.parent;
11681             if (parent.operatorToken.kind === 62 && ts.isIdentifier(parent.left)) {
11682                 return parent.left;
11683             }
11684         }
11685         else if (ts.isVariableDeclaration(node.parent)) {
11686             return node.parent.name;
11687         }
11688     }
11689     ts.getNameOfExpando = getNameOfExpando;
11690     function isSameEntityName(name, initializer) {
11691         if (isPropertyNameLiteral(name) && isPropertyNameLiteral(initializer)) {
11692             return getTextOfIdentifierOrLiteral(name) === getTextOfIdentifierOrLiteral(initializer);
11693         }
11694         if (ts.isIdentifier(name) && isLiteralLikeAccess(initializer) &&
11695             (initializer.expression.kind === 107 ||
11696                 ts.isIdentifier(initializer.expression) &&
11697                     (initializer.expression.escapedText === "window" ||
11698                         initializer.expression.escapedText === "self" ||
11699                         initializer.expression.escapedText === "global"))) {
11700             var nameOrArgument = getNameOrArgument(initializer);
11701             if (ts.isPrivateIdentifier(nameOrArgument)) {
11702                 ts.Debug.fail("Unexpected PrivateIdentifier in name expression with literal-like access.");
11703             }
11704             return isSameEntityName(name, nameOrArgument);
11705         }
11706         if (isLiteralLikeAccess(name) && isLiteralLikeAccess(initializer)) {
11707             return getElementOrPropertyAccessName(name) === getElementOrPropertyAccessName(initializer)
11708                 && isSameEntityName(name.expression, initializer.expression);
11709         }
11710         return false;
11711     }
11712     ts.isSameEntityName = isSameEntityName;
11713     function getRightMostAssignedExpression(node) {
11714         while (isAssignmentExpression(node, true)) {
11715             node = node.right;
11716         }
11717         return node;
11718     }
11719     ts.getRightMostAssignedExpression = getRightMostAssignedExpression;
11720     function isExportsIdentifier(node) {
11721         return ts.isIdentifier(node) && node.escapedText === "exports";
11722     }
11723     ts.isExportsIdentifier = isExportsIdentifier;
11724     function isModuleIdentifier(node) {
11725         return ts.isIdentifier(node) && node.escapedText === "module";
11726     }
11727     ts.isModuleIdentifier = isModuleIdentifier;
11728     function isModuleExportsAccessExpression(node) {
11729         return (ts.isPropertyAccessExpression(node) || isLiteralLikeElementAccess(node))
11730             && isModuleIdentifier(node.expression)
11731             && getElementOrPropertyAccessName(node) === "exports";
11732     }
11733     ts.isModuleExportsAccessExpression = isModuleExportsAccessExpression;
11734     function getAssignmentDeclarationKind(expr) {
11735         var special = getAssignmentDeclarationKindWorker(expr);
11736         return special === 5 || isInJSFile(expr) ? special : 0;
11737     }
11738     ts.getAssignmentDeclarationKind = getAssignmentDeclarationKind;
11739     function isBindableObjectDefinePropertyCall(expr) {
11740         return ts.length(expr.arguments) === 3 &&
11741             ts.isPropertyAccessExpression(expr.expression) &&
11742             ts.isIdentifier(expr.expression.expression) &&
11743             ts.idText(expr.expression.expression) === "Object" &&
11744             ts.idText(expr.expression.name) === "defineProperty" &&
11745             isStringOrNumericLiteralLike(expr.arguments[1]) &&
11746             isBindableStaticNameExpression(expr.arguments[0], true);
11747     }
11748     ts.isBindableObjectDefinePropertyCall = isBindableObjectDefinePropertyCall;
11749     function isLiteralLikeAccess(node) {
11750         return ts.isPropertyAccessExpression(node) || isLiteralLikeElementAccess(node);
11751     }
11752     ts.isLiteralLikeAccess = isLiteralLikeAccess;
11753     function isLiteralLikeElementAccess(node) {
11754         return ts.isElementAccessExpression(node) && (isStringOrNumericLiteralLike(node.argumentExpression) ||
11755             isWellKnownSymbolSyntactically(node.argumentExpression));
11756     }
11757     ts.isLiteralLikeElementAccess = isLiteralLikeElementAccess;
11758     function isBindableStaticAccessExpression(node, excludeThisKeyword) {
11759         return ts.isPropertyAccessExpression(node) && (!excludeThisKeyword && node.expression.kind === 107 || ts.isIdentifier(node.name) && isBindableStaticNameExpression(node.expression, true))
11760             || isBindableStaticElementAccessExpression(node, excludeThisKeyword);
11761     }
11762     ts.isBindableStaticAccessExpression = isBindableStaticAccessExpression;
11763     function isBindableStaticElementAccessExpression(node, excludeThisKeyword) {
11764         return isLiteralLikeElementAccess(node)
11765             && ((!excludeThisKeyword && node.expression.kind === 107) ||
11766                 isEntityNameExpression(node.expression) ||
11767                 isBindableStaticAccessExpression(node.expression, true));
11768     }
11769     ts.isBindableStaticElementAccessExpression = isBindableStaticElementAccessExpression;
11770     function isBindableStaticNameExpression(node, excludeThisKeyword) {
11771         return isEntityNameExpression(node) || isBindableStaticAccessExpression(node, excludeThisKeyword);
11772     }
11773     ts.isBindableStaticNameExpression = isBindableStaticNameExpression;
11774     function getNameOrArgument(expr) {
11775         if (ts.isPropertyAccessExpression(expr)) {
11776             return expr.name;
11777         }
11778         return expr.argumentExpression;
11779     }
11780     ts.getNameOrArgument = getNameOrArgument;
11781     function getAssignmentDeclarationKindWorker(expr) {
11782         if (ts.isCallExpression(expr)) {
11783             if (!isBindableObjectDefinePropertyCall(expr)) {
11784                 return 0;
11785             }
11786             var entityName = expr.arguments[0];
11787             if (isExportsIdentifier(entityName) || isModuleExportsAccessExpression(entityName)) {
11788                 return 8;
11789             }
11790             if (isBindableStaticAccessExpression(entityName) && getElementOrPropertyAccessName(entityName) === "prototype") {
11791                 return 9;
11792             }
11793             return 7;
11794         }
11795         if (expr.operatorToken.kind !== 62 || !isAccessExpression(expr.left) || isVoidZero(getRightMostAssignedExpression(expr))) {
11796             return 0;
11797         }
11798         if (isBindableStaticNameExpression(expr.left.expression, true) && getElementOrPropertyAccessName(expr.left) === "prototype" && ts.isObjectLiteralExpression(getInitializerOfBinaryExpression(expr))) {
11799             return 6;
11800         }
11801         return getAssignmentDeclarationPropertyAccessKind(expr.left);
11802     }
11803     function isVoidZero(node) {
11804         return ts.isVoidExpression(node) && ts.isNumericLiteral(node.expression) && node.expression.text === "0";
11805     }
11806     function getElementOrPropertyAccessArgumentExpressionOrName(node) {
11807         if (ts.isPropertyAccessExpression(node)) {
11808             return node.name;
11809         }
11810         var arg = skipParentheses(node.argumentExpression);
11811         if (ts.isNumericLiteral(arg) || ts.isStringLiteralLike(arg)) {
11812             return arg;
11813         }
11814         return node;
11815     }
11816     ts.getElementOrPropertyAccessArgumentExpressionOrName = getElementOrPropertyAccessArgumentExpressionOrName;
11817     function getElementOrPropertyAccessName(node) {
11818         var name = getElementOrPropertyAccessArgumentExpressionOrName(node);
11819         if (name) {
11820             if (ts.isIdentifier(name)) {
11821                 return name.escapedText;
11822             }
11823             if (ts.isStringLiteralLike(name) || ts.isNumericLiteral(name)) {
11824                 return ts.escapeLeadingUnderscores(name.text);
11825             }
11826         }
11827         if (ts.isElementAccessExpression(node) && isWellKnownSymbolSyntactically(node.argumentExpression)) {
11828             return getPropertyNameForKnownSymbolName(ts.idText(node.argumentExpression.name));
11829         }
11830         return undefined;
11831     }
11832     ts.getElementOrPropertyAccessName = getElementOrPropertyAccessName;
11833     function getAssignmentDeclarationPropertyAccessKind(lhs) {
11834         if (lhs.expression.kind === 107) {
11835             return 4;
11836         }
11837         else if (isModuleExportsAccessExpression(lhs)) {
11838             return 2;
11839         }
11840         else if (isBindableStaticNameExpression(lhs.expression, true)) {
11841             if (isPrototypeAccess(lhs.expression)) {
11842                 return 3;
11843             }
11844             var nextToLast = lhs;
11845             while (!ts.isIdentifier(nextToLast.expression)) {
11846                 nextToLast = nextToLast.expression;
11847             }
11848             var id = nextToLast.expression;
11849             if ((id.escapedText === "exports" ||
11850                 id.escapedText === "module" && getElementOrPropertyAccessName(nextToLast) === "exports") &&
11851                 isBindableStaticAccessExpression(lhs)) {
11852                 return 1;
11853             }
11854             if (isBindableStaticNameExpression(lhs, true) || (ts.isElementAccessExpression(lhs) && isDynamicName(lhs))) {
11855                 return 5;
11856             }
11857         }
11858         return 0;
11859     }
11860     ts.getAssignmentDeclarationPropertyAccessKind = getAssignmentDeclarationPropertyAccessKind;
11861     function getInitializerOfBinaryExpression(expr) {
11862         while (ts.isBinaryExpression(expr.right)) {
11863             expr = expr.right;
11864         }
11865         return expr.right;
11866     }
11867     ts.getInitializerOfBinaryExpression = getInitializerOfBinaryExpression;
11868     function isPrototypePropertyAssignment(node) {
11869         return ts.isBinaryExpression(node) && getAssignmentDeclarationKind(node) === 3;
11870     }
11871     ts.isPrototypePropertyAssignment = isPrototypePropertyAssignment;
11872     function isSpecialPropertyDeclaration(expr) {
11873         return isInJSFile(expr) &&
11874             expr.parent && expr.parent.kind === 233 &&
11875             (!ts.isElementAccessExpression(expr) || isLiteralLikeElementAccess(expr)) &&
11876             !!ts.getJSDocTypeTag(expr.parent);
11877     }
11878     ts.isSpecialPropertyDeclaration = isSpecialPropertyDeclaration;
11879     function setValueDeclaration(symbol, node) {
11880         var valueDeclaration = symbol.valueDeclaration;
11881         if (!valueDeclaration ||
11882             !(node.flags & 8388608 && !(valueDeclaration.flags & 8388608)) &&
11883                 (isAssignmentDeclaration(valueDeclaration) && !isAssignmentDeclaration(node)) ||
11884             (valueDeclaration.kind !== node.kind && isEffectiveModuleDeclaration(valueDeclaration))) {
11885             symbol.valueDeclaration = node;
11886         }
11887     }
11888     ts.setValueDeclaration = setValueDeclaration;
11889     function isFunctionSymbol(symbol) {
11890         if (!symbol || !symbol.valueDeclaration) {
11891             return false;
11892         }
11893         var decl = symbol.valueDeclaration;
11894         return decl.kind === 251 || ts.isVariableDeclaration(decl) && decl.initializer && ts.isFunctionLike(decl.initializer);
11895     }
11896     ts.isFunctionSymbol = isFunctionSymbol;
11897     function importFromModuleSpecifier(node) {
11898         return tryGetImportFromModuleSpecifier(node) || ts.Debug.failBadSyntaxKind(node.parent);
11899     }
11900     ts.importFromModuleSpecifier = importFromModuleSpecifier;
11901     function tryGetImportFromModuleSpecifier(node) {
11902         switch (node.parent.kind) {
11903             case 261:
11904             case 267:
11905                 return node.parent;
11906             case 272:
11907                 return node.parent.parent;
11908             case 203:
11909                 return isImportCall(node.parent) || isRequireCall(node.parent, false) ? node.parent : undefined;
11910             case 191:
11911                 ts.Debug.assert(ts.isStringLiteral(node));
11912                 return ts.tryCast(node.parent.parent, ts.isImportTypeNode);
11913             default:
11914                 return undefined;
11915         }
11916     }
11917     ts.tryGetImportFromModuleSpecifier = tryGetImportFromModuleSpecifier;
11918     function getExternalModuleName(node) {
11919         switch (node.kind) {
11920             case 261:
11921             case 267:
11922                 return node.moduleSpecifier;
11923             case 260:
11924                 return node.moduleReference.kind === 272 ? node.moduleReference.expression : undefined;
11925             case 195:
11926                 return isLiteralImportTypeNode(node) ? node.argument.literal : undefined;
11927             default:
11928                 return ts.Debug.assertNever(node);
11929         }
11930     }
11931     ts.getExternalModuleName = getExternalModuleName;
11932     function getNamespaceDeclarationNode(node) {
11933         switch (node.kind) {
11934             case 261:
11935                 return node.importClause && ts.tryCast(node.importClause.namedBindings, ts.isNamespaceImport);
11936             case 260:
11937                 return node;
11938             case 267:
11939                 return node.exportClause && ts.tryCast(node.exportClause, ts.isNamespaceExport);
11940             default:
11941                 return ts.Debug.assertNever(node);
11942         }
11943     }
11944     ts.getNamespaceDeclarationNode = getNamespaceDeclarationNode;
11945     function isDefaultImport(node) {
11946         return node.kind === 261 && !!node.importClause && !!node.importClause.name;
11947     }
11948     ts.isDefaultImport = isDefaultImport;
11949     function forEachImportClauseDeclaration(node, action) {
11950         if (node.name) {
11951             var result = action(node);
11952             if (result)
11953                 return result;
11954         }
11955         if (node.namedBindings) {
11956             var result = ts.isNamespaceImport(node.namedBindings)
11957                 ? action(node.namedBindings)
11958                 : ts.forEach(node.namedBindings.elements, action);
11959             if (result)
11960                 return result;
11961         }
11962     }
11963     ts.forEachImportClauseDeclaration = forEachImportClauseDeclaration;
11964     function hasQuestionToken(node) {
11965         if (node) {
11966             switch (node.kind) {
11967                 case 160:
11968                 case 165:
11969                 case 164:
11970                 case 289:
11971                 case 288:
11972                 case 163:
11973                 case 162:
11974                     return node.questionToken !== undefined;
11975             }
11976         }
11977         return false;
11978     }
11979     ts.hasQuestionToken = hasQuestionToken;
11980     function isJSDocConstructSignature(node) {
11981         var param = ts.isJSDocFunctionType(node) ? ts.firstOrUndefined(node.parameters) : undefined;
11982         var name = ts.tryCast(param && param.name, ts.isIdentifier);
11983         return !!name && name.escapedText === "new";
11984     }
11985     ts.isJSDocConstructSignature = isJSDocConstructSignature;
11986     function isJSDocTypeAlias(node) {
11987         return node.kind === 331 || node.kind === 324 || node.kind === 325;
11988     }
11989     ts.isJSDocTypeAlias = isJSDocTypeAlias;
11990     function isTypeAlias(node) {
11991         return isJSDocTypeAlias(node) || ts.isTypeAliasDeclaration(node);
11992     }
11993     ts.isTypeAlias = isTypeAlias;
11994     function getSourceOfAssignment(node) {
11995         return ts.isExpressionStatement(node) &&
11996             ts.isBinaryExpression(node.expression) &&
11997             node.expression.operatorToken.kind === 62
11998             ? getRightMostAssignedExpression(node.expression)
11999             : undefined;
12000     }
12001     function getSourceOfDefaultedAssignment(node) {
12002         return ts.isExpressionStatement(node) &&
12003             ts.isBinaryExpression(node.expression) &&
12004             getAssignmentDeclarationKind(node.expression) !== 0 &&
12005             ts.isBinaryExpression(node.expression.right) &&
12006             (node.expression.right.operatorToken.kind === 56 || node.expression.right.operatorToken.kind === 60)
12007             ? node.expression.right.right
12008             : undefined;
12009     }
12010     function getSingleInitializerOfVariableStatementOrPropertyDeclaration(node) {
12011         switch (node.kind) {
12012             case 232:
12013                 var v = getSingleVariableOfVariableStatement(node);
12014                 return v && v.initializer;
12015             case 163:
12016                 return node.initializer;
12017             case 288:
12018                 return node.initializer;
12019         }
12020     }
12021     ts.getSingleInitializerOfVariableStatementOrPropertyDeclaration = getSingleInitializerOfVariableStatementOrPropertyDeclaration;
12022     function getSingleVariableOfVariableStatement(node) {
12023         return ts.isVariableStatement(node) ? ts.firstOrUndefined(node.declarationList.declarations) : undefined;
12024     }
12025     ts.getSingleVariableOfVariableStatement = getSingleVariableOfVariableStatement;
12026     function getNestedModuleDeclaration(node) {
12027         return ts.isModuleDeclaration(node) &&
12028             node.body &&
12029             node.body.kind === 256
12030             ? node.body
12031             : undefined;
12032     }
12033     function getJSDocCommentsAndTags(hostNode, noCache) {
12034         var result;
12035         if (isVariableLike(hostNode) && ts.hasInitializer(hostNode) && ts.hasJSDocNodes(hostNode.initializer)) {
12036             result = ts.append(result, ts.last(hostNode.initializer.jsDoc));
12037         }
12038         var node = hostNode;
12039         while (node && node.parent) {
12040             if (ts.hasJSDocNodes(node)) {
12041                 result = ts.append(result, ts.last(node.jsDoc));
12042             }
12043             if (node.kind === 160) {
12044                 result = ts.addRange(result, (noCache ? ts.getJSDocParameterTagsNoCache : ts.getJSDocParameterTags)(node));
12045                 break;
12046             }
12047             if (node.kind === 159) {
12048                 result = ts.addRange(result, (noCache ? ts.getJSDocTypeParameterTagsNoCache : ts.getJSDocTypeParameterTags)(node));
12049                 break;
12050             }
12051             node = getNextJSDocCommentLocation(node);
12052         }
12053         return result || ts.emptyArray;
12054     }
12055     ts.getJSDocCommentsAndTags = getJSDocCommentsAndTags;
12056     function getNextJSDocCommentLocation(node) {
12057         var parent = node.parent;
12058         if (parent.kind === 288 ||
12059             parent.kind === 266 ||
12060             parent.kind === 163 ||
12061             parent.kind === 233 && node.kind === 201 ||
12062             getNestedModuleDeclaration(parent) ||
12063             ts.isBinaryExpression(node) && node.operatorToken.kind === 62) {
12064             return parent;
12065         }
12066         else if (parent.parent &&
12067             (getSingleVariableOfVariableStatement(parent.parent) === node ||
12068                 ts.isBinaryExpression(parent) && parent.operatorToken.kind === 62)) {
12069             return parent.parent;
12070         }
12071         else if (parent.parent && parent.parent.parent &&
12072             (getSingleVariableOfVariableStatement(parent.parent.parent) ||
12073                 getSingleInitializerOfVariableStatementOrPropertyDeclaration(parent.parent.parent) === node ||
12074                 getSourceOfDefaultedAssignment(parent.parent.parent))) {
12075             return parent.parent.parent;
12076         }
12077     }
12078     function getParameterSymbolFromJSDoc(node) {
12079         if (node.symbol) {
12080             return node.symbol;
12081         }
12082         if (!ts.isIdentifier(node.name)) {
12083             return undefined;
12084         }
12085         var name = node.name.escapedText;
12086         var decl = getHostSignatureFromJSDoc(node);
12087         if (!decl) {
12088             return undefined;
12089         }
12090         var parameter = ts.find(decl.parameters, function (p) { return p.name.kind === 78 && p.name.escapedText === name; });
12091         return parameter && parameter.symbol;
12092     }
12093     ts.getParameterSymbolFromJSDoc = getParameterSymbolFromJSDoc;
12094     function getHostSignatureFromJSDoc(node) {
12095         var host = getEffectiveJSDocHost(node);
12096         return host && ts.isFunctionLike(host) ? host : undefined;
12097     }
12098     ts.getHostSignatureFromJSDoc = getHostSignatureFromJSDoc;
12099     function getEffectiveJSDocHost(node) {
12100         var host = getJSDocHost(node);
12101         var decl = getSourceOfDefaultedAssignment(host) ||
12102             getSourceOfAssignment(host) ||
12103             getSingleInitializerOfVariableStatementOrPropertyDeclaration(host) ||
12104             getSingleVariableOfVariableStatement(host) ||
12105             getNestedModuleDeclaration(host) ||
12106             host;
12107         return decl;
12108     }
12109     ts.getEffectiveJSDocHost = getEffectiveJSDocHost;
12110     function getJSDocHost(node) {
12111         return ts.Debug.checkDefined(ts.findAncestor(node.parent, ts.isJSDoc)).parent;
12112     }
12113     ts.getJSDocHost = getJSDocHost;
12114     function getTypeParameterFromJsDoc(node) {
12115         var name = node.name.escapedText;
12116         var typeParameters = node.parent.parent.parent.typeParameters;
12117         return typeParameters && ts.find(typeParameters, function (p) { return p.name.escapedText === name; });
12118     }
12119     ts.getTypeParameterFromJsDoc = getTypeParameterFromJsDoc;
12120     function hasRestParameter(s) {
12121         var last = ts.lastOrUndefined(s.parameters);
12122         return !!last && isRestParameter(last);
12123     }
12124     ts.hasRestParameter = hasRestParameter;
12125     function isRestParameter(node) {
12126         var type = ts.isJSDocParameterTag(node) ? (node.typeExpression && node.typeExpression.type) : node.type;
12127         return node.dotDotDotToken !== undefined || !!type && type.kind === 309;
12128     }
12129     ts.isRestParameter = isRestParameter;
12130     function hasTypeArguments(node) {
12131         return !!node.typeArguments;
12132     }
12133     ts.hasTypeArguments = hasTypeArguments;
12134     function getAssignmentTargetKind(node) {
12135         var parent = node.parent;
12136         while (true) {
12137             switch (parent.kind) {
12138                 case 216:
12139                     var binaryOperator = parent.operatorToken.kind;
12140                     return isAssignmentOperator(binaryOperator) && parent.left === node ?
12141                         binaryOperator === 62 || isLogicalOrCoalescingAssignmentOperator(binaryOperator) ? 1 : 2 :
12142                         0;
12143                 case 214:
12144                 case 215:
12145                     var unaryOperator = parent.operator;
12146                     return unaryOperator === 45 || unaryOperator === 46 ? 2 : 0;
12147                 case 238:
12148                 case 239:
12149                     return parent.initializer === node ? 1 : 0;
12150                 case 207:
12151                 case 199:
12152                 case 220:
12153                 case 225:
12154                     node = parent;
12155                     break;
12156                 case 289:
12157                     if (parent.name !== node) {
12158                         return 0;
12159                     }
12160                     node = parent.parent;
12161                     break;
12162                 case 288:
12163                     if (parent.name === node) {
12164                         return 0;
12165                     }
12166                     node = parent.parent;
12167                     break;
12168                 default:
12169                     return 0;
12170             }
12171             parent = node.parent;
12172         }
12173     }
12174     ts.getAssignmentTargetKind = getAssignmentTargetKind;
12175     function isAssignmentTarget(node) {
12176         return getAssignmentTargetKind(node) !== 0;
12177     }
12178     ts.isAssignmentTarget = isAssignmentTarget;
12179     function isNodeWithPossibleHoistedDeclaration(node) {
12180         switch (node.kind) {
12181             case 230:
12182             case 232:
12183             case 243:
12184             case 234:
12185             case 244:
12186             case 258:
12187             case 284:
12188             case 285:
12189             case 245:
12190             case 237:
12191             case 238:
12192             case 239:
12193             case 235:
12194             case 236:
12195             case 247:
12196             case 287:
12197                 return true;
12198         }
12199         return false;
12200     }
12201     ts.isNodeWithPossibleHoistedDeclaration = isNodeWithPossibleHoistedDeclaration;
12202     function isValueSignatureDeclaration(node) {
12203         return ts.isFunctionExpression(node) || ts.isArrowFunction(node) || ts.isMethodOrAccessor(node) || ts.isFunctionDeclaration(node) || ts.isConstructorDeclaration(node);
12204     }
12205     ts.isValueSignatureDeclaration = isValueSignatureDeclaration;
12206     function walkUp(node, kind) {
12207         while (node && node.kind === kind) {
12208             node = node.parent;
12209         }
12210         return node;
12211     }
12212     function walkUpParenthesizedTypes(node) {
12213         return walkUp(node, 186);
12214     }
12215     ts.walkUpParenthesizedTypes = walkUpParenthesizedTypes;
12216     function walkUpParenthesizedExpressions(node) {
12217         return walkUp(node, 207);
12218     }
12219     ts.walkUpParenthesizedExpressions = walkUpParenthesizedExpressions;
12220     function walkUpParenthesizedTypesAndGetParentAndChild(node) {
12221         var child;
12222         while (node && node.kind === 186) {
12223             child = node;
12224             node = node.parent;
12225         }
12226         return [child, node];
12227     }
12228     ts.walkUpParenthesizedTypesAndGetParentAndChild = walkUpParenthesizedTypesAndGetParentAndChild;
12229     function skipParentheses(node) {
12230         return ts.skipOuterExpressions(node, 1);
12231     }
12232     ts.skipParentheses = skipParentheses;
12233     function skipParenthesesUp(node) {
12234         while (node.kind === 207) {
12235             node = node.parent;
12236         }
12237         return node;
12238     }
12239     function isDeleteTarget(node) {
12240         if (node.kind !== 201 && node.kind !== 202) {
12241             return false;
12242         }
12243         node = walkUpParenthesizedExpressions(node.parent);
12244         return node && node.kind === 210;
12245     }
12246     ts.isDeleteTarget = isDeleteTarget;
12247     function isNodeDescendantOf(node, ancestor) {
12248         while (node) {
12249             if (node === ancestor)
12250                 return true;
12251             node = node.parent;
12252         }
12253         return false;
12254     }
12255     ts.isNodeDescendantOf = isNodeDescendantOf;
12256     function isDeclarationName(name) {
12257         return !ts.isSourceFile(name) && !ts.isBindingPattern(name) && ts.isDeclaration(name.parent) && name.parent.name === name;
12258     }
12259     ts.isDeclarationName = isDeclarationName;
12260     function getDeclarationFromName(name) {
12261         var parent = name.parent;
12262         switch (name.kind) {
12263             case 10:
12264             case 14:
12265             case 8:
12266                 if (ts.isComputedPropertyName(parent))
12267                     return parent.parent;
12268             case 78:
12269                 if (ts.isDeclaration(parent)) {
12270                     return parent.name === name ? parent : undefined;
12271                 }
12272                 else if (ts.isQualifiedName(parent)) {
12273                     var tag = parent.parent;
12274                     return ts.isJSDocParameterTag(tag) && tag.name === parent ? tag : undefined;
12275                 }
12276                 else {
12277                     var binExp = parent.parent;
12278                     return ts.isBinaryExpression(binExp) &&
12279                         getAssignmentDeclarationKind(binExp) !== 0 &&
12280                         (binExp.left.symbol || binExp.symbol) &&
12281                         ts.getNameOfDeclaration(binExp) === name
12282                         ? binExp
12283                         : undefined;
12284                 }
12285             case 79:
12286                 return ts.isDeclaration(parent) && parent.name === name ? parent : undefined;
12287             default:
12288                 return undefined;
12289         }
12290     }
12291     ts.getDeclarationFromName = getDeclarationFromName;
12292     function isLiteralComputedPropertyDeclarationName(node) {
12293         return isStringOrNumericLiteralLike(node) &&
12294             node.parent.kind === 158 &&
12295             ts.isDeclaration(node.parent.parent);
12296     }
12297     ts.isLiteralComputedPropertyDeclarationName = isLiteralComputedPropertyDeclarationName;
12298     function isIdentifierName(node) {
12299         var parent = node.parent;
12300         switch (parent.kind) {
12301             case 163:
12302             case 162:
12303             case 165:
12304             case 164:
12305             case 167:
12306             case 168:
12307             case 291:
12308             case 288:
12309             case 201:
12310                 return parent.name === node;
12311             case 157:
12312                 return parent.right === node;
12313             case 198:
12314             case 265:
12315                 return parent.propertyName === node;
12316             case 270:
12317             case 280:
12318                 return true;
12319         }
12320         return false;
12321     }
12322     ts.isIdentifierName = isIdentifierName;
12323     function isAliasSymbolDeclaration(node) {
12324         return node.kind === 260 ||
12325             node.kind === 259 ||
12326             node.kind === 262 && !!node.name ||
12327             node.kind === 263 ||
12328             node.kind === 269 ||
12329             node.kind === 265 ||
12330             node.kind === 270 ||
12331             node.kind === 266 && exportAssignmentIsAlias(node) ||
12332             ts.isBinaryExpression(node) && getAssignmentDeclarationKind(node) === 2 && exportAssignmentIsAlias(node) ||
12333             ts.isPropertyAccessExpression(node) && ts.isBinaryExpression(node.parent) && node.parent.left === node && node.parent.operatorToken.kind === 62 && isAliasableExpression(node.parent.right) ||
12334             node.kind === 289 ||
12335             node.kind === 288 && isAliasableExpression(node.initializer);
12336     }
12337     ts.isAliasSymbolDeclaration = isAliasSymbolDeclaration;
12338     function getAliasDeclarationFromName(node) {
12339         switch (node.parent.kind) {
12340             case 262:
12341             case 265:
12342             case 263:
12343             case 270:
12344             case 266:
12345             case 260:
12346                 return node.parent;
12347             case 157:
12348                 do {
12349                     node = node.parent;
12350                 } while (node.parent.kind === 157);
12351                 return getAliasDeclarationFromName(node);
12352         }
12353     }
12354     ts.getAliasDeclarationFromName = getAliasDeclarationFromName;
12355     function isAliasableExpression(e) {
12356         return isEntityNameExpression(e) || ts.isClassExpression(e);
12357     }
12358     ts.isAliasableExpression = isAliasableExpression;
12359     function exportAssignmentIsAlias(node) {
12360         var e = getExportAssignmentExpression(node);
12361         return isAliasableExpression(e);
12362     }
12363     ts.exportAssignmentIsAlias = exportAssignmentIsAlias;
12364     function getExportAssignmentExpression(node) {
12365         return ts.isExportAssignment(node) ? node.expression : node.right;
12366     }
12367     ts.getExportAssignmentExpression = getExportAssignmentExpression;
12368     function getPropertyAssignmentAliasLikeExpression(node) {
12369         return node.kind === 289 ? node.name : node.kind === 288 ? node.initializer :
12370             node.parent.right;
12371     }
12372     ts.getPropertyAssignmentAliasLikeExpression = getPropertyAssignmentAliasLikeExpression;
12373     function getEffectiveBaseTypeNode(node) {
12374         var baseType = getClassExtendsHeritageElement(node);
12375         if (baseType && isInJSFile(node)) {
12376             var tag = ts.getJSDocAugmentsTag(node);
12377             if (tag) {
12378                 return tag.class;
12379             }
12380         }
12381         return baseType;
12382     }
12383     ts.getEffectiveBaseTypeNode = getEffectiveBaseTypeNode;
12384     function getClassExtendsHeritageElement(node) {
12385         var heritageClause = getHeritageClause(node.heritageClauses, 93);
12386         return heritageClause && heritageClause.types.length > 0 ? heritageClause.types[0] : undefined;
12387     }
12388     ts.getClassExtendsHeritageElement = getClassExtendsHeritageElement;
12389     function getEffectiveImplementsTypeNodes(node) {
12390         if (isInJSFile(node)) {
12391             return ts.getJSDocImplementsTags(node).map(function (n) { return n.class; });
12392         }
12393         else {
12394             var heritageClause = getHeritageClause(node.heritageClauses, 116);
12395             return heritageClause === null || heritageClause === void 0 ? void 0 : heritageClause.types;
12396         }
12397     }
12398     ts.getEffectiveImplementsTypeNodes = getEffectiveImplementsTypeNodes;
12399     function getAllSuperTypeNodes(node) {
12400         return ts.isInterfaceDeclaration(node) ? getInterfaceBaseTypeNodes(node) || ts.emptyArray :
12401             ts.isClassLike(node) ? ts.concatenate(ts.singleElementArray(getEffectiveBaseTypeNode(node)), getEffectiveImplementsTypeNodes(node)) || ts.emptyArray :
12402                 ts.emptyArray;
12403     }
12404     ts.getAllSuperTypeNodes = getAllSuperTypeNodes;
12405     function getInterfaceBaseTypeNodes(node) {
12406         var heritageClause = getHeritageClause(node.heritageClauses, 93);
12407         return heritageClause ? heritageClause.types : undefined;
12408     }
12409     ts.getInterfaceBaseTypeNodes = getInterfaceBaseTypeNodes;
12410     function getHeritageClause(clauses, kind) {
12411         if (clauses) {
12412             for (var _i = 0, clauses_1 = clauses; _i < clauses_1.length; _i++) {
12413                 var clause = clauses_1[_i];
12414                 if (clause.token === kind) {
12415                     return clause;
12416                 }
12417             }
12418         }
12419         return undefined;
12420     }
12421     ts.getHeritageClause = getHeritageClause;
12422     function getAncestor(node, kind) {
12423         while (node) {
12424             if (node.kind === kind) {
12425                 return node;
12426             }
12427             node = node.parent;
12428         }
12429         return undefined;
12430     }
12431     ts.getAncestor = getAncestor;
12432     function isKeyword(token) {
12433         return 80 <= token && token <= 156;
12434     }
12435     ts.isKeyword = isKeyword;
12436     function isContextualKeyword(token) {
12437         return 125 <= token && token <= 156;
12438     }
12439     ts.isContextualKeyword = isContextualKeyword;
12440     function isNonContextualKeyword(token) {
12441         return isKeyword(token) && !isContextualKeyword(token);
12442     }
12443     ts.isNonContextualKeyword = isNonContextualKeyword;
12444     function isFutureReservedKeyword(token) {
12445         return 116 <= token && token <= 124;
12446     }
12447     ts.isFutureReservedKeyword = isFutureReservedKeyword;
12448     function isStringANonContextualKeyword(name) {
12449         var token = ts.stringToToken(name);
12450         return token !== undefined && isNonContextualKeyword(token);
12451     }
12452     ts.isStringANonContextualKeyword = isStringANonContextualKeyword;
12453     function isStringAKeyword(name) {
12454         var token = ts.stringToToken(name);
12455         return token !== undefined && isKeyword(token);
12456     }
12457     ts.isStringAKeyword = isStringAKeyword;
12458     function isIdentifierANonContextualKeyword(_a) {
12459         var originalKeywordKind = _a.originalKeywordKind;
12460         return !!originalKeywordKind && !isContextualKeyword(originalKeywordKind);
12461     }
12462     ts.isIdentifierANonContextualKeyword = isIdentifierANonContextualKeyword;
12463     function isTrivia(token) {
12464         return 2 <= token && token <= 7;
12465     }
12466     ts.isTrivia = isTrivia;
12467     function getFunctionFlags(node) {
12468         if (!node) {
12469             return 4;
12470         }
12471         var flags = 0;
12472         switch (node.kind) {
12473             case 251:
12474             case 208:
12475             case 165:
12476                 if (node.asteriskToken) {
12477                     flags |= 1;
12478                 }
12479             case 209:
12480                 if (hasSyntacticModifier(node, 256)) {
12481                     flags |= 2;
12482                 }
12483                 break;
12484         }
12485         if (!node.body) {
12486             flags |= 4;
12487         }
12488         return flags;
12489     }
12490     ts.getFunctionFlags = getFunctionFlags;
12491     function isAsyncFunction(node) {
12492         switch (node.kind) {
12493             case 251:
12494             case 208:
12495             case 209:
12496             case 165:
12497                 return node.body !== undefined
12498                     && node.asteriskToken === undefined
12499                     && hasSyntacticModifier(node, 256);
12500         }
12501         return false;
12502     }
12503     ts.isAsyncFunction = isAsyncFunction;
12504     function isStringOrNumericLiteralLike(node) {
12505         return ts.isStringLiteralLike(node) || ts.isNumericLiteral(node);
12506     }
12507     ts.isStringOrNumericLiteralLike = isStringOrNumericLiteralLike;
12508     function isSignedNumericLiteral(node) {
12509         return ts.isPrefixUnaryExpression(node) && (node.operator === 39 || node.operator === 40) && ts.isNumericLiteral(node.operand);
12510     }
12511     ts.isSignedNumericLiteral = isSignedNumericLiteral;
12512     function hasDynamicName(declaration) {
12513         var name = ts.getNameOfDeclaration(declaration);
12514         return !!name && isDynamicName(name);
12515     }
12516     ts.hasDynamicName = hasDynamicName;
12517     function isDynamicName(name) {
12518         if (!(name.kind === 158 || name.kind === 202)) {
12519             return false;
12520         }
12521         var expr = ts.isElementAccessExpression(name) ? skipParentheses(name.argumentExpression) : name.expression;
12522         return !isStringOrNumericLiteralLike(expr) &&
12523             !isSignedNumericLiteral(expr) &&
12524             !isWellKnownSymbolSyntactically(expr);
12525     }
12526     ts.isDynamicName = isDynamicName;
12527     function isWellKnownSymbolSyntactically(node) {
12528         return ts.isPropertyAccessExpression(node) && isESSymbolIdentifier(node.expression);
12529     }
12530     ts.isWellKnownSymbolSyntactically = isWellKnownSymbolSyntactically;
12531     function getPropertyNameForPropertyNameNode(name) {
12532         switch (name.kind) {
12533             case 78:
12534             case 79:
12535                 return name.escapedText;
12536             case 10:
12537             case 8:
12538                 return ts.escapeLeadingUnderscores(name.text);
12539             case 158:
12540                 var nameExpression = name.expression;
12541                 if (isWellKnownSymbolSyntactically(nameExpression)) {
12542                     return getPropertyNameForKnownSymbolName(ts.idText(nameExpression.name));
12543                 }
12544                 else if (isStringOrNumericLiteralLike(nameExpression)) {
12545                     return ts.escapeLeadingUnderscores(nameExpression.text);
12546                 }
12547                 else if (isSignedNumericLiteral(nameExpression)) {
12548                     if (nameExpression.operator === 40) {
12549                         return ts.tokenToString(nameExpression.operator) + nameExpression.operand.text;
12550                     }
12551                     return nameExpression.operand.text;
12552                 }
12553                 return undefined;
12554             default:
12555                 return ts.Debug.assertNever(name);
12556         }
12557     }
12558     ts.getPropertyNameForPropertyNameNode = getPropertyNameForPropertyNameNode;
12559     function isPropertyNameLiteral(node) {
12560         switch (node.kind) {
12561             case 78:
12562             case 10:
12563             case 14:
12564             case 8:
12565                 return true;
12566             default:
12567                 return false;
12568         }
12569     }
12570     ts.isPropertyNameLiteral = isPropertyNameLiteral;
12571     function getTextOfIdentifierOrLiteral(node) {
12572         return ts.isIdentifierOrPrivateIdentifier(node) ? ts.idText(node) : node.text;
12573     }
12574     ts.getTextOfIdentifierOrLiteral = getTextOfIdentifierOrLiteral;
12575     function getEscapedTextOfIdentifierOrLiteral(node) {
12576         return ts.isIdentifierOrPrivateIdentifier(node) ? node.escapedText : ts.escapeLeadingUnderscores(node.text);
12577     }
12578     ts.getEscapedTextOfIdentifierOrLiteral = getEscapedTextOfIdentifierOrLiteral;
12579     function getPropertyNameForUniqueESSymbol(symbol) {
12580         return "__@" + ts.getSymbolId(symbol) + "@" + symbol.escapedName;
12581     }
12582     ts.getPropertyNameForUniqueESSymbol = getPropertyNameForUniqueESSymbol;
12583     function getPropertyNameForKnownSymbolName(symbolName) {
12584         return "__@" + symbolName;
12585     }
12586     ts.getPropertyNameForKnownSymbolName = getPropertyNameForKnownSymbolName;
12587     function getSymbolNameForPrivateIdentifier(containingClassSymbol, description) {
12588         return "__#" + ts.getSymbolId(containingClassSymbol) + "@" + description;
12589     }
12590     ts.getSymbolNameForPrivateIdentifier = getSymbolNameForPrivateIdentifier;
12591     function isKnownSymbol(symbol) {
12592         return ts.startsWith(symbol.escapedName, "__@");
12593     }
12594     ts.isKnownSymbol = isKnownSymbol;
12595     function isESSymbolIdentifier(node) {
12596         return node.kind === 78 && node.escapedText === "Symbol";
12597     }
12598     ts.isESSymbolIdentifier = isESSymbolIdentifier;
12599     function isPushOrUnshiftIdentifier(node) {
12600         return node.escapedText === "push" || node.escapedText === "unshift";
12601     }
12602     ts.isPushOrUnshiftIdentifier = isPushOrUnshiftIdentifier;
12603     function isParameterDeclaration(node) {
12604         var root = getRootDeclaration(node);
12605         return root.kind === 160;
12606     }
12607     ts.isParameterDeclaration = isParameterDeclaration;
12608     function getRootDeclaration(node) {
12609         while (node.kind === 198) {
12610             node = node.parent.parent;
12611         }
12612         return node;
12613     }
12614     ts.getRootDeclaration = getRootDeclaration;
12615     function nodeStartsNewLexicalEnvironment(node) {
12616         var kind = node.kind;
12617         return kind === 166
12618             || kind === 208
12619             || kind === 251
12620             || kind === 209
12621             || kind === 165
12622             || kind === 167
12623             || kind === 168
12624             || kind === 256
12625             || kind === 297;
12626     }
12627     ts.nodeStartsNewLexicalEnvironment = nodeStartsNewLexicalEnvironment;
12628     function nodeIsSynthesized(range) {
12629         return positionIsSynthesized(range.pos)
12630             || positionIsSynthesized(range.end);
12631     }
12632     ts.nodeIsSynthesized = nodeIsSynthesized;
12633     function getOriginalSourceFile(sourceFile) {
12634         return ts.getParseTreeNode(sourceFile, ts.isSourceFile) || sourceFile;
12635     }
12636     ts.getOriginalSourceFile = getOriginalSourceFile;
12637     function getExpressionAssociativity(expression) {
12638         var operator = getOperator(expression);
12639         var hasArguments = expression.kind === 204 && expression.arguments !== undefined;
12640         return getOperatorAssociativity(expression.kind, operator, hasArguments);
12641     }
12642     ts.getExpressionAssociativity = getExpressionAssociativity;
12643     function getOperatorAssociativity(kind, operator, hasArguments) {
12644         switch (kind) {
12645             case 204:
12646                 return hasArguments ? 0 : 1;
12647             case 214:
12648             case 211:
12649             case 212:
12650             case 210:
12651             case 213:
12652             case 217:
12653             case 219:
12654                 return 1;
12655             case 216:
12656                 switch (operator) {
12657                     case 42:
12658                     case 62:
12659                     case 63:
12660                     case 64:
12661                     case 66:
12662                     case 65:
12663                     case 67:
12664                     case 68:
12665                     case 69:
12666                     case 70:
12667                     case 71:
12668                     case 72:
12669                     case 77:
12670                     case 73:
12671                     case 74:
12672                     case 75:
12673                     case 76:
12674                         return 1;
12675                 }
12676         }
12677         return 0;
12678     }
12679     ts.getOperatorAssociativity = getOperatorAssociativity;
12680     function getExpressionPrecedence(expression) {
12681         var operator = getOperator(expression);
12682         var hasArguments = expression.kind === 204 && expression.arguments !== undefined;
12683         return getOperatorPrecedence(expression.kind, operator, hasArguments);
12684     }
12685     ts.getExpressionPrecedence = getExpressionPrecedence;
12686     function getOperator(expression) {
12687         if (expression.kind === 216) {
12688             return expression.operatorToken.kind;
12689         }
12690         else if (expression.kind === 214 || expression.kind === 215) {
12691             return expression.operator;
12692         }
12693         else {
12694             return expression.kind;
12695         }
12696     }
12697     ts.getOperator = getOperator;
12698     function getOperatorPrecedence(nodeKind, operatorKind, hasArguments) {
12699         switch (nodeKind) {
12700             case 337:
12701                 return 0;
12702             case 220:
12703                 return 1;
12704             case 219:
12705                 return 2;
12706             case 217:
12707                 return 4;
12708             case 216:
12709                 switch (operatorKind) {
12710                     case 27:
12711                         return 0;
12712                     case 62:
12713                     case 63:
12714                     case 64:
12715                     case 66:
12716                     case 65:
12717                     case 67:
12718                     case 68:
12719                     case 69:
12720                     case 70:
12721                     case 71:
12722                     case 72:
12723                     case 77:
12724                     case 73:
12725                     case 74:
12726                     case 75:
12727                     case 76:
12728                         return 3;
12729                     default:
12730                         return getBinaryOperatorPrecedence(operatorKind);
12731                 }
12732             case 214:
12733             case 211:
12734             case 212:
12735             case 210:
12736             case 213:
12737                 return 16;
12738             case 215:
12739                 return 17;
12740             case 203:
12741                 return 18;
12742             case 204:
12743                 return hasArguments ? 19 : 18;
12744             case 205:
12745             case 201:
12746             case 202:
12747                 return 19;
12748             case 107:
12749             case 105:
12750             case 78:
12751             case 103:
12752             case 109:
12753             case 94:
12754             case 8:
12755             case 9:
12756             case 10:
12757             case 199:
12758             case 200:
12759             case 208:
12760             case 209:
12761             case 221:
12762             case 13:
12763             case 14:
12764             case 218:
12765             case 207:
12766             case 222:
12767             case 273:
12768             case 274:
12769             case 277:
12770                 return 20;
12771             default:
12772                 return -1;
12773         }
12774     }
12775     ts.getOperatorPrecedence = getOperatorPrecedence;
12776     function getBinaryOperatorPrecedence(kind) {
12777         switch (kind) {
12778             case 60:
12779                 return 4;
12780             case 56:
12781                 return 5;
12782             case 55:
12783                 return 6;
12784             case 51:
12785                 return 7;
12786             case 52:
12787                 return 8;
12788             case 50:
12789                 return 9;
12790             case 34:
12791             case 35:
12792             case 36:
12793             case 37:
12794                 return 10;
12795             case 29:
12796             case 31:
12797             case 32:
12798             case 33:
12799             case 101:
12800             case 100:
12801             case 126:
12802                 return 11;
12803             case 47:
12804             case 48:
12805             case 49:
12806                 return 12;
12807             case 39:
12808             case 40:
12809                 return 13;
12810             case 41:
12811             case 43:
12812             case 44:
12813                 return 14;
12814             case 42:
12815                 return 15;
12816         }
12817         return -1;
12818     }
12819     ts.getBinaryOperatorPrecedence = getBinaryOperatorPrecedence;
12820     function getSemanticJsxChildren(children) {
12821         return ts.filter(children, function (i) {
12822             switch (i.kind) {
12823                 case 283:
12824                     return !!i.expression;
12825                 case 11:
12826                     return !i.containsOnlyTriviaWhiteSpaces;
12827                 default:
12828                     return true;
12829             }
12830         });
12831     }
12832     ts.getSemanticJsxChildren = getSemanticJsxChildren;
12833     function createDiagnosticCollection() {
12834         var nonFileDiagnostics = [];
12835         var filesWithDiagnostics = [];
12836         var fileDiagnostics = new ts.Map();
12837         var hasReadNonFileDiagnostics = false;
12838         return {
12839             add: add,
12840             lookup: lookup,
12841             getGlobalDiagnostics: getGlobalDiagnostics,
12842             getDiagnostics: getDiagnostics,
12843             reattachFileDiagnostics: reattachFileDiagnostics
12844         };
12845         function reattachFileDiagnostics(newFile) {
12846             ts.forEach(fileDiagnostics.get(newFile.fileName), function (diagnostic) { return diagnostic.file = newFile; });
12847         }
12848         function lookup(diagnostic) {
12849             var diagnostics;
12850             if (diagnostic.file) {
12851                 diagnostics = fileDiagnostics.get(diagnostic.file.fileName);
12852             }
12853             else {
12854                 diagnostics = nonFileDiagnostics;
12855             }
12856             if (!diagnostics) {
12857                 return undefined;
12858             }
12859             var result = ts.binarySearch(diagnostics, diagnostic, ts.identity, compareDiagnosticsSkipRelatedInformation);
12860             if (result >= 0) {
12861                 return diagnostics[result];
12862             }
12863             return undefined;
12864         }
12865         function add(diagnostic) {
12866             var diagnostics;
12867             if (diagnostic.file) {
12868                 diagnostics = fileDiagnostics.get(diagnostic.file.fileName);
12869                 if (!diagnostics) {
12870                     diagnostics = [];
12871                     fileDiagnostics.set(diagnostic.file.fileName, diagnostics);
12872                     ts.insertSorted(filesWithDiagnostics, diagnostic.file.fileName, ts.compareStringsCaseSensitive);
12873                 }
12874             }
12875             else {
12876                 if (hasReadNonFileDiagnostics) {
12877                     hasReadNonFileDiagnostics = false;
12878                     nonFileDiagnostics = nonFileDiagnostics.slice();
12879                 }
12880                 diagnostics = nonFileDiagnostics;
12881             }
12882             ts.insertSorted(diagnostics, diagnostic, compareDiagnostics);
12883         }
12884         function getGlobalDiagnostics() {
12885             hasReadNonFileDiagnostics = true;
12886             return nonFileDiagnostics;
12887         }
12888         function getDiagnostics(fileName) {
12889             if (fileName) {
12890                 return fileDiagnostics.get(fileName) || [];
12891             }
12892             var fileDiags = ts.flatMapToMutable(filesWithDiagnostics, function (f) { return fileDiagnostics.get(f); });
12893             if (!nonFileDiagnostics.length) {
12894                 return fileDiags;
12895             }
12896             fileDiags.unshift.apply(fileDiags, nonFileDiagnostics);
12897             return fileDiags;
12898         }
12899     }
12900     ts.createDiagnosticCollection = createDiagnosticCollection;
12901     var templateSubstitutionRegExp = /\$\{/g;
12902     function escapeTemplateSubstitution(str) {
12903         return str.replace(templateSubstitutionRegExp, "\\${");
12904     }
12905     function hasInvalidEscape(template) {
12906         return template && !!(ts.isNoSubstitutionTemplateLiteral(template)
12907             ? template.templateFlags
12908             : (template.head.templateFlags || ts.some(template.templateSpans, function (span) { return !!span.literal.templateFlags; })));
12909     }
12910     ts.hasInvalidEscape = hasInvalidEscape;
12911     var doubleQuoteEscapedCharsRegExp = /[\\\"\u0000-\u001f\t\v\f\b\r\n\u2028\u2029\u0085]/g;
12912     var singleQuoteEscapedCharsRegExp = /[\\\'\u0000-\u001f\t\v\f\b\r\n\u2028\u2029\u0085]/g;
12913     var backtickQuoteEscapedCharsRegExp = /[\\`]/g;
12914     var escapedCharsMap = new ts.Map(ts.getEntries({
12915         "\t": "\\t",
12916         "\v": "\\v",
12917         "\f": "\\f",
12918         "\b": "\\b",
12919         "\r": "\\r",
12920         "\n": "\\n",
12921         "\\": "\\\\",
12922         "\"": "\\\"",
12923         "\'": "\\\'",
12924         "\`": "\\\`",
12925         "\u2028": "\\u2028",
12926         "\u2029": "\\u2029",
12927         "\u0085": "\\u0085"
12928     }));
12929     function encodeUtf16EscapeSequence(charCode) {
12930         var hexCharCode = charCode.toString(16).toUpperCase();
12931         var paddedHexCode = ("0000" + hexCharCode).slice(-4);
12932         return "\\u" + paddedHexCode;
12933     }
12934     function getReplacement(c, offset, input) {
12935         if (c.charCodeAt(0) === 0) {
12936             var lookAhead = input.charCodeAt(offset + c.length);
12937             if (lookAhead >= 48 && lookAhead <= 57) {
12938                 return "\\x00";
12939             }
12940             return "\\0";
12941         }
12942         return escapedCharsMap.get(c) || encodeUtf16EscapeSequence(c.charCodeAt(0));
12943     }
12944     function escapeString(s, quoteChar) {
12945         var escapedCharsRegExp = quoteChar === 96 ? backtickQuoteEscapedCharsRegExp :
12946             quoteChar === 39 ? singleQuoteEscapedCharsRegExp :
12947                 doubleQuoteEscapedCharsRegExp;
12948         return s.replace(escapedCharsRegExp, getReplacement);
12949     }
12950     ts.escapeString = escapeString;
12951     var nonAsciiCharacters = /[^\u0000-\u007F]/g;
12952     function escapeNonAsciiString(s, quoteChar) {
12953         s = escapeString(s, quoteChar);
12954         return nonAsciiCharacters.test(s) ?
12955             s.replace(nonAsciiCharacters, function (c) { return encodeUtf16EscapeSequence(c.charCodeAt(0)); }) :
12956             s;
12957     }
12958     ts.escapeNonAsciiString = escapeNonAsciiString;
12959     var jsxDoubleQuoteEscapedCharsRegExp = /[\"\u0000-\u001f\u2028\u2029\u0085]/g;
12960     var jsxSingleQuoteEscapedCharsRegExp = /[\'\u0000-\u001f\u2028\u2029\u0085]/g;
12961     var jsxEscapedCharsMap = new ts.Map(ts.getEntries({
12962         "\"": "&quot;",
12963         "\'": "&apos;"
12964     }));
12965     function encodeJsxCharacterEntity(charCode) {
12966         var hexCharCode = charCode.toString(16).toUpperCase();
12967         return "&#x" + hexCharCode + ";";
12968     }
12969     function getJsxAttributeStringReplacement(c) {
12970         if (c.charCodeAt(0) === 0) {
12971             return "&#0;";
12972         }
12973         return jsxEscapedCharsMap.get(c) || encodeJsxCharacterEntity(c.charCodeAt(0));
12974     }
12975     function escapeJsxAttributeString(s, quoteChar) {
12976         var escapedCharsRegExp = quoteChar === 39 ? jsxSingleQuoteEscapedCharsRegExp :
12977             jsxDoubleQuoteEscapedCharsRegExp;
12978         return s.replace(escapedCharsRegExp, getJsxAttributeStringReplacement);
12979     }
12980     ts.escapeJsxAttributeString = escapeJsxAttributeString;
12981     function stripQuotes(name) {
12982         var length = name.length;
12983         if (length >= 2 && name.charCodeAt(0) === name.charCodeAt(length - 1) && isQuoteOrBacktick(name.charCodeAt(0))) {
12984             return name.substring(1, length - 1);
12985         }
12986         return name;
12987     }
12988     ts.stripQuotes = stripQuotes;
12989     function isQuoteOrBacktick(charCode) {
12990         return charCode === 39 ||
12991             charCode === 34 ||
12992             charCode === 96;
12993     }
12994     function isIntrinsicJsxName(name) {
12995         var ch = name.charCodeAt(0);
12996         return (ch >= 97 && ch <= 122) || ts.stringContains(name, "-");
12997     }
12998     ts.isIntrinsicJsxName = isIntrinsicJsxName;
12999     var indentStrings = ["", "    "];
13000     function getIndentString(level) {
13001         var singleLevel = indentStrings[1];
13002         for (var current = indentStrings.length; current <= level; current++) {
13003             indentStrings.push(indentStrings[current - 1] + singleLevel);
13004         }
13005         return indentStrings[level];
13006     }
13007     ts.getIndentString = getIndentString;
13008     function getIndentSize() {
13009         return indentStrings[1].length;
13010     }
13011     ts.getIndentSize = getIndentSize;
13012     function createTextWriter(newLine) {
13013         var output;
13014         var indent;
13015         var lineStart;
13016         var lineCount;
13017         var linePos;
13018         var hasTrailingComment = false;
13019         function updateLineCountAndPosFor(s) {
13020             var lineStartsOfS = ts.computeLineStarts(s);
13021             if (lineStartsOfS.length > 1) {
13022                 lineCount = lineCount + lineStartsOfS.length - 1;
13023                 linePos = output.length - s.length + ts.last(lineStartsOfS);
13024                 lineStart = (linePos - output.length) === 0;
13025             }
13026             else {
13027                 lineStart = false;
13028             }
13029         }
13030         function writeText(s) {
13031             if (s && s.length) {
13032                 if (lineStart) {
13033                     s = getIndentString(indent) + s;
13034                     lineStart = false;
13035                 }
13036                 output += s;
13037                 updateLineCountAndPosFor(s);
13038             }
13039         }
13040         function write(s) {
13041             if (s)
13042                 hasTrailingComment = false;
13043             writeText(s);
13044         }
13045         function writeComment(s) {
13046             if (s)
13047                 hasTrailingComment = true;
13048             writeText(s);
13049         }
13050         function reset() {
13051             output = "";
13052             indent = 0;
13053             lineStart = true;
13054             lineCount = 0;
13055             linePos = 0;
13056             hasTrailingComment = false;
13057         }
13058         function rawWrite(s) {
13059             if (s !== undefined) {
13060                 output += s;
13061                 updateLineCountAndPosFor(s);
13062                 hasTrailingComment = false;
13063             }
13064         }
13065         function writeLiteral(s) {
13066             if (s && s.length) {
13067                 write(s);
13068             }
13069         }
13070         function writeLine(force) {
13071             if (!lineStart || force) {
13072                 output += newLine;
13073                 lineCount++;
13074                 linePos = output.length;
13075                 lineStart = true;
13076                 hasTrailingComment = false;
13077             }
13078         }
13079         function getTextPosWithWriteLine() {
13080             return lineStart ? output.length : (output.length + newLine.length);
13081         }
13082         reset();
13083         return {
13084             write: write,
13085             rawWrite: rawWrite,
13086             writeLiteral: writeLiteral,
13087             writeLine: writeLine,
13088             increaseIndent: function () { indent++; },
13089             decreaseIndent: function () { indent--; },
13090             getIndent: function () { return indent; },
13091             getTextPos: function () { return output.length; },
13092             getLine: function () { return lineCount; },
13093             getColumn: function () { return lineStart ? indent * getIndentSize() : output.length - linePos; },
13094             getText: function () { return output; },
13095             isAtStartOfLine: function () { return lineStart; },
13096             hasTrailingComment: function () { return hasTrailingComment; },
13097             hasTrailingWhitespace: function () { return !!output.length && ts.isWhiteSpaceLike(output.charCodeAt(output.length - 1)); },
13098             clear: reset,
13099             reportInaccessibleThisError: ts.noop,
13100             reportPrivateInBaseOfClassExpression: ts.noop,
13101             reportInaccessibleUniqueSymbolError: ts.noop,
13102             trackSymbol: ts.noop,
13103             writeKeyword: write,
13104             writeOperator: write,
13105             writeParameter: write,
13106             writeProperty: write,
13107             writePunctuation: write,
13108             writeSpace: write,
13109             writeStringLiteral: write,
13110             writeSymbol: function (s, _) { return write(s); },
13111             writeTrailingSemicolon: write,
13112             writeComment: writeComment,
13113             getTextPosWithWriteLine: getTextPosWithWriteLine
13114         };
13115     }
13116     ts.createTextWriter = createTextWriter;
13117     function getTrailingSemicolonDeferringWriter(writer) {
13118         var pendingTrailingSemicolon = false;
13119         function commitPendingTrailingSemicolon() {
13120             if (pendingTrailingSemicolon) {
13121                 writer.writeTrailingSemicolon(";");
13122                 pendingTrailingSemicolon = false;
13123             }
13124         }
13125         return __assign(__assign({}, writer), { writeTrailingSemicolon: function () {
13126                 pendingTrailingSemicolon = true;
13127             },
13128             writeLiteral: function (s) {
13129                 commitPendingTrailingSemicolon();
13130                 writer.writeLiteral(s);
13131             },
13132             writeStringLiteral: function (s) {
13133                 commitPendingTrailingSemicolon();
13134                 writer.writeStringLiteral(s);
13135             },
13136             writeSymbol: function (s, sym) {
13137                 commitPendingTrailingSemicolon();
13138                 writer.writeSymbol(s, sym);
13139             },
13140             writePunctuation: function (s) {
13141                 commitPendingTrailingSemicolon();
13142                 writer.writePunctuation(s);
13143             },
13144             writeKeyword: function (s) {
13145                 commitPendingTrailingSemicolon();
13146                 writer.writeKeyword(s);
13147             },
13148             writeOperator: function (s) {
13149                 commitPendingTrailingSemicolon();
13150                 writer.writeOperator(s);
13151             },
13152             writeParameter: function (s) {
13153                 commitPendingTrailingSemicolon();
13154                 writer.writeParameter(s);
13155             },
13156             writeSpace: function (s) {
13157                 commitPendingTrailingSemicolon();
13158                 writer.writeSpace(s);
13159             },
13160             writeProperty: function (s) {
13161                 commitPendingTrailingSemicolon();
13162                 writer.writeProperty(s);
13163             },
13164             writeComment: function (s) {
13165                 commitPendingTrailingSemicolon();
13166                 writer.writeComment(s);
13167             },
13168             writeLine: function () {
13169                 commitPendingTrailingSemicolon();
13170                 writer.writeLine();
13171             },
13172             increaseIndent: function () {
13173                 commitPendingTrailingSemicolon();
13174                 writer.increaseIndent();
13175             },
13176             decreaseIndent: function () {
13177                 commitPendingTrailingSemicolon();
13178                 writer.decreaseIndent();
13179             } });
13180     }
13181     ts.getTrailingSemicolonDeferringWriter = getTrailingSemicolonDeferringWriter;
13182     function hostUsesCaseSensitiveFileNames(host) {
13183         return host.useCaseSensitiveFileNames ? host.useCaseSensitiveFileNames() : false;
13184     }
13185     ts.hostUsesCaseSensitiveFileNames = hostUsesCaseSensitiveFileNames;
13186     function hostGetCanonicalFileName(host) {
13187         return ts.createGetCanonicalFileName(hostUsesCaseSensitiveFileNames(host));
13188     }
13189     ts.hostGetCanonicalFileName = hostGetCanonicalFileName;
13190     function getResolvedExternalModuleName(host, file, referenceFile) {
13191         return file.moduleName || getExternalModuleNameFromPath(host, file.fileName, referenceFile && referenceFile.fileName);
13192     }
13193     ts.getResolvedExternalModuleName = getResolvedExternalModuleName;
13194     function getExternalModuleNameFromDeclaration(host, resolver, declaration) {
13195         var file = resolver.getExternalModuleFileFromDeclaration(declaration);
13196         if (!file || file.isDeclarationFile) {
13197             return undefined;
13198         }
13199         return getResolvedExternalModuleName(host, file);
13200     }
13201     ts.getExternalModuleNameFromDeclaration = getExternalModuleNameFromDeclaration;
13202     function getExternalModuleNameFromPath(host, fileName, referencePath) {
13203         var getCanonicalFileName = function (f) { return host.getCanonicalFileName(f); };
13204         var dir = ts.toPath(referencePath ? ts.getDirectoryPath(referencePath) : host.getCommonSourceDirectory(), host.getCurrentDirectory(), getCanonicalFileName);
13205         var filePath = ts.getNormalizedAbsolutePath(fileName, host.getCurrentDirectory());
13206         var relativePath = ts.getRelativePathToDirectoryOrUrl(dir, filePath, dir, getCanonicalFileName, false);
13207         var extensionless = removeFileExtension(relativePath);
13208         return referencePath ? ts.ensurePathIsNonModuleName(extensionless) : extensionless;
13209     }
13210     ts.getExternalModuleNameFromPath = getExternalModuleNameFromPath;
13211     function getOwnEmitOutputFilePath(fileName, host, extension) {
13212         var compilerOptions = host.getCompilerOptions();
13213         var emitOutputFilePathWithoutExtension;
13214         if (compilerOptions.outDir) {
13215             emitOutputFilePathWithoutExtension = removeFileExtension(getSourceFilePathInNewDir(fileName, host, compilerOptions.outDir));
13216         }
13217         else {
13218             emitOutputFilePathWithoutExtension = removeFileExtension(fileName);
13219         }
13220         return emitOutputFilePathWithoutExtension + extension;
13221     }
13222     ts.getOwnEmitOutputFilePath = getOwnEmitOutputFilePath;
13223     function getDeclarationEmitOutputFilePath(fileName, host) {
13224         return getDeclarationEmitOutputFilePathWorker(fileName, host.getCompilerOptions(), host.getCurrentDirectory(), host.getCommonSourceDirectory(), function (f) { return host.getCanonicalFileName(f); });
13225     }
13226     ts.getDeclarationEmitOutputFilePath = getDeclarationEmitOutputFilePath;
13227     function getDeclarationEmitOutputFilePathWorker(fileName, options, currentDirectory, commonSourceDirectory, getCanonicalFileName) {
13228         var outputDir = options.declarationDir || options.outDir;
13229         var path = outputDir
13230             ? getSourceFilePathInNewDirWorker(fileName, outputDir, currentDirectory, commonSourceDirectory, getCanonicalFileName)
13231             : fileName;
13232         return removeFileExtension(path) + ".d.ts";
13233     }
13234     ts.getDeclarationEmitOutputFilePathWorker = getDeclarationEmitOutputFilePathWorker;
13235     function outFile(options) {
13236         return options.outFile || options.out;
13237     }
13238     ts.outFile = outFile;
13239     function getPathsBasePath(options, host) {
13240         var _a, _b;
13241         if (!options.paths)
13242             return undefined;
13243         return (_a = options.baseUrl) !== null && _a !== void 0 ? _a : ts.Debug.checkDefined(options.pathsBasePath || ((_b = host.getCurrentDirectory) === null || _b === void 0 ? void 0 : _b.call(host)), "Encountered 'paths' without a 'baseUrl', config file, or host 'getCurrentDirectory'.");
13244     }
13245     ts.getPathsBasePath = getPathsBasePath;
13246     function getSourceFilesToEmit(host, targetSourceFile, forceDtsEmit) {
13247         var options = host.getCompilerOptions();
13248         if (outFile(options)) {
13249             var moduleKind = getEmitModuleKind(options);
13250             var moduleEmitEnabled_1 = options.emitDeclarationOnly || moduleKind === ts.ModuleKind.AMD || moduleKind === ts.ModuleKind.System;
13251             return ts.filter(host.getSourceFiles(), function (sourceFile) {
13252                 return (moduleEmitEnabled_1 || !ts.isExternalModule(sourceFile)) &&
13253                     sourceFileMayBeEmitted(sourceFile, host, forceDtsEmit);
13254             });
13255         }
13256         else {
13257             var sourceFiles = targetSourceFile === undefined ? host.getSourceFiles() : [targetSourceFile];
13258             return ts.filter(sourceFiles, function (sourceFile) { return sourceFileMayBeEmitted(sourceFile, host, forceDtsEmit); });
13259         }
13260     }
13261     ts.getSourceFilesToEmit = getSourceFilesToEmit;
13262     function sourceFileMayBeEmitted(sourceFile, host, forceDtsEmit) {
13263         var options = host.getCompilerOptions();
13264         return !(options.noEmitForJsFiles && isSourceFileJS(sourceFile)) &&
13265             !sourceFile.isDeclarationFile &&
13266             !host.isSourceFileFromExternalLibrary(sourceFile) &&
13267             !(isJsonSourceFile(sourceFile) && host.getResolvedProjectReferenceToRedirect(sourceFile.fileName)) &&
13268             (forceDtsEmit || !host.isSourceOfProjectReferenceRedirect(sourceFile.fileName));
13269     }
13270     ts.sourceFileMayBeEmitted = sourceFileMayBeEmitted;
13271     function getSourceFilePathInNewDir(fileName, host, newDirPath) {
13272         return getSourceFilePathInNewDirWorker(fileName, newDirPath, host.getCurrentDirectory(), host.getCommonSourceDirectory(), function (f) { return host.getCanonicalFileName(f); });
13273     }
13274     ts.getSourceFilePathInNewDir = getSourceFilePathInNewDir;
13275     function getSourceFilePathInNewDirWorker(fileName, newDirPath, currentDirectory, commonSourceDirectory, getCanonicalFileName) {
13276         var sourceFilePath = ts.getNormalizedAbsolutePath(fileName, currentDirectory);
13277         var isSourceFileInCommonSourceDirectory = getCanonicalFileName(sourceFilePath).indexOf(getCanonicalFileName(commonSourceDirectory)) === 0;
13278         sourceFilePath = isSourceFileInCommonSourceDirectory ? sourceFilePath.substring(commonSourceDirectory.length) : sourceFilePath;
13279         return ts.combinePaths(newDirPath, sourceFilePath);
13280     }
13281     ts.getSourceFilePathInNewDirWorker = getSourceFilePathInNewDirWorker;
13282     function writeFile(host, diagnostics, fileName, data, writeByteOrderMark, sourceFiles) {
13283         host.writeFile(fileName, data, writeByteOrderMark, function (hostErrorMessage) {
13284             diagnostics.add(createCompilerDiagnostic(ts.Diagnostics.Could_not_write_file_0_Colon_1, fileName, hostErrorMessage));
13285         }, sourceFiles);
13286     }
13287     ts.writeFile = writeFile;
13288     function ensureDirectoriesExist(directoryPath, createDirectory, directoryExists) {
13289         if (directoryPath.length > ts.getRootLength(directoryPath) && !directoryExists(directoryPath)) {
13290             var parentDirectory = ts.getDirectoryPath(directoryPath);
13291             ensureDirectoriesExist(parentDirectory, createDirectory, directoryExists);
13292             createDirectory(directoryPath);
13293         }
13294     }
13295     function writeFileEnsuringDirectories(path, data, writeByteOrderMark, writeFile, createDirectory, directoryExists) {
13296         try {
13297             writeFile(path, data, writeByteOrderMark);
13298         }
13299         catch (_a) {
13300             ensureDirectoriesExist(ts.getDirectoryPath(ts.normalizePath(path)), createDirectory, directoryExists);
13301             writeFile(path, data, writeByteOrderMark);
13302         }
13303     }
13304     ts.writeFileEnsuringDirectories = writeFileEnsuringDirectories;
13305     function getLineOfLocalPosition(sourceFile, pos) {
13306         var lineStarts = ts.getLineStarts(sourceFile);
13307         return ts.computeLineOfPosition(lineStarts, pos);
13308     }
13309     ts.getLineOfLocalPosition = getLineOfLocalPosition;
13310     function getLineOfLocalPositionFromLineMap(lineMap, pos) {
13311         return ts.computeLineOfPosition(lineMap, pos);
13312     }
13313     ts.getLineOfLocalPositionFromLineMap = getLineOfLocalPositionFromLineMap;
13314     function getFirstConstructorWithBody(node) {
13315         return ts.find(node.members, function (member) { return ts.isConstructorDeclaration(member) && nodeIsPresent(member.body); });
13316     }
13317     ts.getFirstConstructorWithBody = getFirstConstructorWithBody;
13318     function getSetAccessorValueParameter(accessor) {
13319         if (accessor && accessor.parameters.length > 0) {
13320             var hasThis = accessor.parameters.length === 2 && parameterIsThisKeyword(accessor.parameters[0]);
13321             return accessor.parameters[hasThis ? 1 : 0];
13322         }
13323     }
13324     ts.getSetAccessorValueParameter = getSetAccessorValueParameter;
13325     function getSetAccessorTypeAnnotationNode(accessor) {
13326         var parameter = getSetAccessorValueParameter(accessor);
13327         return parameter && parameter.type;
13328     }
13329     ts.getSetAccessorTypeAnnotationNode = getSetAccessorTypeAnnotationNode;
13330     function getThisParameter(signature) {
13331         if (signature.parameters.length && !ts.isJSDocSignature(signature)) {
13332             var thisParameter = signature.parameters[0];
13333             if (parameterIsThisKeyword(thisParameter)) {
13334                 return thisParameter;
13335             }
13336         }
13337     }
13338     ts.getThisParameter = getThisParameter;
13339     function parameterIsThisKeyword(parameter) {
13340         return isThisIdentifier(parameter.name);
13341     }
13342     ts.parameterIsThisKeyword = parameterIsThisKeyword;
13343     function isThisIdentifier(node) {
13344         return !!node && node.kind === 78 && identifierIsThisKeyword(node);
13345     }
13346     ts.isThisIdentifier = isThisIdentifier;
13347     function identifierIsThisKeyword(id) {
13348         return id.originalKeywordKind === 107;
13349     }
13350     ts.identifierIsThisKeyword = identifierIsThisKeyword;
13351     function getAllAccessorDeclarations(declarations, accessor) {
13352         var firstAccessor;
13353         var secondAccessor;
13354         var getAccessor;
13355         var setAccessor;
13356         if (hasDynamicName(accessor)) {
13357             firstAccessor = accessor;
13358             if (accessor.kind === 167) {
13359                 getAccessor = accessor;
13360             }
13361             else if (accessor.kind === 168) {
13362                 setAccessor = accessor;
13363             }
13364             else {
13365                 ts.Debug.fail("Accessor has wrong kind");
13366             }
13367         }
13368         else {
13369             ts.forEach(declarations, function (member) {
13370                 if (ts.isAccessor(member)
13371                     && hasSyntacticModifier(member, 32) === hasSyntacticModifier(accessor, 32)) {
13372                     var memberName = getPropertyNameForPropertyNameNode(member.name);
13373                     var accessorName = getPropertyNameForPropertyNameNode(accessor.name);
13374                     if (memberName === accessorName) {
13375                         if (!firstAccessor) {
13376                             firstAccessor = member;
13377                         }
13378                         else if (!secondAccessor) {
13379                             secondAccessor = member;
13380                         }
13381                         if (member.kind === 167 && !getAccessor) {
13382                             getAccessor = member;
13383                         }
13384                         if (member.kind === 168 && !setAccessor) {
13385                             setAccessor = member;
13386                         }
13387                     }
13388                 }
13389             });
13390         }
13391         return {
13392             firstAccessor: firstAccessor,
13393             secondAccessor: secondAccessor,
13394             getAccessor: getAccessor,
13395             setAccessor: setAccessor
13396         };
13397     }
13398     ts.getAllAccessorDeclarations = getAllAccessorDeclarations;
13399     function getEffectiveTypeAnnotationNode(node) {
13400         if (!isInJSFile(node) && ts.isFunctionDeclaration(node))
13401             return undefined;
13402         var type = node.type;
13403         if (type || !isInJSFile(node))
13404             return type;
13405         return ts.isJSDocPropertyLikeTag(node) ? node.typeExpression && node.typeExpression.type : ts.getJSDocType(node);
13406     }
13407     ts.getEffectiveTypeAnnotationNode = getEffectiveTypeAnnotationNode;
13408     function getTypeAnnotationNode(node) {
13409         return node.type;
13410     }
13411     ts.getTypeAnnotationNode = getTypeAnnotationNode;
13412     function getEffectiveReturnTypeNode(node) {
13413         return ts.isJSDocSignature(node) ?
13414             node.type && node.type.typeExpression && node.type.typeExpression.type :
13415             node.type || (isInJSFile(node) ? ts.getJSDocReturnType(node) : undefined);
13416     }
13417     ts.getEffectiveReturnTypeNode = getEffectiveReturnTypeNode;
13418     function getJSDocTypeParameterDeclarations(node) {
13419         return ts.flatMap(ts.getJSDocTags(node), function (tag) { return isNonTypeAliasTemplate(tag) ? tag.typeParameters : undefined; });
13420     }
13421     ts.getJSDocTypeParameterDeclarations = getJSDocTypeParameterDeclarations;
13422     function isNonTypeAliasTemplate(tag) {
13423         return ts.isJSDocTemplateTag(tag) && !(tag.parent.kind === 311 && tag.parent.tags.some(isJSDocTypeAlias));
13424     }
13425     function getEffectiveSetAccessorTypeAnnotationNode(node) {
13426         var parameter = getSetAccessorValueParameter(node);
13427         return parameter && getEffectiveTypeAnnotationNode(parameter);
13428     }
13429     ts.getEffectiveSetAccessorTypeAnnotationNode = getEffectiveSetAccessorTypeAnnotationNode;
13430     function emitNewLineBeforeLeadingComments(lineMap, writer, node, leadingComments) {
13431         emitNewLineBeforeLeadingCommentsOfPosition(lineMap, writer, node.pos, leadingComments);
13432     }
13433     ts.emitNewLineBeforeLeadingComments = emitNewLineBeforeLeadingComments;
13434     function emitNewLineBeforeLeadingCommentsOfPosition(lineMap, writer, pos, leadingComments) {
13435         if (leadingComments && leadingComments.length && pos !== leadingComments[0].pos &&
13436             getLineOfLocalPositionFromLineMap(lineMap, pos) !== getLineOfLocalPositionFromLineMap(lineMap, leadingComments[0].pos)) {
13437             writer.writeLine();
13438         }
13439     }
13440     ts.emitNewLineBeforeLeadingCommentsOfPosition = emitNewLineBeforeLeadingCommentsOfPosition;
13441     function emitNewLineBeforeLeadingCommentOfPosition(lineMap, writer, pos, commentPos) {
13442         if (pos !== commentPos &&
13443             getLineOfLocalPositionFromLineMap(lineMap, pos) !== getLineOfLocalPositionFromLineMap(lineMap, commentPos)) {
13444             writer.writeLine();
13445         }
13446     }
13447     ts.emitNewLineBeforeLeadingCommentOfPosition = emitNewLineBeforeLeadingCommentOfPosition;
13448     function emitComments(text, lineMap, writer, comments, leadingSeparator, trailingSeparator, newLine, writeComment) {
13449         if (comments && comments.length > 0) {
13450             if (leadingSeparator) {
13451                 writer.writeSpace(" ");
13452             }
13453             var emitInterveningSeparator = false;
13454             for (var _i = 0, comments_1 = comments; _i < comments_1.length; _i++) {
13455                 var comment = comments_1[_i];
13456                 if (emitInterveningSeparator) {
13457                     writer.writeSpace(" ");
13458                     emitInterveningSeparator = false;
13459                 }
13460                 writeComment(text, lineMap, writer, comment.pos, comment.end, newLine);
13461                 if (comment.hasTrailingNewLine) {
13462                     writer.writeLine();
13463                 }
13464                 else {
13465                     emitInterveningSeparator = true;
13466                 }
13467             }
13468             if (emitInterveningSeparator && trailingSeparator) {
13469                 writer.writeSpace(" ");
13470             }
13471         }
13472     }
13473     ts.emitComments = emitComments;
13474     function emitDetachedComments(text, lineMap, writer, writeComment, node, newLine, removeComments) {
13475         var leadingComments;
13476         var currentDetachedCommentInfo;
13477         if (removeComments) {
13478             if (node.pos === 0) {
13479                 leadingComments = ts.filter(ts.getLeadingCommentRanges(text, node.pos), isPinnedCommentLocal);
13480             }
13481         }
13482         else {
13483             leadingComments = ts.getLeadingCommentRanges(text, node.pos);
13484         }
13485         if (leadingComments) {
13486             var detachedComments = [];
13487             var lastComment = void 0;
13488             for (var _i = 0, leadingComments_1 = leadingComments; _i < leadingComments_1.length; _i++) {
13489                 var comment = leadingComments_1[_i];
13490                 if (lastComment) {
13491                     var lastCommentLine = getLineOfLocalPositionFromLineMap(lineMap, lastComment.end);
13492                     var commentLine = getLineOfLocalPositionFromLineMap(lineMap, comment.pos);
13493                     if (commentLine >= lastCommentLine + 2) {
13494                         break;
13495                     }
13496                 }
13497                 detachedComments.push(comment);
13498                 lastComment = comment;
13499             }
13500             if (detachedComments.length) {
13501                 var lastCommentLine = getLineOfLocalPositionFromLineMap(lineMap, ts.last(detachedComments).end);
13502                 var nodeLine = getLineOfLocalPositionFromLineMap(lineMap, ts.skipTrivia(text, node.pos));
13503                 if (nodeLine >= lastCommentLine + 2) {
13504                     emitNewLineBeforeLeadingComments(lineMap, writer, node, leadingComments);
13505                     emitComments(text, lineMap, writer, detachedComments, false, true, newLine, writeComment);
13506                     currentDetachedCommentInfo = { nodePos: node.pos, detachedCommentEndPos: ts.last(detachedComments).end };
13507                 }
13508             }
13509         }
13510         return currentDetachedCommentInfo;
13511         function isPinnedCommentLocal(comment) {
13512             return isPinnedComment(text, comment.pos);
13513         }
13514     }
13515     ts.emitDetachedComments = emitDetachedComments;
13516     function writeCommentRange(text, lineMap, writer, commentPos, commentEnd, newLine) {
13517         if (text.charCodeAt(commentPos + 1) === 42) {
13518             var firstCommentLineAndCharacter = ts.computeLineAndCharacterOfPosition(lineMap, commentPos);
13519             var lineCount = lineMap.length;
13520             var firstCommentLineIndent = void 0;
13521             for (var pos = commentPos, currentLine = firstCommentLineAndCharacter.line; pos < commentEnd; currentLine++) {
13522                 var nextLineStart = (currentLine + 1) === lineCount
13523                     ? text.length + 1
13524                     : lineMap[currentLine + 1];
13525                 if (pos !== commentPos) {
13526                     if (firstCommentLineIndent === undefined) {
13527                         firstCommentLineIndent = calculateIndent(text, lineMap[firstCommentLineAndCharacter.line], commentPos);
13528                     }
13529                     var currentWriterIndentSpacing = writer.getIndent() * getIndentSize();
13530                     var spacesToEmit = currentWriterIndentSpacing - firstCommentLineIndent + calculateIndent(text, pos, nextLineStart);
13531                     if (spacesToEmit > 0) {
13532                         var numberOfSingleSpacesToEmit = spacesToEmit % getIndentSize();
13533                         var indentSizeSpaceString = getIndentString((spacesToEmit - numberOfSingleSpacesToEmit) / getIndentSize());
13534                         writer.rawWrite(indentSizeSpaceString);
13535                         while (numberOfSingleSpacesToEmit) {
13536                             writer.rawWrite(" ");
13537                             numberOfSingleSpacesToEmit--;
13538                         }
13539                     }
13540                     else {
13541                         writer.rawWrite("");
13542                     }
13543                 }
13544                 writeTrimmedCurrentLine(text, commentEnd, writer, newLine, pos, nextLineStart);
13545                 pos = nextLineStart;
13546             }
13547         }
13548         else {
13549             writer.writeComment(text.substring(commentPos, commentEnd));
13550         }
13551     }
13552     ts.writeCommentRange = writeCommentRange;
13553     function writeTrimmedCurrentLine(text, commentEnd, writer, newLine, pos, nextLineStart) {
13554         var end = Math.min(commentEnd, nextLineStart - 1);
13555         var currentLineText = text.substring(pos, end).replace(/^\s+|\s+$/g, "");
13556         if (currentLineText) {
13557             writer.writeComment(currentLineText);
13558             if (end !== commentEnd) {
13559                 writer.writeLine();
13560             }
13561         }
13562         else {
13563             writer.rawWrite(newLine);
13564         }
13565     }
13566     function calculateIndent(text, pos, end) {
13567         var currentLineIndent = 0;
13568         for (; pos < end && ts.isWhiteSpaceSingleLine(text.charCodeAt(pos)); pos++) {
13569             if (text.charCodeAt(pos) === 9) {
13570                 currentLineIndent += getIndentSize() - (currentLineIndent % getIndentSize());
13571             }
13572             else {
13573                 currentLineIndent++;
13574             }
13575         }
13576         return currentLineIndent;
13577     }
13578     function hasEffectiveModifiers(node) {
13579         return getEffectiveModifierFlags(node) !== 0;
13580     }
13581     ts.hasEffectiveModifiers = hasEffectiveModifiers;
13582     function hasSyntacticModifiers(node) {
13583         return getSyntacticModifierFlags(node) !== 0;
13584     }
13585     ts.hasSyntacticModifiers = hasSyntacticModifiers;
13586     function hasEffectiveModifier(node, flags) {
13587         return !!getSelectedEffectiveModifierFlags(node, flags);
13588     }
13589     ts.hasEffectiveModifier = hasEffectiveModifier;
13590     function hasSyntacticModifier(node, flags) {
13591         return !!getSelectedSyntacticModifierFlags(node, flags);
13592     }
13593     ts.hasSyntacticModifier = hasSyntacticModifier;
13594     function hasStaticModifier(node) {
13595         return hasSyntacticModifier(node, 32);
13596     }
13597     ts.hasStaticModifier = hasStaticModifier;
13598     function hasEffectiveReadonlyModifier(node) {
13599         return hasEffectiveModifier(node, 64);
13600     }
13601     ts.hasEffectiveReadonlyModifier = hasEffectiveReadonlyModifier;
13602     function getSelectedEffectiveModifierFlags(node, flags) {
13603         return getEffectiveModifierFlags(node) & flags;
13604     }
13605     ts.getSelectedEffectiveModifierFlags = getSelectedEffectiveModifierFlags;
13606     function getSelectedSyntacticModifierFlags(node, flags) {
13607         return getSyntacticModifierFlags(node) & flags;
13608     }
13609     ts.getSelectedSyntacticModifierFlags = getSelectedSyntacticModifierFlags;
13610     function getModifierFlagsWorker(node, includeJSDoc, alwaysIncludeJSDoc) {
13611         if (node.kind >= 0 && node.kind <= 156) {
13612             return 0;
13613         }
13614         if (!(node.modifierFlagsCache & 536870912)) {
13615             node.modifierFlagsCache = getSyntacticModifierFlagsNoCache(node) | 536870912;
13616         }
13617         if (includeJSDoc && !(node.modifierFlagsCache & 4096) && (alwaysIncludeJSDoc || isInJSFile(node)) && node.parent) {
13618             node.modifierFlagsCache |= getJSDocModifierFlagsNoCache(node) | 4096;
13619         }
13620         return node.modifierFlagsCache & ~(536870912 | 4096);
13621     }
13622     function getEffectiveModifierFlags(node) {
13623         return getModifierFlagsWorker(node, true);
13624     }
13625     ts.getEffectiveModifierFlags = getEffectiveModifierFlags;
13626     function getEffectiveModifierFlagsAlwaysIncludeJSDoc(node) {
13627         return getModifierFlagsWorker(node, true, true);
13628     }
13629     ts.getEffectiveModifierFlagsAlwaysIncludeJSDoc = getEffectiveModifierFlagsAlwaysIncludeJSDoc;
13630     function getSyntacticModifierFlags(node) {
13631         return getModifierFlagsWorker(node, false);
13632     }
13633     ts.getSyntacticModifierFlags = getSyntacticModifierFlags;
13634     function getJSDocModifierFlagsNoCache(node) {
13635         var flags = 0;
13636         if (!!node.parent && !ts.isParameter(node)) {
13637             if (isInJSFile(node)) {
13638                 if (ts.getJSDocPublicTagNoCache(node))
13639                     flags |= 4;
13640                 if (ts.getJSDocPrivateTagNoCache(node))
13641                     flags |= 8;
13642                 if (ts.getJSDocProtectedTagNoCache(node))
13643                     flags |= 16;
13644                 if (ts.getJSDocReadonlyTagNoCache(node))
13645                     flags |= 64;
13646             }
13647             if (ts.getJSDocDeprecatedTagNoCache(node))
13648                 flags |= 8192;
13649         }
13650         return flags;
13651     }
13652     function getEffectiveModifierFlagsNoCache(node) {
13653         return getSyntacticModifierFlagsNoCache(node) | getJSDocModifierFlagsNoCache(node);
13654     }
13655     ts.getEffectiveModifierFlagsNoCache = getEffectiveModifierFlagsNoCache;
13656     function getSyntacticModifierFlagsNoCache(node) {
13657         var flags = modifiersToFlags(node.modifiers);
13658         if (node.flags & 4 || (node.kind === 78 && node.isInJSDocNamespace)) {
13659             flags |= 1;
13660         }
13661         return flags;
13662     }
13663     ts.getSyntacticModifierFlagsNoCache = getSyntacticModifierFlagsNoCache;
13664     function modifiersToFlags(modifiers) {
13665         var flags = 0;
13666         if (modifiers) {
13667             for (var _i = 0, modifiers_1 = modifiers; _i < modifiers_1.length; _i++) {
13668                 var modifier = modifiers_1[_i];
13669                 flags |= modifierToFlag(modifier.kind);
13670             }
13671         }
13672         return flags;
13673     }
13674     ts.modifiersToFlags = modifiersToFlags;
13675     function modifierToFlag(token) {
13676         switch (token) {
13677             case 123: return 32;
13678             case 122: return 4;
13679             case 121: return 16;
13680             case 120: return 8;
13681             case 125: return 128;
13682             case 92: return 1;
13683             case 133: return 2;
13684             case 84: return 2048;
13685             case 87: return 512;
13686             case 129: return 256;
13687             case 142: return 64;
13688         }
13689         return 0;
13690     }
13691     ts.modifierToFlag = modifierToFlag;
13692     function isLogicalOperator(token) {
13693         return token === 56
13694             || token === 55
13695             || token === 53;
13696     }
13697     ts.isLogicalOperator = isLogicalOperator;
13698     function isLogicalOrCoalescingAssignmentOperator(token) {
13699         return token === 74
13700             || token === 75
13701             || token === 76;
13702     }
13703     ts.isLogicalOrCoalescingAssignmentOperator = isLogicalOrCoalescingAssignmentOperator;
13704     function isLogicalOrCoalescingAssignmentExpression(expr) {
13705         return isLogicalOrCoalescingAssignmentOperator(expr.operatorToken.kind);
13706     }
13707     ts.isLogicalOrCoalescingAssignmentExpression = isLogicalOrCoalescingAssignmentExpression;
13708     function isAssignmentOperator(token) {
13709         return token >= 62 && token <= 77;
13710     }
13711     ts.isAssignmentOperator = isAssignmentOperator;
13712     function tryGetClassExtendingExpressionWithTypeArguments(node) {
13713         var cls = tryGetClassImplementingOrExtendingExpressionWithTypeArguments(node);
13714         return cls && !cls.isImplements ? cls.class : undefined;
13715     }
13716     ts.tryGetClassExtendingExpressionWithTypeArguments = tryGetClassExtendingExpressionWithTypeArguments;
13717     function tryGetClassImplementingOrExtendingExpressionWithTypeArguments(node) {
13718         return ts.isExpressionWithTypeArguments(node)
13719             && ts.isHeritageClause(node.parent)
13720             && ts.isClassLike(node.parent.parent)
13721             ? { class: node.parent.parent, isImplements: node.parent.token === 116 }
13722             : undefined;
13723     }
13724     ts.tryGetClassImplementingOrExtendingExpressionWithTypeArguments = tryGetClassImplementingOrExtendingExpressionWithTypeArguments;
13725     function isAssignmentExpression(node, excludeCompoundAssignment) {
13726         return ts.isBinaryExpression(node)
13727             && (excludeCompoundAssignment
13728                 ? node.operatorToken.kind === 62
13729                 : isAssignmentOperator(node.operatorToken.kind))
13730             && ts.isLeftHandSideExpression(node.left);
13731     }
13732     ts.isAssignmentExpression = isAssignmentExpression;
13733     function isDestructuringAssignment(node) {
13734         if (isAssignmentExpression(node, true)) {
13735             var kind = node.left.kind;
13736             return kind === 200
13737                 || kind === 199;
13738         }
13739         return false;
13740     }
13741     ts.isDestructuringAssignment = isDestructuringAssignment;
13742     function isExpressionWithTypeArgumentsInClassExtendsClause(node) {
13743         return tryGetClassExtendingExpressionWithTypeArguments(node) !== undefined;
13744     }
13745     ts.isExpressionWithTypeArgumentsInClassExtendsClause = isExpressionWithTypeArgumentsInClassExtendsClause;
13746     function isEntityNameExpression(node) {
13747         return node.kind === 78 || isPropertyAccessEntityNameExpression(node);
13748     }
13749     ts.isEntityNameExpression = isEntityNameExpression;
13750     function getFirstIdentifier(node) {
13751         switch (node.kind) {
13752             case 78:
13753                 return node;
13754             case 157:
13755                 do {
13756                     node = node.left;
13757                 } while (node.kind !== 78);
13758                 return node;
13759             case 201:
13760                 do {
13761                     node = node.expression;
13762                 } while (node.kind !== 78);
13763                 return node;
13764         }
13765     }
13766     ts.getFirstIdentifier = getFirstIdentifier;
13767     function isDottedName(node) {
13768         return node.kind === 78 || node.kind === 107 || node.kind === 105 ||
13769             node.kind === 201 && isDottedName(node.expression) ||
13770             node.kind === 207 && isDottedName(node.expression);
13771     }
13772     ts.isDottedName = isDottedName;
13773     function isPropertyAccessEntityNameExpression(node) {
13774         return ts.isPropertyAccessExpression(node) && ts.isIdentifier(node.name) && isEntityNameExpression(node.expression);
13775     }
13776     ts.isPropertyAccessEntityNameExpression = isPropertyAccessEntityNameExpression;
13777     function tryGetPropertyAccessOrIdentifierToString(expr) {
13778         if (ts.isPropertyAccessExpression(expr)) {
13779             var baseStr = tryGetPropertyAccessOrIdentifierToString(expr.expression);
13780             if (baseStr !== undefined) {
13781                 return baseStr + "." + entityNameToString(expr.name);
13782             }
13783         }
13784         else if (ts.isIdentifier(expr)) {
13785             return ts.unescapeLeadingUnderscores(expr.escapedText);
13786         }
13787         return undefined;
13788     }
13789     ts.tryGetPropertyAccessOrIdentifierToString = tryGetPropertyAccessOrIdentifierToString;
13790     function isPrototypeAccess(node) {
13791         return isBindableStaticAccessExpression(node) && getElementOrPropertyAccessName(node) === "prototype";
13792     }
13793     ts.isPrototypeAccess = isPrototypeAccess;
13794     function isRightSideOfQualifiedNameOrPropertyAccess(node) {
13795         return (node.parent.kind === 157 && node.parent.right === node) ||
13796             (node.parent.kind === 201 && node.parent.name === node);
13797     }
13798     ts.isRightSideOfQualifiedNameOrPropertyAccess = isRightSideOfQualifiedNameOrPropertyAccess;
13799     function isEmptyObjectLiteral(expression) {
13800         return expression.kind === 200 &&
13801             expression.properties.length === 0;
13802     }
13803     ts.isEmptyObjectLiteral = isEmptyObjectLiteral;
13804     function isEmptyArrayLiteral(expression) {
13805         return expression.kind === 199 &&
13806             expression.elements.length === 0;
13807     }
13808     ts.isEmptyArrayLiteral = isEmptyArrayLiteral;
13809     function getLocalSymbolForExportDefault(symbol) {
13810         if (!isExportDefaultSymbol(symbol))
13811             return undefined;
13812         for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) {
13813             var decl = _a[_i];
13814             if (decl.localSymbol)
13815                 return decl.localSymbol;
13816         }
13817         return undefined;
13818     }
13819     ts.getLocalSymbolForExportDefault = getLocalSymbolForExportDefault;
13820     function isExportDefaultSymbol(symbol) {
13821         return symbol && ts.length(symbol.declarations) > 0 && hasSyntacticModifier(symbol.declarations[0], 512);
13822     }
13823     function tryExtractTSExtension(fileName) {
13824         return ts.find(ts.supportedTSExtensionsForExtractExtension, function (extension) { return ts.fileExtensionIs(fileName, extension); });
13825     }
13826     ts.tryExtractTSExtension = tryExtractTSExtension;
13827     function getExpandedCharCodes(input) {
13828         var output = [];
13829         var length = input.length;
13830         for (var i = 0; i < length; i++) {
13831             var charCode = input.charCodeAt(i);
13832             if (charCode < 0x80) {
13833                 output.push(charCode);
13834             }
13835             else if (charCode < 0x800) {
13836                 output.push((charCode >> 6) | 192);
13837                 output.push((charCode & 63) | 128);
13838             }
13839             else if (charCode < 0x10000) {
13840                 output.push((charCode >> 12) | 224);
13841                 output.push(((charCode >> 6) & 63) | 128);
13842                 output.push((charCode & 63) | 128);
13843             }
13844             else if (charCode < 0x20000) {
13845                 output.push((charCode >> 18) | 240);
13846                 output.push(((charCode >> 12) & 63) | 128);
13847                 output.push(((charCode >> 6) & 63) | 128);
13848                 output.push((charCode & 63) | 128);
13849             }
13850             else {
13851                 ts.Debug.assert(false, "Unexpected code point");
13852             }
13853         }
13854         return output;
13855     }
13856     var base64Digits = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";
13857     function convertToBase64(input) {
13858         var result = "";
13859         var charCodes = getExpandedCharCodes(input);
13860         var i = 0;
13861         var length = charCodes.length;
13862         var byte1, byte2, byte3, byte4;
13863         while (i < length) {
13864             byte1 = charCodes[i] >> 2;
13865             byte2 = (charCodes[i] & 3) << 4 | charCodes[i + 1] >> 4;
13866             byte3 = (charCodes[i + 1] & 15) << 2 | charCodes[i + 2] >> 6;
13867             byte4 = charCodes[i + 2] & 63;
13868             if (i + 1 >= length) {
13869                 byte3 = byte4 = 64;
13870             }
13871             else if (i + 2 >= length) {
13872                 byte4 = 64;
13873             }
13874             result += base64Digits.charAt(byte1) + base64Digits.charAt(byte2) + base64Digits.charAt(byte3) + base64Digits.charAt(byte4);
13875             i += 3;
13876         }
13877         return result;
13878     }
13879     ts.convertToBase64 = convertToBase64;
13880     function getStringFromExpandedCharCodes(codes) {
13881         var output = "";
13882         var i = 0;
13883         var length = codes.length;
13884         while (i < length) {
13885             var charCode = codes[i];
13886             if (charCode < 0x80) {
13887                 output += String.fromCharCode(charCode);
13888                 i++;
13889             }
13890             else if ((charCode & 192) === 192) {
13891                 var value = charCode & 63;
13892                 i++;
13893                 var nextCode = codes[i];
13894                 while ((nextCode & 192) === 128) {
13895                     value = (value << 6) | (nextCode & 63);
13896                     i++;
13897                     nextCode = codes[i];
13898                 }
13899                 output += String.fromCharCode(value);
13900             }
13901             else {
13902                 output += String.fromCharCode(charCode);
13903                 i++;
13904             }
13905         }
13906         return output;
13907     }
13908     function base64encode(host, input) {
13909         if (host && host.base64encode) {
13910             return host.base64encode(input);
13911         }
13912         return convertToBase64(input);
13913     }
13914     ts.base64encode = base64encode;
13915     function base64decode(host, input) {
13916         if (host && host.base64decode) {
13917             return host.base64decode(input);
13918         }
13919         var length = input.length;
13920         var expandedCharCodes = [];
13921         var i = 0;
13922         while (i < length) {
13923             if (input.charCodeAt(i) === base64Digits.charCodeAt(64)) {
13924                 break;
13925             }
13926             var ch1 = base64Digits.indexOf(input[i]);
13927             var ch2 = base64Digits.indexOf(input[i + 1]);
13928             var ch3 = base64Digits.indexOf(input[i + 2]);
13929             var ch4 = base64Digits.indexOf(input[i + 3]);
13930             var code1 = ((ch1 & 63) << 2) | ((ch2 >> 4) & 3);
13931             var code2 = ((ch2 & 15) << 4) | ((ch3 >> 2) & 15);
13932             var code3 = ((ch3 & 3) << 6) | (ch4 & 63);
13933             if (code2 === 0 && ch3 !== 0) {
13934                 expandedCharCodes.push(code1);
13935             }
13936             else if (code3 === 0 && ch4 !== 0) {
13937                 expandedCharCodes.push(code1, code2);
13938             }
13939             else {
13940                 expandedCharCodes.push(code1, code2, code3);
13941             }
13942             i += 4;
13943         }
13944         return getStringFromExpandedCharCodes(expandedCharCodes);
13945     }
13946     ts.base64decode = base64decode;
13947     function readJson(path, host) {
13948         try {
13949             var jsonText = host.readFile(path);
13950             if (!jsonText)
13951                 return {};
13952             var result = ts.parseConfigFileTextToJson(path, jsonText);
13953             if (result.error) {
13954                 return {};
13955             }
13956             return result.config;
13957         }
13958         catch (e) {
13959             return {};
13960         }
13961     }
13962     ts.readJson = readJson;
13963     function directoryProbablyExists(directoryName, host) {
13964         return !host.directoryExists || host.directoryExists(directoryName);
13965     }
13966     ts.directoryProbablyExists = directoryProbablyExists;
13967     var carriageReturnLineFeed = "\r\n";
13968     var lineFeed = "\n";
13969     function getNewLineCharacter(options, getNewLine) {
13970         switch (options.newLine) {
13971             case 0:
13972                 return carriageReturnLineFeed;
13973             case 1:
13974                 return lineFeed;
13975         }
13976         return getNewLine ? getNewLine() : ts.sys ? ts.sys.newLine : carriageReturnLineFeed;
13977     }
13978     ts.getNewLineCharacter = getNewLineCharacter;
13979     function createRange(pos, end) {
13980         if (end === void 0) { end = pos; }
13981         ts.Debug.assert(end >= pos || end === -1);
13982         return { pos: pos, end: end };
13983     }
13984     ts.createRange = createRange;
13985     function moveRangeEnd(range, end) {
13986         return createRange(range.pos, end);
13987     }
13988     ts.moveRangeEnd = moveRangeEnd;
13989     function moveRangePos(range, pos) {
13990         return createRange(pos, range.end);
13991     }
13992     ts.moveRangePos = moveRangePos;
13993     function moveRangePastDecorators(node) {
13994         return node.decorators && node.decorators.length > 0
13995             ? moveRangePos(node, node.decorators.end)
13996             : node;
13997     }
13998     ts.moveRangePastDecorators = moveRangePastDecorators;
13999     function moveRangePastModifiers(node) {
14000         return node.modifiers && node.modifiers.length > 0
14001             ? moveRangePos(node, node.modifiers.end)
14002             : moveRangePastDecorators(node);
14003     }
14004     ts.moveRangePastModifiers = moveRangePastModifiers;
14005     function isCollapsedRange(range) {
14006         return range.pos === range.end;
14007     }
14008     ts.isCollapsedRange = isCollapsedRange;
14009     function createTokenRange(pos, token) {
14010         return createRange(pos, pos + ts.tokenToString(token).length);
14011     }
14012     ts.createTokenRange = createTokenRange;
14013     function rangeIsOnSingleLine(range, sourceFile) {
14014         return rangeStartIsOnSameLineAsRangeEnd(range, range, sourceFile);
14015     }
14016     ts.rangeIsOnSingleLine = rangeIsOnSingleLine;
14017     function rangeStartPositionsAreOnSameLine(range1, range2, sourceFile) {
14018         return positionsAreOnSameLine(getStartPositionOfRange(range1, sourceFile, false), getStartPositionOfRange(range2, sourceFile, false), sourceFile);
14019     }
14020     ts.rangeStartPositionsAreOnSameLine = rangeStartPositionsAreOnSameLine;
14021     function rangeEndPositionsAreOnSameLine(range1, range2, sourceFile) {
14022         return positionsAreOnSameLine(range1.end, range2.end, sourceFile);
14023     }
14024     ts.rangeEndPositionsAreOnSameLine = rangeEndPositionsAreOnSameLine;
14025     function rangeStartIsOnSameLineAsRangeEnd(range1, range2, sourceFile) {
14026         return positionsAreOnSameLine(getStartPositionOfRange(range1, sourceFile, false), range2.end, sourceFile);
14027     }
14028     ts.rangeStartIsOnSameLineAsRangeEnd = rangeStartIsOnSameLineAsRangeEnd;
14029     function rangeEndIsOnSameLineAsRangeStart(range1, range2, sourceFile) {
14030         return positionsAreOnSameLine(range1.end, getStartPositionOfRange(range2, sourceFile, false), sourceFile);
14031     }
14032     ts.rangeEndIsOnSameLineAsRangeStart = rangeEndIsOnSameLineAsRangeStart;
14033     function getLinesBetweenRangeEndAndRangeStart(range1, range2, sourceFile, includeSecondRangeComments) {
14034         var range2Start = getStartPositionOfRange(range2, sourceFile, includeSecondRangeComments);
14035         return ts.getLinesBetweenPositions(sourceFile, range1.end, range2Start);
14036     }
14037     ts.getLinesBetweenRangeEndAndRangeStart = getLinesBetweenRangeEndAndRangeStart;
14038     function getLinesBetweenRangeEndPositions(range1, range2, sourceFile) {
14039         return ts.getLinesBetweenPositions(sourceFile, range1.end, range2.end);
14040     }
14041     ts.getLinesBetweenRangeEndPositions = getLinesBetweenRangeEndPositions;
14042     function isNodeArrayMultiLine(list, sourceFile) {
14043         return !positionsAreOnSameLine(list.pos, list.end, sourceFile);
14044     }
14045     ts.isNodeArrayMultiLine = isNodeArrayMultiLine;
14046     function positionsAreOnSameLine(pos1, pos2, sourceFile) {
14047         return ts.getLinesBetweenPositions(sourceFile, pos1, pos2) === 0;
14048     }
14049     ts.positionsAreOnSameLine = positionsAreOnSameLine;
14050     function getStartPositionOfRange(range, sourceFile, includeComments) {
14051         return positionIsSynthesized(range.pos) ? -1 : ts.skipTrivia(sourceFile.text, range.pos, false, includeComments);
14052     }
14053     ts.getStartPositionOfRange = getStartPositionOfRange;
14054     function getLinesBetweenPositionAndPrecedingNonWhitespaceCharacter(pos, stopPos, sourceFile, includeComments) {
14055         var startPos = ts.skipTrivia(sourceFile.text, pos, false, includeComments);
14056         var prevPos = getPreviousNonWhitespacePosition(startPos, stopPos, sourceFile);
14057         return ts.getLinesBetweenPositions(sourceFile, prevPos !== null && prevPos !== void 0 ? prevPos : stopPos, startPos);
14058     }
14059     ts.getLinesBetweenPositionAndPrecedingNonWhitespaceCharacter = getLinesBetweenPositionAndPrecedingNonWhitespaceCharacter;
14060     function getLinesBetweenPositionAndNextNonWhitespaceCharacter(pos, stopPos, sourceFile, includeComments) {
14061         var nextPos = ts.skipTrivia(sourceFile.text, pos, false, includeComments);
14062         return ts.getLinesBetweenPositions(sourceFile, pos, Math.min(stopPos, nextPos));
14063     }
14064     ts.getLinesBetweenPositionAndNextNonWhitespaceCharacter = getLinesBetweenPositionAndNextNonWhitespaceCharacter;
14065     function getPreviousNonWhitespacePosition(pos, stopPos, sourceFile) {
14066         if (stopPos === void 0) { stopPos = 0; }
14067         while (pos-- > stopPos) {
14068             if (!ts.isWhiteSpaceLike(sourceFile.text.charCodeAt(pos))) {
14069                 return pos;
14070             }
14071         }
14072     }
14073     function isDeclarationNameOfEnumOrNamespace(node) {
14074         var parseNode = ts.getParseTreeNode(node);
14075         if (parseNode) {
14076             switch (parseNode.parent.kind) {
14077                 case 255:
14078                 case 256:
14079                     return parseNode === parseNode.parent.name;
14080             }
14081         }
14082         return false;
14083     }
14084     ts.isDeclarationNameOfEnumOrNamespace = isDeclarationNameOfEnumOrNamespace;
14085     function getInitializedVariables(node) {
14086         return ts.filter(node.declarations, isInitializedVariable);
14087     }
14088     ts.getInitializedVariables = getInitializedVariables;
14089     function isInitializedVariable(node) {
14090         return node.initializer !== undefined;
14091     }
14092     function isWatchSet(options) {
14093         return options.watch && options.hasOwnProperty("watch");
14094     }
14095     ts.isWatchSet = isWatchSet;
14096     function closeFileWatcher(watcher) {
14097         watcher.close();
14098     }
14099     ts.closeFileWatcher = closeFileWatcher;
14100     function getCheckFlags(symbol) {
14101         return symbol.flags & 33554432 ? symbol.checkFlags : 0;
14102     }
14103     ts.getCheckFlags = getCheckFlags;
14104     function getDeclarationModifierFlagsFromSymbol(s) {
14105         if (s.valueDeclaration) {
14106             var flags = ts.getCombinedModifierFlags(s.valueDeclaration);
14107             return s.parent && s.parent.flags & 32 ? flags : flags & ~28;
14108         }
14109         if (getCheckFlags(s) & 6) {
14110             var checkFlags = s.checkFlags;
14111             var accessModifier = checkFlags & 1024 ? 8 :
14112                 checkFlags & 256 ? 4 :
14113                     16;
14114             var staticModifier = checkFlags & 2048 ? 32 : 0;
14115             return accessModifier | staticModifier;
14116         }
14117         if (s.flags & 4194304) {
14118             return 4 | 32;
14119         }
14120         return 0;
14121     }
14122     ts.getDeclarationModifierFlagsFromSymbol = getDeclarationModifierFlagsFromSymbol;
14123     function skipAlias(symbol, checker) {
14124         return symbol.flags & 2097152 ? checker.getAliasedSymbol(symbol) : symbol;
14125     }
14126     ts.skipAlias = skipAlias;
14127     function getCombinedLocalAndExportSymbolFlags(symbol) {
14128         return symbol.exportSymbol ? symbol.exportSymbol.flags | symbol.flags : symbol.flags;
14129     }
14130     ts.getCombinedLocalAndExportSymbolFlags = getCombinedLocalAndExportSymbolFlags;
14131     function isWriteOnlyAccess(node) {
14132         return accessKind(node) === 1;
14133     }
14134     ts.isWriteOnlyAccess = isWriteOnlyAccess;
14135     function isWriteAccess(node) {
14136         return accessKind(node) !== 0;
14137     }
14138     ts.isWriteAccess = isWriteAccess;
14139     function accessKind(node) {
14140         var parent = node.parent;
14141         if (!parent)
14142             return 0;
14143         switch (parent.kind) {
14144             case 207:
14145                 return accessKind(parent);
14146             case 215:
14147             case 214:
14148                 var operator = parent.operator;
14149                 return operator === 45 || operator === 46 ? writeOrReadWrite() : 0;
14150             case 216:
14151                 var _a = parent, left = _a.left, operatorToken = _a.operatorToken;
14152                 return left === node && isAssignmentOperator(operatorToken.kind) ?
14153                     operatorToken.kind === 62 ? 1 : writeOrReadWrite()
14154                     : 0;
14155             case 201:
14156                 return parent.name !== node ? 0 : accessKind(parent);
14157             case 288: {
14158                 var parentAccess = accessKind(parent.parent);
14159                 return node === parent.name ? reverseAccessKind(parentAccess) : parentAccess;
14160             }
14161             case 289:
14162                 return node === parent.objectAssignmentInitializer ? 0 : accessKind(parent.parent);
14163             case 199:
14164                 return accessKind(parent);
14165             default:
14166                 return 0;
14167         }
14168         function writeOrReadWrite() {
14169             return parent.parent && skipParenthesesUp(parent.parent).kind === 233 ? 1 : 2;
14170         }
14171     }
14172     function reverseAccessKind(a) {
14173         switch (a) {
14174             case 0:
14175                 return 1;
14176             case 1:
14177                 return 0;
14178             case 2:
14179                 return 2;
14180             default:
14181                 return ts.Debug.assertNever(a);
14182         }
14183     }
14184     function compareDataObjects(dst, src) {
14185         if (!dst || !src || Object.keys(dst).length !== Object.keys(src).length) {
14186             return false;
14187         }
14188         for (var e in dst) {
14189             if (typeof dst[e] === "object") {
14190                 if (!compareDataObjects(dst[e], src[e])) {
14191                     return false;
14192                 }
14193             }
14194             else if (typeof dst[e] !== "function") {
14195                 if (dst[e] !== src[e]) {
14196                     return false;
14197                 }
14198             }
14199         }
14200         return true;
14201     }
14202     ts.compareDataObjects = compareDataObjects;
14203     function clearMap(map, onDeleteValue) {
14204         map.forEach(onDeleteValue);
14205         map.clear();
14206     }
14207     ts.clearMap = clearMap;
14208     function mutateMapSkippingNewValues(map, newMap, options) {
14209         var onDeleteValue = options.onDeleteValue, onExistingValue = options.onExistingValue;
14210         map.forEach(function (existingValue, key) {
14211             var valueInNewMap = newMap.get(key);
14212             if (valueInNewMap === undefined) {
14213                 map.delete(key);
14214                 onDeleteValue(existingValue, key);
14215             }
14216             else if (onExistingValue) {
14217                 onExistingValue(existingValue, valueInNewMap, key);
14218             }
14219         });
14220     }
14221     ts.mutateMapSkippingNewValues = mutateMapSkippingNewValues;
14222     function mutateMap(map, newMap, options) {
14223         mutateMapSkippingNewValues(map, newMap, options);
14224         var createNewValue = options.createNewValue;
14225         newMap.forEach(function (valueInNewMap, key) {
14226             if (!map.has(key)) {
14227                 map.set(key, createNewValue(key, valueInNewMap));
14228             }
14229         });
14230     }
14231     ts.mutateMap = mutateMap;
14232     function isAbstractConstructorType(type) {
14233         return !!(getObjectFlags(type) & 16) && !!type.symbol && isAbstractConstructorSymbol(type.symbol);
14234     }
14235     ts.isAbstractConstructorType = isAbstractConstructorType;
14236     function isAbstractConstructorSymbol(symbol) {
14237         if (symbol.flags & 32) {
14238             var declaration = getClassLikeDeclarationOfSymbol(symbol);
14239             return !!declaration && hasSyntacticModifier(declaration, 128);
14240         }
14241         return false;
14242     }
14243     ts.isAbstractConstructorSymbol = isAbstractConstructorSymbol;
14244     function getClassLikeDeclarationOfSymbol(symbol) {
14245         return ts.find(symbol.declarations, ts.isClassLike);
14246     }
14247     ts.getClassLikeDeclarationOfSymbol = getClassLikeDeclarationOfSymbol;
14248     function getObjectFlags(type) {
14249         return type.flags & 3899393 ? type.objectFlags : 0;
14250     }
14251     ts.getObjectFlags = getObjectFlags;
14252     function typeHasCallOrConstructSignatures(type, checker) {
14253         return checker.getSignaturesOfType(type, 0).length !== 0 || checker.getSignaturesOfType(type, 1).length !== 0;
14254     }
14255     ts.typeHasCallOrConstructSignatures = typeHasCallOrConstructSignatures;
14256     function forSomeAncestorDirectory(directory, callback) {
14257         return !!ts.forEachAncestorDirectory(directory, function (d) { return callback(d) ? true : undefined; });
14258     }
14259     ts.forSomeAncestorDirectory = forSomeAncestorDirectory;
14260     function isUMDExportSymbol(symbol) {
14261         return !!symbol && !!symbol.declarations && !!symbol.declarations[0] && ts.isNamespaceExportDeclaration(symbol.declarations[0]);
14262     }
14263     ts.isUMDExportSymbol = isUMDExportSymbol;
14264     function showModuleSpecifier(_a) {
14265         var moduleSpecifier = _a.moduleSpecifier;
14266         return ts.isStringLiteral(moduleSpecifier) ? moduleSpecifier.text : getTextOfNode(moduleSpecifier);
14267     }
14268     ts.showModuleSpecifier = showModuleSpecifier;
14269     function getLastChild(node) {
14270         var lastChild;
14271         ts.forEachChild(node, function (child) {
14272             if (nodeIsPresent(child))
14273                 lastChild = child;
14274         }, function (children) {
14275             for (var i = children.length - 1; i >= 0; i--) {
14276                 if (nodeIsPresent(children[i])) {
14277                     lastChild = children[i];
14278                     break;
14279                 }
14280             }
14281         });
14282         return lastChild;
14283     }
14284     ts.getLastChild = getLastChild;
14285     function addToSeen(seen, key, value) {
14286         if (value === void 0) { value = true; }
14287         key = String(key);
14288         if (seen.has(key)) {
14289             return false;
14290         }
14291         seen.set(key, value);
14292         return true;
14293     }
14294     ts.addToSeen = addToSeen;
14295     function isObjectTypeDeclaration(node) {
14296         return ts.isClassLike(node) || ts.isInterfaceDeclaration(node) || ts.isTypeLiteralNode(node);
14297     }
14298     ts.isObjectTypeDeclaration = isObjectTypeDeclaration;
14299     function isTypeNodeKind(kind) {
14300         return (kind >= 172 && kind <= 195)
14301             || kind === 128
14302             || kind === 152
14303             || kind === 144
14304             || kind === 155
14305             || kind === 145
14306             || kind === 131
14307             || kind === 147
14308             || kind === 148
14309             || kind === 113
14310             || kind === 150
14311             || kind === 141
14312             || kind === 223
14313             || kind === 303
14314             || kind === 304
14315             || kind === 305
14316             || kind === 306
14317             || kind === 307
14318             || kind === 308
14319             || kind === 309;
14320     }
14321     ts.isTypeNodeKind = isTypeNodeKind;
14322     function isAccessExpression(node) {
14323         return node.kind === 201 || node.kind === 202;
14324     }
14325     ts.isAccessExpression = isAccessExpression;
14326     function getNameOfAccessExpression(node) {
14327         if (node.kind === 201) {
14328             return node.name;
14329         }
14330         ts.Debug.assert(node.kind === 202);
14331         return node.argumentExpression;
14332     }
14333     ts.getNameOfAccessExpression = getNameOfAccessExpression;
14334     function isBundleFileTextLike(section) {
14335         switch (section.kind) {
14336             case "text":
14337             case "internal":
14338                 return true;
14339             default:
14340                 return false;
14341         }
14342     }
14343     ts.isBundleFileTextLike = isBundleFileTextLike;
14344     function isNamedImportsOrExports(node) {
14345         return node.kind === 264 || node.kind === 268;
14346     }
14347     ts.isNamedImportsOrExports = isNamedImportsOrExports;
14348     function getLeftmostAccessExpression(expr) {
14349         while (isAccessExpression(expr)) {
14350             expr = expr.expression;
14351         }
14352         return expr;
14353     }
14354     ts.getLeftmostAccessExpression = getLeftmostAccessExpression;
14355     function getLeftmostExpression(node, stopAtCallExpressions) {
14356         while (true) {
14357             switch (node.kind) {
14358                 case 215:
14359                     node = node.operand;
14360                     continue;
14361                 case 216:
14362                     node = node.left;
14363                     continue;
14364                 case 217:
14365                     node = node.condition;
14366                     continue;
14367                 case 205:
14368                     node = node.tag;
14369                     continue;
14370                 case 203:
14371                     if (stopAtCallExpressions) {
14372                         return node;
14373                     }
14374                 case 224:
14375                 case 202:
14376                 case 201:
14377                 case 225:
14378                 case 336:
14379                     node = node.expression;
14380                     continue;
14381             }
14382             return node;
14383         }
14384     }
14385     ts.getLeftmostExpression = getLeftmostExpression;
14386     function Symbol(flags, name) {
14387         this.flags = flags;
14388         this.escapedName = name;
14389         this.declarations = undefined;
14390         this.valueDeclaration = undefined;
14391         this.id = undefined;
14392         this.mergeId = undefined;
14393         this.parent = undefined;
14394     }
14395     function Type(checker, flags) {
14396         this.flags = flags;
14397         if (ts.Debug.isDebugging || ts.tracing.isTracing()) {
14398             this.checker = checker;
14399         }
14400     }
14401     function Signature(checker, flags) {
14402         this.flags = flags;
14403         if (ts.Debug.isDebugging) {
14404             this.checker = checker;
14405         }
14406     }
14407     function Node(kind, pos, end) {
14408         this.pos = pos;
14409         this.end = end;
14410         this.kind = kind;
14411         this.id = 0;
14412         this.flags = 0;
14413         this.modifierFlagsCache = 0;
14414         this.transformFlags = 0;
14415         this.parent = undefined;
14416         this.original = undefined;
14417     }
14418     function Token(kind, pos, end) {
14419         this.pos = pos;
14420         this.end = end;
14421         this.kind = kind;
14422         this.id = 0;
14423         this.flags = 0;
14424         this.transformFlags = 0;
14425         this.parent = undefined;
14426     }
14427     function Identifier(kind, pos, end) {
14428         this.pos = pos;
14429         this.end = end;
14430         this.kind = kind;
14431         this.id = 0;
14432         this.flags = 0;
14433         this.transformFlags = 0;
14434         this.parent = undefined;
14435         this.original = undefined;
14436         this.flowNode = undefined;
14437     }
14438     function SourceMapSource(fileName, text, skipTrivia) {
14439         this.fileName = fileName;
14440         this.text = text;
14441         this.skipTrivia = skipTrivia || (function (pos) { return pos; });
14442     }
14443     ts.objectAllocator = {
14444         getNodeConstructor: function () { return Node; },
14445         getTokenConstructor: function () { return Token; },
14446         getIdentifierConstructor: function () { return Identifier; },
14447         getPrivateIdentifierConstructor: function () { return Node; },
14448         getSourceFileConstructor: function () { return Node; },
14449         getSymbolConstructor: function () { return Symbol; },
14450         getTypeConstructor: function () { return Type; },
14451         getSignatureConstructor: function () { return Signature; },
14452         getSourceMapSourceConstructor: function () { return SourceMapSource; },
14453     };
14454     function setObjectAllocator(alloc) {
14455         ts.objectAllocator = alloc;
14456     }
14457     ts.setObjectAllocator = setObjectAllocator;
14458     function formatStringFromArgs(text, args, baseIndex) {
14459         if (baseIndex === void 0) { baseIndex = 0; }
14460         return text.replace(/{(\d+)}/g, function (_match, index) { return "" + ts.Debug.checkDefined(args[+index + baseIndex]); });
14461     }
14462     ts.formatStringFromArgs = formatStringFromArgs;
14463     function setLocalizedDiagnosticMessages(messages) {
14464         ts.localizedDiagnosticMessages = messages;
14465     }
14466     ts.setLocalizedDiagnosticMessages = setLocalizedDiagnosticMessages;
14467     function getLocaleSpecificMessage(message) {
14468         return ts.localizedDiagnosticMessages && ts.localizedDiagnosticMessages[message.key] || message.message;
14469     }
14470     ts.getLocaleSpecificMessage = getLocaleSpecificMessage;
14471     function createDetachedDiagnostic(fileName, start, length, message) {
14472         ts.Debug.assertGreaterThanOrEqual(start, 0);
14473         ts.Debug.assertGreaterThanOrEqual(length, 0);
14474         var text = getLocaleSpecificMessage(message);
14475         if (arguments.length > 4) {
14476             text = formatStringFromArgs(text, arguments, 4);
14477         }
14478         return {
14479             file: undefined,
14480             start: start,
14481             length: length,
14482             messageText: text,
14483             category: message.category,
14484             code: message.code,
14485             reportsUnnecessary: message.reportsUnnecessary,
14486             fileName: fileName,
14487         };
14488     }
14489     ts.createDetachedDiagnostic = createDetachedDiagnostic;
14490     function isDiagnosticWithDetachedLocation(diagnostic) {
14491         return diagnostic.file === undefined
14492             && diagnostic.start !== undefined
14493             && diagnostic.length !== undefined
14494             && typeof diagnostic.fileName === "string";
14495     }
14496     function attachFileToDiagnostic(diagnostic, file) {
14497         var fileName = file.fileName || "";
14498         var length = file.text.length;
14499         ts.Debug.assertEqual(diagnostic.fileName, fileName);
14500         ts.Debug.assertLessThanOrEqual(diagnostic.start, length);
14501         ts.Debug.assertLessThanOrEqual(diagnostic.start + diagnostic.length, length);
14502         var diagnosticWithLocation = {
14503             file: file,
14504             start: diagnostic.start,
14505             length: diagnostic.length,
14506             messageText: diagnostic.messageText,
14507             category: diagnostic.category,
14508             code: diagnostic.code,
14509             reportsUnnecessary: diagnostic.reportsUnnecessary
14510         };
14511         if (diagnostic.relatedInformation) {
14512             diagnosticWithLocation.relatedInformation = [];
14513             for (var _i = 0, _a = diagnostic.relatedInformation; _i < _a.length; _i++) {
14514                 var related = _a[_i];
14515                 if (isDiagnosticWithDetachedLocation(related) && related.fileName === fileName) {
14516                     ts.Debug.assertLessThanOrEqual(related.start, length);
14517                     ts.Debug.assertLessThanOrEqual(related.start + related.length, length);
14518                     diagnosticWithLocation.relatedInformation.push(attachFileToDiagnostic(related, file));
14519                 }
14520                 else {
14521                     diagnosticWithLocation.relatedInformation.push(related);
14522                 }
14523             }
14524         }
14525         return diagnosticWithLocation;
14526     }
14527     function attachFileToDiagnostics(diagnostics, file) {
14528         var diagnosticsWithLocation = [];
14529         for (var _i = 0, diagnostics_1 = diagnostics; _i < diagnostics_1.length; _i++) {
14530             var diagnostic = diagnostics_1[_i];
14531             diagnosticsWithLocation.push(attachFileToDiagnostic(diagnostic, file));
14532         }
14533         return diagnosticsWithLocation;
14534     }
14535     ts.attachFileToDiagnostics = attachFileToDiagnostics;
14536     function createFileDiagnostic(file, start, length, message) {
14537         ts.Debug.assertGreaterThanOrEqual(start, 0);
14538         ts.Debug.assertGreaterThanOrEqual(length, 0);
14539         if (file) {
14540             ts.Debug.assertLessThanOrEqual(start, file.text.length);
14541             ts.Debug.assertLessThanOrEqual(start + length, file.text.length);
14542         }
14543         var text = getLocaleSpecificMessage(message);
14544         if (arguments.length > 4) {
14545             text = formatStringFromArgs(text, arguments, 4);
14546         }
14547         return {
14548             file: file,
14549             start: start,
14550             length: length,
14551             messageText: text,
14552             category: message.category,
14553             code: message.code,
14554             reportsUnnecessary: message.reportsUnnecessary,
14555             reportsDeprecated: message.reportsDeprecated
14556         };
14557     }
14558     ts.createFileDiagnostic = createFileDiagnostic;
14559     function formatMessage(_dummy, message) {
14560         var text = getLocaleSpecificMessage(message);
14561         if (arguments.length > 2) {
14562             text = formatStringFromArgs(text, arguments, 2);
14563         }
14564         return text;
14565     }
14566     ts.formatMessage = formatMessage;
14567     function createCompilerDiagnostic(message) {
14568         var text = getLocaleSpecificMessage(message);
14569         if (arguments.length > 1) {
14570             text = formatStringFromArgs(text, arguments, 1);
14571         }
14572         return {
14573             file: undefined,
14574             start: undefined,
14575             length: undefined,
14576             messageText: text,
14577             category: message.category,
14578             code: message.code,
14579             reportsUnnecessary: message.reportsUnnecessary,
14580             reportsDeprecated: message.reportsDeprecated
14581         };
14582     }
14583     ts.createCompilerDiagnostic = createCompilerDiagnostic;
14584     function createCompilerDiagnosticFromMessageChain(chain) {
14585         return {
14586             file: undefined,
14587             start: undefined,
14588             length: undefined,
14589             code: chain.code,
14590             category: chain.category,
14591             messageText: chain.next ? chain : chain.messageText,
14592         };
14593     }
14594     ts.createCompilerDiagnosticFromMessageChain = createCompilerDiagnosticFromMessageChain;
14595     function chainDiagnosticMessages(details, message) {
14596         var text = getLocaleSpecificMessage(message);
14597         if (arguments.length > 2) {
14598             text = formatStringFromArgs(text, arguments, 2);
14599         }
14600         return {
14601             messageText: text,
14602             category: message.category,
14603             code: message.code,
14604             next: details === undefined || Array.isArray(details) ? details : [details]
14605         };
14606     }
14607     ts.chainDiagnosticMessages = chainDiagnosticMessages;
14608     function concatenateDiagnosticMessageChains(headChain, tailChain) {
14609         var lastChain = headChain;
14610         while (lastChain.next) {
14611             lastChain = lastChain.next[0];
14612         }
14613         lastChain.next = [tailChain];
14614     }
14615     ts.concatenateDiagnosticMessageChains = concatenateDiagnosticMessageChains;
14616     function getDiagnosticFilePath(diagnostic) {
14617         return diagnostic.file ? diagnostic.file.path : undefined;
14618     }
14619     function compareDiagnostics(d1, d2) {
14620         return compareDiagnosticsSkipRelatedInformation(d1, d2) ||
14621             compareRelatedInformation(d1, d2) ||
14622             0;
14623     }
14624     ts.compareDiagnostics = compareDiagnostics;
14625     function compareDiagnosticsSkipRelatedInformation(d1, d2) {
14626         return ts.compareStringsCaseSensitive(getDiagnosticFilePath(d1), getDiagnosticFilePath(d2)) ||
14627             ts.compareValues(d1.start, d2.start) ||
14628             ts.compareValues(d1.length, d2.length) ||
14629             ts.compareValues(d1.code, d2.code) ||
14630             compareMessageText(d1.messageText, d2.messageText) ||
14631             0;
14632     }
14633     ts.compareDiagnosticsSkipRelatedInformation = compareDiagnosticsSkipRelatedInformation;
14634     function compareRelatedInformation(d1, d2) {
14635         if (!d1.relatedInformation && !d2.relatedInformation) {
14636             return 0;
14637         }
14638         if (d1.relatedInformation && d2.relatedInformation) {
14639             return ts.compareValues(d1.relatedInformation.length, d2.relatedInformation.length) || ts.forEach(d1.relatedInformation, function (d1i, index) {
14640                 var d2i = d2.relatedInformation[index];
14641                 return compareDiagnostics(d1i, d2i);
14642             }) || 0;
14643         }
14644         return d1.relatedInformation ? -1 : 1;
14645     }
14646     function compareMessageText(t1, t2) {
14647         if (typeof t1 === "string" && typeof t2 === "string") {
14648             return ts.compareStringsCaseSensitive(t1, t2);
14649         }
14650         else if (typeof t1 === "string") {
14651             return -1;
14652         }
14653         else if (typeof t2 === "string") {
14654             return 1;
14655         }
14656         var res = ts.compareStringsCaseSensitive(t1.messageText, t2.messageText);
14657         if (res) {
14658             return res;
14659         }
14660         if (!t1.next && !t2.next) {
14661             return 0;
14662         }
14663         if (!t1.next) {
14664             return -1;
14665         }
14666         if (!t2.next) {
14667             return 1;
14668         }
14669         var len = Math.min(t1.next.length, t2.next.length);
14670         for (var i = 0; i < len; i++) {
14671             res = compareMessageText(t1.next[i], t2.next[i]);
14672             if (res) {
14673                 return res;
14674             }
14675         }
14676         if (t1.next.length < t2.next.length) {
14677             return -1;
14678         }
14679         else if (t1.next.length > t2.next.length) {
14680             return 1;
14681         }
14682         return 0;
14683     }
14684     function getLanguageVariant(scriptKind) {
14685         return scriptKind === 4 || scriptKind === 2 || scriptKind === 1 || scriptKind === 6 ? 1 : 0;
14686     }
14687     ts.getLanguageVariant = getLanguageVariant;
14688     function getEmitScriptTarget(compilerOptions) {
14689         return compilerOptions.target || 0;
14690     }
14691     ts.getEmitScriptTarget = getEmitScriptTarget;
14692     function getEmitModuleKind(compilerOptions) {
14693         return typeof compilerOptions.module === "number" ?
14694             compilerOptions.module :
14695             getEmitScriptTarget(compilerOptions) >= 2 ? ts.ModuleKind.ES2015 : ts.ModuleKind.CommonJS;
14696     }
14697     ts.getEmitModuleKind = getEmitModuleKind;
14698     function getEmitModuleResolutionKind(compilerOptions) {
14699         var moduleResolution = compilerOptions.moduleResolution;
14700         if (moduleResolution === undefined) {
14701             moduleResolution = getEmitModuleKind(compilerOptions) === ts.ModuleKind.CommonJS ? ts.ModuleResolutionKind.NodeJs : ts.ModuleResolutionKind.Classic;
14702         }
14703         return moduleResolution;
14704     }
14705     ts.getEmitModuleResolutionKind = getEmitModuleResolutionKind;
14706     function hasJsonModuleEmitEnabled(options) {
14707         switch (getEmitModuleKind(options)) {
14708             case ts.ModuleKind.CommonJS:
14709             case ts.ModuleKind.AMD:
14710             case ts.ModuleKind.ES2015:
14711             case ts.ModuleKind.ES2020:
14712             case ts.ModuleKind.ESNext:
14713                 return true;
14714             default:
14715                 return false;
14716         }
14717     }
14718     ts.hasJsonModuleEmitEnabled = hasJsonModuleEmitEnabled;
14719     function unreachableCodeIsError(options) {
14720         return options.allowUnreachableCode === false;
14721     }
14722     ts.unreachableCodeIsError = unreachableCodeIsError;
14723     function unusedLabelIsError(options) {
14724         return options.allowUnusedLabels === false;
14725     }
14726     ts.unusedLabelIsError = unusedLabelIsError;
14727     function getAreDeclarationMapsEnabled(options) {
14728         return !!(getEmitDeclarations(options) && options.declarationMap);
14729     }
14730     ts.getAreDeclarationMapsEnabled = getAreDeclarationMapsEnabled;
14731     function getAllowSyntheticDefaultImports(compilerOptions) {
14732         var moduleKind = getEmitModuleKind(compilerOptions);
14733         return compilerOptions.allowSyntheticDefaultImports !== undefined
14734             ? compilerOptions.allowSyntheticDefaultImports
14735             : compilerOptions.esModuleInterop ||
14736                 moduleKind === ts.ModuleKind.System;
14737     }
14738     ts.getAllowSyntheticDefaultImports = getAllowSyntheticDefaultImports;
14739     function getEmitDeclarations(compilerOptions) {
14740         return !!(compilerOptions.declaration || compilerOptions.composite);
14741     }
14742     ts.getEmitDeclarations = getEmitDeclarations;
14743     function isIncrementalCompilation(options) {
14744         return !!(options.incremental || options.composite);
14745     }
14746     ts.isIncrementalCompilation = isIncrementalCompilation;
14747     function getStrictOptionValue(compilerOptions, flag) {
14748         return compilerOptions[flag] === undefined ? !!compilerOptions.strict : !!compilerOptions[flag];
14749     }
14750     ts.getStrictOptionValue = getStrictOptionValue;
14751     function getAllowJSCompilerOption(compilerOptions) {
14752         return compilerOptions.allowJs === undefined ? !!compilerOptions.checkJs : compilerOptions.allowJs;
14753     }
14754     ts.getAllowJSCompilerOption = getAllowJSCompilerOption;
14755     function compilerOptionsAffectSemanticDiagnostics(newOptions, oldOptions) {
14756         return oldOptions !== newOptions &&
14757             ts.semanticDiagnosticsOptionDeclarations.some(function (option) { return !isJsonEqual(getCompilerOptionValue(oldOptions, option), getCompilerOptionValue(newOptions, option)); });
14758     }
14759     ts.compilerOptionsAffectSemanticDiagnostics = compilerOptionsAffectSemanticDiagnostics;
14760     function compilerOptionsAffectEmit(newOptions, oldOptions) {
14761         return oldOptions !== newOptions &&
14762             ts.affectsEmitOptionDeclarations.some(function (option) { return !isJsonEqual(getCompilerOptionValue(oldOptions, option), getCompilerOptionValue(newOptions, option)); });
14763     }
14764     ts.compilerOptionsAffectEmit = compilerOptionsAffectEmit;
14765     function getCompilerOptionValue(options, option) {
14766         return option.strictFlag ? getStrictOptionValue(options, option.name) : options[option.name];
14767     }
14768     ts.getCompilerOptionValue = getCompilerOptionValue;
14769     function getJSXTransformEnabled(options) {
14770         var jsx = options.jsx;
14771         return jsx === 2 || jsx === 4 || jsx === 5;
14772     }
14773     ts.getJSXTransformEnabled = getJSXTransformEnabled;
14774     function getJSXImplicitImportBase(compilerOptions, file) {
14775         var jsxImportSourcePragmas = file === null || file === void 0 ? void 0 : file.pragmas.get("jsximportsource");
14776         var jsxImportSourcePragma = ts.isArray(jsxImportSourcePragmas) ? jsxImportSourcePragmas[0] : jsxImportSourcePragmas;
14777         return compilerOptions.jsx === 4 ||
14778             compilerOptions.jsx === 5 ||
14779             compilerOptions.jsxImportSource ||
14780             jsxImportSourcePragma ?
14781             (jsxImportSourcePragma === null || jsxImportSourcePragma === void 0 ? void 0 : jsxImportSourcePragma.arguments.factory) || compilerOptions.jsxImportSource || "react" :
14782             undefined;
14783     }
14784     ts.getJSXImplicitImportBase = getJSXImplicitImportBase;
14785     function getJSXRuntimeImport(base, options) {
14786         return base ? base + "/" + (options.jsx === 5 ? "jsx-dev-runtime" : "jsx-runtime") : undefined;
14787     }
14788     ts.getJSXRuntimeImport = getJSXRuntimeImport;
14789     function hasZeroOrOneAsteriskCharacter(str) {
14790         var seenAsterisk = false;
14791         for (var i = 0; i < str.length; i++) {
14792             if (str.charCodeAt(i) === 42) {
14793                 if (!seenAsterisk) {
14794                     seenAsterisk = true;
14795                 }
14796                 else {
14797                     return false;
14798                 }
14799             }
14800         }
14801         return true;
14802     }
14803     ts.hasZeroOrOneAsteriskCharacter = hasZeroOrOneAsteriskCharacter;
14804     function createSymlinkCache() {
14805         var symlinkedDirectories;
14806         var symlinkedFiles;
14807         return {
14808             getSymlinkedFiles: function () { return symlinkedFiles; },
14809             getSymlinkedDirectories: function () { return symlinkedDirectories; },
14810             setSymlinkedFile: function (path, real) { return (symlinkedFiles || (symlinkedFiles = new ts.Map())).set(path, real); },
14811             setSymlinkedDirectory: function (path, directory) { return (symlinkedDirectories || (symlinkedDirectories = new ts.Map())).set(path, directory); },
14812         };
14813     }
14814     ts.createSymlinkCache = createSymlinkCache;
14815     function discoverProbableSymlinks(files, getCanonicalFileName, cwd) {
14816         var cache = createSymlinkCache();
14817         var symlinks = ts.flatten(ts.mapDefined(files, function (sf) {
14818             return sf.resolvedModules && ts.compact(ts.arrayFrom(ts.mapIterator(sf.resolvedModules.values(), function (res) {
14819                 return res && res.originalPath && res.resolvedFileName !== res.originalPath ? [res.resolvedFileName, res.originalPath] : undefined;
14820             })));
14821         }));
14822         for (var _i = 0, symlinks_1 = symlinks; _i < symlinks_1.length; _i++) {
14823             var _a = symlinks_1[_i], resolvedPath = _a[0], originalPath = _a[1];
14824             var _b = guessDirectorySymlink(resolvedPath, originalPath, cwd, getCanonicalFileName) || ts.emptyArray, commonResolved = _b[0], commonOriginal = _b[1];
14825             if (commonResolved && commonOriginal) {
14826                 cache.setSymlinkedDirectory(ts.toPath(commonOriginal, cwd, getCanonicalFileName), { real: commonResolved, realPath: ts.toPath(commonResolved, cwd, getCanonicalFileName) });
14827             }
14828         }
14829         return cache;
14830     }
14831     ts.discoverProbableSymlinks = discoverProbableSymlinks;
14832     function guessDirectorySymlink(a, b, cwd, getCanonicalFileName) {
14833         var aParts = ts.getPathComponents(ts.toPath(a, cwd, getCanonicalFileName));
14834         var bParts = ts.getPathComponents(ts.toPath(b, cwd, getCanonicalFileName));
14835         var isDirectory = false;
14836         while (!isNodeModulesOrScopedPackageDirectory(aParts[aParts.length - 2], getCanonicalFileName) &&
14837             !isNodeModulesOrScopedPackageDirectory(bParts[bParts.length - 2], getCanonicalFileName) &&
14838             getCanonicalFileName(aParts[aParts.length - 1]) === getCanonicalFileName(bParts[bParts.length - 1])) {
14839             aParts.pop();
14840             bParts.pop();
14841             isDirectory = true;
14842         }
14843         return isDirectory ? [ts.getPathFromPathComponents(aParts), ts.getPathFromPathComponents(bParts)] : undefined;
14844     }
14845     function isNodeModulesOrScopedPackageDirectory(s, getCanonicalFileName) {
14846         return getCanonicalFileName(s) === "node_modules" || ts.startsWith(s, "@");
14847     }
14848     function stripLeadingDirectorySeparator(s) {
14849         return ts.isAnyDirectorySeparator(s.charCodeAt(0)) ? s.slice(1) : undefined;
14850     }
14851     function tryRemoveDirectoryPrefix(path, dirPath, getCanonicalFileName) {
14852         var withoutPrefix = ts.tryRemovePrefix(path, dirPath, getCanonicalFileName);
14853         return withoutPrefix === undefined ? undefined : stripLeadingDirectorySeparator(withoutPrefix);
14854     }
14855     ts.tryRemoveDirectoryPrefix = tryRemoveDirectoryPrefix;
14856     var reservedCharacterPattern = /[^\w\s\/]/g;
14857     function regExpEscape(text) {
14858         return text.replace(reservedCharacterPattern, escapeRegExpCharacter);
14859     }
14860     ts.regExpEscape = regExpEscape;
14861     function escapeRegExpCharacter(match) {
14862         return "\\" + match;
14863     }
14864     var wildcardCharCodes = [42, 63];
14865     ts.commonPackageFolders = ["node_modules", "bower_components", "jspm_packages"];
14866     var implicitExcludePathRegexPattern = "(?!(" + ts.commonPackageFolders.join("|") + ")(/|$))";
14867     var filesMatcher = {
14868         singleAsteriskRegexFragment: "([^./]|(\\.(?!min\\.js$))?)*",
14869         doubleAsteriskRegexFragment: "(/" + implicitExcludePathRegexPattern + "[^/.][^/]*)*?",
14870         replaceWildcardCharacter: function (match) { return replaceWildcardCharacter(match, filesMatcher.singleAsteriskRegexFragment); }
14871     };
14872     var directoriesMatcher = {
14873         singleAsteriskRegexFragment: "[^/]*",
14874         doubleAsteriskRegexFragment: "(/" + implicitExcludePathRegexPattern + "[^/.][^/]*)*?",
14875         replaceWildcardCharacter: function (match) { return replaceWildcardCharacter(match, directoriesMatcher.singleAsteriskRegexFragment); }
14876     };
14877     var excludeMatcher = {
14878         singleAsteriskRegexFragment: "[^/]*",
14879         doubleAsteriskRegexFragment: "(/.+?)?",
14880         replaceWildcardCharacter: function (match) { return replaceWildcardCharacter(match, excludeMatcher.singleAsteriskRegexFragment); }
14881     };
14882     var wildcardMatchers = {
14883         files: filesMatcher,
14884         directories: directoriesMatcher,
14885         exclude: excludeMatcher
14886     };
14887     function getRegularExpressionForWildcard(specs, basePath, usage) {
14888         var patterns = getRegularExpressionsForWildcards(specs, basePath, usage);
14889         if (!patterns || !patterns.length) {
14890             return undefined;
14891         }
14892         var pattern = patterns.map(function (pattern) { return "(" + pattern + ")"; }).join("|");
14893         var terminator = usage === "exclude" ? "($|/)" : "$";
14894         return "^(" + pattern + ")" + terminator;
14895     }
14896     ts.getRegularExpressionForWildcard = getRegularExpressionForWildcard;
14897     function getRegularExpressionsForWildcards(specs, basePath, usage) {
14898         if (specs === undefined || specs.length === 0) {
14899             return undefined;
14900         }
14901         return ts.flatMap(specs, function (spec) {
14902             return spec && getSubPatternFromSpec(spec, basePath, usage, wildcardMatchers[usage]);
14903         });
14904     }
14905     ts.getRegularExpressionsForWildcards = getRegularExpressionsForWildcards;
14906     function isImplicitGlob(lastPathComponent) {
14907         return !/[.*?]/.test(lastPathComponent);
14908     }
14909     ts.isImplicitGlob = isImplicitGlob;
14910     function getSubPatternFromSpec(spec, basePath, usage, _a) {
14911         var singleAsteriskRegexFragment = _a.singleAsteriskRegexFragment, doubleAsteriskRegexFragment = _a.doubleAsteriskRegexFragment, replaceWildcardCharacter = _a.replaceWildcardCharacter;
14912         var subpattern = "";
14913         var hasWrittenComponent = false;
14914         var components = ts.getNormalizedPathComponents(spec, basePath);
14915         var lastComponent = ts.last(components);
14916         if (usage !== "exclude" && lastComponent === "**") {
14917             return undefined;
14918         }
14919         components[0] = ts.removeTrailingDirectorySeparator(components[0]);
14920         if (isImplicitGlob(lastComponent)) {
14921             components.push("**", "*");
14922         }
14923         var optionalCount = 0;
14924         for (var _i = 0, components_1 = components; _i < components_1.length; _i++) {
14925             var component = components_1[_i];
14926             if (component === "**") {
14927                 subpattern += doubleAsteriskRegexFragment;
14928             }
14929             else {
14930                 if (usage === "directories") {
14931                     subpattern += "(";
14932                     optionalCount++;
14933                 }
14934                 if (hasWrittenComponent) {
14935                     subpattern += ts.directorySeparator;
14936                 }
14937                 if (usage !== "exclude") {
14938                     var componentPattern = "";
14939                     if (component.charCodeAt(0) === 42) {
14940                         componentPattern += "([^./]" + singleAsteriskRegexFragment + ")?";
14941                         component = component.substr(1);
14942                     }
14943                     else if (component.charCodeAt(0) === 63) {
14944                         componentPattern += "[^./]";
14945                         component = component.substr(1);
14946                     }
14947                     componentPattern += component.replace(reservedCharacterPattern, replaceWildcardCharacter);
14948                     if (componentPattern !== component) {
14949                         subpattern += implicitExcludePathRegexPattern;
14950                     }
14951                     subpattern += componentPattern;
14952                 }
14953                 else {
14954                     subpattern += component.replace(reservedCharacterPattern, replaceWildcardCharacter);
14955                 }
14956             }
14957             hasWrittenComponent = true;
14958         }
14959         while (optionalCount > 0) {
14960             subpattern += ")?";
14961             optionalCount--;
14962         }
14963         return subpattern;
14964     }
14965     function replaceWildcardCharacter(match, singleAsteriskRegexFragment) {
14966         return match === "*" ? singleAsteriskRegexFragment : match === "?" ? "[^/]" : "\\" + match;
14967     }
14968     function getFileMatcherPatterns(path, excludes, includes, useCaseSensitiveFileNames, currentDirectory) {
14969         path = ts.normalizePath(path);
14970         currentDirectory = ts.normalizePath(currentDirectory);
14971         var absolutePath = ts.combinePaths(currentDirectory, path);
14972         return {
14973             includeFilePatterns: ts.map(getRegularExpressionsForWildcards(includes, absolutePath, "files"), function (pattern) { return "^" + pattern + "$"; }),
14974             includeFilePattern: getRegularExpressionForWildcard(includes, absolutePath, "files"),
14975             includeDirectoryPattern: getRegularExpressionForWildcard(includes, absolutePath, "directories"),
14976             excludePattern: getRegularExpressionForWildcard(excludes, absolutePath, "exclude"),
14977             basePaths: getBasePaths(path, includes, useCaseSensitiveFileNames)
14978         };
14979     }
14980     ts.getFileMatcherPatterns = getFileMatcherPatterns;
14981     function getRegexFromPattern(pattern, useCaseSensitiveFileNames) {
14982         return new RegExp(pattern, useCaseSensitiveFileNames ? "" : "i");
14983     }
14984     ts.getRegexFromPattern = getRegexFromPattern;
14985     function matchFiles(path, extensions, excludes, includes, useCaseSensitiveFileNames, currentDirectory, depth, getFileSystemEntries, realpath) {
14986         path = ts.normalizePath(path);
14987         currentDirectory = ts.normalizePath(currentDirectory);
14988         var patterns = getFileMatcherPatterns(path, excludes, includes, useCaseSensitiveFileNames, currentDirectory);
14989         var includeFileRegexes = patterns.includeFilePatterns && patterns.includeFilePatterns.map(function (pattern) { return getRegexFromPattern(pattern, useCaseSensitiveFileNames); });
14990         var includeDirectoryRegex = patterns.includeDirectoryPattern && getRegexFromPattern(patterns.includeDirectoryPattern, useCaseSensitiveFileNames);
14991         var excludeRegex = patterns.excludePattern && getRegexFromPattern(patterns.excludePattern, useCaseSensitiveFileNames);
14992         var results = includeFileRegexes ? includeFileRegexes.map(function () { return []; }) : [[]];
14993         var visited = new ts.Map();
14994         var toCanonical = ts.createGetCanonicalFileName(useCaseSensitiveFileNames);
14995         for (var _i = 0, _a = patterns.basePaths; _i < _a.length; _i++) {
14996             var basePath = _a[_i];
14997             visitDirectory(basePath, ts.combinePaths(currentDirectory, basePath), depth);
14998         }
14999         return ts.flatten(results);
15000         function visitDirectory(path, absolutePath, depth) {
15001             var canonicalPath = toCanonical(realpath(absolutePath));
15002             if (visited.has(canonicalPath))
15003                 return;
15004             visited.set(canonicalPath, true);
15005             var _a = getFileSystemEntries(path), files = _a.files, directories = _a.directories;
15006             var _loop_1 = function (current) {
15007                 var name = ts.combinePaths(path, current);
15008                 var absoluteName = ts.combinePaths(absolutePath, current);
15009                 if (extensions && !ts.fileExtensionIsOneOf(name, extensions))
15010                     return "continue";
15011                 if (excludeRegex && excludeRegex.test(absoluteName))
15012                     return "continue";
15013                 if (!includeFileRegexes) {
15014                     results[0].push(name);
15015                 }
15016                 else {
15017                     var includeIndex = ts.findIndex(includeFileRegexes, function (re) { return re.test(absoluteName); });
15018                     if (includeIndex !== -1) {
15019                         results[includeIndex].push(name);
15020                     }
15021                 }
15022             };
15023             for (var _i = 0, _b = ts.sort(files, ts.compareStringsCaseSensitive); _i < _b.length; _i++) {
15024                 var current = _b[_i];
15025                 _loop_1(current);
15026             }
15027             if (depth !== undefined) {
15028                 depth--;
15029                 if (depth === 0) {
15030                     return;
15031                 }
15032             }
15033             for (var _c = 0, _d = ts.sort(directories, ts.compareStringsCaseSensitive); _c < _d.length; _c++) {
15034                 var current = _d[_c];
15035                 var name = ts.combinePaths(path, current);
15036                 var absoluteName = ts.combinePaths(absolutePath, current);
15037                 if ((!includeDirectoryRegex || includeDirectoryRegex.test(absoluteName)) &&
15038                     (!excludeRegex || !excludeRegex.test(absoluteName))) {
15039                     visitDirectory(name, absoluteName, depth);
15040                 }
15041             }
15042         }
15043     }
15044     ts.matchFiles = matchFiles;
15045     function getBasePaths(path, includes, useCaseSensitiveFileNames) {
15046         var basePaths = [path];
15047         if (includes) {
15048             var includeBasePaths = [];
15049             for (var _i = 0, includes_1 = includes; _i < includes_1.length; _i++) {
15050                 var include = includes_1[_i];
15051                 var absolute = ts.isRootedDiskPath(include) ? include : ts.normalizePath(ts.combinePaths(path, include));
15052                 includeBasePaths.push(getIncludeBasePath(absolute));
15053             }
15054             includeBasePaths.sort(ts.getStringComparer(!useCaseSensitiveFileNames));
15055             var _loop_2 = function (includeBasePath) {
15056                 if (ts.every(basePaths, function (basePath) { return !ts.containsPath(basePath, includeBasePath, path, !useCaseSensitiveFileNames); })) {
15057                     basePaths.push(includeBasePath);
15058                 }
15059             };
15060             for (var _a = 0, includeBasePaths_1 = includeBasePaths; _a < includeBasePaths_1.length; _a++) {
15061                 var includeBasePath = includeBasePaths_1[_a];
15062                 _loop_2(includeBasePath);
15063             }
15064         }
15065         return basePaths;
15066     }
15067     function getIncludeBasePath(absolute) {
15068         var wildcardOffset = ts.indexOfAnyCharCode(absolute, wildcardCharCodes);
15069         if (wildcardOffset < 0) {
15070             return !ts.hasExtension(absolute)
15071                 ? absolute
15072                 : ts.removeTrailingDirectorySeparator(ts.getDirectoryPath(absolute));
15073         }
15074         return absolute.substring(0, absolute.lastIndexOf(ts.directorySeparator, wildcardOffset));
15075     }
15076     function ensureScriptKind(fileName, scriptKind) {
15077         return scriptKind || getScriptKindFromFileName(fileName) || 3;
15078     }
15079     ts.ensureScriptKind = ensureScriptKind;
15080     function getScriptKindFromFileName(fileName) {
15081         var ext = fileName.substr(fileName.lastIndexOf("."));
15082         switch (ext.toLowerCase()) {
15083             case ".js":
15084                 return 1;
15085             case ".jsx":
15086                 return 2;
15087             case ".ts":
15088                 return 3;
15089             case ".tsx":
15090                 return 4;
15091             case ".json":
15092                 return 6;
15093             default:
15094                 return 0;
15095         }
15096     }
15097     ts.getScriptKindFromFileName = getScriptKindFromFileName;
15098     ts.supportedTSExtensions = [".ts", ".tsx", ".d.ts"];
15099     ts.supportedTSExtensionsWithJson = [".ts", ".tsx", ".d.ts", ".json"];
15100     ts.supportedTSExtensionsForExtractExtension = [".d.ts", ".ts", ".tsx"];
15101     ts.supportedJSExtensions = [".js", ".jsx"];
15102     ts.supportedJSAndJsonExtensions = [".js", ".jsx", ".json"];
15103     var allSupportedExtensions = __spreadArrays(ts.supportedTSExtensions, ts.supportedJSExtensions);
15104     var allSupportedExtensionsWithJson = __spreadArrays(ts.supportedTSExtensions, ts.supportedJSExtensions, [".json"]);
15105     function getSupportedExtensions(options, extraFileExtensions) {
15106         var needJsExtensions = options && getAllowJSCompilerOption(options);
15107         if (!extraFileExtensions || extraFileExtensions.length === 0) {
15108             return needJsExtensions ? allSupportedExtensions : ts.supportedTSExtensions;
15109         }
15110         var extensions = __spreadArrays(needJsExtensions ? allSupportedExtensions : ts.supportedTSExtensions, ts.mapDefined(extraFileExtensions, function (x) { return x.scriptKind === 7 || needJsExtensions && isJSLike(x.scriptKind) ? x.extension : undefined; }));
15111         return ts.deduplicate(extensions, ts.equateStringsCaseSensitive, ts.compareStringsCaseSensitive);
15112     }
15113     ts.getSupportedExtensions = getSupportedExtensions;
15114     function getSuppoertedExtensionsWithJsonIfResolveJsonModule(options, supportedExtensions) {
15115         if (!options || !options.resolveJsonModule) {
15116             return supportedExtensions;
15117         }
15118         if (supportedExtensions === allSupportedExtensions) {
15119             return allSupportedExtensionsWithJson;
15120         }
15121         if (supportedExtensions === ts.supportedTSExtensions) {
15122             return ts.supportedTSExtensionsWithJson;
15123         }
15124         return __spreadArrays(supportedExtensions, [".json"]);
15125     }
15126     ts.getSuppoertedExtensionsWithJsonIfResolveJsonModule = getSuppoertedExtensionsWithJsonIfResolveJsonModule;
15127     function isJSLike(scriptKind) {
15128         return scriptKind === 1 || scriptKind === 2;
15129     }
15130     function hasJSFileExtension(fileName) {
15131         return ts.some(ts.supportedJSExtensions, function (extension) { return ts.fileExtensionIs(fileName, extension); });
15132     }
15133     ts.hasJSFileExtension = hasJSFileExtension;
15134     function hasTSFileExtension(fileName) {
15135         return ts.some(ts.supportedTSExtensions, function (extension) { return ts.fileExtensionIs(fileName, extension); });
15136     }
15137     ts.hasTSFileExtension = hasTSFileExtension;
15138     function isSupportedSourceFileName(fileName, compilerOptions, extraFileExtensions) {
15139         if (!fileName) {
15140             return false;
15141         }
15142         var supportedExtensions = getSupportedExtensions(compilerOptions, extraFileExtensions);
15143         for (var _i = 0, _a = getSuppoertedExtensionsWithJsonIfResolveJsonModule(compilerOptions, supportedExtensions); _i < _a.length; _i++) {
15144             var extension = _a[_i];
15145             if (ts.fileExtensionIs(fileName, extension)) {
15146                 return true;
15147             }
15148         }
15149         return false;
15150     }
15151     ts.isSupportedSourceFileName = isSupportedSourceFileName;
15152     function getExtensionPriority(path, supportedExtensions) {
15153         for (var i = supportedExtensions.length - 1; i >= 0; i--) {
15154             if (ts.fileExtensionIs(path, supportedExtensions[i])) {
15155                 return adjustExtensionPriority(i, supportedExtensions);
15156             }
15157         }
15158         return 0;
15159     }
15160     ts.getExtensionPriority = getExtensionPriority;
15161     function adjustExtensionPriority(extensionPriority, supportedExtensions) {
15162         if (extensionPriority < 2) {
15163             return 0;
15164         }
15165         else if (extensionPriority < supportedExtensions.length) {
15166             return 2;
15167         }
15168         else {
15169             return supportedExtensions.length;
15170         }
15171     }
15172     ts.adjustExtensionPriority = adjustExtensionPriority;
15173     function getNextLowestExtensionPriority(extensionPriority, supportedExtensions) {
15174         if (extensionPriority < 2) {
15175             return 2;
15176         }
15177         else {
15178             return supportedExtensions.length;
15179         }
15180     }
15181     ts.getNextLowestExtensionPriority = getNextLowestExtensionPriority;
15182     var extensionsToRemove = [".d.ts", ".ts", ".js", ".tsx", ".jsx", ".json"];
15183     function removeFileExtension(path) {
15184         for (var _i = 0, extensionsToRemove_1 = extensionsToRemove; _i < extensionsToRemove_1.length; _i++) {
15185             var ext = extensionsToRemove_1[_i];
15186             var extensionless = tryRemoveExtension(path, ext);
15187             if (extensionless !== undefined) {
15188                 return extensionless;
15189             }
15190         }
15191         return path;
15192     }
15193     ts.removeFileExtension = removeFileExtension;
15194     function tryRemoveExtension(path, extension) {
15195         return ts.fileExtensionIs(path, extension) ? removeExtension(path, extension) : undefined;
15196     }
15197     ts.tryRemoveExtension = tryRemoveExtension;
15198     function removeExtension(path, extension) {
15199         return path.substring(0, path.length - extension.length);
15200     }
15201     ts.removeExtension = removeExtension;
15202     function changeExtension(path, newExtension) {
15203         return ts.changeAnyExtension(path, newExtension, extensionsToRemove, false);
15204     }
15205     ts.changeExtension = changeExtension;
15206     function tryParsePattern(pattern) {
15207         ts.Debug.assert(hasZeroOrOneAsteriskCharacter(pattern));
15208         var indexOfStar = pattern.indexOf("*");
15209         return indexOfStar === -1 ? undefined : {
15210             prefix: pattern.substr(0, indexOfStar),
15211             suffix: pattern.substr(indexOfStar + 1)
15212         };
15213     }
15214     ts.tryParsePattern = tryParsePattern;
15215     function positionIsSynthesized(pos) {
15216         return !(pos >= 0);
15217     }
15218     ts.positionIsSynthesized = positionIsSynthesized;
15219     function extensionIsTS(ext) {
15220         return ext === ".ts" || ext === ".tsx" || ext === ".d.ts";
15221     }
15222     ts.extensionIsTS = extensionIsTS;
15223     function resolutionExtensionIsTSOrJson(ext) {
15224         return extensionIsTS(ext) || ext === ".json";
15225     }
15226     ts.resolutionExtensionIsTSOrJson = resolutionExtensionIsTSOrJson;
15227     function extensionFromPath(path) {
15228         var ext = tryGetExtensionFromPath(path);
15229         return ext !== undefined ? ext : ts.Debug.fail("File " + path + " has unknown extension.");
15230     }
15231     ts.extensionFromPath = extensionFromPath;
15232     function isAnySupportedFileExtension(path) {
15233         return tryGetExtensionFromPath(path) !== undefined;
15234     }
15235     ts.isAnySupportedFileExtension = isAnySupportedFileExtension;
15236     function tryGetExtensionFromPath(path) {
15237         return ts.find(extensionsToRemove, function (e) { return ts.fileExtensionIs(path, e); });
15238     }
15239     ts.tryGetExtensionFromPath = tryGetExtensionFromPath;
15240     function isCheckJsEnabledForFile(sourceFile, compilerOptions) {
15241         return sourceFile.checkJsDirective ? sourceFile.checkJsDirective.enabled : compilerOptions.checkJs;
15242     }
15243     ts.isCheckJsEnabledForFile = isCheckJsEnabledForFile;
15244     ts.emptyFileSystemEntries = {
15245         files: ts.emptyArray,
15246         directories: ts.emptyArray
15247     };
15248     function matchPatternOrExact(patternStrings, candidate) {
15249         var patterns = [];
15250         for (var _i = 0, patternStrings_1 = patternStrings; _i < patternStrings_1.length; _i++) {
15251             var patternString = patternStrings_1[_i];
15252             if (!hasZeroOrOneAsteriskCharacter(patternString))
15253                 continue;
15254             var pattern = tryParsePattern(patternString);
15255             if (pattern) {
15256                 patterns.push(pattern);
15257             }
15258             else if (patternString === candidate) {
15259                 return patternString;
15260             }
15261         }
15262         return ts.findBestPatternMatch(patterns, function (_) { return _; }, candidate);
15263     }
15264     ts.matchPatternOrExact = matchPatternOrExact;
15265     function sliceAfter(arr, value) {
15266         var index = arr.indexOf(value);
15267         ts.Debug.assert(index !== -1);
15268         return arr.slice(index);
15269     }
15270     ts.sliceAfter = sliceAfter;
15271     function addRelatedInfo(diagnostic) {
15272         var _a;
15273         var relatedInformation = [];
15274         for (var _i = 1; _i < arguments.length; _i++) {
15275             relatedInformation[_i - 1] = arguments[_i];
15276         }
15277         if (!relatedInformation.length) {
15278             return diagnostic;
15279         }
15280         if (!diagnostic.relatedInformation) {
15281             diagnostic.relatedInformation = [];
15282         }
15283         ts.Debug.assert(diagnostic.relatedInformation !== ts.emptyArray, "Diagnostic had empty array singleton for related info, but is still being constructed!");
15284         (_a = diagnostic.relatedInformation).push.apply(_a, relatedInformation);
15285         return diagnostic;
15286     }
15287     ts.addRelatedInfo = addRelatedInfo;
15288     function minAndMax(arr, getValue) {
15289         ts.Debug.assert(arr.length !== 0);
15290         var min = getValue(arr[0]);
15291         var max = min;
15292         for (var i = 1; i < arr.length; i++) {
15293             var value = getValue(arr[i]);
15294             if (value < min) {
15295                 min = value;
15296             }
15297             else if (value > max) {
15298                 max = value;
15299             }
15300         }
15301         return { min: min, max: max };
15302     }
15303     ts.minAndMax = minAndMax;
15304     function rangeOfNode(node) {
15305         return { pos: getTokenPosOfNode(node), end: node.end };
15306     }
15307     ts.rangeOfNode = rangeOfNode;
15308     function rangeOfTypeParameters(typeParameters) {
15309         return { pos: typeParameters.pos - 1, end: typeParameters.end + 1 };
15310     }
15311     ts.rangeOfTypeParameters = rangeOfTypeParameters;
15312     function skipTypeChecking(sourceFile, options, host) {
15313         return (options.skipLibCheck && sourceFile.isDeclarationFile ||
15314             options.skipDefaultLibCheck && sourceFile.hasNoDefaultLib) ||
15315             host.isSourceOfProjectReferenceRedirect(sourceFile.fileName);
15316     }
15317     ts.skipTypeChecking = skipTypeChecking;
15318     function isJsonEqual(a, b) {
15319         return a === b || typeof a === "object" && a !== null && typeof b === "object" && b !== null && ts.equalOwnProperties(a, b, isJsonEqual);
15320     }
15321     ts.isJsonEqual = isJsonEqual;
15322     function parsePseudoBigInt(stringValue) {
15323         var log2Base;
15324         switch (stringValue.charCodeAt(1)) {
15325             case 98:
15326             case 66:
15327                 log2Base = 1;
15328                 break;
15329             case 111:
15330             case 79:
15331                 log2Base = 3;
15332                 break;
15333             case 120:
15334             case 88:
15335                 log2Base = 4;
15336                 break;
15337             default:
15338                 var nIndex = stringValue.length - 1;
15339                 var nonZeroStart = 0;
15340                 while (stringValue.charCodeAt(nonZeroStart) === 48) {
15341                     nonZeroStart++;
15342                 }
15343                 return stringValue.slice(nonZeroStart, nIndex) || "0";
15344         }
15345         var startIndex = 2, endIndex = stringValue.length - 1;
15346         var bitsNeeded = (endIndex - startIndex) * log2Base;
15347         var segments = new Uint16Array((bitsNeeded >>> 4) + (bitsNeeded & 15 ? 1 : 0));
15348         for (var i = endIndex - 1, bitOffset = 0; i >= startIndex; i--, bitOffset += log2Base) {
15349             var segment = bitOffset >>> 4;
15350             var digitChar = stringValue.charCodeAt(i);
15351             var digit = digitChar <= 57
15352                 ? digitChar - 48
15353                 : 10 + digitChar -
15354                     (digitChar <= 70 ? 65 : 97);
15355             var shiftedDigit = digit << (bitOffset & 15);
15356             segments[segment] |= shiftedDigit;
15357             var residual = shiftedDigit >>> 16;
15358             if (residual)
15359                 segments[segment + 1] |= residual;
15360         }
15361         var base10Value = "";
15362         var firstNonzeroSegment = segments.length - 1;
15363         var segmentsRemaining = true;
15364         while (segmentsRemaining) {
15365             var mod10 = 0;
15366             segmentsRemaining = false;
15367             for (var segment = firstNonzeroSegment; segment >= 0; segment--) {
15368                 var newSegment = mod10 << 16 | segments[segment];
15369                 var segmentValue = (newSegment / 10) | 0;
15370                 segments[segment] = segmentValue;
15371                 mod10 = newSegment - segmentValue * 10;
15372                 if (segmentValue && !segmentsRemaining) {
15373                     firstNonzeroSegment = segment;
15374                     segmentsRemaining = true;
15375                 }
15376             }
15377             base10Value = mod10 + base10Value;
15378         }
15379         return base10Value;
15380     }
15381     ts.parsePseudoBigInt = parsePseudoBigInt;
15382     function pseudoBigIntToString(_a) {
15383         var negative = _a.negative, base10Value = _a.base10Value;
15384         return (negative && base10Value !== "0" ? "-" : "") + base10Value;
15385     }
15386     ts.pseudoBigIntToString = pseudoBigIntToString;
15387     function isValidTypeOnlyAliasUseSite(useSite) {
15388         return !!(useSite.flags & 8388608)
15389             || isPartOfTypeQuery(useSite)
15390             || isIdentifierInNonEmittingHeritageClause(useSite)
15391             || isPartOfPossiblyValidTypeOrAbstractComputedPropertyName(useSite)
15392             || !isExpressionNode(useSite);
15393     }
15394     ts.isValidTypeOnlyAliasUseSite = isValidTypeOnlyAliasUseSite;
15395     function typeOnlyDeclarationIsExport(typeOnlyDeclaration) {
15396         return typeOnlyDeclaration.kind === 270;
15397     }
15398     ts.typeOnlyDeclarationIsExport = typeOnlyDeclarationIsExport;
15399     function isPartOfPossiblyValidTypeOrAbstractComputedPropertyName(node) {
15400         while (node.kind === 78 || node.kind === 201) {
15401             node = node.parent;
15402         }
15403         if (node.kind !== 158) {
15404             return false;
15405         }
15406         if (hasSyntacticModifier(node.parent, 128)) {
15407             return true;
15408         }
15409         var containerKind = node.parent.parent.kind;
15410         return containerKind === 253 || containerKind === 177;
15411     }
15412     function isIdentifierInNonEmittingHeritageClause(node) {
15413         if (node.kind !== 78)
15414             return false;
15415         var heritageClause = ts.findAncestor(node.parent, function (parent) {
15416             switch (parent.kind) {
15417                 case 286:
15418                     return true;
15419                 case 201:
15420                 case 223:
15421                     return false;
15422                 default:
15423                     return "quit";
15424             }
15425         });
15426         return (heritageClause === null || heritageClause === void 0 ? void 0 : heritageClause.token) === 116 || (heritageClause === null || heritageClause === void 0 ? void 0 : heritageClause.parent.kind) === 253;
15427     }
15428     function isIdentifierTypeReference(node) {
15429         return ts.isTypeReferenceNode(node) && ts.isIdentifier(node.typeName);
15430     }
15431     ts.isIdentifierTypeReference = isIdentifierTypeReference;
15432     function arrayIsHomogeneous(array, comparer) {
15433         if (comparer === void 0) { comparer = ts.equateValues; }
15434         if (array.length < 2)
15435             return true;
15436         var first = array[0];
15437         for (var i = 1, length_1 = array.length; i < length_1; i++) {
15438             var target = array[i];
15439             if (!comparer(first, target))
15440                 return false;
15441         }
15442         return true;
15443     }
15444     ts.arrayIsHomogeneous = arrayIsHomogeneous;
15445     function setTextRangePos(range, pos) {
15446         range.pos = pos;
15447         return range;
15448     }
15449     ts.setTextRangePos = setTextRangePos;
15450     function setTextRangeEnd(range, end) {
15451         range.end = end;
15452         return range;
15453     }
15454     ts.setTextRangeEnd = setTextRangeEnd;
15455     function setTextRangePosEnd(range, pos, end) {
15456         return setTextRangeEnd(setTextRangePos(range, pos), end);
15457     }
15458     ts.setTextRangePosEnd = setTextRangePosEnd;
15459     function setTextRangePosWidth(range, pos, width) {
15460         return setTextRangePosEnd(range, pos, pos + width);
15461     }
15462     ts.setTextRangePosWidth = setTextRangePosWidth;
15463     function setNodeFlags(node, newFlags) {
15464         if (node) {
15465             node.flags = newFlags;
15466         }
15467         return node;
15468     }
15469     ts.setNodeFlags = setNodeFlags;
15470     function setParent(child, parent) {
15471         if (child && parent) {
15472             child.parent = parent;
15473         }
15474         return child;
15475     }
15476     ts.setParent = setParent;
15477     function setEachParent(children, parent) {
15478         if (children) {
15479             for (var _i = 0, children_1 = children; _i < children_1.length; _i++) {
15480                 var child = children_1[_i];
15481                 setParent(child, parent);
15482             }
15483         }
15484         return children;
15485     }
15486     ts.setEachParent = setEachParent;
15487     function setParentRecursive(rootNode, incremental) {
15488         if (!rootNode)
15489             return rootNode;
15490         ts.forEachChildRecursively(rootNode, ts.isJSDocNode(rootNode) ? bindParentToChildIgnoringJSDoc : bindParentToChild);
15491         return rootNode;
15492         function bindParentToChildIgnoringJSDoc(child, parent) {
15493             if (incremental && child.parent === parent) {
15494                 return "skip";
15495             }
15496             setParent(child, parent);
15497         }
15498         function bindJSDoc(child) {
15499             if (ts.hasJSDocNodes(child)) {
15500                 for (var _i = 0, _a = child.jsDoc; _i < _a.length; _i++) {
15501                     var doc = _a[_i];
15502                     bindParentToChildIgnoringJSDoc(doc, child);
15503                     ts.forEachChildRecursively(doc, bindParentToChildIgnoringJSDoc);
15504                 }
15505             }
15506         }
15507         function bindParentToChild(child, parent) {
15508             return bindParentToChildIgnoringJSDoc(child, parent) || bindJSDoc(child);
15509         }
15510     }
15511     ts.setParentRecursive = setParentRecursive;
15512 })(ts || (ts = {}));
15513 var ts;
15514 (function (ts) {
15515     function createBaseNodeFactory() {
15516         var NodeConstructor;
15517         var TokenConstructor;
15518         var IdentifierConstructor;
15519         var PrivateIdentifierConstructor;
15520         var SourceFileConstructor;
15521         return {
15522             createBaseSourceFileNode: createBaseSourceFileNode,
15523             createBaseIdentifierNode: createBaseIdentifierNode,
15524             createBasePrivateIdentifierNode: createBasePrivateIdentifierNode,
15525             createBaseTokenNode: createBaseTokenNode,
15526             createBaseNode: createBaseNode
15527         };
15528         function createBaseSourceFileNode(kind) {
15529             return new (SourceFileConstructor || (SourceFileConstructor = ts.objectAllocator.getSourceFileConstructor()))(kind, -1, -1);
15530         }
15531         function createBaseIdentifierNode(kind) {
15532             return new (IdentifierConstructor || (IdentifierConstructor = ts.objectAllocator.getIdentifierConstructor()))(kind, -1, -1);
15533         }
15534         function createBasePrivateIdentifierNode(kind) {
15535             return new (PrivateIdentifierConstructor || (PrivateIdentifierConstructor = ts.objectAllocator.getPrivateIdentifierConstructor()))(kind, -1, -1);
15536         }
15537         function createBaseTokenNode(kind) {
15538             return new (TokenConstructor || (TokenConstructor = ts.objectAllocator.getTokenConstructor()))(kind, -1, -1);
15539         }
15540         function createBaseNode(kind) {
15541             return new (NodeConstructor || (NodeConstructor = ts.objectAllocator.getNodeConstructor()))(kind, -1, -1);
15542         }
15543     }
15544     ts.createBaseNodeFactory = createBaseNodeFactory;
15545 })(ts || (ts = {}));
15546 var ts;
15547 (function (ts) {
15548     function createParenthesizerRules(factory) {
15549         return {
15550             parenthesizeLeftSideOfBinary: parenthesizeLeftSideOfBinary,
15551             parenthesizeRightSideOfBinary: parenthesizeRightSideOfBinary,
15552             parenthesizeExpressionOfComputedPropertyName: parenthesizeExpressionOfComputedPropertyName,
15553             parenthesizeConditionOfConditionalExpression: parenthesizeConditionOfConditionalExpression,
15554             parenthesizeBranchOfConditionalExpression: parenthesizeBranchOfConditionalExpression,
15555             parenthesizeExpressionOfExportDefault: parenthesizeExpressionOfExportDefault,
15556             parenthesizeExpressionOfNew: parenthesizeExpressionOfNew,
15557             parenthesizeLeftSideOfAccess: parenthesizeLeftSideOfAccess,
15558             parenthesizeOperandOfPostfixUnary: parenthesizeOperandOfPostfixUnary,
15559             parenthesizeOperandOfPrefixUnary: parenthesizeOperandOfPrefixUnary,
15560             parenthesizeExpressionsOfCommaDelimitedList: parenthesizeExpressionsOfCommaDelimitedList,
15561             parenthesizeExpressionForDisallowedComma: parenthesizeExpressionForDisallowedComma,
15562             parenthesizeExpressionOfExpressionStatement: parenthesizeExpressionOfExpressionStatement,
15563             parenthesizeConciseBodyOfArrowFunction: parenthesizeConciseBodyOfArrowFunction,
15564             parenthesizeMemberOfConditionalType: parenthesizeMemberOfConditionalType,
15565             parenthesizeMemberOfElementType: parenthesizeMemberOfElementType,
15566             parenthesizeElementTypeOfArrayType: parenthesizeElementTypeOfArrayType,
15567             parenthesizeConstituentTypesOfUnionOrIntersectionType: parenthesizeConstituentTypesOfUnionOrIntersectionType,
15568             parenthesizeTypeArguments: parenthesizeTypeArguments,
15569         };
15570         function binaryOperandNeedsParentheses(binaryOperator, operand, isLeftSideOfBinary, leftOperand) {
15571             var binaryOperatorPrecedence = ts.getOperatorPrecedence(216, binaryOperator);
15572             var binaryOperatorAssociativity = ts.getOperatorAssociativity(216, binaryOperator);
15573             var emittedOperand = ts.skipPartiallyEmittedExpressions(operand);
15574             if (!isLeftSideOfBinary && operand.kind === 209 && binaryOperatorPrecedence > 3) {
15575                 return true;
15576             }
15577             var operandPrecedence = ts.getExpressionPrecedence(emittedOperand);
15578             switch (ts.compareValues(operandPrecedence, binaryOperatorPrecedence)) {
15579                 case -1:
15580                     if (!isLeftSideOfBinary
15581                         && binaryOperatorAssociativity === 1
15582                         && operand.kind === 219) {
15583                         return false;
15584                     }
15585                     return true;
15586                 case 1:
15587                     return false;
15588                 case 0:
15589                     if (isLeftSideOfBinary) {
15590                         return binaryOperatorAssociativity === 1;
15591                     }
15592                     else {
15593                         if (ts.isBinaryExpression(emittedOperand)
15594                             && emittedOperand.operatorToken.kind === binaryOperator) {
15595                             if (operatorHasAssociativeProperty(binaryOperator)) {
15596                                 return false;
15597                             }
15598                             if (binaryOperator === 39) {
15599                                 var leftKind = leftOperand ? getLiteralKindOfBinaryPlusOperand(leftOperand) : 0;
15600                                 if (ts.isLiteralKind(leftKind) && leftKind === getLiteralKindOfBinaryPlusOperand(emittedOperand)) {
15601                                     return false;
15602                                 }
15603                             }
15604                         }
15605                         var operandAssociativity = ts.getExpressionAssociativity(emittedOperand);
15606                         return operandAssociativity === 0;
15607                     }
15608             }
15609         }
15610         function operatorHasAssociativeProperty(binaryOperator) {
15611             return binaryOperator === 41
15612                 || binaryOperator === 51
15613                 || binaryOperator === 50
15614                 || binaryOperator === 52;
15615         }
15616         function getLiteralKindOfBinaryPlusOperand(node) {
15617             node = ts.skipPartiallyEmittedExpressions(node);
15618             if (ts.isLiteralKind(node.kind)) {
15619                 return node.kind;
15620             }
15621             if (node.kind === 216 && node.operatorToken.kind === 39) {
15622                 if (node.cachedLiteralKind !== undefined) {
15623                     return node.cachedLiteralKind;
15624                 }
15625                 var leftKind = getLiteralKindOfBinaryPlusOperand(node.left);
15626                 var literalKind = ts.isLiteralKind(leftKind)
15627                     && leftKind === getLiteralKindOfBinaryPlusOperand(node.right)
15628                     ? leftKind
15629                     : 0;
15630                 node.cachedLiteralKind = literalKind;
15631                 return literalKind;
15632             }
15633             return 0;
15634         }
15635         function parenthesizeBinaryOperand(binaryOperator, operand, isLeftSideOfBinary, leftOperand) {
15636             var skipped = ts.skipPartiallyEmittedExpressions(operand);
15637             if (skipped.kind === 207) {
15638                 return operand;
15639             }
15640             return binaryOperandNeedsParentheses(binaryOperator, operand, isLeftSideOfBinary, leftOperand)
15641                 ? factory.createParenthesizedExpression(operand)
15642                 : operand;
15643         }
15644         function parenthesizeLeftSideOfBinary(binaryOperator, leftSide) {
15645             return parenthesizeBinaryOperand(binaryOperator, leftSide, true);
15646         }
15647         function parenthesizeRightSideOfBinary(binaryOperator, leftSide, rightSide) {
15648             return parenthesizeBinaryOperand(binaryOperator, rightSide, false, leftSide);
15649         }
15650         function parenthesizeExpressionOfComputedPropertyName(expression) {
15651             return ts.isCommaSequence(expression) ? factory.createParenthesizedExpression(expression) : expression;
15652         }
15653         function parenthesizeConditionOfConditionalExpression(condition) {
15654             var conditionalPrecedence = ts.getOperatorPrecedence(217, 57);
15655             var emittedCondition = ts.skipPartiallyEmittedExpressions(condition);
15656             var conditionPrecedence = ts.getExpressionPrecedence(emittedCondition);
15657             if (ts.compareValues(conditionPrecedence, conditionalPrecedence) !== 1) {
15658                 return factory.createParenthesizedExpression(condition);
15659             }
15660             return condition;
15661         }
15662         function parenthesizeBranchOfConditionalExpression(branch) {
15663             var emittedExpression = ts.skipPartiallyEmittedExpressions(branch);
15664             return ts.isCommaSequence(emittedExpression)
15665                 ? factory.createParenthesizedExpression(branch)
15666                 : branch;
15667         }
15668         function parenthesizeExpressionOfExportDefault(expression) {
15669             var check = ts.skipPartiallyEmittedExpressions(expression);
15670             var needsParens = ts.isCommaSequence(check);
15671             if (!needsParens) {
15672                 switch (ts.getLeftmostExpression(check, false).kind) {
15673                     case 221:
15674                     case 208:
15675                         needsParens = true;
15676                 }
15677             }
15678             return needsParens ? factory.createParenthesizedExpression(expression) : expression;
15679         }
15680         function parenthesizeExpressionOfNew(expression) {
15681             var leftmostExpr = ts.getLeftmostExpression(expression, true);
15682             switch (leftmostExpr.kind) {
15683                 case 203:
15684                     return factory.createParenthesizedExpression(expression);
15685                 case 204:
15686                     return !leftmostExpr.arguments
15687                         ? factory.createParenthesizedExpression(expression)
15688                         : expression;
15689             }
15690             return parenthesizeLeftSideOfAccess(expression);
15691         }
15692         function parenthesizeLeftSideOfAccess(expression) {
15693             var emittedExpression = ts.skipPartiallyEmittedExpressions(expression);
15694             if (ts.isLeftHandSideExpression(emittedExpression)
15695                 && (emittedExpression.kind !== 204 || emittedExpression.arguments)) {
15696                 return expression;
15697             }
15698             return ts.setTextRange(factory.createParenthesizedExpression(expression), expression);
15699         }
15700         function parenthesizeOperandOfPostfixUnary(operand) {
15701             return ts.isLeftHandSideExpression(operand) ? operand : ts.setTextRange(factory.createParenthesizedExpression(operand), operand);
15702         }
15703         function parenthesizeOperandOfPrefixUnary(operand) {
15704             return ts.isUnaryExpression(operand) ? operand : ts.setTextRange(factory.createParenthesizedExpression(operand), operand);
15705         }
15706         function parenthesizeExpressionsOfCommaDelimitedList(elements) {
15707             var result = ts.sameMap(elements, parenthesizeExpressionForDisallowedComma);
15708             return ts.setTextRange(factory.createNodeArray(result, elements.hasTrailingComma), elements);
15709         }
15710         function parenthesizeExpressionForDisallowedComma(expression) {
15711             var emittedExpression = ts.skipPartiallyEmittedExpressions(expression);
15712             var expressionPrecedence = ts.getExpressionPrecedence(emittedExpression);
15713             var commaPrecedence = ts.getOperatorPrecedence(216, 27);
15714             return expressionPrecedence > commaPrecedence ? expression : ts.setTextRange(factory.createParenthesizedExpression(expression), expression);
15715         }
15716         function parenthesizeExpressionOfExpressionStatement(expression) {
15717             var emittedExpression = ts.skipPartiallyEmittedExpressions(expression);
15718             if (ts.isCallExpression(emittedExpression)) {
15719                 var callee = emittedExpression.expression;
15720                 var kind = ts.skipPartiallyEmittedExpressions(callee).kind;
15721                 if (kind === 208 || kind === 209) {
15722                     var updated = factory.updateCallExpression(emittedExpression, ts.setTextRange(factory.createParenthesizedExpression(callee), callee), emittedExpression.typeArguments, emittedExpression.arguments);
15723                     return factory.restoreOuterExpressions(expression, updated, 8);
15724                 }
15725             }
15726             var leftmostExpressionKind = ts.getLeftmostExpression(emittedExpression, false).kind;
15727             if (leftmostExpressionKind === 200 || leftmostExpressionKind === 208) {
15728                 return ts.setTextRange(factory.createParenthesizedExpression(expression), expression);
15729             }
15730             return expression;
15731         }
15732         function parenthesizeConciseBodyOfArrowFunction(body) {
15733             if (!ts.isBlock(body) && (ts.isCommaSequence(body) || ts.getLeftmostExpression(body, false).kind === 200)) {
15734                 return ts.setTextRange(factory.createParenthesizedExpression(body), body);
15735             }
15736             return body;
15737         }
15738         function parenthesizeMemberOfConditionalType(member) {
15739             return member.kind === 184 ? factory.createParenthesizedType(member) : member;
15740         }
15741         function parenthesizeMemberOfElementType(member) {
15742             switch (member.kind) {
15743                 case 182:
15744                 case 183:
15745                 case 174:
15746                 case 175:
15747                     return factory.createParenthesizedType(member);
15748             }
15749             return parenthesizeMemberOfConditionalType(member);
15750         }
15751         function parenthesizeElementTypeOfArrayType(member) {
15752             switch (member.kind) {
15753                 case 176:
15754                 case 188:
15755                 case 185:
15756                     return factory.createParenthesizedType(member);
15757             }
15758             return parenthesizeMemberOfElementType(member);
15759         }
15760         function parenthesizeConstituentTypesOfUnionOrIntersectionType(members) {
15761             return factory.createNodeArray(ts.sameMap(members, parenthesizeMemberOfElementType));
15762         }
15763         function parenthesizeOrdinalTypeArgument(node, i) {
15764             return i === 0 && ts.isFunctionOrConstructorTypeNode(node) && node.typeParameters ? factory.createParenthesizedType(node) : node;
15765         }
15766         function parenthesizeTypeArguments(typeArguments) {
15767             if (ts.some(typeArguments)) {
15768                 return factory.createNodeArray(ts.sameMap(typeArguments, parenthesizeOrdinalTypeArgument));
15769             }
15770         }
15771     }
15772     ts.createParenthesizerRules = createParenthesizerRules;
15773     ts.nullParenthesizerRules = {
15774         parenthesizeLeftSideOfBinary: function (_binaryOperator, leftSide) { return leftSide; },
15775         parenthesizeRightSideOfBinary: function (_binaryOperator, _leftSide, rightSide) { return rightSide; },
15776         parenthesizeExpressionOfComputedPropertyName: ts.identity,
15777         parenthesizeConditionOfConditionalExpression: ts.identity,
15778         parenthesizeBranchOfConditionalExpression: ts.identity,
15779         parenthesizeExpressionOfExportDefault: ts.identity,
15780         parenthesizeExpressionOfNew: function (expression) { return ts.cast(expression, ts.isLeftHandSideExpression); },
15781         parenthesizeLeftSideOfAccess: function (expression) { return ts.cast(expression, ts.isLeftHandSideExpression); },
15782         parenthesizeOperandOfPostfixUnary: function (operand) { return ts.cast(operand, ts.isLeftHandSideExpression); },
15783         parenthesizeOperandOfPrefixUnary: function (operand) { return ts.cast(operand, ts.isUnaryExpression); },
15784         parenthesizeExpressionsOfCommaDelimitedList: function (nodes) { return ts.cast(nodes, ts.isNodeArray); },
15785         parenthesizeExpressionForDisallowedComma: ts.identity,
15786         parenthesizeExpressionOfExpressionStatement: ts.identity,
15787         parenthesizeConciseBodyOfArrowFunction: ts.identity,
15788         parenthesizeMemberOfConditionalType: ts.identity,
15789         parenthesizeMemberOfElementType: ts.identity,
15790         parenthesizeElementTypeOfArrayType: ts.identity,
15791         parenthesizeConstituentTypesOfUnionOrIntersectionType: function (nodes) { return ts.cast(nodes, ts.isNodeArray); },
15792         parenthesizeTypeArguments: function (nodes) { return nodes && ts.cast(nodes, ts.isNodeArray); },
15793     };
15794 })(ts || (ts = {}));
15795 var ts;
15796 (function (ts) {
15797     function createNodeConverters(factory) {
15798         return {
15799             convertToFunctionBlock: convertToFunctionBlock,
15800             convertToFunctionExpression: convertToFunctionExpression,
15801             convertToArrayAssignmentElement: convertToArrayAssignmentElement,
15802             convertToObjectAssignmentElement: convertToObjectAssignmentElement,
15803             convertToAssignmentPattern: convertToAssignmentPattern,
15804             convertToObjectAssignmentPattern: convertToObjectAssignmentPattern,
15805             convertToArrayAssignmentPattern: convertToArrayAssignmentPattern,
15806             convertToAssignmentElementTarget: convertToAssignmentElementTarget,
15807         };
15808         function convertToFunctionBlock(node, multiLine) {
15809             if (ts.isBlock(node))
15810                 return node;
15811             var returnStatement = factory.createReturnStatement(node);
15812             ts.setTextRange(returnStatement, node);
15813             var body = factory.createBlock([returnStatement], multiLine);
15814             ts.setTextRange(body, node);
15815             return body;
15816         }
15817         function convertToFunctionExpression(node) {
15818             if (!node.body)
15819                 return ts.Debug.fail("Cannot convert a FunctionDeclaration without a body");
15820             var updated = factory.createFunctionExpression(node.modifiers, node.asteriskToken, node.name, node.typeParameters, node.parameters, node.type, node.body);
15821             ts.setOriginalNode(updated, node);
15822             ts.setTextRange(updated, node);
15823             if (ts.getStartsOnNewLine(node)) {
15824                 ts.setStartsOnNewLine(updated, true);
15825             }
15826             return updated;
15827         }
15828         function convertToArrayAssignmentElement(element) {
15829             if (ts.isBindingElement(element)) {
15830                 if (element.dotDotDotToken) {
15831                     ts.Debug.assertNode(element.name, ts.isIdentifier);
15832                     return ts.setOriginalNode(ts.setTextRange(factory.createSpreadElement(element.name), element), element);
15833                 }
15834                 var expression = convertToAssignmentElementTarget(element.name);
15835                 return element.initializer
15836                     ? ts.setOriginalNode(ts.setTextRange(factory.createAssignment(expression, element.initializer), element), element)
15837                     : expression;
15838             }
15839             return ts.cast(element, ts.isExpression);
15840         }
15841         function convertToObjectAssignmentElement(element) {
15842             if (ts.isBindingElement(element)) {
15843                 if (element.dotDotDotToken) {
15844                     ts.Debug.assertNode(element.name, ts.isIdentifier);
15845                     return ts.setOriginalNode(ts.setTextRange(factory.createSpreadAssignment(element.name), element), element);
15846                 }
15847                 if (element.propertyName) {
15848                     var expression = convertToAssignmentElementTarget(element.name);
15849                     return ts.setOriginalNode(ts.setTextRange(factory.createPropertyAssignment(element.propertyName, element.initializer ? factory.createAssignment(expression, element.initializer) : expression), element), element);
15850                 }
15851                 ts.Debug.assertNode(element.name, ts.isIdentifier);
15852                 return ts.setOriginalNode(ts.setTextRange(factory.createShorthandPropertyAssignment(element.name, element.initializer), element), element);
15853             }
15854             return ts.cast(element, ts.isObjectLiteralElementLike);
15855         }
15856         function convertToAssignmentPattern(node) {
15857             switch (node.kind) {
15858                 case 197:
15859                 case 199:
15860                     return convertToArrayAssignmentPattern(node);
15861                 case 196:
15862                 case 200:
15863                     return convertToObjectAssignmentPattern(node);
15864             }
15865         }
15866         function convertToObjectAssignmentPattern(node) {
15867             if (ts.isObjectBindingPattern(node)) {
15868                 return ts.setOriginalNode(ts.setTextRange(factory.createObjectLiteralExpression(ts.map(node.elements, convertToObjectAssignmentElement)), node), node);
15869             }
15870             return ts.cast(node, ts.isObjectLiteralExpression);
15871         }
15872         function convertToArrayAssignmentPattern(node) {
15873             if (ts.isArrayBindingPattern(node)) {
15874                 return ts.setOriginalNode(ts.setTextRange(factory.createArrayLiteralExpression(ts.map(node.elements, convertToArrayAssignmentElement)), node), node);
15875             }
15876             return ts.cast(node, ts.isArrayLiteralExpression);
15877         }
15878         function convertToAssignmentElementTarget(node) {
15879             if (ts.isBindingPattern(node)) {
15880                 return convertToAssignmentPattern(node);
15881             }
15882             return ts.cast(node, ts.isExpression);
15883         }
15884     }
15885     ts.createNodeConverters = createNodeConverters;
15886     ts.nullNodeConverters = {
15887         convertToFunctionBlock: ts.notImplemented,
15888         convertToFunctionExpression: ts.notImplemented,
15889         convertToArrayAssignmentElement: ts.notImplemented,
15890         convertToObjectAssignmentElement: ts.notImplemented,
15891         convertToAssignmentPattern: ts.notImplemented,
15892         convertToObjectAssignmentPattern: ts.notImplemented,
15893         convertToArrayAssignmentPattern: ts.notImplemented,
15894         convertToAssignmentElementTarget: ts.notImplemented,
15895     };
15896 })(ts || (ts = {}));
15897 var ts;
15898 (function (ts) {
15899     var nextAutoGenerateId = 0;
15900     function createNodeFactory(flags, baseFactory) {
15901         var update = flags & 8 ? updateWithoutOriginal : updateWithOriginal;
15902         var parenthesizerRules = ts.memoize(function () { return flags & 1 ? ts.nullParenthesizerRules : ts.createParenthesizerRules(factory); });
15903         var converters = ts.memoize(function () { return flags & 2 ? ts.nullNodeConverters : ts.createNodeConverters(factory); });
15904         var getBinaryCreateFunction = ts.memoizeOne(function (operator) { return function (left, right) { return createBinaryExpression(left, operator, right); }; });
15905         var getPrefixUnaryCreateFunction = ts.memoizeOne(function (operator) { return function (operand) { return createPrefixUnaryExpression(operator, operand); }; });
15906         var getPostfixUnaryCreateFunction = ts.memoizeOne(function (operator) { return function (operand) { return createPostfixUnaryExpression(operand, operator); }; });
15907         var getJSDocPrimaryTypeCreateFunction = ts.memoizeOne(function (kind) { return function () { return createJSDocPrimaryTypeWorker(kind); }; });
15908         var getJSDocUnaryTypeCreateFunction = ts.memoizeOne(function (kind) { return function (type) { return createJSDocUnaryTypeWorker(kind, type); }; });
15909         var getJSDocUnaryTypeUpdateFunction = ts.memoizeOne(function (kind) { return function (node, type) { return updateJSDocUnaryTypeWorker(kind, node, type); }; });
15910         var getJSDocSimpleTagCreateFunction = ts.memoizeOne(function (kind) { return function (tagName, comment) { return createJSDocSimpleTagWorker(kind, tagName, comment); }; });
15911         var getJSDocSimpleTagUpdateFunction = ts.memoizeOne(function (kind) { return function (node, tagName, comment) { return updateJSDocSimpleTagWorker(kind, node, tagName, comment); }; });
15912         var getJSDocTypeLikeTagCreateFunction = ts.memoizeOne(function (kind) { return function (tagName, typeExpression, comment) { return createJSDocTypeLikeTagWorker(kind, tagName, typeExpression, comment); }; });
15913         var getJSDocTypeLikeTagUpdateFunction = ts.memoizeOne(function (kind) { return function (node, tagName, typeExpression, comment) { return updateJSDocTypeLikeTagWorker(kind, node, tagName, typeExpression, comment); }; });
15914         var factory = {
15915             get parenthesizer() { return parenthesizerRules(); },
15916             get converters() { return converters(); },
15917             createNodeArray: createNodeArray,
15918             createNumericLiteral: createNumericLiteral,
15919             createBigIntLiteral: createBigIntLiteral,
15920             createStringLiteral: createStringLiteral,
15921             createStringLiteralFromNode: createStringLiteralFromNode,
15922             createRegularExpressionLiteral: createRegularExpressionLiteral,
15923             createLiteralLikeNode: createLiteralLikeNode,
15924             createIdentifier: createIdentifier,
15925             updateIdentifier: updateIdentifier,
15926             createTempVariable: createTempVariable,
15927             createLoopVariable: createLoopVariable,
15928             createUniqueName: createUniqueName,
15929             getGeneratedNameForNode: getGeneratedNameForNode,
15930             createPrivateIdentifier: createPrivateIdentifier,
15931             createToken: createToken,
15932             createSuper: createSuper,
15933             createThis: createThis,
15934             createNull: createNull,
15935             createTrue: createTrue,
15936             createFalse: createFalse,
15937             createModifier: createModifier,
15938             createModifiersFromModifierFlags: createModifiersFromModifierFlags,
15939             createQualifiedName: createQualifiedName,
15940             updateQualifiedName: updateQualifiedName,
15941             createComputedPropertyName: createComputedPropertyName,
15942             updateComputedPropertyName: updateComputedPropertyName,
15943             createTypeParameterDeclaration: createTypeParameterDeclaration,
15944             updateTypeParameterDeclaration: updateTypeParameterDeclaration,
15945             createParameterDeclaration: createParameterDeclaration,
15946             updateParameterDeclaration: updateParameterDeclaration,
15947             createDecorator: createDecorator,
15948             updateDecorator: updateDecorator,
15949             createPropertySignature: createPropertySignature,
15950             updatePropertySignature: updatePropertySignature,
15951             createPropertyDeclaration: createPropertyDeclaration,
15952             updatePropertyDeclaration: updatePropertyDeclaration,
15953             createMethodSignature: createMethodSignature,
15954             updateMethodSignature: updateMethodSignature,
15955             createMethodDeclaration: createMethodDeclaration,
15956             updateMethodDeclaration: updateMethodDeclaration,
15957             createConstructorDeclaration: createConstructorDeclaration,
15958             updateConstructorDeclaration: updateConstructorDeclaration,
15959             createGetAccessorDeclaration: createGetAccessorDeclaration,
15960             updateGetAccessorDeclaration: updateGetAccessorDeclaration,
15961             createSetAccessorDeclaration: createSetAccessorDeclaration,
15962             updateSetAccessorDeclaration: updateSetAccessorDeclaration,
15963             createCallSignature: createCallSignature,
15964             updateCallSignature: updateCallSignature,
15965             createConstructSignature: createConstructSignature,
15966             updateConstructSignature: updateConstructSignature,
15967             createIndexSignature: createIndexSignature,
15968             updateIndexSignature: updateIndexSignature,
15969             createTemplateLiteralTypeSpan: createTemplateLiteralTypeSpan,
15970             updateTemplateLiteralTypeSpan: updateTemplateLiteralTypeSpan,
15971             createKeywordTypeNode: createKeywordTypeNode,
15972             createTypePredicateNode: createTypePredicateNode,
15973             updateTypePredicateNode: updateTypePredicateNode,
15974             createTypeReferenceNode: createTypeReferenceNode,
15975             updateTypeReferenceNode: updateTypeReferenceNode,
15976             createFunctionTypeNode: createFunctionTypeNode,
15977             updateFunctionTypeNode: updateFunctionTypeNode,
15978             createConstructorTypeNode: createConstructorTypeNode,
15979             updateConstructorTypeNode: updateConstructorTypeNode,
15980             createTypeQueryNode: createTypeQueryNode,
15981             updateTypeQueryNode: updateTypeQueryNode,
15982             createTypeLiteralNode: createTypeLiteralNode,
15983             updateTypeLiteralNode: updateTypeLiteralNode,
15984             createArrayTypeNode: createArrayTypeNode,
15985             updateArrayTypeNode: updateArrayTypeNode,
15986             createTupleTypeNode: createTupleTypeNode,
15987             updateTupleTypeNode: updateTupleTypeNode,
15988             createNamedTupleMember: createNamedTupleMember,
15989             updateNamedTupleMember: updateNamedTupleMember,
15990             createOptionalTypeNode: createOptionalTypeNode,
15991             updateOptionalTypeNode: updateOptionalTypeNode,
15992             createRestTypeNode: createRestTypeNode,
15993             updateRestTypeNode: updateRestTypeNode,
15994             createUnionTypeNode: createUnionTypeNode,
15995             updateUnionTypeNode: updateUnionTypeNode,
15996             createIntersectionTypeNode: createIntersectionTypeNode,
15997             updateIntersectionTypeNode: updateIntersectionTypeNode,
15998             createConditionalTypeNode: createConditionalTypeNode,
15999             updateConditionalTypeNode: updateConditionalTypeNode,
16000             createInferTypeNode: createInferTypeNode,
16001             updateInferTypeNode: updateInferTypeNode,
16002             createImportTypeNode: createImportTypeNode,
16003             updateImportTypeNode: updateImportTypeNode,
16004             createParenthesizedType: createParenthesizedType,
16005             updateParenthesizedType: updateParenthesizedType,
16006             createThisTypeNode: createThisTypeNode,
16007             createTypeOperatorNode: createTypeOperatorNode,
16008             updateTypeOperatorNode: updateTypeOperatorNode,
16009             createIndexedAccessTypeNode: createIndexedAccessTypeNode,
16010             updateIndexedAccessTypeNode: updateIndexedAccessTypeNode,
16011             createMappedTypeNode: createMappedTypeNode,
16012             updateMappedTypeNode: updateMappedTypeNode,
16013             createLiteralTypeNode: createLiteralTypeNode,
16014             updateLiteralTypeNode: updateLiteralTypeNode,
16015             createTemplateLiteralType: createTemplateLiteralType,
16016             updateTemplateLiteralType: updateTemplateLiteralType,
16017             createObjectBindingPattern: createObjectBindingPattern,
16018             updateObjectBindingPattern: updateObjectBindingPattern,
16019             createArrayBindingPattern: createArrayBindingPattern,
16020             updateArrayBindingPattern: updateArrayBindingPattern,
16021             createBindingElement: createBindingElement,
16022             updateBindingElement: updateBindingElement,
16023             createArrayLiteralExpression: createArrayLiteralExpression,
16024             updateArrayLiteralExpression: updateArrayLiteralExpression,
16025             createObjectLiteralExpression: createObjectLiteralExpression,
16026             updateObjectLiteralExpression: updateObjectLiteralExpression,
16027             createPropertyAccessExpression: flags & 4 ?
16028                 function (expression, name) { return ts.setEmitFlags(createPropertyAccessExpression(expression, name), 131072); } :
16029                 createPropertyAccessExpression,
16030             updatePropertyAccessExpression: updatePropertyAccessExpression,
16031             createPropertyAccessChain: flags & 4 ?
16032                 function (expression, questionDotToken, name) { return ts.setEmitFlags(createPropertyAccessChain(expression, questionDotToken, name), 131072); } :
16033                 createPropertyAccessChain,
16034             updatePropertyAccessChain: updatePropertyAccessChain,
16035             createElementAccessExpression: createElementAccessExpression,
16036             updateElementAccessExpression: updateElementAccessExpression,
16037             createElementAccessChain: createElementAccessChain,
16038             updateElementAccessChain: updateElementAccessChain,
16039             createCallExpression: createCallExpression,
16040             updateCallExpression: updateCallExpression,
16041             createCallChain: createCallChain,
16042             updateCallChain: updateCallChain,
16043             createNewExpression: createNewExpression,
16044             updateNewExpression: updateNewExpression,
16045             createTaggedTemplateExpression: createTaggedTemplateExpression,
16046             updateTaggedTemplateExpression: updateTaggedTemplateExpression,
16047             createTypeAssertion: createTypeAssertion,
16048             updateTypeAssertion: updateTypeAssertion,
16049             createParenthesizedExpression: createParenthesizedExpression,
16050             updateParenthesizedExpression: updateParenthesizedExpression,
16051             createFunctionExpression: createFunctionExpression,
16052             updateFunctionExpression: updateFunctionExpression,
16053             createArrowFunction: createArrowFunction,
16054             updateArrowFunction: updateArrowFunction,
16055             createDeleteExpression: createDeleteExpression,
16056             updateDeleteExpression: updateDeleteExpression,
16057             createTypeOfExpression: createTypeOfExpression,
16058             updateTypeOfExpression: updateTypeOfExpression,
16059             createVoidExpression: createVoidExpression,
16060             updateVoidExpression: updateVoidExpression,
16061             createAwaitExpression: createAwaitExpression,
16062             updateAwaitExpression: updateAwaitExpression,
16063             createPrefixUnaryExpression: createPrefixUnaryExpression,
16064             updatePrefixUnaryExpression: updatePrefixUnaryExpression,
16065             createPostfixUnaryExpression: createPostfixUnaryExpression,
16066             updatePostfixUnaryExpression: updatePostfixUnaryExpression,
16067             createBinaryExpression: createBinaryExpression,
16068             updateBinaryExpression: updateBinaryExpression,
16069             createConditionalExpression: createConditionalExpression,
16070             updateConditionalExpression: updateConditionalExpression,
16071             createTemplateExpression: createTemplateExpression,
16072             updateTemplateExpression: updateTemplateExpression,
16073             createTemplateHead: createTemplateHead,
16074             createTemplateMiddle: createTemplateMiddle,
16075             createTemplateTail: createTemplateTail,
16076             createNoSubstitutionTemplateLiteral: createNoSubstitutionTemplateLiteral,
16077             createTemplateLiteralLikeNode: createTemplateLiteralLikeNode,
16078             createYieldExpression: createYieldExpression,
16079             updateYieldExpression: updateYieldExpression,
16080             createSpreadElement: createSpreadElement,
16081             updateSpreadElement: updateSpreadElement,
16082             createClassExpression: createClassExpression,
16083             updateClassExpression: updateClassExpression,
16084             createOmittedExpression: createOmittedExpression,
16085             createExpressionWithTypeArguments: createExpressionWithTypeArguments,
16086             updateExpressionWithTypeArguments: updateExpressionWithTypeArguments,
16087             createAsExpression: createAsExpression,
16088             updateAsExpression: updateAsExpression,
16089             createNonNullExpression: createNonNullExpression,
16090             updateNonNullExpression: updateNonNullExpression,
16091             createNonNullChain: createNonNullChain,
16092             updateNonNullChain: updateNonNullChain,
16093             createMetaProperty: createMetaProperty,
16094             updateMetaProperty: updateMetaProperty,
16095             createTemplateSpan: createTemplateSpan,
16096             updateTemplateSpan: updateTemplateSpan,
16097             createSemicolonClassElement: createSemicolonClassElement,
16098             createBlock: createBlock,
16099             updateBlock: updateBlock,
16100             createVariableStatement: createVariableStatement,
16101             updateVariableStatement: updateVariableStatement,
16102             createEmptyStatement: createEmptyStatement,
16103             createExpressionStatement: createExpressionStatement,
16104             updateExpressionStatement: updateExpressionStatement,
16105             createIfStatement: createIfStatement,
16106             updateIfStatement: updateIfStatement,
16107             createDoStatement: createDoStatement,
16108             updateDoStatement: updateDoStatement,
16109             createWhileStatement: createWhileStatement,
16110             updateWhileStatement: updateWhileStatement,
16111             createForStatement: createForStatement,
16112             updateForStatement: updateForStatement,
16113             createForInStatement: createForInStatement,
16114             updateForInStatement: updateForInStatement,
16115             createForOfStatement: createForOfStatement,
16116             updateForOfStatement: updateForOfStatement,
16117             createContinueStatement: createContinueStatement,
16118             updateContinueStatement: updateContinueStatement,
16119             createBreakStatement: createBreakStatement,
16120             updateBreakStatement: updateBreakStatement,
16121             createReturnStatement: createReturnStatement,
16122             updateReturnStatement: updateReturnStatement,
16123             createWithStatement: createWithStatement,
16124             updateWithStatement: updateWithStatement,
16125             createSwitchStatement: createSwitchStatement,
16126             updateSwitchStatement: updateSwitchStatement,
16127             createLabeledStatement: createLabeledStatement,
16128             updateLabeledStatement: updateLabeledStatement,
16129             createThrowStatement: createThrowStatement,
16130             updateThrowStatement: updateThrowStatement,
16131             createTryStatement: createTryStatement,
16132             updateTryStatement: updateTryStatement,
16133             createDebuggerStatement: createDebuggerStatement,
16134             createVariableDeclaration: createVariableDeclaration,
16135             updateVariableDeclaration: updateVariableDeclaration,
16136             createVariableDeclarationList: createVariableDeclarationList,
16137             updateVariableDeclarationList: updateVariableDeclarationList,
16138             createFunctionDeclaration: createFunctionDeclaration,
16139             updateFunctionDeclaration: updateFunctionDeclaration,
16140             createClassDeclaration: createClassDeclaration,
16141             updateClassDeclaration: updateClassDeclaration,
16142             createInterfaceDeclaration: createInterfaceDeclaration,
16143             updateInterfaceDeclaration: updateInterfaceDeclaration,
16144             createTypeAliasDeclaration: createTypeAliasDeclaration,
16145             updateTypeAliasDeclaration: updateTypeAliasDeclaration,
16146             createEnumDeclaration: createEnumDeclaration,
16147             updateEnumDeclaration: updateEnumDeclaration,
16148             createModuleDeclaration: createModuleDeclaration,
16149             updateModuleDeclaration: updateModuleDeclaration,
16150             createModuleBlock: createModuleBlock,
16151             updateModuleBlock: updateModuleBlock,
16152             createCaseBlock: createCaseBlock,
16153             updateCaseBlock: updateCaseBlock,
16154             createNamespaceExportDeclaration: createNamespaceExportDeclaration,
16155             updateNamespaceExportDeclaration: updateNamespaceExportDeclaration,
16156             createImportEqualsDeclaration: createImportEqualsDeclaration,
16157             updateImportEqualsDeclaration: updateImportEqualsDeclaration,
16158             createImportDeclaration: createImportDeclaration,
16159             updateImportDeclaration: updateImportDeclaration,
16160             createImportClause: createImportClause,
16161             updateImportClause: updateImportClause,
16162             createNamespaceImport: createNamespaceImport,
16163             updateNamespaceImport: updateNamespaceImport,
16164             createNamespaceExport: createNamespaceExport,
16165             updateNamespaceExport: updateNamespaceExport,
16166             createNamedImports: createNamedImports,
16167             updateNamedImports: updateNamedImports,
16168             createImportSpecifier: createImportSpecifier,
16169             updateImportSpecifier: updateImportSpecifier,
16170             createExportAssignment: createExportAssignment,
16171             updateExportAssignment: updateExportAssignment,
16172             createExportDeclaration: createExportDeclaration,
16173             updateExportDeclaration: updateExportDeclaration,
16174             createNamedExports: createNamedExports,
16175             updateNamedExports: updateNamedExports,
16176             createExportSpecifier: createExportSpecifier,
16177             updateExportSpecifier: updateExportSpecifier,
16178             createMissingDeclaration: createMissingDeclaration,
16179             createExternalModuleReference: createExternalModuleReference,
16180             updateExternalModuleReference: updateExternalModuleReference,
16181             get createJSDocAllType() { return getJSDocPrimaryTypeCreateFunction(303); },
16182             get createJSDocUnknownType() { return getJSDocPrimaryTypeCreateFunction(304); },
16183             get createJSDocNonNullableType() { return getJSDocUnaryTypeCreateFunction(306); },
16184             get updateJSDocNonNullableType() { return getJSDocUnaryTypeUpdateFunction(306); },
16185             get createJSDocNullableType() { return getJSDocUnaryTypeCreateFunction(305); },
16186             get updateJSDocNullableType() { return getJSDocUnaryTypeUpdateFunction(305); },
16187             get createJSDocOptionalType() { return getJSDocUnaryTypeCreateFunction(307); },
16188             get updateJSDocOptionalType() { return getJSDocUnaryTypeUpdateFunction(307); },
16189             get createJSDocVariadicType() { return getJSDocUnaryTypeCreateFunction(309); },
16190             get updateJSDocVariadicType() { return getJSDocUnaryTypeUpdateFunction(309); },
16191             get createJSDocNamepathType() { return getJSDocUnaryTypeCreateFunction(310); },
16192             get updateJSDocNamepathType() { return getJSDocUnaryTypeUpdateFunction(310); },
16193             createJSDocFunctionType: createJSDocFunctionType,
16194             updateJSDocFunctionType: updateJSDocFunctionType,
16195             createJSDocTypeLiteral: createJSDocTypeLiteral,
16196             updateJSDocTypeLiteral: updateJSDocTypeLiteral,
16197             createJSDocTypeExpression: createJSDocTypeExpression,
16198             updateJSDocTypeExpression: updateJSDocTypeExpression,
16199             createJSDocSignature: createJSDocSignature,
16200             updateJSDocSignature: updateJSDocSignature,
16201             createJSDocTemplateTag: createJSDocTemplateTag,
16202             updateJSDocTemplateTag: updateJSDocTemplateTag,
16203             createJSDocTypedefTag: createJSDocTypedefTag,
16204             updateJSDocTypedefTag: updateJSDocTypedefTag,
16205             createJSDocParameterTag: createJSDocParameterTag,
16206             updateJSDocParameterTag: updateJSDocParameterTag,
16207             createJSDocPropertyTag: createJSDocPropertyTag,
16208             updateJSDocPropertyTag: updateJSDocPropertyTag,
16209             createJSDocCallbackTag: createJSDocCallbackTag,
16210             updateJSDocCallbackTag: updateJSDocCallbackTag,
16211             createJSDocAugmentsTag: createJSDocAugmentsTag,
16212             updateJSDocAugmentsTag: updateJSDocAugmentsTag,
16213             createJSDocImplementsTag: createJSDocImplementsTag,
16214             updateJSDocImplementsTag: updateJSDocImplementsTag,
16215             createJSDocSeeTag: createJSDocSeeTag,
16216             updateJSDocSeeTag: updateJSDocSeeTag,
16217             createJSDocNameReference: createJSDocNameReference,
16218             updateJSDocNameReference: updateJSDocNameReference,
16219             get createJSDocTypeTag() { return getJSDocTypeLikeTagCreateFunction(329); },
16220             get updateJSDocTypeTag() { return getJSDocTypeLikeTagUpdateFunction(329); },
16221             get createJSDocReturnTag() { return getJSDocTypeLikeTagCreateFunction(327); },
16222             get updateJSDocReturnTag() { return getJSDocTypeLikeTagUpdateFunction(327); },
16223             get createJSDocThisTag() { return getJSDocTypeLikeTagCreateFunction(328); },
16224             get updateJSDocThisTag() { return getJSDocTypeLikeTagUpdateFunction(328); },
16225             get createJSDocEnumTag() { return getJSDocTypeLikeTagCreateFunction(325); },
16226             get updateJSDocEnumTag() { return getJSDocTypeLikeTagUpdateFunction(325); },
16227             get createJSDocAuthorTag() { return getJSDocSimpleTagCreateFunction(317); },
16228             get updateJSDocAuthorTag() { return getJSDocSimpleTagUpdateFunction(317); },
16229             get createJSDocClassTag() { return getJSDocSimpleTagCreateFunction(319); },
16230             get updateJSDocClassTag() { return getJSDocSimpleTagUpdateFunction(319); },
16231             get createJSDocPublicTag() { return getJSDocSimpleTagCreateFunction(320); },
16232             get updateJSDocPublicTag() { return getJSDocSimpleTagUpdateFunction(320); },
16233             get createJSDocPrivateTag() { return getJSDocSimpleTagCreateFunction(321); },
16234             get updateJSDocPrivateTag() { return getJSDocSimpleTagUpdateFunction(321); },
16235             get createJSDocProtectedTag() { return getJSDocSimpleTagCreateFunction(322); },
16236             get updateJSDocProtectedTag() { return getJSDocSimpleTagUpdateFunction(322); },
16237             get createJSDocReadonlyTag() { return getJSDocSimpleTagCreateFunction(323); },
16238             get updateJSDocReadonlyTag() { return getJSDocSimpleTagUpdateFunction(323); },
16239             get createJSDocDeprecatedTag() { return getJSDocSimpleTagCreateFunction(318); },
16240             get updateJSDocDeprecatedTag() { return getJSDocSimpleTagUpdateFunction(318); },
16241             createJSDocUnknownTag: createJSDocUnknownTag,
16242             updateJSDocUnknownTag: updateJSDocUnknownTag,
16243             createJSDocComment: createJSDocComment,
16244             updateJSDocComment: updateJSDocComment,
16245             createJsxElement: createJsxElement,
16246             updateJsxElement: updateJsxElement,
16247             createJsxSelfClosingElement: createJsxSelfClosingElement,
16248             updateJsxSelfClosingElement: updateJsxSelfClosingElement,
16249             createJsxOpeningElement: createJsxOpeningElement,
16250             updateJsxOpeningElement: updateJsxOpeningElement,
16251             createJsxClosingElement: createJsxClosingElement,
16252             updateJsxClosingElement: updateJsxClosingElement,
16253             createJsxFragment: createJsxFragment,
16254             createJsxText: createJsxText,
16255             updateJsxText: updateJsxText,
16256             createJsxOpeningFragment: createJsxOpeningFragment,
16257             createJsxJsxClosingFragment: createJsxJsxClosingFragment,
16258             updateJsxFragment: updateJsxFragment,
16259             createJsxAttribute: createJsxAttribute,
16260             updateJsxAttribute: updateJsxAttribute,
16261             createJsxAttributes: createJsxAttributes,
16262             updateJsxAttributes: updateJsxAttributes,
16263             createJsxSpreadAttribute: createJsxSpreadAttribute,
16264             updateJsxSpreadAttribute: updateJsxSpreadAttribute,
16265             createJsxExpression: createJsxExpression,
16266             updateJsxExpression: updateJsxExpression,
16267             createCaseClause: createCaseClause,
16268             updateCaseClause: updateCaseClause,
16269             createDefaultClause: createDefaultClause,
16270             updateDefaultClause: updateDefaultClause,
16271             createHeritageClause: createHeritageClause,
16272             updateHeritageClause: updateHeritageClause,
16273             createCatchClause: createCatchClause,
16274             updateCatchClause: updateCatchClause,
16275             createPropertyAssignment: createPropertyAssignment,
16276             updatePropertyAssignment: updatePropertyAssignment,
16277             createShorthandPropertyAssignment: createShorthandPropertyAssignment,
16278             updateShorthandPropertyAssignment: updateShorthandPropertyAssignment,
16279             createSpreadAssignment: createSpreadAssignment,
16280             updateSpreadAssignment: updateSpreadAssignment,
16281             createEnumMember: createEnumMember,
16282             updateEnumMember: updateEnumMember,
16283             createSourceFile: createSourceFile,
16284             updateSourceFile: updateSourceFile,
16285             createBundle: createBundle,
16286             updateBundle: updateBundle,
16287             createUnparsedSource: createUnparsedSource,
16288             createUnparsedPrologue: createUnparsedPrologue,
16289             createUnparsedPrepend: createUnparsedPrepend,
16290             createUnparsedTextLike: createUnparsedTextLike,
16291             createUnparsedSyntheticReference: createUnparsedSyntheticReference,
16292             createInputFiles: createInputFiles,
16293             createSyntheticExpression: createSyntheticExpression,
16294             createSyntaxList: createSyntaxList,
16295             createNotEmittedStatement: createNotEmittedStatement,
16296             createPartiallyEmittedExpression: createPartiallyEmittedExpression,
16297             updatePartiallyEmittedExpression: updatePartiallyEmittedExpression,
16298             createCommaListExpression: createCommaListExpression,
16299             updateCommaListExpression: updateCommaListExpression,
16300             createEndOfDeclarationMarker: createEndOfDeclarationMarker,
16301             createMergeDeclarationMarker: createMergeDeclarationMarker,
16302             createSyntheticReferenceExpression: createSyntheticReferenceExpression,
16303             updateSyntheticReferenceExpression: updateSyntheticReferenceExpression,
16304             cloneNode: cloneNode,
16305             get createComma() { return getBinaryCreateFunction(27); },
16306             get createAssignment() { return getBinaryCreateFunction(62); },
16307             get createLogicalOr() { return getBinaryCreateFunction(56); },
16308             get createLogicalAnd() { return getBinaryCreateFunction(55); },
16309             get createBitwiseOr() { return getBinaryCreateFunction(51); },
16310             get createBitwiseXor() { return getBinaryCreateFunction(52); },
16311             get createBitwiseAnd() { return getBinaryCreateFunction(50); },
16312             get createStrictEquality() { return getBinaryCreateFunction(36); },
16313             get createStrictInequality() { return getBinaryCreateFunction(37); },
16314             get createEquality() { return getBinaryCreateFunction(34); },
16315             get createInequality() { return getBinaryCreateFunction(35); },
16316             get createLessThan() { return getBinaryCreateFunction(29); },
16317             get createLessThanEquals() { return getBinaryCreateFunction(32); },
16318             get createGreaterThan() { return getBinaryCreateFunction(31); },
16319             get createGreaterThanEquals() { return getBinaryCreateFunction(33); },
16320             get createLeftShift() { return getBinaryCreateFunction(47); },
16321             get createRightShift() { return getBinaryCreateFunction(48); },
16322             get createUnsignedRightShift() { return getBinaryCreateFunction(49); },
16323             get createAdd() { return getBinaryCreateFunction(39); },
16324             get createSubtract() { return getBinaryCreateFunction(40); },
16325             get createMultiply() { return getBinaryCreateFunction(41); },
16326             get createDivide() { return getBinaryCreateFunction(43); },
16327             get createModulo() { return getBinaryCreateFunction(44); },
16328             get createExponent() { return getBinaryCreateFunction(42); },
16329             get createPrefixPlus() { return getPrefixUnaryCreateFunction(39); },
16330             get createPrefixMinus() { return getPrefixUnaryCreateFunction(40); },
16331             get createPrefixIncrement() { return getPrefixUnaryCreateFunction(45); },
16332             get createPrefixDecrement() { return getPrefixUnaryCreateFunction(46); },
16333             get createBitwiseNot() { return getPrefixUnaryCreateFunction(54); },
16334             get createLogicalNot() { return getPrefixUnaryCreateFunction(53); },
16335             get createPostfixIncrement() { return getPostfixUnaryCreateFunction(45); },
16336             get createPostfixDecrement() { return getPostfixUnaryCreateFunction(46); },
16337             createImmediatelyInvokedFunctionExpression: createImmediatelyInvokedFunctionExpression,
16338             createImmediatelyInvokedArrowFunction: createImmediatelyInvokedArrowFunction,
16339             createVoidZero: createVoidZero,
16340             createExportDefault: createExportDefault,
16341             createExternalModuleExport: createExternalModuleExport,
16342             createTypeCheck: createTypeCheck,
16343             createMethodCall: createMethodCall,
16344             createGlobalMethodCall: createGlobalMethodCall,
16345             createFunctionBindCall: createFunctionBindCall,
16346             createFunctionCallCall: createFunctionCallCall,
16347             createFunctionApplyCall: createFunctionApplyCall,
16348             createArraySliceCall: createArraySliceCall,
16349             createArrayConcatCall: createArrayConcatCall,
16350             createObjectDefinePropertyCall: createObjectDefinePropertyCall,
16351             createPropertyDescriptor: createPropertyDescriptor,
16352             createCallBinding: createCallBinding,
16353             inlineExpressions: inlineExpressions,
16354             getInternalName: getInternalName,
16355             getLocalName: getLocalName,
16356             getExportName: getExportName,
16357             getDeclarationName: getDeclarationName,
16358             getNamespaceMemberName: getNamespaceMemberName,
16359             getExternalModuleOrNamespaceExportName: getExternalModuleOrNamespaceExportName,
16360             restoreOuterExpressions: restoreOuterExpressions,
16361             restoreEnclosingLabel: restoreEnclosingLabel,
16362             createUseStrictPrologue: createUseStrictPrologue,
16363             copyPrologue: copyPrologue,
16364             copyStandardPrologue: copyStandardPrologue,
16365             copyCustomPrologue: copyCustomPrologue,
16366             ensureUseStrict: ensureUseStrict,
16367             liftToBlock: liftToBlock,
16368             mergeLexicalEnvironment: mergeLexicalEnvironment,
16369             updateModifiers: updateModifiers,
16370         };
16371         return factory;
16372         function createNodeArray(elements, hasTrailingComma) {
16373             if (elements === undefined || elements === ts.emptyArray) {
16374                 elements = [];
16375             }
16376             else if (ts.isNodeArray(elements)) {
16377                 if (elements.transformFlags === undefined) {
16378                     aggregateChildrenFlags(elements);
16379                 }
16380                 ts.Debug.attachNodeArrayDebugInfo(elements);
16381                 return elements;
16382             }
16383             var length = elements.length;
16384             var array = (length >= 1 && length <= 4 ? elements.slice() : elements);
16385             ts.setTextRangePosEnd(array, -1, -1);
16386             array.hasTrailingComma = !!hasTrailingComma;
16387             aggregateChildrenFlags(array);
16388             ts.Debug.attachNodeArrayDebugInfo(array);
16389             return array;
16390         }
16391         function createBaseNode(kind) {
16392             return baseFactory.createBaseNode(kind);
16393         }
16394         function createBaseDeclaration(kind, decorators, modifiers) {
16395             var node = createBaseNode(kind);
16396             node.decorators = asNodeArray(decorators);
16397             node.modifiers = asNodeArray(modifiers);
16398             node.transformFlags |=
16399                 propagateChildrenFlags(node.decorators) |
16400                     propagateChildrenFlags(node.modifiers);
16401             node.symbol = undefined;
16402             node.localSymbol = undefined;
16403             node.locals = undefined;
16404             node.nextContainer = undefined;
16405             return node;
16406         }
16407         function createBaseNamedDeclaration(kind, decorators, modifiers, name) {
16408             var node = createBaseDeclaration(kind, decorators, modifiers);
16409             name = asName(name);
16410             node.name = name;
16411             if (name) {
16412                 switch (node.kind) {
16413                     case 165:
16414                     case 167:
16415                     case 168:
16416                     case 163:
16417                     case 288:
16418                         if (ts.isIdentifier(name)) {
16419                             node.transformFlags |= propagateIdentifierNameFlags(name);
16420                             break;
16421                         }
16422                     default:
16423                         node.transformFlags |= propagateChildFlags(name);
16424                         break;
16425                 }
16426             }
16427             return node;
16428         }
16429         function createBaseGenericNamedDeclaration(kind, decorators, modifiers, name, typeParameters) {
16430             var node = createBaseNamedDeclaration(kind, decorators, modifiers, name);
16431             node.typeParameters = asNodeArray(typeParameters);
16432             node.transformFlags |= propagateChildrenFlags(node.typeParameters);
16433             if (typeParameters)
16434                 node.transformFlags |= 1;
16435             return node;
16436         }
16437         function createBaseSignatureDeclaration(kind, decorators, modifiers, name, typeParameters, parameters, type) {
16438             var node = createBaseGenericNamedDeclaration(kind, decorators, modifiers, name, typeParameters);
16439             node.parameters = createNodeArray(parameters);
16440             node.type = type;
16441             node.transformFlags |=
16442                 propagateChildrenFlags(node.parameters) |
16443                     propagateChildFlags(node.type);
16444             if (type)
16445                 node.transformFlags |= 1;
16446             return node;
16447         }
16448         function updateBaseSignatureDeclaration(updated, original) {
16449             if (original.typeArguments)
16450                 updated.typeArguments = original.typeArguments;
16451             return update(updated, original);
16452         }
16453         function createBaseFunctionLikeDeclaration(kind, decorators, modifiers, name, typeParameters, parameters, type, body) {
16454             var node = createBaseSignatureDeclaration(kind, decorators, modifiers, name, typeParameters, parameters, type);
16455             node.body = body;
16456             node.transformFlags |= propagateChildFlags(node.body) & ~8388608;
16457             if (!body)
16458                 node.transformFlags |= 1;
16459             return node;
16460         }
16461         function updateBaseFunctionLikeDeclaration(updated, original) {
16462             if (original.exclamationToken)
16463                 updated.exclamationToken = original.exclamationToken;
16464             if (original.typeArguments)
16465                 updated.typeArguments = original.typeArguments;
16466             return updateBaseSignatureDeclaration(updated, original);
16467         }
16468         function createBaseInterfaceOrClassLikeDeclaration(kind, decorators, modifiers, name, typeParameters, heritageClauses) {
16469             var node = createBaseGenericNamedDeclaration(kind, decorators, modifiers, name, typeParameters);
16470             node.heritageClauses = asNodeArray(heritageClauses);
16471             node.transformFlags |= propagateChildrenFlags(node.heritageClauses);
16472             return node;
16473         }
16474         function createBaseClassLikeDeclaration(kind, decorators, modifiers, name, typeParameters, heritageClauses, members) {
16475             var node = createBaseInterfaceOrClassLikeDeclaration(kind, decorators, modifiers, name, typeParameters, heritageClauses);
16476             node.members = createNodeArray(members);
16477             node.transformFlags |= propagateChildrenFlags(node.members);
16478             return node;
16479         }
16480         function createBaseBindingLikeDeclaration(kind, decorators, modifiers, name, initializer) {
16481             var node = createBaseNamedDeclaration(kind, decorators, modifiers, name);
16482             node.initializer = initializer;
16483             node.transformFlags |= propagateChildFlags(node.initializer);
16484             return node;
16485         }
16486         function createBaseVariableLikeDeclaration(kind, decorators, modifiers, name, type, initializer) {
16487             var node = createBaseBindingLikeDeclaration(kind, decorators, modifiers, name, initializer);
16488             node.type = type;
16489             node.transformFlags |= propagateChildFlags(type);
16490             if (type)
16491                 node.transformFlags |= 1;
16492             return node;
16493         }
16494         function createBaseLiteral(kind, text) {
16495             var node = createBaseToken(kind);
16496             node.text = text;
16497             return node;
16498         }
16499         function createNumericLiteral(value, numericLiteralFlags) {
16500             if (numericLiteralFlags === void 0) { numericLiteralFlags = 0; }
16501             var node = createBaseLiteral(8, typeof value === "number" ? value + "" : value);
16502             node.numericLiteralFlags = numericLiteralFlags;
16503             if (numericLiteralFlags & 384)
16504                 node.transformFlags |= 256;
16505             return node;
16506         }
16507         function createBigIntLiteral(value) {
16508             var node = createBaseLiteral(9, typeof value === "string" ? value : ts.pseudoBigIntToString(value) + "n");
16509             node.transformFlags |= 4;
16510             return node;
16511         }
16512         function createBaseStringLiteral(text, isSingleQuote) {
16513             var node = createBaseLiteral(10, text);
16514             node.singleQuote = isSingleQuote;
16515             return node;
16516         }
16517         function createStringLiteral(text, isSingleQuote, hasExtendedUnicodeEscape) {
16518             var node = createBaseStringLiteral(text, isSingleQuote);
16519             node.hasExtendedUnicodeEscape = hasExtendedUnicodeEscape;
16520             if (hasExtendedUnicodeEscape)
16521                 node.transformFlags |= 256;
16522             return node;
16523         }
16524         function createStringLiteralFromNode(sourceNode) {
16525             var node = createBaseStringLiteral(ts.getTextOfIdentifierOrLiteral(sourceNode), undefined);
16526             node.textSourceNode = sourceNode;
16527             return node;
16528         }
16529         function createRegularExpressionLiteral(text) {
16530             var node = createBaseLiteral(13, text);
16531             return node;
16532         }
16533         function createLiteralLikeNode(kind, text) {
16534             switch (kind) {
16535                 case 8: return createNumericLiteral(text, 0);
16536                 case 9: return createBigIntLiteral(text);
16537                 case 10: return createStringLiteral(text, undefined);
16538                 case 11: return createJsxText(text, false);
16539                 case 12: return createJsxText(text, true);
16540                 case 13: return createRegularExpressionLiteral(text);
16541                 case 14: return createTemplateLiteralLikeNode(kind, text, undefined, 0);
16542             }
16543         }
16544         function createBaseIdentifier(text, originalKeywordKind) {
16545             if (originalKeywordKind === undefined && text) {
16546                 originalKeywordKind = ts.stringToToken(text);
16547             }
16548             if (originalKeywordKind === 78) {
16549                 originalKeywordKind = undefined;
16550             }
16551             var node = baseFactory.createBaseIdentifierNode(78);
16552             node.originalKeywordKind = originalKeywordKind;
16553             node.escapedText = ts.escapeLeadingUnderscores(text);
16554             return node;
16555         }
16556         function createBaseGeneratedIdentifier(text, autoGenerateFlags) {
16557             var node = createBaseIdentifier(text, undefined);
16558             node.autoGenerateFlags = autoGenerateFlags;
16559             node.autoGenerateId = nextAutoGenerateId;
16560             nextAutoGenerateId++;
16561             return node;
16562         }
16563         function createIdentifier(text, typeArguments, originalKeywordKind) {
16564             var node = createBaseIdentifier(text, originalKeywordKind);
16565             if (typeArguments) {
16566                 node.typeArguments = createNodeArray(typeArguments);
16567             }
16568             if (node.originalKeywordKind === 130) {
16569                 node.transformFlags |= 8388608;
16570             }
16571             return node;
16572         }
16573         function updateIdentifier(node, typeArguments) {
16574             return node.typeArguments !== typeArguments
16575                 ? update(createIdentifier(ts.idText(node), typeArguments), node)
16576                 : node;
16577         }
16578         function createTempVariable(recordTempVariable, reservedInNestedScopes) {
16579             var flags = 1;
16580             if (reservedInNestedScopes)
16581                 flags |= 8;
16582             var name = createBaseGeneratedIdentifier("", flags);
16583             if (recordTempVariable) {
16584                 recordTempVariable(name);
16585             }
16586             return name;
16587         }
16588         function createLoopVariable() {
16589             return createBaseGeneratedIdentifier("", 2);
16590         }
16591         function createUniqueName(text, flags) {
16592             if (flags === void 0) { flags = 0; }
16593             ts.Debug.assert(!(flags & 7), "Argument out of range: flags");
16594             ts.Debug.assert((flags & (16 | 32)) !== 32, "GeneratedIdentifierFlags.FileLevel cannot be set without also setting GeneratedIdentifierFlags.Optimistic");
16595             return createBaseGeneratedIdentifier(text, 3 | flags);
16596         }
16597         function getGeneratedNameForNode(node, flags) {
16598             if (flags === void 0) { flags = 0; }
16599             ts.Debug.assert(!(flags & 7), "Argument out of range: flags");
16600             var name = createBaseGeneratedIdentifier(node && ts.isIdentifier(node) ? ts.idText(node) : "", 4 | flags);
16601             name.original = node;
16602             return name;
16603         }
16604         function createPrivateIdentifier(text) {
16605             if (!ts.startsWith(text, "#"))
16606                 ts.Debug.fail("First character of private identifier must be #: " + text);
16607             var node = baseFactory.createBasePrivateIdentifierNode(79);
16608             node.escapedText = ts.escapeLeadingUnderscores(text);
16609             node.transformFlags |= 4194304;
16610             return node;
16611         }
16612         function createBaseToken(kind) {
16613             return baseFactory.createBaseTokenNode(kind);
16614         }
16615         function createToken(token) {
16616             ts.Debug.assert(token >= 0 && token <= 156, "Invalid token");
16617             ts.Debug.assert(token <= 14 || token >= 17, "Invalid token. Use 'createTemplateLiteralLikeNode' to create template literals.");
16618             ts.Debug.assert(token <= 8 || token >= 14, "Invalid token. Use 'createLiteralLikeNode' to create literals.");
16619             ts.Debug.assert(token !== 78, "Invalid token. Use 'createIdentifier' to create identifiers");
16620             var node = createBaseToken(token);
16621             var transformFlags = 0;
16622             switch (token) {
16623                 case 129:
16624                     transformFlags =
16625                         64 |
16626                             32;
16627                     break;
16628                 case 122:
16629                 case 120:
16630                 case 121:
16631                 case 142:
16632                 case 125:
16633                 case 133:
16634                 case 84:
16635                 case 128:
16636                 case 144:
16637                 case 155:
16638                 case 141:
16639                 case 145:
16640                 case 147:
16641                 case 131:
16642                 case 148:
16643                 case 113:
16644                 case 152:
16645                 case 150:
16646                     transformFlags = 1;
16647                     break;
16648                 case 123:
16649                 case 105:
16650                     transformFlags = 256;
16651                     break;
16652                 case 107:
16653                     transformFlags = 4096;
16654                     break;
16655             }
16656             if (transformFlags) {
16657                 node.transformFlags |= transformFlags;
16658             }
16659             return node;
16660         }
16661         function createSuper() {
16662             return createToken(105);
16663         }
16664         function createThis() {
16665             return createToken(107);
16666         }
16667         function createNull() {
16668             return createToken(103);
16669         }
16670         function createTrue() {
16671             return createToken(109);
16672         }
16673         function createFalse() {
16674             return createToken(94);
16675         }
16676         function createModifier(kind) {
16677             return createToken(kind);
16678         }
16679         function createModifiersFromModifierFlags(flags) {
16680             var result = [];
16681             if (flags & 1) {
16682                 result.push(createModifier(92));
16683             }
16684             if (flags & 2) {
16685                 result.push(createModifier(133));
16686             }
16687             if (flags & 512) {
16688                 result.push(createModifier(87));
16689             }
16690             if (flags & 2048) {
16691                 result.push(createModifier(84));
16692             }
16693             if (flags & 4) {
16694                 result.push(createModifier(122));
16695             }
16696             if (flags & 8) {
16697                 result.push(createModifier(120));
16698             }
16699             if (flags & 16) {
16700                 result.push(createModifier(121));
16701             }
16702             if (flags & 128) {
16703                 result.push(createModifier(125));
16704             }
16705             if (flags & 32) {
16706                 result.push(createModifier(123));
16707             }
16708             if (flags & 64) {
16709                 result.push(createModifier(142));
16710             }
16711             if (flags & 256) {
16712                 result.push(createModifier(129));
16713             }
16714             return result;
16715         }
16716         function createQualifiedName(left, right) {
16717             var node = createBaseNode(157);
16718             node.left = left;
16719             node.right = asName(right);
16720             node.transformFlags |=
16721                 propagateChildFlags(node.left) |
16722                     propagateIdentifierNameFlags(node.right);
16723             return node;
16724         }
16725         function updateQualifiedName(node, left, right) {
16726             return node.left !== left
16727                 || node.right !== right
16728                 ? update(createQualifiedName(left, right), node)
16729                 : node;
16730         }
16731         function createComputedPropertyName(expression) {
16732             var node = createBaseNode(158);
16733             node.expression = parenthesizerRules().parenthesizeExpressionOfComputedPropertyName(expression);
16734             node.transformFlags |=
16735                 propagateChildFlags(node.expression) |
16736                     256 |
16737                     32768;
16738             return node;
16739         }
16740         function updateComputedPropertyName(node, expression) {
16741             return node.expression !== expression
16742                 ? update(createComputedPropertyName(expression), node)
16743                 : node;
16744         }
16745         function createTypeParameterDeclaration(name, constraint, defaultType) {
16746             var node = createBaseNamedDeclaration(159, undefined, undefined, name);
16747             node.constraint = constraint;
16748             node.default = defaultType;
16749             node.transformFlags = 1;
16750             return node;
16751         }
16752         function updateTypeParameterDeclaration(node, name, constraint, defaultType) {
16753             return node.name !== name
16754                 || node.constraint !== constraint
16755                 || node.default !== defaultType
16756                 ? update(createTypeParameterDeclaration(name, constraint, defaultType), node)
16757                 : node;
16758         }
16759         function createParameterDeclaration(decorators, modifiers, dotDotDotToken, name, questionToken, type, initializer) {
16760             var node = createBaseVariableLikeDeclaration(160, decorators, modifiers, name, type, initializer && parenthesizerRules().parenthesizeExpressionForDisallowedComma(initializer));
16761             node.dotDotDotToken = dotDotDotToken;
16762             node.questionToken = questionToken;
16763             if (ts.isThisIdentifier(node.name)) {
16764                 node.transformFlags = 1;
16765             }
16766             else {
16767                 node.transformFlags |=
16768                     propagateChildFlags(node.dotDotDotToken) |
16769                         propagateChildFlags(node.questionToken);
16770                 if (questionToken)
16771                     node.transformFlags |= 1;
16772                 if (ts.modifiersToFlags(node.modifiers) & 92)
16773                     node.transformFlags |= 2048;
16774                 if (initializer || dotDotDotToken)
16775                     node.transformFlags |= 256;
16776             }
16777             return node;
16778         }
16779         function updateParameterDeclaration(node, decorators, modifiers, dotDotDotToken, name, questionToken, type, initializer) {
16780             return node.decorators !== decorators
16781                 || node.modifiers !== modifiers
16782                 || node.dotDotDotToken !== dotDotDotToken
16783                 || node.name !== name
16784                 || node.questionToken !== questionToken
16785                 || node.type !== type
16786                 || node.initializer !== initializer
16787                 ? update(createParameterDeclaration(decorators, modifiers, dotDotDotToken, name, questionToken, type, initializer), node)
16788                 : node;
16789         }
16790         function createDecorator(expression) {
16791             var node = createBaseNode(161);
16792             node.expression = parenthesizerRules().parenthesizeLeftSideOfAccess(expression);
16793             node.transformFlags |=
16794                 propagateChildFlags(node.expression) |
16795                     1 |
16796                     2048;
16797             return node;
16798         }
16799         function updateDecorator(node, expression) {
16800             return node.expression !== expression
16801                 ? update(createDecorator(expression), node)
16802                 : node;
16803         }
16804         function createPropertySignature(modifiers, name, questionToken, type) {
16805             var node = createBaseNamedDeclaration(162, undefined, modifiers, name);
16806             node.type = type;
16807             node.questionToken = questionToken;
16808             node.transformFlags = 1;
16809             return node;
16810         }
16811         function updatePropertySignature(node, modifiers, name, questionToken, type) {
16812             return node.modifiers !== modifiers
16813                 || node.name !== name
16814                 || node.questionToken !== questionToken
16815                 || node.type !== type
16816                 ? update(createPropertySignature(modifiers, name, questionToken, type), node)
16817                 : node;
16818         }
16819         function createPropertyDeclaration(decorators, modifiers, name, questionOrExclamationToken, type, initializer) {
16820             var node = createBaseVariableLikeDeclaration(163, decorators, modifiers, name, type, initializer);
16821             node.questionToken = questionOrExclamationToken && ts.isQuestionToken(questionOrExclamationToken) ? questionOrExclamationToken : undefined;
16822             node.exclamationToken = questionOrExclamationToken && ts.isExclamationToken(questionOrExclamationToken) ? questionOrExclamationToken : undefined;
16823             node.transformFlags |=
16824                 propagateChildFlags(node.questionToken) |
16825                     propagateChildFlags(node.exclamationToken) |
16826                     4194304;
16827             if (ts.isComputedPropertyName(node.name) || (ts.hasStaticModifier(node) && node.initializer)) {
16828                 node.transformFlags |= 2048;
16829             }
16830             if (questionOrExclamationToken || ts.modifiersToFlags(node.modifiers) & 2) {
16831                 node.transformFlags |= 1;
16832             }
16833             return node;
16834         }
16835         function updatePropertyDeclaration(node, decorators, modifiers, name, questionOrExclamationToken, type, initializer) {
16836             return node.decorators !== decorators
16837                 || node.modifiers !== modifiers
16838                 || node.name !== name
16839                 || node.questionToken !== (questionOrExclamationToken !== undefined && ts.isQuestionToken(questionOrExclamationToken) ? questionOrExclamationToken : undefined)
16840                 || node.exclamationToken !== (questionOrExclamationToken !== undefined && ts.isExclamationToken(questionOrExclamationToken) ? questionOrExclamationToken : undefined)
16841                 || node.type !== type
16842                 || node.initializer !== initializer
16843                 ? update(createPropertyDeclaration(decorators, modifiers, name, questionOrExclamationToken, type, initializer), node)
16844                 : node;
16845         }
16846         function createMethodSignature(modifiers, name, questionToken, typeParameters, parameters, type) {
16847             var node = createBaseSignatureDeclaration(164, undefined, modifiers, name, typeParameters, parameters, type);
16848             node.questionToken = questionToken;
16849             node.transformFlags = 1;
16850             return node;
16851         }
16852         function updateMethodSignature(node, modifiers, name, questionToken, typeParameters, parameters, type) {
16853             return node.modifiers !== modifiers
16854                 || node.name !== name
16855                 || node.questionToken !== questionToken
16856                 || node.typeParameters !== typeParameters
16857                 || node.parameters !== parameters
16858                 || node.type !== type
16859                 ? updateBaseSignatureDeclaration(createMethodSignature(modifiers, name, questionToken, typeParameters, parameters, type), node)
16860                 : node;
16861         }
16862         function createMethodDeclaration(decorators, modifiers, asteriskToken, name, questionToken, typeParameters, parameters, type, body) {
16863             var node = createBaseFunctionLikeDeclaration(165, decorators, modifiers, name, typeParameters, parameters, type, body);
16864             node.asteriskToken = asteriskToken;
16865             node.questionToken = questionToken;
16866             node.transformFlags |=
16867                 propagateChildFlags(node.asteriskToken) |
16868                     propagateChildFlags(node.questionToken) |
16869                     256;
16870             if (questionToken) {
16871                 node.transformFlags |= 1;
16872             }
16873             if (ts.modifiersToFlags(node.modifiers) & 256) {
16874                 if (asteriskToken) {
16875                     node.transformFlags |= 32;
16876                 }
16877                 else {
16878                     node.transformFlags |= 64;
16879                 }
16880             }
16881             else if (asteriskToken) {
16882                 node.transformFlags |= 512;
16883             }
16884             return node;
16885         }
16886         function updateMethodDeclaration(node, decorators, modifiers, asteriskToken, name, questionToken, typeParameters, parameters, type, body) {
16887             return node.decorators !== decorators
16888                 || node.modifiers !== modifiers
16889                 || node.asteriskToken !== asteriskToken
16890                 || node.name !== name
16891                 || node.questionToken !== questionToken
16892                 || node.typeParameters !== typeParameters
16893                 || node.parameters !== parameters
16894                 || node.type !== type
16895                 || node.body !== body
16896                 ? updateBaseFunctionLikeDeclaration(createMethodDeclaration(decorators, modifiers, asteriskToken, name, questionToken, typeParameters, parameters, type, body), node)
16897                 : node;
16898         }
16899         function createConstructorDeclaration(decorators, modifiers, parameters, body) {
16900             var node = createBaseFunctionLikeDeclaration(166, decorators, modifiers, undefined, undefined, parameters, undefined, body);
16901             node.transformFlags |= 256;
16902             return node;
16903         }
16904         function updateConstructorDeclaration(node, decorators, modifiers, parameters, body) {
16905             return node.decorators !== decorators
16906                 || node.modifiers !== modifiers
16907                 || node.parameters !== parameters
16908                 || node.body !== body
16909                 ? updateBaseFunctionLikeDeclaration(createConstructorDeclaration(decorators, modifiers, parameters, body), node)
16910                 : node;
16911         }
16912         function createGetAccessorDeclaration(decorators, modifiers, name, parameters, type, body) {
16913             return createBaseFunctionLikeDeclaration(167, decorators, modifiers, name, undefined, parameters, type, body);
16914         }
16915         function updateGetAccessorDeclaration(node, decorators, modifiers, name, parameters, type, body) {
16916             return node.decorators !== decorators
16917                 || node.modifiers !== modifiers
16918                 || node.name !== name
16919                 || node.parameters !== parameters
16920                 || node.type !== type
16921                 || node.body !== body
16922                 ? updateBaseFunctionLikeDeclaration(createGetAccessorDeclaration(decorators, modifiers, name, parameters, type, body), node)
16923                 : node;
16924         }
16925         function createSetAccessorDeclaration(decorators, modifiers, name, parameters, body) {
16926             return createBaseFunctionLikeDeclaration(168, decorators, modifiers, name, undefined, parameters, undefined, body);
16927         }
16928         function updateSetAccessorDeclaration(node, decorators, modifiers, name, parameters, body) {
16929             return node.decorators !== decorators
16930                 || node.modifiers !== modifiers
16931                 || node.name !== name
16932                 || node.parameters !== parameters
16933                 || node.body !== body
16934                 ? updateBaseFunctionLikeDeclaration(createSetAccessorDeclaration(decorators, modifiers, name, parameters, body), node)
16935                 : node;
16936         }
16937         function createCallSignature(typeParameters, parameters, type) {
16938             var node = createBaseSignatureDeclaration(169, undefined, undefined, undefined, typeParameters, parameters, type);
16939             node.transformFlags = 1;
16940             return node;
16941         }
16942         function updateCallSignature(node, typeParameters, parameters, type) {
16943             return node.typeParameters !== typeParameters
16944                 || node.parameters !== parameters
16945                 || node.type !== type
16946                 ? updateBaseSignatureDeclaration(createCallSignature(typeParameters, parameters, type), node)
16947                 : node;
16948         }
16949         function createConstructSignature(typeParameters, parameters, type) {
16950             var node = createBaseSignatureDeclaration(170, undefined, undefined, undefined, typeParameters, parameters, type);
16951             node.transformFlags = 1;
16952             return node;
16953         }
16954         function updateConstructSignature(node, typeParameters, parameters, type) {
16955             return node.typeParameters !== typeParameters
16956                 || node.parameters !== parameters
16957                 || node.type !== type
16958                 ? updateBaseSignatureDeclaration(createConstructSignature(typeParameters, parameters, type), node)
16959                 : node;
16960         }
16961         function createIndexSignature(decorators, modifiers, parameters, type) {
16962             var node = createBaseSignatureDeclaration(171, decorators, modifiers, undefined, undefined, parameters, type);
16963             node.transformFlags = 1;
16964             return node;
16965         }
16966         function updateIndexSignature(node, decorators, modifiers, parameters, type) {
16967             return node.parameters !== parameters
16968                 || node.type !== type
16969                 || node.decorators !== decorators
16970                 || node.modifiers !== modifiers
16971                 ? updateBaseSignatureDeclaration(createIndexSignature(decorators, modifiers, parameters, type), node)
16972                 : node;
16973         }
16974         function createTemplateLiteralTypeSpan(type, literal) {
16975             var node = createBaseNode(194);
16976             node.type = type;
16977             node.literal = literal;
16978             node.transformFlags = 1;
16979             return node;
16980         }
16981         function updateTemplateLiteralTypeSpan(node, type, literal) {
16982             return node.type !== type
16983                 || node.literal !== literal
16984                 ? update(createTemplateLiteralTypeSpan(type, literal), node)
16985                 : node;
16986         }
16987         function createKeywordTypeNode(kind) {
16988             return createToken(kind);
16989         }
16990         function createTypePredicateNode(assertsModifier, parameterName, type) {
16991             var node = createBaseNode(172);
16992             node.assertsModifier = assertsModifier;
16993             node.parameterName = asName(parameterName);
16994             node.type = type;
16995             node.transformFlags = 1;
16996             return node;
16997         }
16998         function updateTypePredicateNode(node, assertsModifier, parameterName, type) {
16999             return node.assertsModifier !== assertsModifier
17000                 || node.parameterName !== parameterName
17001                 || node.type !== type
17002                 ? update(createTypePredicateNode(assertsModifier, parameterName, type), node)
17003                 : node;
17004         }
17005         function createTypeReferenceNode(typeName, typeArguments) {
17006             var node = createBaseNode(173);
17007             node.typeName = asName(typeName);
17008             node.typeArguments = typeArguments && parenthesizerRules().parenthesizeTypeArguments(createNodeArray(typeArguments));
17009             node.transformFlags = 1;
17010             return node;
17011         }
17012         function updateTypeReferenceNode(node, typeName, typeArguments) {
17013             return node.typeName !== typeName
17014                 || node.typeArguments !== typeArguments
17015                 ? update(createTypeReferenceNode(typeName, typeArguments), node)
17016                 : node;
17017         }
17018         function createFunctionTypeNode(typeParameters, parameters, type) {
17019             var node = createBaseSignatureDeclaration(174, undefined, undefined, undefined, typeParameters, parameters, type);
17020             node.transformFlags = 1;
17021             return node;
17022         }
17023         function updateFunctionTypeNode(node, typeParameters, parameters, type) {
17024             return node.typeParameters !== typeParameters
17025                 || node.parameters !== parameters
17026                 || node.type !== type
17027                 ? updateBaseSignatureDeclaration(createFunctionTypeNode(typeParameters, parameters, type), node)
17028                 : node;
17029         }
17030         function createConstructorTypeNode(typeParameters, parameters, type) {
17031             var node = createBaseSignatureDeclaration(175, undefined, undefined, undefined, typeParameters, parameters, type);
17032             node.transformFlags = 1;
17033             return node;
17034         }
17035         function updateConstructorTypeNode(node, typeParameters, parameters, type) {
17036             return node.typeParameters !== typeParameters
17037                 || node.parameters !== parameters
17038                 || node.type !== type
17039                 ? updateBaseSignatureDeclaration(createConstructorTypeNode(typeParameters, parameters, type), node)
17040                 : node;
17041         }
17042         function createTypeQueryNode(exprName) {
17043             var node = createBaseNode(176);
17044             node.exprName = exprName;
17045             node.transformFlags = 1;
17046             return node;
17047         }
17048         function updateTypeQueryNode(node, exprName) {
17049             return node.exprName !== exprName
17050                 ? update(createTypeQueryNode(exprName), node)
17051                 : node;
17052         }
17053         function createTypeLiteralNode(members) {
17054             var node = createBaseNode(177);
17055             node.members = createNodeArray(members);
17056             node.transformFlags = 1;
17057             return node;
17058         }
17059         function updateTypeLiteralNode(node, members) {
17060             return node.members !== members
17061                 ? update(createTypeLiteralNode(members), node)
17062                 : node;
17063         }
17064         function createArrayTypeNode(elementType) {
17065             var node = createBaseNode(178);
17066             node.elementType = parenthesizerRules().parenthesizeElementTypeOfArrayType(elementType);
17067             node.transformFlags = 1;
17068             return node;
17069         }
17070         function updateArrayTypeNode(node, elementType) {
17071             return node.elementType !== elementType
17072                 ? update(createArrayTypeNode(elementType), node)
17073                 : node;
17074         }
17075         function createTupleTypeNode(elements) {
17076             var node = createBaseNode(179);
17077             node.elements = createNodeArray(elements);
17078             node.transformFlags = 1;
17079             return node;
17080         }
17081         function updateTupleTypeNode(node, elements) {
17082             return node.elements !== elements
17083                 ? update(createTupleTypeNode(elements), node)
17084                 : node;
17085         }
17086         function createNamedTupleMember(dotDotDotToken, name, questionToken, type) {
17087             var node = createBaseNode(192);
17088             node.dotDotDotToken = dotDotDotToken;
17089             node.name = name;
17090             node.questionToken = questionToken;
17091             node.type = type;
17092             node.transformFlags = 1;
17093             return node;
17094         }
17095         function updateNamedTupleMember(node, dotDotDotToken, name, questionToken, type) {
17096             return node.dotDotDotToken !== dotDotDotToken
17097                 || node.name !== name
17098                 || node.questionToken !== questionToken
17099                 || node.type !== type
17100                 ? update(createNamedTupleMember(dotDotDotToken, name, questionToken, type), node)
17101                 : node;
17102         }
17103         function createOptionalTypeNode(type) {
17104             var node = createBaseNode(180);
17105             node.type = parenthesizerRules().parenthesizeElementTypeOfArrayType(type);
17106             node.transformFlags = 1;
17107             return node;
17108         }
17109         function updateOptionalTypeNode(node, type) {
17110             return node.type !== type
17111                 ? update(createOptionalTypeNode(type), node)
17112                 : node;
17113         }
17114         function createRestTypeNode(type) {
17115             var node = createBaseNode(181);
17116             node.type = type;
17117             node.transformFlags = 1;
17118             return node;
17119         }
17120         function updateRestTypeNode(node, type) {
17121             return node.type !== type
17122                 ? update(createRestTypeNode(type), node)
17123                 : node;
17124         }
17125         function createUnionOrIntersectionTypeNode(kind, types) {
17126             var node = createBaseNode(kind);
17127             node.types = parenthesizerRules().parenthesizeConstituentTypesOfUnionOrIntersectionType(types);
17128             node.transformFlags = 1;
17129             return node;
17130         }
17131         function updateUnionOrIntersectionTypeNode(node, types) {
17132             return node.types !== types
17133                 ? update(createUnionOrIntersectionTypeNode(node.kind, types), node)
17134                 : node;
17135         }
17136         function createUnionTypeNode(types) {
17137             return createUnionOrIntersectionTypeNode(182, types);
17138         }
17139         function updateUnionTypeNode(node, types) {
17140             return updateUnionOrIntersectionTypeNode(node, types);
17141         }
17142         function createIntersectionTypeNode(types) {
17143             return createUnionOrIntersectionTypeNode(183, types);
17144         }
17145         function updateIntersectionTypeNode(node, types) {
17146             return updateUnionOrIntersectionTypeNode(node, types);
17147         }
17148         function createConditionalTypeNode(checkType, extendsType, trueType, falseType) {
17149             var node = createBaseNode(184);
17150             node.checkType = parenthesizerRules().parenthesizeMemberOfConditionalType(checkType);
17151             node.extendsType = parenthesizerRules().parenthesizeMemberOfConditionalType(extendsType);
17152             node.trueType = trueType;
17153             node.falseType = falseType;
17154             node.transformFlags = 1;
17155             return node;
17156         }
17157         function updateConditionalTypeNode(node, checkType, extendsType, trueType, falseType) {
17158             return node.checkType !== checkType
17159                 || node.extendsType !== extendsType
17160                 || node.trueType !== trueType
17161                 || node.falseType !== falseType
17162                 ? update(createConditionalTypeNode(checkType, extendsType, trueType, falseType), node)
17163                 : node;
17164         }
17165         function createInferTypeNode(typeParameter) {
17166             var node = createBaseNode(185);
17167             node.typeParameter = typeParameter;
17168             node.transformFlags = 1;
17169             return node;
17170         }
17171         function updateInferTypeNode(node, typeParameter) {
17172             return node.typeParameter !== typeParameter
17173                 ? update(createInferTypeNode(typeParameter), node)
17174                 : node;
17175         }
17176         function createTemplateLiteralType(head, templateSpans) {
17177             var node = createBaseNode(193);
17178             node.head = head;
17179             node.templateSpans = createNodeArray(templateSpans);
17180             node.transformFlags = 1;
17181             return node;
17182         }
17183         function updateTemplateLiteralType(node, head, templateSpans) {
17184             return node.head !== head
17185                 || node.templateSpans !== templateSpans
17186                 ? update(createTemplateLiteralType(head, templateSpans), node)
17187                 : node;
17188         }
17189         function createImportTypeNode(argument, qualifier, typeArguments, isTypeOf) {
17190             if (isTypeOf === void 0) { isTypeOf = false; }
17191             var node = createBaseNode(195);
17192             node.argument = argument;
17193             node.qualifier = qualifier;
17194             node.typeArguments = typeArguments && parenthesizerRules().parenthesizeTypeArguments(typeArguments);
17195             node.isTypeOf = isTypeOf;
17196             node.transformFlags = 1;
17197             return node;
17198         }
17199         function updateImportTypeNode(node, argument, qualifier, typeArguments, isTypeOf) {
17200             if (isTypeOf === void 0) { isTypeOf = node.isTypeOf; }
17201             return node.argument !== argument
17202                 || node.qualifier !== qualifier
17203                 || node.typeArguments !== typeArguments
17204                 || node.isTypeOf !== isTypeOf
17205                 ? update(createImportTypeNode(argument, qualifier, typeArguments, isTypeOf), node)
17206                 : node;
17207         }
17208         function createParenthesizedType(type) {
17209             var node = createBaseNode(186);
17210             node.type = type;
17211             node.transformFlags = 1;
17212             return node;
17213         }
17214         function updateParenthesizedType(node, type) {
17215             return node.type !== type
17216                 ? update(createParenthesizedType(type), node)
17217                 : node;
17218         }
17219         function createThisTypeNode() {
17220             var node = createBaseNode(187);
17221             node.transformFlags = 1;
17222             return node;
17223         }
17224         function createTypeOperatorNode(operator, type) {
17225             var node = createBaseNode(188);
17226             node.operator = operator;
17227             node.type = parenthesizerRules().parenthesizeMemberOfElementType(type);
17228             node.transformFlags = 1;
17229             return node;
17230         }
17231         function updateTypeOperatorNode(node, type) {
17232             return node.type !== type
17233                 ? update(createTypeOperatorNode(node.operator, type), node)
17234                 : node;
17235         }
17236         function createIndexedAccessTypeNode(objectType, indexType) {
17237             var node = createBaseNode(189);
17238             node.objectType = parenthesizerRules().parenthesizeMemberOfElementType(objectType);
17239             node.indexType = indexType;
17240             node.transformFlags = 1;
17241             return node;
17242         }
17243         function updateIndexedAccessTypeNode(node, objectType, indexType) {
17244             return node.objectType !== objectType
17245                 || node.indexType !== indexType
17246                 ? update(createIndexedAccessTypeNode(objectType, indexType), node)
17247                 : node;
17248         }
17249         function createMappedTypeNode(readonlyToken, typeParameter, nameType, questionToken, type) {
17250             var node = createBaseNode(190);
17251             node.readonlyToken = readonlyToken;
17252             node.typeParameter = typeParameter;
17253             node.nameType = nameType;
17254             node.questionToken = questionToken;
17255             node.type = type;
17256             node.transformFlags = 1;
17257             return node;
17258         }
17259         function updateMappedTypeNode(node, readonlyToken, typeParameter, nameType, questionToken, type) {
17260             return node.readonlyToken !== readonlyToken
17261                 || node.typeParameter !== typeParameter
17262                 || node.nameType !== nameType
17263                 || node.questionToken !== questionToken
17264                 || node.type !== type
17265                 ? update(createMappedTypeNode(readonlyToken, typeParameter, nameType, questionToken, type), node)
17266                 : node;
17267         }
17268         function createLiteralTypeNode(literal) {
17269             var node = createBaseNode(191);
17270             node.literal = literal;
17271             node.transformFlags = 1;
17272             return node;
17273         }
17274         function updateLiteralTypeNode(node, literal) {
17275             return node.literal !== literal
17276                 ? update(createLiteralTypeNode(literal), node)
17277                 : node;
17278         }
17279         function createObjectBindingPattern(elements) {
17280             var node = createBaseNode(196);
17281             node.elements = createNodeArray(elements);
17282             node.transformFlags |=
17283                 propagateChildrenFlags(node.elements) |
17284                     256 |
17285                     131072;
17286             if (node.transformFlags & 8192) {
17287                 node.transformFlags |=
17288                     32 |
17289                         16384;
17290             }
17291             return node;
17292         }
17293         function updateObjectBindingPattern(node, elements) {
17294             return node.elements !== elements
17295                 ? update(createObjectBindingPattern(elements), node)
17296                 : node;
17297         }
17298         function createArrayBindingPattern(elements) {
17299             var node = createBaseNode(197);
17300             node.elements = createNodeArray(elements);
17301             node.transformFlags |=
17302                 propagateChildrenFlags(node.elements) |
17303                     256 |
17304                     131072;
17305             return node;
17306         }
17307         function updateArrayBindingPattern(node, elements) {
17308             return node.elements !== elements
17309                 ? update(createArrayBindingPattern(elements), node)
17310                 : node;
17311         }
17312         function createBindingElement(dotDotDotToken, propertyName, name, initializer) {
17313             var node = createBaseBindingLikeDeclaration(198, undefined, undefined, name, initializer);
17314             node.propertyName = asName(propertyName);
17315             node.dotDotDotToken = dotDotDotToken;
17316             node.transformFlags |=
17317                 propagateChildFlags(node.dotDotDotToken) |
17318                     256;
17319             if (node.propertyName) {
17320                 node.transformFlags |= ts.isIdentifier(node.propertyName) ?
17321                     propagateIdentifierNameFlags(node.propertyName) :
17322                     propagateChildFlags(node.propertyName);
17323             }
17324             if (dotDotDotToken)
17325                 node.transformFlags |= 8192;
17326             return node;
17327         }
17328         function updateBindingElement(node, dotDotDotToken, propertyName, name, initializer) {
17329             return node.propertyName !== propertyName
17330                 || node.dotDotDotToken !== dotDotDotToken
17331                 || node.name !== name
17332                 || node.initializer !== initializer
17333                 ? update(createBindingElement(dotDotDotToken, propertyName, name, initializer), node)
17334                 : node;
17335         }
17336         function createBaseExpression(kind) {
17337             var node = createBaseNode(kind);
17338             return node;
17339         }
17340         function createArrayLiteralExpression(elements, multiLine) {
17341             var node = createBaseExpression(199);
17342             node.elements = parenthesizerRules().parenthesizeExpressionsOfCommaDelimitedList(createNodeArray(elements));
17343             node.multiLine = multiLine;
17344             node.transformFlags |= propagateChildrenFlags(node.elements);
17345             return node;
17346         }
17347         function updateArrayLiteralExpression(node, elements) {
17348             return node.elements !== elements
17349                 ? update(createArrayLiteralExpression(elements, node.multiLine), node)
17350                 : node;
17351         }
17352         function createObjectLiteralExpression(properties, multiLine) {
17353             var node = createBaseExpression(200);
17354             node.properties = createNodeArray(properties);
17355             node.multiLine = multiLine;
17356             node.transformFlags |= propagateChildrenFlags(node.properties);
17357             return node;
17358         }
17359         function updateObjectLiteralExpression(node, properties) {
17360             return node.properties !== properties
17361                 ? update(createObjectLiteralExpression(properties, node.multiLine), node)
17362                 : node;
17363         }
17364         function createPropertyAccessExpression(expression, name) {
17365             var node = createBaseExpression(201);
17366             node.expression = parenthesizerRules().parenthesizeLeftSideOfAccess(expression);
17367             node.name = asName(name);
17368             node.transformFlags =
17369                 propagateChildFlags(node.expression) |
17370                     (ts.isIdentifier(node.name) ?
17371                         propagateIdentifierNameFlags(node.name) :
17372                         propagateChildFlags(node.name));
17373             if (ts.isSuperKeyword(expression)) {
17374                 node.transformFlags |=
17375                     64 |
17376                         32;
17377             }
17378             return node;
17379         }
17380         function updatePropertyAccessExpression(node, expression, name) {
17381             if (ts.isPropertyAccessChain(node)) {
17382                 return updatePropertyAccessChain(node, expression, node.questionDotToken, ts.cast(name, ts.isIdentifier));
17383             }
17384             return node.expression !== expression
17385                 || node.name !== name
17386                 ? update(createPropertyAccessExpression(expression, name), node)
17387                 : node;
17388         }
17389         function createPropertyAccessChain(expression, questionDotToken, name) {
17390             var node = createBaseExpression(201);
17391             node.flags |= 32;
17392             node.expression = parenthesizerRules().parenthesizeLeftSideOfAccess(expression);
17393             node.questionDotToken = questionDotToken;
17394             node.name = asName(name);
17395             node.transformFlags |=
17396                 8 |
17397                     propagateChildFlags(node.expression) |
17398                     propagateChildFlags(node.questionDotToken) |
17399                     (ts.isIdentifier(node.name) ?
17400                         propagateIdentifierNameFlags(node.name) :
17401                         propagateChildFlags(node.name));
17402             return node;
17403         }
17404         function updatePropertyAccessChain(node, expression, questionDotToken, name) {
17405             ts.Debug.assert(!!(node.flags & 32), "Cannot update a PropertyAccessExpression using updatePropertyAccessChain. Use updatePropertyAccess instead.");
17406             return node.expression !== expression
17407                 || node.questionDotToken !== questionDotToken
17408                 || node.name !== name
17409                 ? update(createPropertyAccessChain(expression, questionDotToken, name), node)
17410                 : node;
17411         }
17412         function createElementAccessExpression(expression, index) {
17413             var node = createBaseExpression(202);
17414             node.expression = parenthesizerRules().parenthesizeLeftSideOfAccess(expression);
17415             node.argumentExpression = asExpression(index);
17416             node.transformFlags |=
17417                 propagateChildFlags(node.expression) |
17418                     propagateChildFlags(node.argumentExpression);
17419             if (ts.isSuperKeyword(expression)) {
17420                 node.transformFlags |=
17421                     64 |
17422                         32;
17423             }
17424             return node;
17425         }
17426         function updateElementAccessExpression(node, expression, argumentExpression) {
17427             if (ts.isElementAccessChain(node)) {
17428                 return updateElementAccessChain(node, expression, node.questionDotToken, argumentExpression);
17429             }
17430             return node.expression !== expression
17431                 || node.argumentExpression !== argumentExpression
17432                 ? update(createElementAccessExpression(expression, argumentExpression), node)
17433                 : node;
17434         }
17435         function createElementAccessChain(expression, questionDotToken, index) {
17436             var node = createBaseExpression(202);
17437             node.flags |= 32;
17438             node.expression = parenthesizerRules().parenthesizeLeftSideOfAccess(expression);
17439             node.questionDotToken = questionDotToken;
17440             node.argumentExpression = asExpression(index);
17441             node.transformFlags |=
17442                 propagateChildFlags(node.expression) |
17443                     propagateChildFlags(node.questionDotToken) |
17444                     propagateChildFlags(node.argumentExpression) |
17445                     8;
17446             return node;
17447         }
17448         function updateElementAccessChain(node, expression, questionDotToken, argumentExpression) {
17449             ts.Debug.assert(!!(node.flags & 32), "Cannot update a ElementAccessExpression using updateElementAccessChain. Use updateElementAccess instead.");
17450             return node.expression !== expression
17451                 || node.questionDotToken !== questionDotToken
17452                 || node.argumentExpression !== argumentExpression
17453                 ? update(createElementAccessChain(expression, questionDotToken, argumentExpression), node)
17454                 : node;
17455         }
17456         function createCallExpression(expression, typeArguments, argumentsArray) {
17457             var node = createBaseExpression(203);
17458             node.expression = parenthesizerRules().parenthesizeLeftSideOfAccess(expression);
17459             node.typeArguments = asNodeArray(typeArguments);
17460             node.arguments = parenthesizerRules().parenthesizeExpressionsOfCommaDelimitedList(createNodeArray(argumentsArray));
17461             node.transformFlags |=
17462                 propagateChildFlags(node.expression) |
17463                     propagateChildrenFlags(node.typeArguments) |
17464                     propagateChildrenFlags(node.arguments);
17465             if (node.typeArguments) {
17466                 node.transformFlags |= 1;
17467             }
17468             if (ts.isImportKeyword(node.expression)) {
17469                 node.transformFlags |= 2097152;
17470             }
17471             else if (ts.isSuperProperty(node.expression)) {
17472                 node.transformFlags |= 4096;
17473             }
17474             return node;
17475         }
17476         function updateCallExpression(node, expression, typeArguments, argumentsArray) {
17477             if (ts.isCallChain(node)) {
17478                 return updateCallChain(node, expression, node.questionDotToken, typeArguments, argumentsArray);
17479             }
17480             return node.expression !== expression
17481                 || node.typeArguments !== typeArguments
17482                 || node.arguments !== argumentsArray
17483                 ? update(createCallExpression(expression, typeArguments, argumentsArray), node)
17484                 : node;
17485         }
17486         function createCallChain(expression, questionDotToken, typeArguments, argumentsArray) {
17487             var node = createBaseExpression(203);
17488             node.flags |= 32;
17489             node.expression = parenthesizerRules().parenthesizeLeftSideOfAccess(expression);
17490             node.questionDotToken = questionDotToken;
17491             node.typeArguments = asNodeArray(typeArguments);
17492             node.arguments = parenthesizerRules().parenthesizeExpressionsOfCommaDelimitedList(createNodeArray(argumentsArray));
17493             node.transformFlags |=
17494                 propagateChildFlags(node.expression) |
17495                     propagateChildFlags(node.questionDotToken) |
17496                     propagateChildrenFlags(node.typeArguments) |
17497                     propagateChildrenFlags(node.arguments) |
17498                     8;
17499             if (node.typeArguments) {
17500                 node.transformFlags |= 1;
17501             }
17502             if (ts.isSuperProperty(node.expression)) {
17503                 node.transformFlags |= 4096;
17504             }
17505             return node;
17506         }
17507         function updateCallChain(node, expression, questionDotToken, typeArguments, argumentsArray) {
17508             ts.Debug.assert(!!(node.flags & 32), "Cannot update a CallExpression using updateCallChain. Use updateCall instead.");
17509             return node.expression !== expression
17510                 || node.questionDotToken !== questionDotToken
17511                 || node.typeArguments !== typeArguments
17512                 || node.arguments !== argumentsArray
17513                 ? update(createCallChain(expression, questionDotToken, typeArguments, argumentsArray), node)
17514                 : node;
17515         }
17516         function createNewExpression(expression, typeArguments, argumentsArray) {
17517             var node = createBaseExpression(204);
17518             node.expression = parenthesizerRules().parenthesizeExpressionOfNew(expression);
17519             node.typeArguments = asNodeArray(typeArguments);
17520             node.arguments = argumentsArray ? parenthesizerRules().parenthesizeExpressionsOfCommaDelimitedList(argumentsArray) : undefined;
17521             node.transformFlags |=
17522                 propagateChildFlags(node.expression) |
17523                     propagateChildrenFlags(node.typeArguments) |
17524                     propagateChildrenFlags(node.arguments) |
17525                     8;
17526             if (node.typeArguments) {
17527                 node.transformFlags |= 1;
17528             }
17529             return node;
17530         }
17531         function updateNewExpression(node, expression, typeArguments, argumentsArray) {
17532             return node.expression !== expression
17533                 || node.typeArguments !== typeArguments
17534                 || node.arguments !== argumentsArray
17535                 ? update(createNewExpression(expression, typeArguments, argumentsArray), node)
17536                 : node;
17537         }
17538         function createTaggedTemplateExpression(tag, typeArguments, template) {
17539             var node = createBaseExpression(205);
17540             node.tag = parenthesizerRules().parenthesizeLeftSideOfAccess(tag);
17541             node.typeArguments = asNodeArray(typeArguments);
17542             node.template = template;
17543             node.transformFlags |=
17544                 propagateChildFlags(node.tag) |
17545                     propagateChildrenFlags(node.typeArguments) |
17546                     propagateChildFlags(node.template) |
17547                     256;
17548             if (node.typeArguments) {
17549                 node.transformFlags |= 1;
17550             }
17551             if (ts.hasInvalidEscape(node.template)) {
17552                 node.transformFlags |= 32;
17553             }
17554             return node;
17555         }
17556         function updateTaggedTemplateExpression(node, tag, typeArguments, template) {
17557             return node.tag !== tag
17558                 || node.typeArguments !== typeArguments
17559                 || node.template !== template
17560                 ? update(createTaggedTemplateExpression(tag, typeArguments, template), node)
17561                 : node;
17562         }
17563         function createTypeAssertion(type, expression) {
17564             var node = createBaseExpression(206);
17565             node.expression = parenthesizerRules().parenthesizeOperandOfPrefixUnary(expression);
17566             node.type = type;
17567             node.transformFlags |=
17568                 propagateChildFlags(node.expression) |
17569                     propagateChildFlags(node.type) |
17570                     1;
17571             return node;
17572         }
17573         function updateTypeAssertion(node, type, expression) {
17574             return node.type !== type
17575                 || node.expression !== expression
17576                 ? update(createTypeAssertion(type, expression), node)
17577                 : node;
17578         }
17579         function createParenthesizedExpression(expression) {
17580             var node = createBaseExpression(207);
17581             node.expression = expression;
17582             node.transformFlags = propagateChildFlags(node.expression);
17583             return node;
17584         }
17585         function updateParenthesizedExpression(node, expression) {
17586             return node.expression !== expression
17587                 ? update(createParenthesizedExpression(expression), node)
17588                 : node;
17589         }
17590         function createFunctionExpression(modifiers, asteriskToken, name, typeParameters, parameters, type, body) {
17591             var node = createBaseFunctionLikeDeclaration(208, undefined, modifiers, name, typeParameters, parameters, type, body);
17592             node.asteriskToken = asteriskToken;
17593             node.transformFlags |= propagateChildFlags(node.asteriskToken);
17594             if (node.typeParameters) {
17595                 node.transformFlags |= 1;
17596             }
17597             if (ts.modifiersToFlags(node.modifiers) & 256) {
17598                 if (node.asteriskToken) {
17599                     node.transformFlags |= 32;
17600                 }
17601                 else {
17602                     node.transformFlags |= 64;
17603                 }
17604             }
17605             else if (node.asteriskToken) {
17606                 node.transformFlags |= 512;
17607             }
17608             return node;
17609         }
17610         function updateFunctionExpression(node, modifiers, asteriskToken, name, typeParameters, parameters, type, body) {
17611             return node.name !== name
17612                 || node.modifiers !== modifiers
17613                 || node.asteriskToken !== asteriskToken
17614                 || node.typeParameters !== typeParameters
17615                 || node.parameters !== parameters
17616                 || node.type !== type
17617                 || node.body !== body
17618                 ? updateBaseFunctionLikeDeclaration(createFunctionExpression(modifiers, asteriskToken, name, typeParameters, parameters, type, body), node)
17619                 : node;
17620         }
17621         function createArrowFunction(modifiers, typeParameters, parameters, type, equalsGreaterThanToken, body) {
17622             var node = createBaseFunctionLikeDeclaration(209, undefined, modifiers, undefined, typeParameters, parameters, type, parenthesizerRules().parenthesizeConciseBodyOfArrowFunction(body));
17623             node.equalsGreaterThanToken = equalsGreaterThanToken !== null && equalsGreaterThanToken !== void 0 ? equalsGreaterThanToken : createToken(38);
17624             node.transformFlags |=
17625                 propagateChildFlags(node.equalsGreaterThanToken) |
17626                     256;
17627             if (ts.modifiersToFlags(node.modifiers) & 256) {
17628                 node.transformFlags |= 64;
17629             }
17630             return node;
17631         }
17632         function updateArrowFunction(node, modifiers, typeParameters, parameters, type, equalsGreaterThanToken, body) {
17633             return node.modifiers !== modifiers
17634                 || node.typeParameters !== typeParameters
17635                 || node.parameters !== parameters
17636                 || node.type !== type
17637                 || node.equalsGreaterThanToken !== equalsGreaterThanToken
17638                 || node.body !== body
17639                 ? updateBaseFunctionLikeDeclaration(createArrowFunction(modifiers, typeParameters, parameters, type, equalsGreaterThanToken, body), node)
17640                 : node;
17641         }
17642         function createDeleteExpression(expression) {
17643             var node = createBaseExpression(210);
17644             node.expression = parenthesizerRules().parenthesizeOperandOfPrefixUnary(expression);
17645             node.transformFlags |= propagateChildFlags(node.expression);
17646             return node;
17647         }
17648         function updateDeleteExpression(node, expression) {
17649             return node.expression !== expression
17650                 ? update(createDeleteExpression(expression), node)
17651                 : node;
17652         }
17653         function createTypeOfExpression(expression) {
17654             var node = createBaseExpression(211);
17655             node.expression = parenthesizerRules().parenthesizeOperandOfPrefixUnary(expression);
17656             node.transformFlags |= propagateChildFlags(node.expression);
17657             return node;
17658         }
17659         function updateTypeOfExpression(node, expression) {
17660             return node.expression !== expression
17661                 ? update(createTypeOfExpression(expression), node)
17662                 : node;
17663         }
17664         function createVoidExpression(expression) {
17665             var node = createBaseExpression(212);
17666             node.expression = parenthesizerRules().parenthesizeOperandOfPrefixUnary(expression);
17667             node.transformFlags |= propagateChildFlags(node.expression);
17668             return node;
17669         }
17670         function updateVoidExpression(node, expression) {
17671             return node.expression !== expression
17672                 ? update(createVoidExpression(expression), node)
17673                 : node;
17674         }
17675         function createAwaitExpression(expression) {
17676             var node = createBaseExpression(213);
17677             node.expression = parenthesizerRules().parenthesizeOperandOfPrefixUnary(expression);
17678             node.transformFlags |=
17679                 propagateChildFlags(node.expression) |
17680                     64 |
17681                     32 |
17682                     524288;
17683             return node;
17684         }
17685         function updateAwaitExpression(node, expression) {
17686             return node.expression !== expression
17687                 ? update(createAwaitExpression(expression), node)
17688                 : node;
17689         }
17690         function createPrefixUnaryExpression(operator, operand) {
17691             var node = createBaseExpression(214);
17692             node.operator = operator;
17693             node.operand = parenthesizerRules().parenthesizeOperandOfPrefixUnary(operand);
17694             node.transformFlags |= propagateChildFlags(node.operand);
17695             return node;
17696         }
17697         function updatePrefixUnaryExpression(node, operand) {
17698             return node.operand !== operand
17699                 ? update(createPrefixUnaryExpression(node.operator, operand), node)
17700                 : node;
17701         }
17702         function createPostfixUnaryExpression(operand, operator) {
17703             var node = createBaseExpression(215);
17704             node.operator = operator;
17705             node.operand = parenthesizerRules().parenthesizeOperandOfPostfixUnary(operand);
17706             node.transformFlags = propagateChildFlags(node.operand);
17707             return node;
17708         }
17709         function updatePostfixUnaryExpression(node, operand) {
17710             return node.operand !== operand
17711                 ? update(createPostfixUnaryExpression(operand, node.operator), node)
17712                 : node;
17713         }
17714         function createBinaryExpression(left, operator, right) {
17715             var node = createBaseExpression(216);
17716             var operatorToken = asToken(operator);
17717             var operatorKind = operatorToken.kind;
17718             node.left = parenthesizerRules().parenthesizeLeftSideOfBinary(operatorKind, left);
17719             node.operatorToken = operatorToken;
17720             node.right = parenthesizerRules().parenthesizeRightSideOfBinary(operatorKind, node.left, right);
17721             node.transformFlags |=
17722                 propagateChildFlags(node.left) |
17723                     propagateChildFlags(node.operatorToken) |
17724                     propagateChildFlags(node.right);
17725             if (operatorKind === 60) {
17726                 node.transformFlags |= 8;
17727             }
17728             else if (operatorKind === 62) {
17729                 if (ts.isObjectLiteralExpression(node.left)) {
17730                     node.transformFlags |=
17731                         256 |
17732                             32 |
17733                             1024 |
17734                             propagateAssignmentPatternFlags(node.left);
17735                 }
17736                 else if (ts.isArrayLiteralExpression(node.left)) {
17737                     node.transformFlags |=
17738                         256 |
17739                             1024 |
17740                             propagateAssignmentPatternFlags(node.left);
17741                 }
17742             }
17743             else if (operatorKind === 42 || operatorKind === 66) {
17744                 node.transformFlags |= 128;
17745             }
17746             else if (ts.isLogicalOrCoalescingAssignmentOperator(operatorKind)) {
17747                 node.transformFlags |= 4;
17748             }
17749             return node;
17750         }
17751         function propagateAssignmentPatternFlags(node) {
17752             if (node.transformFlags & 16384)
17753                 return 16384;
17754             if (node.transformFlags & 32) {
17755                 for (var _i = 0, _a = ts.getElementsOfBindingOrAssignmentPattern(node); _i < _a.length; _i++) {
17756                     var element = _a[_i];
17757                     var target = ts.getTargetOfBindingOrAssignmentElement(element);
17758                     if (target && ts.isAssignmentPattern(target)) {
17759                         if (target.transformFlags & 16384) {
17760                             return 16384;
17761                         }
17762                         if (target.transformFlags & 32) {
17763                             var flags_1 = propagateAssignmentPatternFlags(target);
17764                             if (flags_1)
17765                                 return flags_1;
17766                         }
17767                     }
17768                 }
17769             }
17770             return 0;
17771         }
17772         function updateBinaryExpression(node, left, operator, right) {
17773             return node.left !== left
17774                 || node.operatorToken !== operator
17775                 || node.right !== right
17776                 ? update(createBinaryExpression(left, operator, right), node)
17777                 : node;
17778         }
17779         function createConditionalExpression(condition, questionToken, whenTrue, colonToken, whenFalse) {
17780             var node = createBaseExpression(217);
17781             node.condition = parenthesizerRules().parenthesizeConditionOfConditionalExpression(condition);
17782             node.questionToken = questionToken !== null && questionToken !== void 0 ? questionToken : createToken(57);
17783             node.whenTrue = parenthesizerRules().parenthesizeBranchOfConditionalExpression(whenTrue);
17784             node.colonToken = colonToken !== null && colonToken !== void 0 ? colonToken : createToken(58);
17785             node.whenFalse = parenthesizerRules().parenthesizeBranchOfConditionalExpression(whenFalse);
17786             node.transformFlags |=
17787                 propagateChildFlags(node.condition) |
17788                     propagateChildFlags(node.questionToken) |
17789                     propagateChildFlags(node.whenTrue) |
17790                     propagateChildFlags(node.colonToken) |
17791                     propagateChildFlags(node.whenFalse);
17792             return node;
17793         }
17794         function updateConditionalExpression(node, condition, questionToken, whenTrue, colonToken, whenFalse) {
17795             return node.condition !== condition
17796                 || node.questionToken !== questionToken
17797                 || node.whenTrue !== whenTrue
17798                 || node.colonToken !== colonToken
17799                 || node.whenFalse !== whenFalse
17800                 ? update(createConditionalExpression(condition, questionToken, whenTrue, colonToken, whenFalse), node)
17801                 : node;
17802         }
17803         function createTemplateExpression(head, templateSpans) {
17804             var node = createBaseExpression(218);
17805             node.head = head;
17806             node.templateSpans = createNodeArray(templateSpans);
17807             node.transformFlags |=
17808                 propagateChildFlags(node.head) |
17809                     propagateChildrenFlags(node.templateSpans) |
17810                     256;
17811             return node;
17812         }
17813         function updateTemplateExpression(node, head, templateSpans) {
17814             return node.head !== head
17815                 || node.templateSpans !== templateSpans
17816                 ? update(createTemplateExpression(head, templateSpans), node)
17817                 : node;
17818         }
17819         function createTemplateLiteralLikeNodeChecked(kind, text, rawText, templateFlags) {
17820             if (templateFlags === void 0) { templateFlags = 0; }
17821             ts.Debug.assert(!(templateFlags & ~2048), "Unsupported template flags.");
17822             var cooked = undefined;
17823             if (rawText !== undefined && rawText !== text) {
17824                 cooked = getCookedText(kind, rawText);
17825                 if (typeof cooked === "object") {
17826                     return ts.Debug.fail("Invalid raw text");
17827                 }
17828             }
17829             if (text === undefined) {
17830                 if (cooked === undefined) {
17831                     return ts.Debug.fail("Arguments 'text' and 'rawText' may not both be undefined.");
17832                 }
17833                 text = cooked;
17834             }
17835             else if (cooked !== undefined) {
17836                 ts.Debug.assert(text === cooked, "Expected argument 'text' to be the normalized (i.e. 'cooked') version of argument 'rawText'.");
17837             }
17838             return createTemplateLiteralLikeNode(kind, text, rawText, templateFlags);
17839         }
17840         function createTemplateLiteralLikeNode(kind, text, rawText, templateFlags) {
17841             var node = createBaseToken(kind);
17842             node.text = text;
17843             node.rawText = rawText;
17844             node.templateFlags = templateFlags & 2048;
17845             node.transformFlags |= 256;
17846             if (node.templateFlags) {
17847                 node.transformFlags |= 32;
17848             }
17849             return node;
17850         }
17851         function createTemplateHead(text, rawText, templateFlags) {
17852             return createTemplateLiteralLikeNodeChecked(15, text, rawText, templateFlags);
17853         }
17854         function createTemplateMiddle(text, rawText, templateFlags) {
17855             return createTemplateLiteralLikeNodeChecked(16, text, rawText, templateFlags);
17856         }
17857         function createTemplateTail(text, rawText, templateFlags) {
17858             return createTemplateLiteralLikeNodeChecked(17, text, rawText, templateFlags);
17859         }
17860         function createNoSubstitutionTemplateLiteral(text, rawText, templateFlags) {
17861             return createTemplateLiteralLikeNodeChecked(14, text, rawText, templateFlags);
17862         }
17863         function createYieldExpression(asteriskToken, expression) {
17864             ts.Debug.assert(!asteriskToken || !!expression, "A `YieldExpression` with an asteriskToken must have an expression.");
17865             var node = createBaseExpression(219);
17866             node.expression = expression && parenthesizerRules().parenthesizeExpressionForDisallowedComma(expression);
17867             node.asteriskToken = asteriskToken;
17868             node.transformFlags |=
17869                 propagateChildFlags(node.expression) |
17870                     propagateChildFlags(node.asteriskToken) |
17871                     256 |
17872                     32 |
17873                     262144;
17874             return node;
17875         }
17876         function updateYieldExpression(node, asteriskToken, expression) {
17877             return node.expression !== expression
17878                 || node.asteriskToken !== asteriskToken
17879                 ? update(createYieldExpression(asteriskToken, expression), node)
17880                 : node;
17881         }
17882         function createSpreadElement(expression) {
17883             var node = createBaseExpression(220);
17884             node.expression = parenthesizerRules().parenthesizeExpressionForDisallowedComma(expression);
17885             node.transformFlags |=
17886                 propagateChildFlags(node.expression) |
17887                     256 |
17888                     8192;
17889             return node;
17890         }
17891         function updateSpreadElement(node, expression) {
17892             return node.expression !== expression
17893                 ? update(createSpreadElement(expression), node)
17894                 : node;
17895         }
17896         function createClassExpression(decorators, modifiers, name, typeParameters, heritageClauses, members) {
17897             var node = createBaseClassLikeDeclaration(221, decorators, modifiers, name, typeParameters, heritageClauses, members);
17898             node.transformFlags |= 256;
17899             return node;
17900         }
17901         function updateClassExpression(node, decorators, modifiers, name, typeParameters, heritageClauses, members) {
17902             return node.decorators !== decorators
17903                 || node.modifiers !== modifiers
17904                 || node.name !== name
17905                 || node.typeParameters !== typeParameters
17906                 || node.heritageClauses !== heritageClauses
17907                 || node.members !== members
17908                 ? update(createClassExpression(decorators, modifiers, name, typeParameters, heritageClauses, members), node)
17909                 : node;
17910         }
17911         function createOmittedExpression() {
17912             return createBaseExpression(222);
17913         }
17914         function createExpressionWithTypeArguments(expression, typeArguments) {
17915             var node = createBaseNode(223);
17916             node.expression = parenthesizerRules().parenthesizeLeftSideOfAccess(expression);
17917             node.typeArguments = typeArguments && parenthesizerRules().parenthesizeTypeArguments(typeArguments);
17918             node.transformFlags |=
17919                 propagateChildFlags(node.expression) |
17920                     propagateChildrenFlags(node.typeArguments) |
17921                     256;
17922             return node;
17923         }
17924         function updateExpressionWithTypeArguments(node, expression, typeArguments) {
17925             return node.expression !== expression
17926                 || node.typeArguments !== typeArguments
17927                 ? update(createExpressionWithTypeArguments(expression, typeArguments), node)
17928                 : node;
17929         }
17930         function createAsExpression(expression, type) {
17931             var node = createBaseExpression(224);
17932             node.expression = expression;
17933             node.type = type;
17934             node.transformFlags |=
17935                 propagateChildFlags(node.expression) |
17936                     propagateChildFlags(node.type) |
17937                     1;
17938             return node;
17939         }
17940         function updateAsExpression(node, expression, type) {
17941             return node.expression !== expression
17942                 || node.type !== type
17943                 ? update(createAsExpression(expression, type), node)
17944                 : node;
17945         }
17946         function createNonNullExpression(expression) {
17947             var node = createBaseExpression(225);
17948             node.expression = parenthesizerRules().parenthesizeLeftSideOfAccess(expression);
17949             node.transformFlags |=
17950                 propagateChildFlags(node.expression) |
17951                     1;
17952             return node;
17953         }
17954         function updateNonNullExpression(node, expression) {
17955             if (ts.isNonNullChain(node)) {
17956                 return updateNonNullChain(node, expression);
17957             }
17958             return node.expression !== expression
17959                 ? update(createNonNullExpression(expression), node)
17960                 : node;
17961         }
17962         function createNonNullChain(expression) {
17963             var node = createBaseExpression(225);
17964             node.flags |= 32;
17965             node.expression = parenthesizerRules().parenthesizeLeftSideOfAccess(expression);
17966             node.transformFlags |=
17967                 propagateChildFlags(node.expression) |
17968                     1;
17969             return node;
17970         }
17971         function updateNonNullChain(node, expression) {
17972             ts.Debug.assert(!!(node.flags & 32), "Cannot update a NonNullExpression using updateNonNullChain. Use updateNonNullExpression instead.");
17973             return node.expression !== expression
17974                 ? update(createNonNullChain(expression), node)
17975                 : node;
17976         }
17977         function createMetaProperty(keywordToken, name) {
17978             var node = createBaseExpression(226);
17979             node.keywordToken = keywordToken;
17980             node.name = name;
17981             node.transformFlags |= propagateChildFlags(node.name);
17982             switch (keywordToken) {
17983                 case 102:
17984                     node.transformFlags |= 256;
17985                     break;
17986                 case 99:
17987                     node.transformFlags |= 4;
17988                     break;
17989                 default:
17990                     return ts.Debug.assertNever(keywordToken);
17991             }
17992             return node;
17993         }
17994         function updateMetaProperty(node, name) {
17995             return node.name !== name
17996                 ? update(createMetaProperty(node.keywordToken, name), node)
17997                 : node;
17998         }
17999         function createTemplateSpan(expression, literal) {
18000             var node = createBaseNode(228);
18001             node.expression = expression;
18002             node.literal = literal;
18003             node.transformFlags |=
18004                 propagateChildFlags(node.expression) |
18005                     propagateChildFlags(node.literal) |
18006                     256;
18007             return node;
18008         }
18009         function updateTemplateSpan(node, expression, literal) {
18010             return node.expression !== expression
18011                 || node.literal !== literal
18012                 ? update(createTemplateSpan(expression, literal), node)
18013                 : node;
18014         }
18015         function createSemicolonClassElement() {
18016             var node = createBaseNode(229);
18017             node.transformFlags |= 256;
18018             return node;
18019         }
18020         function createBlock(statements, multiLine) {
18021             var node = createBaseNode(230);
18022             node.statements = createNodeArray(statements);
18023             node.multiLine = multiLine;
18024             node.transformFlags |= propagateChildrenFlags(node.statements);
18025             return node;
18026         }
18027         function updateBlock(node, statements) {
18028             return node.statements !== statements
18029                 ? update(createBlock(statements, node.multiLine), node)
18030                 : node;
18031         }
18032         function createVariableStatement(modifiers, declarationList) {
18033             var node = createBaseDeclaration(232, undefined, modifiers);
18034             node.declarationList = ts.isArray(declarationList) ? createVariableDeclarationList(declarationList) : declarationList;
18035             node.transformFlags |=
18036                 propagateChildFlags(node.declarationList);
18037             if (ts.modifiersToFlags(node.modifiers) & 2) {
18038                 node.transformFlags = 1;
18039             }
18040             return node;
18041         }
18042         function updateVariableStatement(node, modifiers, declarationList) {
18043             return node.modifiers !== modifiers
18044                 || node.declarationList !== declarationList
18045                 ? update(createVariableStatement(modifiers, declarationList), node)
18046                 : node;
18047         }
18048         function createEmptyStatement() {
18049             return createBaseNode(231);
18050         }
18051         function createExpressionStatement(expression) {
18052             var node = createBaseNode(233);
18053             node.expression = parenthesizerRules().parenthesizeExpressionOfExpressionStatement(expression);
18054             node.transformFlags |= propagateChildFlags(node.expression);
18055             return node;
18056         }
18057         function updateExpressionStatement(node, expression) {
18058             return node.expression !== expression
18059                 ? update(createExpressionStatement(expression), node)
18060                 : node;
18061         }
18062         function createIfStatement(expression, thenStatement, elseStatement) {
18063             var node = createBaseNode(234);
18064             node.expression = expression;
18065             node.thenStatement = asEmbeddedStatement(thenStatement);
18066             node.elseStatement = asEmbeddedStatement(elseStatement);
18067             node.transformFlags |=
18068                 propagateChildFlags(node.expression) |
18069                     propagateChildFlags(node.thenStatement) |
18070                     propagateChildFlags(node.elseStatement);
18071             return node;
18072         }
18073         function updateIfStatement(node, expression, thenStatement, elseStatement) {
18074             return node.expression !== expression
18075                 || node.thenStatement !== thenStatement
18076                 || node.elseStatement !== elseStatement
18077                 ? update(createIfStatement(expression, thenStatement, elseStatement), node)
18078                 : node;
18079         }
18080         function createDoStatement(statement, expression) {
18081             var node = createBaseNode(235);
18082             node.statement = asEmbeddedStatement(statement);
18083             node.expression = expression;
18084             node.transformFlags |=
18085                 propagateChildFlags(node.statement) |
18086                     propagateChildFlags(node.expression);
18087             return node;
18088         }
18089         function updateDoStatement(node, statement, expression) {
18090             return node.statement !== statement
18091                 || node.expression !== expression
18092                 ? update(createDoStatement(statement, expression), node)
18093                 : node;
18094         }
18095         function createWhileStatement(expression, statement) {
18096             var node = createBaseNode(236);
18097             node.expression = expression;
18098             node.statement = asEmbeddedStatement(statement);
18099             node.transformFlags |=
18100                 propagateChildFlags(node.expression) |
18101                     propagateChildFlags(node.statement);
18102             return node;
18103         }
18104         function updateWhileStatement(node, expression, statement) {
18105             return node.expression !== expression
18106                 || node.statement !== statement
18107                 ? update(createWhileStatement(expression, statement), node)
18108                 : node;
18109         }
18110         function createForStatement(initializer, condition, incrementor, statement) {
18111             var node = createBaseNode(237);
18112             node.initializer = initializer;
18113             node.condition = condition;
18114             node.incrementor = incrementor;
18115             node.statement = asEmbeddedStatement(statement);
18116             node.transformFlags |=
18117                 propagateChildFlags(node.initializer) |
18118                     propagateChildFlags(node.condition) |
18119                     propagateChildFlags(node.incrementor) |
18120                     propagateChildFlags(node.statement);
18121             return node;
18122         }
18123         function updateForStatement(node, initializer, condition, incrementor, statement) {
18124             return node.initializer !== initializer
18125                 || node.condition !== condition
18126                 || node.incrementor !== incrementor
18127                 || node.statement !== statement
18128                 ? update(createForStatement(initializer, condition, incrementor, statement), node)
18129                 : node;
18130         }
18131         function createForInStatement(initializer, expression, statement) {
18132             var node = createBaseNode(238);
18133             node.initializer = initializer;
18134             node.expression = expression;
18135             node.statement = asEmbeddedStatement(statement);
18136             node.transformFlags |=
18137                 propagateChildFlags(node.initializer) |
18138                     propagateChildFlags(node.expression) |
18139                     propagateChildFlags(node.statement);
18140             return node;
18141         }
18142         function updateForInStatement(node, initializer, expression, statement) {
18143             return node.initializer !== initializer
18144                 || node.expression !== expression
18145                 || node.statement !== statement
18146                 ? update(createForInStatement(initializer, expression, statement), node)
18147                 : node;
18148         }
18149         function createForOfStatement(awaitModifier, initializer, expression, statement) {
18150             var node = createBaseNode(239);
18151             node.awaitModifier = awaitModifier;
18152             node.initializer = initializer;
18153             node.expression = parenthesizerRules().parenthesizeExpressionForDisallowedComma(expression);
18154             node.statement = asEmbeddedStatement(statement);
18155             node.transformFlags |=
18156                 propagateChildFlags(node.awaitModifier) |
18157                     propagateChildFlags(node.initializer) |
18158                     propagateChildFlags(node.expression) |
18159                     propagateChildFlags(node.statement) |
18160                     256;
18161             if (awaitModifier)
18162                 node.transformFlags |= 32;
18163             return node;
18164         }
18165         function updateForOfStatement(node, awaitModifier, initializer, expression, statement) {
18166             return node.awaitModifier !== awaitModifier
18167                 || node.initializer !== initializer
18168                 || node.expression !== expression
18169                 || node.statement !== statement
18170                 ? update(createForOfStatement(awaitModifier, initializer, expression, statement), node)
18171                 : node;
18172         }
18173         function createContinueStatement(label) {
18174             var node = createBaseNode(240);
18175             node.label = asName(label);
18176             node.transformFlags |=
18177                 propagateChildFlags(node.label) |
18178                     1048576;
18179             return node;
18180         }
18181         function updateContinueStatement(node, label) {
18182             return node.label !== label
18183                 ? update(createContinueStatement(label), node)
18184                 : node;
18185         }
18186         function createBreakStatement(label) {
18187             var node = createBaseNode(241);
18188             node.label = asName(label);
18189             node.transformFlags |=
18190                 propagateChildFlags(node.label) |
18191                     1048576;
18192             return node;
18193         }
18194         function updateBreakStatement(node, label) {
18195             return node.label !== label
18196                 ? update(createBreakStatement(label), node)
18197                 : node;
18198         }
18199         function createReturnStatement(expression) {
18200             var node = createBaseNode(242);
18201             node.expression = expression;
18202             node.transformFlags |=
18203                 propagateChildFlags(node.expression) |
18204                     32 |
18205                     1048576;
18206             return node;
18207         }
18208         function updateReturnStatement(node, expression) {
18209             return node.expression !== expression
18210                 ? update(createReturnStatement(expression), node)
18211                 : node;
18212         }
18213         function createWithStatement(expression, statement) {
18214             var node = createBaseNode(243);
18215             node.expression = expression;
18216             node.statement = asEmbeddedStatement(statement);
18217             node.transformFlags |=
18218                 propagateChildFlags(node.expression) |
18219                     propagateChildFlags(node.statement);
18220             return node;
18221         }
18222         function updateWithStatement(node, expression, statement) {
18223             return node.expression !== expression
18224                 || node.statement !== statement
18225                 ? update(createWithStatement(expression, statement), node)
18226                 : node;
18227         }
18228         function createSwitchStatement(expression, caseBlock) {
18229             var node = createBaseNode(244);
18230             node.expression = parenthesizerRules().parenthesizeExpressionForDisallowedComma(expression);
18231             node.caseBlock = caseBlock;
18232             node.transformFlags |=
18233                 propagateChildFlags(node.expression) |
18234                     propagateChildFlags(node.caseBlock);
18235             return node;
18236         }
18237         function updateSwitchStatement(node, expression, caseBlock) {
18238             return node.expression !== expression
18239                 || node.caseBlock !== caseBlock
18240                 ? update(createSwitchStatement(expression, caseBlock), node)
18241                 : node;
18242         }
18243         function createLabeledStatement(label, statement) {
18244             var node = createBaseNode(245);
18245             node.label = asName(label);
18246             node.statement = asEmbeddedStatement(statement);
18247             node.transformFlags |=
18248                 propagateChildFlags(node.label) |
18249                     propagateChildFlags(node.statement);
18250             return node;
18251         }
18252         function updateLabeledStatement(node, label, statement) {
18253             return node.label !== label
18254                 || node.statement !== statement
18255                 ? update(createLabeledStatement(label, statement), node)
18256                 : node;
18257         }
18258         function createThrowStatement(expression) {
18259             var node = createBaseNode(246);
18260             node.expression = expression;
18261             node.transformFlags |= propagateChildFlags(node.expression);
18262             return node;
18263         }
18264         function updateThrowStatement(node, expression) {
18265             return node.expression !== expression
18266                 ? update(createThrowStatement(expression), node)
18267                 : node;
18268         }
18269         function createTryStatement(tryBlock, catchClause, finallyBlock) {
18270             var node = createBaseNode(247);
18271             node.tryBlock = tryBlock;
18272             node.catchClause = catchClause;
18273             node.finallyBlock = finallyBlock;
18274             node.transformFlags |=
18275                 propagateChildFlags(node.tryBlock) |
18276                     propagateChildFlags(node.catchClause) |
18277                     propagateChildFlags(node.finallyBlock);
18278             return node;
18279         }
18280         function updateTryStatement(node, tryBlock, catchClause, finallyBlock) {
18281             return node.tryBlock !== tryBlock
18282                 || node.catchClause !== catchClause
18283                 || node.finallyBlock !== finallyBlock
18284                 ? update(createTryStatement(tryBlock, catchClause, finallyBlock), node)
18285                 : node;
18286         }
18287         function createDebuggerStatement() {
18288             return createBaseNode(248);
18289         }
18290         function createVariableDeclaration(name, exclamationToken, type, initializer) {
18291             var node = createBaseVariableLikeDeclaration(249, undefined, undefined, name, type, initializer && parenthesizerRules().parenthesizeExpressionForDisallowedComma(initializer));
18292             node.exclamationToken = exclamationToken;
18293             node.transformFlags |= propagateChildFlags(node.exclamationToken);
18294             if (exclamationToken) {
18295                 node.transformFlags |= 1;
18296             }
18297             return node;
18298         }
18299         function updateVariableDeclaration(node, name, exclamationToken, type, initializer) {
18300             return node.name !== name
18301                 || node.type !== type
18302                 || node.exclamationToken !== exclamationToken
18303                 || node.initializer !== initializer
18304                 ? update(createVariableDeclaration(name, exclamationToken, type, initializer), node)
18305                 : node;
18306         }
18307         function createVariableDeclarationList(declarations, flags) {
18308             if (flags === void 0) { flags = 0; }
18309             var node = createBaseNode(250);
18310             node.flags |= flags & 3;
18311             node.declarations = createNodeArray(declarations);
18312             node.transformFlags |=
18313                 propagateChildrenFlags(node.declarations) |
18314                     1048576;
18315             if (flags & 3) {
18316                 node.transformFlags |=
18317                     256 |
18318                         65536;
18319             }
18320             return node;
18321         }
18322         function updateVariableDeclarationList(node, declarations) {
18323             return node.declarations !== declarations
18324                 ? update(createVariableDeclarationList(declarations, node.flags), node)
18325                 : node;
18326         }
18327         function createFunctionDeclaration(decorators, modifiers, asteriskToken, name, typeParameters, parameters, type, body) {
18328             var node = createBaseFunctionLikeDeclaration(251, decorators, modifiers, name, typeParameters, parameters, type, body);
18329             node.asteriskToken = asteriskToken;
18330             if (!node.body || ts.modifiersToFlags(node.modifiers) & 2) {
18331                 node.transformFlags = 1;
18332             }
18333             else {
18334                 node.transformFlags |=
18335                     propagateChildFlags(node.asteriskToken) |
18336                         1048576;
18337                 if (ts.modifiersToFlags(node.modifiers) & 256) {
18338                     if (node.asteriskToken) {
18339                         node.transformFlags |= 32;
18340                     }
18341                     else {
18342                         node.transformFlags |= 64;
18343                     }
18344                 }
18345                 else if (node.asteriskToken) {
18346                     node.transformFlags |= 512;
18347                 }
18348             }
18349             return node;
18350         }
18351         function updateFunctionDeclaration(node, decorators, modifiers, asteriskToken, name, typeParameters, parameters, type, body) {
18352             return node.decorators !== decorators
18353                 || node.modifiers !== modifiers
18354                 || node.asteriskToken !== asteriskToken
18355                 || node.name !== name
18356                 || node.typeParameters !== typeParameters
18357                 || node.parameters !== parameters
18358                 || node.type !== type
18359                 || node.body !== body
18360                 ? updateBaseFunctionLikeDeclaration(createFunctionDeclaration(decorators, modifiers, asteriskToken, name, typeParameters, parameters, type, body), node)
18361                 : node;
18362         }
18363         function createClassDeclaration(decorators, modifiers, name, typeParameters, heritageClauses, members) {
18364             var node = createBaseClassLikeDeclaration(252, decorators, modifiers, name, typeParameters, heritageClauses, members);
18365             if (ts.modifiersToFlags(node.modifiers) & 2) {
18366                 node.transformFlags = 1;
18367             }
18368             else {
18369                 node.transformFlags |= 256;
18370                 if (node.transformFlags & 2048) {
18371                     node.transformFlags |= 1;
18372                 }
18373             }
18374             return node;
18375         }
18376         function updateClassDeclaration(node, decorators, modifiers, name, typeParameters, heritageClauses, members) {
18377             return node.decorators !== decorators
18378                 || node.modifiers !== modifiers
18379                 || node.name !== name
18380                 || node.typeParameters !== typeParameters
18381                 || node.heritageClauses !== heritageClauses
18382                 || node.members !== members
18383                 ? update(createClassDeclaration(decorators, modifiers, name, typeParameters, heritageClauses, members), node)
18384                 : node;
18385         }
18386         function createInterfaceDeclaration(decorators, modifiers, name, typeParameters, heritageClauses, members) {
18387             var node = createBaseInterfaceOrClassLikeDeclaration(253, decorators, modifiers, name, typeParameters, heritageClauses);
18388             node.members = createNodeArray(members);
18389             node.transformFlags = 1;
18390             return node;
18391         }
18392         function updateInterfaceDeclaration(node, decorators, modifiers, name, typeParameters, heritageClauses, members) {
18393             return node.decorators !== decorators
18394                 || node.modifiers !== modifiers
18395                 || node.name !== name
18396                 || node.typeParameters !== typeParameters
18397                 || node.heritageClauses !== heritageClauses
18398                 || node.members !== members
18399                 ? update(createInterfaceDeclaration(decorators, modifiers, name, typeParameters, heritageClauses, members), node)
18400                 : node;
18401         }
18402         function createTypeAliasDeclaration(decorators, modifiers, name, typeParameters, type) {
18403             var node = createBaseGenericNamedDeclaration(254, decorators, modifiers, name, typeParameters);
18404             node.type = type;
18405             node.transformFlags = 1;
18406             return node;
18407         }
18408         function updateTypeAliasDeclaration(node, decorators, modifiers, name, typeParameters, type) {
18409             return node.decorators !== decorators
18410                 || node.modifiers !== modifiers
18411                 || node.name !== name
18412                 || node.typeParameters !== typeParameters
18413                 || node.type !== type
18414                 ? update(createTypeAliasDeclaration(decorators, modifiers, name, typeParameters, type), node)
18415                 : node;
18416         }
18417         function createEnumDeclaration(decorators, modifiers, name, members) {
18418             var node = createBaseNamedDeclaration(255, decorators, modifiers, name);
18419             node.members = createNodeArray(members);
18420             node.transformFlags |=
18421                 propagateChildrenFlags(node.members) |
18422                     1;
18423             node.transformFlags &= ~8388608;
18424             return node;
18425         }
18426         function updateEnumDeclaration(node, decorators, modifiers, name, members) {
18427             return node.decorators !== decorators
18428                 || node.modifiers !== modifiers
18429                 || node.name !== name
18430                 || node.members !== members
18431                 ? update(createEnumDeclaration(decorators, modifiers, name, members), node)
18432                 : node;
18433         }
18434         function createModuleDeclaration(decorators, modifiers, name, body, flags) {
18435             if (flags === void 0) { flags = 0; }
18436             var node = createBaseDeclaration(256, decorators, modifiers);
18437             node.flags |= flags & (16 | 4 | 1024);
18438             node.name = name;
18439             node.body = body;
18440             if (ts.modifiersToFlags(node.modifiers) & 2) {
18441                 node.transformFlags = 1;
18442             }
18443             else {
18444                 node.transformFlags |=
18445                     propagateChildFlags(node.name) |
18446                         propagateChildFlags(node.body) |
18447                         1;
18448             }
18449             node.transformFlags &= ~8388608;
18450             return node;
18451         }
18452         function updateModuleDeclaration(node, decorators, modifiers, name, body) {
18453             return node.decorators !== decorators
18454                 || node.modifiers !== modifiers
18455                 || node.name !== name
18456                 || node.body !== body
18457                 ? update(createModuleDeclaration(decorators, modifiers, name, body, node.flags), node)
18458                 : node;
18459         }
18460         function createModuleBlock(statements) {
18461             var node = createBaseNode(257);
18462             node.statements = createNodeArray(statements);
18463             node.transformFlags |= propagateChildrenFlags(node.statements);
18464             return node;
18465         }
18466         function updateModuleBlock(node, statements) {
18467             return node.statements !== statements
18468                 ? update(createModuleBlock(statements), node)
18469                 : node;
18470         }
18471         function createCaseBlock(clauses) {
18472             var node = createBaseNode(258);
18473             node.clauses = createNodeArray(clauses);
18474             node.transformFlags |= propagateChildrenFlags(node.clauses);
18475             return node;
18476         }
18477         function updateCaseBlock(node, clauses) {
18478             return node.clauses !== clauses
18479                 ? update(createCaseBlock(clauses), node)
18480                 : node;
18481         }
18482         function createNamespaceExportDeclaration(name) {
18483             var node = createBaseNamedDeclaration(259, undefined, undefined, name);
18484             node.transformFlags = 1;
18485             return node;
18486         }
18487         function updateNamespaceExportDeclaration(node, name) {
18488             return node.name !== name
18489                 ? update(createNamespaceExportDeclaration(name), node)
18490                 : node;
18491         }
18492         function createImportEqualsDeclaration(decorators, modifiers, name, moduleReference) {
18493             var node = createBaseNamedDeclaration(260, decorators, modifiers, name);
18494             node.moduleReference = moduleReference;
18495             node.transformFlags |= propagateChildFlags(node.moduleReference);
18496             if (!ts.isExternalModuleReference(node.moduleReference))
18497                 node.transformFlags |= 1;
18498             node.transformFlags &= ~8388608;
18499             return node;
18500         }
18501         function updateImportEqualsDeclaration(node, decorators, modifiers, name, moduleReference) {
18502             return node.decorators !== decorators
18503                 || node.modifiers !== modifiers
18504                 || node.name !== name
18505                 || node.moduleReference !== moduleReference
18506                 ? update(createImportEqualsDeclaration(decorators, modifiers, name, moduleReference), node)
18507                 : node;
18508         }
18509         function createImportDeclaration(decorators, modifiers, importClause, moduleSpecifier) {
18510             var node = createBaseDeclaration(261, decorators, modifiers);
18511             node.importClause = importClause;
18512             node.moduleSpecifier = moduleSpecifier;
18513             node.transformFlags |=
18514                 propagateChildFlags(node.importClause) |
18515                     propagateChildFlags(node.moduleSpecifier);
18516             node.transformFlags &= ~8388608;
18517             return node;
18518         }
18519         function updateImportDeclaration(node, decorators, modifiers, importClause, moduleSpecifier) {
18520             return node.decorators !== decorators
18521                 || node.modifiers !== modifiers
18522                 || node.importClause !== importClause
18523                 || node.moduleSpecifier !== moduleSpecifier
18524                 ? update(createImportDeclaration(decorators, modifiers, importClause, moduleSpecifier), node)
18525                 : node;
18526         }
18527         function createImportClause(isTypeOnly, name, namedBindings) {
18528             var node = createBaseNode(262);
18529             node.isTypeOnly = isTypeOnly;
18530             node.name = name;
18531             node.namedBindings = namedBindings;
18532             node.transformFlags |=
18533                 propagateChildFlags(node.name) |
18534                     propagateChildFlags(node.namedBindings);
18535             if (isTypeOnly) {
18536                 node.transformFlags |= 1;
18537             }
18538             node.transformFlags &= ~8388608;
18539             return node;
18540         }
18541         function updateImportClause(node, isTypeOnly, name, namedBindings) {
18542             return node.isTypeOnly !== isTypeOnly
18543                 || node.name !== name
18544                 || node.namedBindings !== namedBindings
18545                 ? update(createImportClause(isTypeOnly, name, namedBindings), node)
18546                 : node;
18547         }
18548         function createNamespaceImport(name) {
18549             var node = createBaseNode(263);
18550             node.name = name;
18551             node.transformFlags |= propagateChildFlags(node.name);
18552             node.transformFlags &= ~8388608;
18553             return node;
18554         }
18555         function updateNamespaceImport(node, name) {
18556             return node.name !== name
18557                 ? update(createNamespaceImport(name), node)
18558                 : node;
18559         }
18560         function createNamespaceExport(name) {
18561             var node = createBaseNode(269);
18562             node.name = name;
18563             node.transformFlags |=
18564                 propagateChildFlags(node.name) |
18565                     4;
18566             node.transformFlags &= ~8388608;
18567             return node;
18568         }
18569         function updateNamespaceExport(node, name) {
18570             return node.name !== name
18571                 ? update(createNamespaceExport(name), node)
18572                 : node;
18573         }
18574         function createNamedImports(elements) {
18575             var node = createBaseNode(264);
18576             node.elements = createNodeArray(elements);
18577             node.transformFlags |= propagateChildrenFlags(node.elements);
18578             node.transformFlags &= ~8388608;
18579             return node;
18580         }
18581         function updateNamedImports(node, elements) {
18582             return node.elements !== elements
18583                 ? update(createNamedImports(elements), node)
18584                 : node;
18585         }
18586         function createImportSpecifier(propertyName, name) {
18587             var node = createBaseNode(265);
18588             node.propertyName = propertyName;
18589             node.name = name;
18590             node.transformFlags |=
18591                 propagateChildFlags(node.propertyName) |
18592                     propagateChildFlags(node.name);
18593             node.transformFlags &= ~8388608;
18594             return node;
18595         }
18596         function updateImportSpecifier(node, propertyName, name) {
18597             return node.propertyName !== propertyName
18598                 || node.name !== name
18599                 ? update(createImportSpecifier(propertyName, name), node)
18600                 : node;
18601         }
18602         function createExportAssignment(decorators, modifiers, isExportEquals, expression) {
18603             var node = createBaseDeclaration(266, decorators, modifiers);
18604             node.isExportEquals = isExportEquals;
18605             node.expression = isExportEquals
18606                 ? parenthesizerRules().parenthesizeRightSideOfBinary(62, undefined, expression)
18607                 : parenthesizerRules().parenthesizeExpressionOfExportDefault(expression);
18608             node.transformFlags |= propagateChildFlags(node.expression);
18609             node.transformFlags &= ~8388608;
18610             return node;
18611         }
18612         function updateExportAssignment(node, decorators, modifiers, expression) {
18613             return node.decorators !== decorators
18614                 || node.modifiers !== modifiers
18615                 || node.expression !== expression
18616                 ? update(createExportAssignment(decorators, modifiers, node.isExportEquals, expression), node)
18617                 : node;
18618         }
18619         function createExportDeclaration(decorators, modifiers, isTypeOnly, exportClause, moduleSpecifier) {
18620             var node = createBaseDeclaration(267, decorators, modifiers);
18621             node.isTypeOnly = isTypeOnly;
18622             node.exportClause = exportClause;
18623             node.moduleSpecifier = moduleSpecifier;
18624             node.transformFlags |=
18625                 propagateChildFlags(node.exportClause) |
18626                     propagateChildFlags(node.moduleSpecifier);
18627             node.transformFlags &= ~8388608;
18628             return node;
18629         }
18630         function updateExportDeclaration(node, decorators, modifiers, isTypeOnly, exportClause, moduleSpecifier) {
18631             return node.decorators !== decorators
18632                 || node.modifiers !== modifiers
18633                 || node.isTypeOnly !== isTypeOnly
18634                 || node.exportClause !== exportClause
18635                 || node.moduleSpecifier !== moduleSpecifier
18636                 ? update(createExportDeclaration(decorators, modifiers, isTypeOnly, exportClause, moduleSpecifier), node)
18637                 : node;
18638         }
18639         function createNamedExports(elements) {
18640             var node = createBaseNode(268);
18641             node.elements = createNodeArray(elements);
18642             node.transformFlags |= propagateChildrenFlags(node.elements);
18643             node.transformFlags &= ~8388608;
18644             return node;
18645         }
18646         function updateNamedExports(node, elements) {
18647             return node.elements !== elements
18648                 ? update(createNamedExports(elements), node)
18649                 : node;
18650         }
18651         function createExportSpecifier(propertyName, name) {
18652             var node = createBaseNode(270);
18653             node.propertyName = asName(propertyName);
18654             node.name = asName(name);
18655             node.transformFlags |=
18656                 propagateChildFlags(node.propertyName) |
18657                     propagateChildFlags(node.name);
18658             node.transformFlags &= ~8388608;
18659             return node;
18660         }
18661         function updateExportSpecifier(node, propertyName, name) {
18662             return node.propertyName !== propertyName
18663                 || node.name !== name
18664                 ? update(createExportSpecifier(propertyName, name), node)
18665                 : node;
18666         }
18667         function createMissingDeclaration() {
18668             var node = createBaseDeclaration(271, undefined, undefined);
18669             return node;
18670         }
18671         function createExternalModuleReference(expression) {
18672             var node = createBaseNode(272);
18673             node.expression = expression;
18674             node.transformFlags |= propagateChildFlags(node.expression);
18675             node.transformFlags &= ~8388608;
18676             return node;
18677         }
18678         function updateExternalModuleReference(node, expression) {
18679             return node.expression !== expression
18680                 ? update(createExternalModuleReference(expression), node)
18681                 : node;
18682         }
18683         function createJSDocPrimaryTypeWorker(kind) {
18684             return createBaseNode(kind);
18685         }
18686         function createJSDocUnaryTypeWorker(kind, type) {
18687             var node = createBaseNode(kind);
18688             node.type = type;
18689             return node;
18690         }
18691         function updateJSDocUnaryTypeWorker(kind, node, type) {
18692             return node.type !== type
18693                 ? update(createJSDocUnaryTypeWorker(kind, type), node)
18694                 : node;
18695         }
18696         function createJSDocFunctionType(parameters, type) {
18697             var node = createBaseSignatureDeclaration(308, undefined, undefined, undefined, undefined, parameters, type);
18698             return node;
18699         }
18700         function updateJSDocFunctionType(node, parameters, type) {
18701             return node.parameters !== parameters
18702                 || node.type !== type
18703                 ? update(createJSDocFunctionType(parameters, type), node)
18704                 : node;
18705         }
18706         function createJSDocTypeLiteral(propertyTags, isArrayType) {
18707             if (isArrayType === void 0) { isArrayType = false; }
18708             var node = createBaseNode(312);
18709             node.jsDocPropertyTags = asNodeArray(propertyTags);
18710             node.isArrayType = isArrayType;
18711             return node;
18712         }
18713         function updateJSDocTypeLiteral(node, propertyTags, isArrayType) {
18714             return node.jsDocPropertyTags !== propertyTags
18715                 || node.isArrayType !== isArrayType
18716                 ? update(createJSDocTypeLiteral(propertyTags, isArrayType), node)
18717                 : node;
18718         }
18719         function createJSDocTypeExpression(type) {
18720             var node = createBaseNode(301);
18721             node.type = type;
18722             return node;
18723         }
18724         function updateJSDocTypeExpression(node, type) {
18725             return node.type !== type
18726                 ? update(createJSDocTypeExpression(type), node)
18727                 : node;
18728         }
18729         function createJSDocSignature(typeParameters, parameters, type) {
18730             var node = createBaseNode(313);
18731             node.typeParameters = asNodeArray(typeParameters);
18732             node.parameters = createNodeArray(parameters);
18733             node.type = type;
18734             return node;
18735         }
18736         function updateJSDocSignature(node, typeParameters, parameters, type) {
18737             return node.typeParameters !== typeParameters
18738                 || node.parameters !== parameters
18739                 || node.type !== type
18740                 ? update(createJSDocSignature(typeParameters, parameters, type), node)
18741                 : node;
18742         }
18743         function getDefaultTagName(node) {
18744             var defaultTagName = getDefaultTagNameForKind(node.kind);
18745             return node.tagName.escapedText === ts.escapeLeadingUnderscores(defaultTagName)
18746                 ? node.tagName
18747                 : createIdentifier(defaultTagName);
18748         }
18749         function createBaseJSDocTag(kind, tagName, comment) {
18750             var node = createBaseNode(kind);
18751             node.tagName = tagName;
18752             node.comment = comment;
18753             return node;
18754         }
18755         function createJSDocTemplateTag(tagName, constraint, typeParameters, comment) {
18756             var node = createBaseJSDocTag(330, tagName !== null && tagName !== void 0 ? tagName : createIdentifier("template"), comment);
18757             node.constraint = constraint;
18758             node.typeParameters = createNodeArray(typeParameters);
18759             return node;
18760         }
18761         function updateJSDocTemplateTag(node, tagName, constraint, typeParameters, comment) {
18762             if (tagName === void 0) { tagName = getDefaultTagName(node); }
18763             return node.tagName !== tagName
18764                 || node.constraint !== constraint
18765                 || node.typeParameters !== typeParameters
18766                 || node.comment !== comment
18767                 ? update(createJSDocTemplateTag(tagName, constraint, typeParameters, comment), node)
18768                 : node;
18769         }
18770         function createJSDocTypedefTag(tagName, typeExpression, fullName, comment) {
18771             var node = createBaseJSDocTag(331, tagName !== null && tagName !== void 0 ? tagName : createIdentifier("typedef"), comment);
18772             node.typeExpression = typeExpression;
18773             node.fullName = fullName;
18774             node.name = ts.getJSDocTypeAliasName(fullName);
18775             return node;
18776         }
18777         function updateJSDocTypedefTag(node, tagName, typeExpression, fullName, comment) {
18778             if (tagName === void 0) { tagName = getDefaultTagName(node); }
18779             return node.tagName !== tagName
18780                 || node.typeExpression !== typeExpression
18781                 || node.fullName !== fullName
18782                 || node.comment !== comment
18783                 ? update(createJSDocTypedefTag(tagName, typeExpression, fullName, comment), node)
18784                 : node;
18785         }
18786         function createJSDocParameterTag(tagName, name, isBracketed, typeExpression, isNameFirst, comment) {
18787             var node = createBaseJSDocTag(326, tagName !== null && tagName !== void 0 ? tagName : createIdentifier("param"), comment);
18788             node.typeExpression = typeExpression;
18789             node.name = name;
18790             node.isNameFirst = !!isNameFirst;
18791             node.isBracketed = isBracketed;
18792             return node;
18793         }
18794         function updateJSDocParameterTag(node, tagName, name, isBracketed, typeExpression, isNameFirst, comment) {
18795             if (tagName === void 0) { tagName = getDefaultTagName(node); }
18796             return node.tagName !== tagName
18797                 || node.name !== name
18798                 || node.isBracketed !== isBracketed
18799                 || node.typeExpression !== typeExpression
18800                 || node.isNameFirst !== isNameFirst
18801                 || node.comment !== comment
18802                 ? update(createJSDocParameterTag(tagName, name, isBracketed, typeExpression, isNameFirst, comment), node)
18803                 : node;
18804         }
18805         function createJSDocPropertyTag(tagName, name, isBracketed, typeExpression, isNameFirst, comment) {
18806             var node = createBaseJSDocTag(333, tagName !== null && tagName !== void 0 ? tagName : createIdentifier("prop"), comment);
18807             node.typeExpression = typeExpression;
18808             node.name = name;
18809             node.isNameFirst = !!isNameFirst;
18810             node.isBracketed = isBracketed;
18811             return node;
18812         }
18813         function updateJSDocPropertyTag(node, tagName, name, isBracketed, typeExpression, isNameFirst, comment) {
18814             if (tagName === void 0) { tagName = getDefaultTagName(node); }
18815             return node.tagName !== tagName
18816                 || node.name !== name
18817                 || node.isBracketed !== isBracketed
18818                 || node.typeExpression !== typeExpression
18819                 || node.isNameFirst !== isNameFirst
18820                 || node.comment !== comment
18821                 ? update(createJSDocPropertyTag(tagName, name, isBracketed, typeExpression, isNameFirst, comment), node)
18822                 : node;
18823         }
18824         function createJSDocCallbackTag(tagName, typeExpression, fullName, comment) {
18825             var node = createBaseJSDocTag(324, tagName !== null && tagName !== void 0 ? tagName : createIdentifier("callback"), comment);
18826             node.typeExpression = typeExpression;
18827             node.fullName = fullName;
18828             node.name = ts.getJSDocTypeAliasName(fullName);
18829             return node;
18830         }
18831         function updateJSDocCallbackTag(node, tagName, typeExpression, fullName, comment) {
18832             if (tagName === void 0) { tagName = getDefaultTagName(node); }
18833             return node.tagName !== tagName
18834                 || node.typeExpression !== typeExpression
18835                 || node.fullName !== fullName
18836                 || node.comment !== comment
18837                 ? update(createJSDocCallbackTag(tagName, typeExpression, fullName, comment), node)
18838                 : node;
18839         }
18840         function createJSDocAugmentsTag(tagName, className, comment) {
18841             var node = createBaseJSDocTag(315, tagName !== null && tagName !== void 0 ? tagName : createIdentifier("augments"), comment);
18842             node.class = className;
18843             return node;
18844         }
18845         function updateJSDocAugmentsTag(node, tagName, className, comment) {
18846             if (tagName === void 0) { tagName = getDefaultTagName(node); }
18847             return node.tagName !== tagName
18848                 || node.class !== className
18849                 || node.comment !== comment
18850                 ? update(createJSDocAugmentsTag(tagName, className, comment), node)
18851                 : node;
18852         }
18853         function createJSDocImplementsTag(tagName, className, comment) {
18854             var node = createBaseJSDocTag(316, tagName !== null && tagName !== void 0 ? tagName : createIdentifier("implements"), comment);
18855             node.class = className;
18856             return node;
18857         }
18858         function createJSDocSeeTag(tagName, name, comment) {
18859             var node = createBaseJSDocTag(332, tagName !== null && tagName !== void 0 ? tagName : createIdentifier("see"), comment);
18860             node.name = name;
18861             return node;
18862         }
18863         function updateJSDocSeeTag(node, tagName, name, comment) {
18864             return node.tagName !== tagName
18865                 || node.name !== name
18866                 || node.comment !== comment
18867                 ? update(createJSDocSeeTag(tagName, name, comment), node)
18868                 : node;
18869         }
18870         function createJSDocNameReference(name) {
18871             var node = createBaseNode(302);
18872             node.name = name;
18873             return node;
18874         }
18875         function updateJSDocNameReference(node, name) {
18876             return node.name !== name
18877                 ? update(createJSDocNameReference(name), node)
18878                 : node;
18879         }
18880         function updateJSDocImplementsTag(node, tagName, className, comment) {
18881             if (tagName === void 0) { tagName = getDefaultTagName(node); }
18882             return node.tagName !== tagName
18883                 || node.class !== className
18884                 || node.comment !== comment
18885                 ? update(createJSDocImplementsTag(tagName, className, comment), node)
18886                 : node;
18887         }
18888         function createJSDocSimpleTagWorker(kind, tagName, comment) {
18889             var node = createBaseJSDocTag(kind, tagName !== null && tagName !== void 0 ? tagName : createIdentifier(getDefaultTagNameForKind(kind)), comment);
18890             return node;
18891         }
18892         function updateJSDocSimpleTagWorker(kind, node, tagName, comment) {
18893             if (tagName === void 0) { tagName = getDefaultTagName(node); }
18894             return node.tagName !== tagName
18895                 || node.comment !== comment
18896                 ? update(createJSDocSimpleTagWorker(kind, tagName, comment), node) :
18897                 node;
18898         }
18899         function createJSDocTypeLikeTagWorker(kind, tagName, typeExpression, comment) {
18900             var node = createBaseJSDocTag(kind, tagName !== null && tagName !== void 0 ? tagName : createIdentifier(getDefaultTagNameForKind(kind)), comment);
18901             node.typeExpression = typeExpression;
18902             return node;
18903         }
18904         function updateJSDocTypeLikeTagWorker(kind, node, tagName, typeExpression, comment) {
18905             if (tagName === void 0) { tagName = getDefaultTagName(node); }
18906             return node.tagName !== tagName
18907                 || node.typeExpression !== typeExpression
18908                 || node.comment !== comment
18909                 ? update(createJSDocTypeLikeTagWorker(kind, tagName, typeExpression, comment), node)
18910                 : node;
18911         }
18912         function createJSDocUnknownTag(tagName, comment) {
18913             var node = createBaseJSDocTag(314, tagName, comment);
18914             return node;
18915         }
18916         function updateJSDocUnknownTag(node, tagName, comment) {
18917             return node.tagName !== tagName
18918                 || node.comment !== comment
18919                 ? update(createJSDocUnknownTag(tagName, comment), node)
18920                 : node;
18921         }
18922         function createJSDocComment(comment, tags) {
18923             var node = createBaseNode(311);
18924             node.comment = comment;
18925             node.tags = asNodeArray(tags);
18926             return node;
18927         }
18928         function updateJSDocComment(node, comment, tags) {
18929             return node.comment !== comment
18930                 || node.tags !== tags
18931                 ? update(createJSDocComment(comment, tags), node)
18932                 : node;
18933         }
18934         function createJsxElement(openingElement, children, closingElement) {
18935             var node = createBaseNode(273);
18936             node.openingElement = openingElement;
18937             node.children = createNodeArray(children);
18938             node.closingElement = closingElement;
18939             node.transformFlags |=
18940                 propagateChildFlags(node.openingElement) |
18941                     propagateChildrenFlags(node.children) |
18942                     propagateChildFlags(node.closingElement) |
18943                     2;
18944             return node;
18945         }
18946         function updateJsxElement(node, openingElement, children, closingElement) {
18947             return node.openingElement !== openingElement
18948                 || node.children !== children
18949                 || node.closingElement !== closingElement
18950                 ? update(createJsxElement(openingElement, children, closingElement), node)
18951                 : node;
18952         }
18953         function createJsxSelfClosingElement(tagName, typeArguments, attributes) {
18954             var node = createBaseNode(274);
18955             node.tagName = tagName;
18956             node.typeArguments = asNodeArray(typeArguments);
18957             node.attributes = attributes;
18958             node.transformFlags |=
18959                 propagateChildFlags(node.tagName) |
18960                     propagateChildrenFlags(node.typeArguments) |
18961                     propagateChildFlags(node.attributes) |
18962                     2;
18963             if (node.typeArguments) {
18964                 node.transformFlags |= 1;
18965             }
18966             return node;
18967         }
18968         function updateJsxSelfClosingElement(node, tagName, typeArguments, attributes) {
18969             return node.tagName !== tagName
18970                 || node.typeArguments !== typeArguments
18971                 || node.attributes !== attributes
18972                 ? update(createJsxSelfClosingElement(tagName, typeArguments, attributes), node)
18973                 : node;
18974         }
18975         function createJsxOpeningElement(tagName, typeArguments, attributes) {
18976             var node = createBaseNode(275);
18977             node.tagName = tagName;
18978             node.typeArguments = asNodeArray(typeArguments);
18979             node.attributes = attributes;
18980             node.transformFlags |=
18981                 propagateChildFlags(node.tagName) |
18982                     propagateChildrenFlags(node.typeArguments) |
18983                     propagateChildFlags(node.attributes) |
18984                     2;
18985             if (typeArguments) {
18986                 node.transformFlags |= 1;
18987             }
18988             return node;
18989         }
18990         function updateJsxOpeningElement(node, tagName, typeArguments, attributes) {
18991             return node.tagName !== tagName
18992                 || node.typeArguments !== typeArguments
18993                 || node.attributes !== attributes
18994                 ? update(createJsxOpeningElement(tagName, typeArguments, attributes), node)
18995                 : node;
18996         }
18997         function createJsxClosingElement(tagName) {
18998             var node = createBaseNode(276);
18999             node.tagName = tagName;
19000             node.transformFlags |=
19001                 propagateChildFlags(node.tagName) |
19002                     2;
19003             return node;
19004         }
19005         function updateJsxClosingElement(node, tagName) {
19006             return node.tagName !== tagName
19007                 ? update(createJsxClosingElement(tagName), node)
19008                 : node;
19009         }
19010         function createJsxFragment(openingFragment, children, closingFragment) {
19011             var node = createBaseNode(277);
19012             node.openingFragment = openingFragment;
19013             node.children = createNodeArray(children);
19014             node.closingFragment = closingFragment;
19015             node.transformFlags |=
19016                 propagateChildFlags(node.openingFragment) |
19017                     propagateChildrenFlags(node.children) |
19018                     propagateChildFlags(node.closingFragment) |
19019                     2;
19020             return node;
19021         }
19022         function updateJsxFragment(node, openingFragment, children, closingFragment) {
19023             return node.openingFragment !== openingFragment
19024                 || node.children !== children
19025                 || node.closingFragment !== closingFragment
19026                 ? update(createJsxFragment(openingFragment, children, closingFragment), node)
19027                 : node;
19028         }
19029         function createJsxText(text, containsOnlyTriviaWhiteSpaces) {
19030             var node = createBaseNode(11);
19031             node.text = text;
19032             node.containsOnlyTriviaWhiteSpaces = !!containsOnlyTriviaWhiteSpaces;
19033             node.transformFlags |= 2;
19034             return node;
19035         }
19036         function updateJsxText(node, text, containsOnlyTriviaWhiteSpaces) {
19037             return node.text !== text
19038                 || node.containsOnlyTriviaWhiteSpaces !== containsOnlyTriviaWhiteSpaces
19039                 ? update(createJsxText(text, containsOnlyTriviaWhiteSpaces), node)
19040                 : node;
19041         }
19042         function createJsxOpeningFragment() {
19043             var node = createBaseNode(278);
19044             node.transformFlags |= 2;
19045             return node;
19046         }
19047         function createJsxJsxClosingFragment() {
19048             var node = createBaseNode(279);
19049             node.transformFlags |= 2;
19050             return node;
19051         }
19052         function createJsxAttribute(name, initializer) {
19053             var node = createBaseNode(280);
19054             node.name = name;
19055             node.initializer = initializer;
19056             node.transformFlags |=
19057                 propagateChildFlags(node.name) |
19058                     propagateChildFlags(node.initializer) |
19059                     2;
19060             return node;
19061         }
19062         function updateJsxAttribute(node, name, initializer) {
19063             return node.name !== name
19064                 || node.initializer !== initializer
19065                 ? update(createJsxAttribute(name, initializer), node)
19066                 : node;
19067         }
19068         function createJsxAttributes(properties) {
19069             var node = createBaseNode(281);
19070             node.properties = createNodeArray(properties);
19071             node.transformFlags |=
19072                 propagateChildrenFlags(node.properties) |
19073                     2;
19074             return node;
19075         }
19076         function updateJsxAttributes(node, properties) {
19077             return node.properties !== properties
19078                 ? update(createJsxAttributes(properties), node)
19079                 : node;
19080         }
19081         function createJsxSpreadAttribute(expression) {
19082             var node = createBaseNode(282);
19083             node.expression = expression;
19084             node.transformFlags |=
19085                 propagateChildFlags(node.expression) |
19086                     2;
19087             return node;
19088         }
19089         function updateJsxSpreadAttribute(node, expression) {
19090             return node.expression !== expression
19091                 ? update(createJsxSpreadAttribute(expression), node)
19092                 : node;
19093         }
19094         function createJsxExpression(dotDotDotToken, expression) {
19095             var node = createBaseNode(283);
19096             node.dotDotDotToken = dotDotDotToken;
19097             node.expression = expression;
19098             node.transformFlags |=
19099                 propagateChildFlags(node.dotDotDotToken) |
19100                     propagateChildFlags(node.expression) |
19101                     2;
19102             return node;
19103         }
19104         function updateJsxExpression(node, expression) {
19105             return node.expression !== expression
19106                 ? update(createJsxExpression(node.dotDotDotToken, expression), node)
19107                 : node;
19108         }
19109         function createCaseClause(expression, statements) {
19110             var node = createBaseNode(284);
19111             node.expression = parenthesizerRules().parenthesizeExpressionForDisallowedComma(expression);
19112             node.statements = createNodeArray(statements);
19113             node.transformFlags |=
19114                 propagateChildFlags(node.expression) |
19115                     propagateChildrenFlags(node.statements);
19116             return node;
19117         }
19118         function updateCaseClause(node, expression, statements) {
19119             return node.expression !== expression
19120                 || node.statements !== statements
19121                 ? update(createCaseClause(expression, statements), node)
19122                 : node;
19123         }
19124         function createDefaultClause(statements) {
19125             var node = createBaseNode(285);
19126             node.statements = createNodeArray(statements);
19127             node.transformFlags = propagateChildrenFlags(node.statements);
19128             return node;
19129         }
19130         function updateDefaultClause(node, statements) {
19131             return node.statements !== statements
19132                 ? update(createDefaultClause(statements), node)
19133                 : node;
19134         }
19135         function createHeritageClause(token, types) {
19136             var node = createBaseNode(286);
19137             node.token = token;
19138             node.types = createNodeArray(types);
19139             node.transformFlags |= propagateChildrenFlags(node.types);
19140             switch (token) {
19141                 case 93:
19142                     node.transformFlags |= 256;
19143                     break;
19144                 case 116:
19145                     node.transformFlags |= 1;
19146                     break;
19147                 default:
19148                     return ts.Debug.assertNever(token);
19149             }
19150             return node;
19151         }
19152         function updateHeritageClause(node, types) {
19153             return node.types !== types
19154                 ? update(createHeritageClause(node.token, types), node)
19155                 : node;
19156         }
19157         function createCatchClause(variableDeclaration, block) {
19158             var node = createBaseNode(287);
19159             variableDeclaration = !ts.isString(variableDeclaration) ? variableDeclaration : createVariableDeclaration(variableDeclaration, undefined, undefined, undefined);
19160             node.variableDeclaration = variableDeclaration;
19161             node.block = block;
19162             node.transformFlags |=
19163                 propagateChildFlags(node.variableDeclaration) |
19164                     propagateChildFlags(node.block);
19165             if (!variableDeclaration)
19166                 node.transformFlags |= 16;
19167             return node;
19168         }
19169         function updateCatchClause(node, variableDeclaration, block) {
19170             return node.variableDeclaration !== variableDeclaration
19171                 || node.block !== block
19172                 ? update(createCatchClause(variableDeclaration, block), node)
19173                 : node;
19174         }
19175         function createPropertyAssignment(name, initializer) {
19176             var node = createBaseNamedDeclaration(288, undefined, undefined, name);
19177             node.initializer = parenthesizerRules().parenthesizeExpressionForDisallowedComma(initializer);
19178             node.transformFlags |=
19179                 propagateChildFlags(node.name) |
19180                     propagateChildFlags(node.initializer);
19181             return node;
19182         }
19183         function finishUpdatePropertyAssignment(updated, original) {
19184             if (original.decorators)
19185                 updated.decorators = original.decorators;
19186             if (original.modifiers)
19187                 updated.modifiers = original.modifiers;
19188             if (original.questionToken)
19189                 updated.questionToken = original.questionToken;
19190             if (original.exclamationToken)
19191                 updated.exclamationToken = original.exclamationToken;
19192             return update(updated, original);
19193         }
19194         function updatePropertyAssignment(node, name, initializer) {
19195             return node.name !== name
19196                 || node.initializer !== initializer
19197                 ? finishUpdatePropertyAssignment(createPropertyAssignment(name, initializer), node)
19198                 : node;
19199         }
19200         function createShorthandPropertyAssignment(name, objectAssignmentInitializer) {
19201             var node = createBaseNamedDeclaration(289, undefined, undefined, name);
19202             node.objectAssignmentInitializer = objectAssignmentInitializer && parenthesizerRules().parenthesizeExpressionForDisallowedComma(objectAssignmentInitializer);
19203             node.transformFlags |=
19204                 propagateChildFlags(node.objectAssignmentInitializer) |
19205                     256;
19206             return node;
19207         }
19208         function finishUpdateShorthandPropertyAssignment(updated, original) {
19209             if (original.decorators)
19210                 updated.decorators = original.decorators;
19211             if (original.modifiers)
19212                 updated.modifiers = original.modifiers;
19213             if (original.equalsToken)
19214                 updated.equalsToken = original.equalsToken;
19215             if (original.questionToken)
19216                 updated.questionToken = original.questionToken;
19217             if (original.exclamationToken)
19218                 updated.exclamationToken = original.exclamationToken;
19219             return update(updated, original);
19220         }
19221         function updateShorthandPropertyAssignment(node, name, objectAssignmentInitializer) {
19222             return node.name !== name
19223                 || node.objectAssignmentInitializer !== objectAssignmentInitializer
19224                 ? finishUpdateShorthandPropertyAssignment(createShorthandPropertyAssignment(name, objectAssignmentInitializer), node)
19225                 : node;
19226         }
19227         function createSpreadAssignment(expression) {
19228             var node = createBaseNode(290);
19229             node.expression = parenthesizerRules().parenthesizeExpressionForDisallowedComma(expression);
19230             node.transformFlags |=
19231                 propagateChildFlags(node.expression) |
19232                     32 |
19233                     16384;
19234             return node;
19235         }
19236         function updateSpreadAssignment(node, expression) {
19237             return node.expression !== expression
19238                 ? update(createSpreadAssignment(expression), node)
19239                 : node;
19240         }
19241         function createEnumMember(name, initializer) {
19242             var node = createBaseNode(291);
19243             node.name = asName(name);
19244             node.initializer = initializer && parenthesizerRules().parenthesizeExpressionForDisallowedComma(initializer);
19245             node.transformFlags |=
19246                 propagateChildFlags(node.name) |
19247                     propagateChildFlags(node.initializer) |
19248                     1;
19249             return node;
19250         }
19251         function updateEnumMember(node, name, initializer) {
19252             return node.name !== name
19253                 || node.initializer !== initializer
19254                 ? update(createEnumMember(name, initializer), node)
19255                 : node;
19256         }
19257         function createSourceFile(statements, endOfFileToken, flags) {
19258             var node = baseFactory.createBaseSourceFileNode(297);
19259             node.statements = createNodeArray(statements);
19260             node.endOfFileToken = endOfFileToken;
19261             node.flags |= flags;
19262             node.fileName = "";
19263             node.text = "";
19264             node.languageVersion = 0;
19265             node.languageVariant = 0;
19266             node.scriptKind = 0;
19267             node.isDeclarationFile = false;
19268             node.hasNoDefaultLib = false;
19269             node.transformFlags |=
19270                 propagateChildrenFlags(node.statements) |
19271                     propagateChildFlags(node.endOfFileToken);
19272             return node;
19273         }
19274         function cloneSourceFileWithChanges(source, statements, isDeclarationFile, referencedFiles, typeReferences, hasNoDefaultLib, libReferences) {
19275             var node = baseFactory.createBaseSourceFileNode(297);
19276             for (var p in source) {
19277                 if (p === "emitNode" || ts.hasProperty(node, p) || !ts.hasProperty(source, p))
19278                     continue;
19279                 node[p] = source[p];
19280             }
19281             node.flags |= source.flags;
19282             node.statements = createNodeArray(statements);
19283             node.endOfFileToken = source.endOfFileToken;
19284             node.isDeclarationFile = isDeclarationFile;
19285             node.referencedFiles = referencedFiles;
19286             node.typeReferenceDirectives = typeReferences;
19287             node.hasNoDefaultLib = hasNoDefaultLib;
19288             node.libReferenceDirectives = libReferences;
19289             node.transformFlags =
19290                 propagateChildrenFlags(node.statements) |
19291                     propagateChildFlags(node.endOfFileToken);
19292             return node;
19293         }
19294         function updateSourceFile(node, statements, isDeclarationFile, referencedFiles, typeReferenceDirectives, hasNoDefaultLib, libReferenceDirectives) {
19295             if (isDeclarationFile === void 0) { isDeclarationFile = node.isDeclarationFile; }
19296             if (referencedFiles === void 0) { referencedFiles = node.referencedFiles; }
19297             if (typeReferenceDirectives === void 0) { typeReferenceDirectives = node.typeReferenceDirectives; }
19298             if (hasNoDefaultLib === void 0) { hasNoDefaultLib = node.hasNoDefaultLib; }
19299             if (libReferenceDirectives === void 0) { libReferenceDirectives = node.libReferenceDirectives; }
19300             return node.statements !== statements
19301                 || node.isDeclarationFile !== isDeclarationFile
19302                 || node.referencedFiles !== referencedFiles
19303                 || node.typeReferenceDirectives !== typeReferenceDirectives
19304                 || node.hasNoDefaultLib !== hasNoDefaultLib
19305                 || node.libReferenceDirectives !== libReferenceDirectives
19306                 ? update(cloneSourceFileWithChanges(node, statements, isDeclarationFile, referencedFiles, typeReferenceDirectives, hasNoDefaultLib, libReferenceDirectives), node)
19307                 : node;
19308         }
19309         function createBundle(sourceFiles, prepends) {
19310             if (prepends === void 0) { prepends = ts.emptyArray; }
19311             var node = createBaseNode(298);
19312             node.prepends = prepends;
19313             node.sourceFiles = sourceFiles;
19314             return node;
19315         }
19316         function updateBundle(node, sourceFiles, prepends) {
19317             if (prepends === void 0) { prepends = ts.emptyArray; }
19318             return node.sourceFiles !== sourceFiles
19319                 || node.prepends !== prepends
19320                 ? update(createBundle(sourceFiles, prepends), node)
19321                 : node;
19322         }
19323         function createUnparsedSource(prologues, syntheticReferences, texts) {
19324             var node = createBaseNode(299);
19325             node.prologues = prologues;
19326             node.syntheticReferences = syntheticReferences;
19327             node.texts = texts;
19328             node.fileName = "";
19329             node.text = "";
19330             node.referencedFiles = ts.emptyArray;
19331             node.libReferenceDirectives = ts.emptyArray;
19332             node.getLineAndCharacterOfPosition = function (pos) { return ts.getLineAndCharacterOfPosition(node, pos); };
19333             return node;
19334         }
19335         function createBaseUnparsedNode(kind, data) {
19336             var node = createBaseNode(kind);
19337             node.data = data;
19338             return node;
19339         }
19340         function createUnparsedPrologue(data) {
19341             return createBaseUnparsedNode(292, data);
19342         }
19343         function createUnparsedPrepend(data, texts) {
19344             var node = createBaseUnparsedNode(293, data);
19345             node.texts = texts;
19346             return node;
19347         }
19348         function createUnparsedTextLike(data, internal) {
19349             return createBaseUnparsedNode(internal ? 295 : 294, data);
19350         }
19351         function createUnparsedSyntheticReference(section) {
19352             var node = createBaseNode(296);
19353             node.data = section.data;
19354             node.section = section;
19355             return node;
19356         }
19357         function createInputFiles() {
19358             var node = createBaseNode(300);
19359             node.javascriptText = "";
19360             node.declarationText = "";
19361             return node;
19362         }
19363         function createSyntheticExpression(type, isSpread, tupleNameSource) {
19364             if (isSpread === void 0) { isSpread = false; }
19365             var node = createBaseNode(227);
19366             node.type = type;
19367             node.isSpread = isSpread;
19368             node.tupleNameSource = tupleNameSource;
19369             return node;
19370         }
19371         function createSyntaxList(children) {
19372             var node = createBaseNode(334);
19373             node._children = children;
19374             return node;
19375         }
19376         function createNotEmittedStatement(original) {
19377             var node = createBaseNode(335);
19378             node.original = original;
19379             ts.setTextRange(node, original);
19380             return node;
19381         }
19382         function createPartiallyEmittedExpression(expression, original) {
19383             var node = createBaseNode(336);
19384             node.expression = expression;
19385             node.original = original;
19386             node.transformFlags |=
19387                 propagateChildFlags(node.expression) |
19388                     1;
19389             ts.setTextRange(node, original);
19390             return node;
19391         }
19392         function updatePartiallyEmittedExpression(node, expression) {
19393             return node.expression !== expression
19394                 ? update(createPartiallyEmittedExpression(expression, node.original), node)
19395                 : node;
19396         }
19397         function flattenCommaElements(node) {
19398             if (ts.nodeIsSynthesized(node) && !ts.isParseTreeNode(node) && !node.original && !node.emitNode && !node.id) {
19399                 if (ts.isCommaListExpression(node)) {
19400                     return node.elements;
19401                 }
19402                 if (ts.isBinaryExpression(node) && ts.isCommaToken(node.operatorToken)) {
19403                     return [node.left, node.right];
19404                 }
19405             }
19406             return node;
19407         }
19408         function createCommaListExpression(elements) {
19409             var node = createBaseNode(337);
19410             node.elements = createNodeArray(ts.sameFlatMap(elements, flattenCommaElements));
19411             node.transformFlags |= propagateChildrenFlags(node.elements);
19412             return node;
19413         }
19414         function updateCommaListExpression(node, elements) {
19415             return node.elements !== elements
19416                 ? update(createCommaListExpression(elements), node)
19417                 : node;
19418         }
19419         function createEndOfDeclarationMarker(original) {
19420             var node = createBaseNode(339);
19421             node.emitNode = {};
19422             node.original = original;
19423             return node;
19424         }
19425         function createMergeDeclarationMarker(original) {
19426             var node = createBaseNode(338);
19427             node.emitNode = {};
19428             node.original = original;
19429             return node;
19430         }
19431         function createSyntheticReferenceExpression(expression, thisArg) {
19432             var node = createBaseNode(340);
19433             node.expression = expression;
19434             node.thisArg = thisArg;
19435             node.transformFlags |=
19436                 propagateChildFlags(node.expression) |
19437                     propagateChildFlags(node.thisArg);
19438             return node;
19439         }
19440         function updateSyntheticReferenceExpression(node, expression, thisArg) {
19441             return node.expression !== expression
19442                 || node.thisArg !== thisArg
19443                 ? update(createSyntheticReferenceExpression(expression, thisArg), node)
19444                 : node;
19445         }
19446         function cloneNode(node) {
19447             if (node === undefined) {
19448                 return node;
19449             }
19450             var clone = ts.isSourceFile(node) ? baseFactory.createBaseSourceFileNode(297) :
19451                 ts.isIdentifier(node) ? baseFactory.createBaseIdentifierNode(78) :
19452                     ts.isPrivateIdentifier(node) ? baseFactory.createBasePrivateIdentifierNode(79) :
19453                         !ts.isNodeKind(node.kind) ? baseFactory.createBaseTokenNode(node.kind) :
19454                             baseFactory.createBaseNode(node.kind);
19455             clone.flags |= (node.flags & ~8);
19456             clone.transformFlags = node.transformFlags;
19457             setOriginalNode(clone, node);
19458             for (var key in node) {
19459                 if (clone.hasOwnProperty(key) || !node.hasOwnProperty(key)) {
19460                     continue;
19461                 }
19462                 clone[key] = node[key];
19463             }
19464             return clone;
19465         }
19466         function createImmediatelyInvokedFunctionExpression(statements, param, paramValue) {
19467             return createCallExpression(createFunctionExpression(undefined, undefined, undefined, undefined, param ? [param] : [], undefined, createBlock(statements, true)), undefined, paramValue ? [paramValue] : []);
19468         }
19469         function createImmediatelyInvokedArrowFunction(statements, param, paramValue) {
19470             return createCallExpression(createArrowFunction(undefined, undefined, param ? [param] : [], undefined, undefined, createBlock(statements, true)), undefined, paramValue ? [paramValue] : []);
19471         }
19472         function createVoidZero() {
19473             return createVoidExpression(createNumericLiteral("0"));
19474         }
19475         function createExportDefault(expression) {
19476             return createExportAssignment(undefined, undefined, false, expression);
19477         }
19478         function createExternalModuleExport(exportName) {
19479             return createExportDeclaration(undefined, undefined, false, createNamedExports([
19480                 createExportSpecifier(undefined, exportName)
19481             ]));
19482         }
19483         function createTypeCheck(value, tag) {
19484             return tag === "undefined"
19485                 ? factory.createStrictEquality(value, createVoidZero())
19486                 : factory.createStrictEquality(createTypeOfExpression(value), createStringLiteral(tag));
19487         }
19488         function createMethodCall(object, methodName, argumentsList) {
19489             return createCallExpression(createPropertyAccessExpression(object, methodName), undefined, argumentsList);
19490         }
19491         function createFunctionBindCall(target, thisArg, argumentsList) {
19492             return createMethodCall(target, "bind", __spreadArrays([thisArg], argumentsList));
19493         }
19494         function createFunctionCallCall(target, thisArg, argumentsList) {
19495             return createMethodCall(target, "call", __spreadArrays([thisArg], argumentsList));
19496         }
19497         function createFunctionApplyCall(target, thisArg, argumentsExpression) {
19498             return createMethodCall(target, "apply", [thisArg, argumentsExpression]);
19499         }
19500         function createGlobalMethodCall(globalObjectName, methodName, argumentsList) {
19501             return createMethodCall(createIdentifier(globalObjectName), methodName, argumentsList);
19502         }
19503         function createArraySliceCall(array, start) {
19504             return createMethodCall(array, "slice", start === undefined ? [] : [asExpression(start)]);
19505         }
19506         function createArrayConcatCall(array, argumentsList) {
19507             return createMethodCall(array, "concat", argumentsList);
19508         }
19509         function createObjectDefinePropertyCall(target, propertyName, attributes) {
19510             return createGlobalMethodCall("Object", "defineProperty", [target, asExpression(propertyName), attributes]);
19511         }
19512         function tryAddPropertyAssignment(properties, propertyName, expression) {
19513             if (expression) {
19514                 properties.push(createPropertyAssignment(propertyName, expression));
19515                 return true;
19516             }
19517             return false;
19518         }
19519         function createPropertyDescriptor(attributes, singleLine) {
19520             var properties = [];
19521             tryAddPropertyAssignment(properties, "enumerable", asExpression(attributes.enumerable));
19522             tryAddPropertyAssignment(properties, "configurable", asExpression(attributes.configurable));
19523             var isData = tryAddPropertyAssignment(properties, "writable", asExpression(attributes.writable));
19524             isData = tryAddPropertyAssignment(properties, "value", attributes.value) || isData;
19525             var isAccessor = tryAddPropertyAssignment(properties, "get", attributes.get);
19526             isAccessor = tryAddPropertyAssignment(properties, "set", attributes.set) || isAccessor;
19527             ts.Debug.assert(!(isData && isAccessor), "A PropertyDescriptor may not be both an accessor descriptor and a data descriptor.");
19528             return createObjectLiteralExpression(properties, !singleLine);
19529         }
19530         function updateOuterExpression(outerExpression, expression) {
19531             switch (outerExpression.kind) {
19532                 case 207: return updateParenthesizedExpression(outerExpression, expression);
19533                 case 206: return updateTypeAssertion(outerExpression, outerExpression.type, expression);
19534                 case 224: return updateAsExpression(outerExpression, expression, outerExpression.type);
19535                 case 225: return updateNonNullExpression(outerExpression, expression);
19536                 case 336: return updatePartiallyEmittedExpression(outerExpression, expression);
19537             }
19538         }
19539         function isIgnorableParen(node) {
19540             return ts.isParenthesizedExpression(node)
19541                 && ts.nodeIsSynthesized(node)
19542                 && ts.nodeIsSynthesized(ts.getSourceMapRange(node))
19543                 && ts.nodeIsSynthesized(ts.getCommentRange(node))
19544                 && !ts.some(ts.getSyntheticLeadingComments(node))
19545                 && !ts.some(ts.getSyntheticTrailingComments(node));
19546         }
19547         function restoreOuterExpressions(outerExpression, innerExpression, kinds) {
19548             if (kinds === void 0) { kinds = 15; }
19549             if (outerExpression && ts.isOuterExpression(outerExpression, kinds) && !isIgnorableParen(outerExpression)) {
19550                 return updateOuterExpression(outerExpression, restoreOuterExpressions(outerExpression.expression, innerExpression));
19551             }
19552             return innerExpression;
19553         }
19554         function restoreEnclosingLabel(node, outermostLabeledStatement, afterRestoreLabelCallback) {
19555             if (!outermostLabeledStatement) {
19556                 return node;
19557             }
19558             var updated = updateLabeledStatement(outermostLabeledStatement, outermostLabeledStatement.label, ts.isLabeledStatement(outermostLabeledStatement.statement)
19559                 ? restoreEnclosingLabel(node, outermostLabeledStatement.statement)
19560                 : node);
19561             if (afterRestoreLabelCallback) {
19562                 afterRestoreLabelCallback(outermostLabeledStatement);
19563             }
19564             return updated;
19565         }
19566         function shouldBeCapturedInTempVariable(node, cacheIdentifiers) {
19567             var target = ts.skipParentheses(node);
19568             switch (target.kind) {
19569                 case 78:
19570                     return cacheIdentifiers;
19571                 case 107:
19572                 case 8:
19573                 case 9:
19574                 case 10:
19575                     return false;
19576                 case 199:
19577                     var elements = target.elements;
19578                     if (elements.length === 0) {
19579                         return false;
19580                     }
19581                     return true;
19582                 case 200:
19583                     return target.properties.length > 0;
19584                 default:
19585                     return true;
19586             }
19587         }
19588         function createCallBinding(expression, recordTempVariable, languageVersion, cacheIdentifiers) {
19589             if (cacheIdentifiers === void 0) { cacheIdentifiers = false; }
19590             var callee = ts.skipOuterExpressions(expression, 15);
19591             var thisArg;
19592             var target;
19593             if (ts.isSuperProperty(callee)) {
19594                 thisArg = createThis();
19595                 target = callee;
19596             }
19597             else if (ts.isSuperKeyword(callee)) {
19598                 thisArg = createThis();
19599                 target = languageVersion !== undefined && languageVersion < 2
19600                     ? ts.setTextRange(createIdentifier("_super"), callee)
19601                     : callee;
19602             }
19603             else if (ts.getEmitFlags(callee) & 4096) {
19604                 thisArg = createVoidZero();
19605                 target = parenthesizerRules().parenthesizeLeftSideOfAccess(callee);
19606             }
19607             else if (ts.isPropertyAccessExpression(callee)) {
19608                 if (shouldBeCapturedInTempVariable(callee.expression, cacheIdentifiers)) {
19609                     thisArg = createTempVariable(recordTempVariable);
19610                     target = createPropertyAccessExpression(ts.setTextRange(factory.createAssignment(thisArg, callee.expression), callee.expression), callee.name);
19611                     ts.setTextRange(target, callee);
19612                 }
19613                 else {
19614                     thisArg = callee.expression;
19615                     target = callee;
19616                 }
19617             }
19618             else if (ts.isElementAccessExpression(callee)) {
19619                 if (shouldBeCapturedInTempVariable(callee.expression, cacheIdentifiers)) {
19620                     thisArg = createTempVariable(recordTempVariable);
19621                     target = createElementAccessExpression(ts.setTextRange(factory.createAssignment(thisArg, callee.expression), callee.expression), callee.argumentExpression);
19622                     ts.setTextRange(target, callee);
19623                 }
19624                 else {
19625                     thisArg = callee.expression;
19626                     target = callee;
19627                 }
19628             }
19629             else {
19630                 thisArg = createVoidZero();
19631                 target = parenthesizerRules().parenthesizeLeftSideOfAccess(expression);
19632             }
19633             return { target: target, thisArg: thisArg };
19634         }
19635         function inlineExpressions(expressions) {
19636             return expressions.length > 10
19637                 ? createCommaListExpression(expressions)
19638                 : ts.reduceLeft(expressions, factory.createComma);
19639         }
19640         function getName(node, allowComments, allowSourceMaps, emitFlags) {
19641             if (emitFlags === void 0) { emitFlags = 0; }
19642             var nodeName = ts.getNameOfDeclaration(node);
19643             if (nodeName && ts.isIdentifier(nodeName) && !ts.isGeneratedIdentifier(nodeName)) {
19644                 var name = ts.setParent(ts.setTextRange(cloneNode(nodeName), nodeName), nodeName.parent);
19645                 emitFlags |= ts.getEmitFlags(nodeName);
19646                 if (!allowSourceMaps)
19647                     emitFlags |= 48;
19648                 if (!allowComments)
19649                     emitFlags |= 1536;
19650                 if (emitFlags)
19651                     ts.setEmitFlags(name, emitFlags);
19652                 return name;
19653             }
19654             return getGeneratedNameForNode(node);
19655         }
19656         function getInternalName(node, allowComments, allowSourceMaps) {
19657             return getName(node, allowComments, allowSourceMaps, 16384 | 32768);
19658         }
19659         function getLocalName(node, allowComments, allowSourceMaps) {
19660             return getName(node, allowComments, allowSourceMaps, 16384);
19661         }
19662         function getExportName(node, allowComments, allowSourceMaps) {
19663             return getName(node, allowComments, allowSourceMaps, 8192);
19664         }
19665         function getDeclarationName(node, allowComments, allowSourceMaps) {
19666             return getName(node, allowComments, allowSourceMaps);
19667         }
19668         function getNamespaceMemberName(ns, name, allowComments, allowSourceMaps) {
19669             var qualifiedName = createPropertyAccessExpression(ns, ts.nodeIsSynthesized(name) ? name : cloneNode(name));
19670             ts.setTextRange(qualifiedName, name);
19671             var emitFlags = 0;
19672             if (!allowSourceMaps)
19673                 emitFlags |= 48;
19674             if (!allowComments)
19675                 emitFlags |= 1536;
19676             if (emitFlags)
19677                 ts.setEmitFlags(qualifiedName, emitFlags);
19678             return qualifiedName;
19679         }
19680         function getExternalModuleOrNamespaceExportName(ns, node, allowComments, allowSourceMaps) {
19681             if (ns && ts.hasSyntacticModifier(node, 1)) {
19682                 return getNamespaceMemberName(ns, getName(node), allowComments, allowSourceMaps);
19683             }
19684             return getExportName(node, allowComments, allowSourceMaps);
19685         }
19686         function copyPrologue(source, target, ensureUseStrict, visitor) {
19687             var offset = copyStandardPrologue(source, target, ensureUseStrict);
19688             return copyCustomPrologue(source, target, offset, visitor);
19689         }
19690         function isUseStrictPrologue(node) {
19691             return ts.isStringLiteral(node.expression) && node.expression.text === "use strict";
19692         }
19693         function createUseStrictPrologue() {
19694             return ts.startOnNewLine(createExpressionStatement(createStringLiteral("use strict")));
19695         }
19696         function copyStandardPrologue(source, target, ensureUseStrict) {
19697             ts.Debug.assert(target.length === 0, "Prologue directives should be at the first statement in the target statements array");
19698             var foundUseStrict = false;
19699             var statementOffset = 0;
19700             var numStatements = source.length;
19701             while (statementOffset < numStatements) {
19702                 var statement = source[statementOffset];
19703                 if (ts.isPrologueDirective(statement)) {
19704                     if (isUseStrictPrologue(statement)) {
19705                         foundUseStrict = true;
19706                     }
19707                     target.push(statement);
19708                 }
19709                 else {
19710                     break;
19711                 }
19712                 statementOffset++;
19713             }
19714             if (ensureUseStrict && !foundUseStrict) {
19715                 target.push(createUseStrictPrologue());
19716             }
19717             return statementOffset;
19718         }
19719         function copyCustomPrologue(source, target, statementOffset, visitor, filter) {
19720             if (filter === void 0) { filter = ts.returnTrue; }
19721             var numStatements = source.length;
19722             while (statementOffset !== undefined && statementOffset < numStatements) {
19723                 var statement = source[statementOffset];
19724                 if (ts.getEmitFlags(statement) & 1048576 && filter(statement)) {
19725                     ts.append(target, visitor ? ts.visitNode(statement, visitor, ts.isStatement) : statement);
19726                 }
19727                 else {
19728                     break;
19729                 }
19730                 statementOffset++;
19731             }
19732             return statementOffset;
19733         }
19734         function ensureUseStrict(statements) {
19735             var foundUseStrict = ts.findUseStrictPrologue(statements);
19736             if (!foundUseStrict) {
19737                 return ts.setTextRange(createNodeArray(__spreadArrays([createUseStrictPrologue()], statements)), statements);
19738             }
19739             return statements;
19740         }
19741         function liftToBlock(nodes) {
19742             ts.Debug.assert(ts.every(nodes, ts.isStatementOrBlock), "Cannot lift nodes to a Block.");
19743             return ts.singleOrUndefined(nodes) || createBlock(nodes);
19744         }
19745         function findSpanEnd(array, test, start) {
19746             var i = start;
19747             while (i < array.length && test(array[i])) {
19748                 i++;
19749             }
19750             return i;
19751         }
19752         function mergeLexicalEnvironment(statements, declarations) {
19753             if (!ts.some(declarations)) {
19754                 return statements;
19755             }
19756             var leftStandardPrologueEnd = findSpanEnd(statements, ts.isPrologueDirective, 0);
19757             var leftHoistedFunctionsEnd = findSpanEnd(statements, ts.isHoistedFunction, leftStandardPrologueEnd);
19758             var leftHoistedVariablesEnd = findSpanEnd(statements, ts.isHoistedVariableStatement, leftHoistedFunctionsEnd);
19759             var rightStandardPrologueEnd = findSpanEnd(declarations, ts.isPrologueDirective, 0);
19760             var rightHoistedFunctionsEnd = findSpanEnd(declarations, ts.isHoistedFunction, rightStandardPrologueEnd);
19761             var rightHoistedVariablesEnd = findSpanEnd(declarations, ts.isHoistedVariableStatement, rightHoistedFunctionsEnd);
19762             var rightCustomPrologueEnd = findSpanEnd(declarations, ts.isCustomPrologue, rightHoistedVariablesEnd);
19763             ts.Debug.assert(rightCustomPrologueEnd === declarations.length, "Expected declarations to be valid standard or custom prologues");
19764             var left = ts.isNodeArray(statements) ? statements.slice() : statements;
19765             if (rightCustomPrologueEnd > rightHoistedVariablesEnd) {
19766                 left.splice.apply(left, __spreadArrays([leftHoistedVariablesEnd, 0], declarations.slice(rightHoistedVariablesEnd, rightCustomPrologueEnd)));
19767             }
19768             if (rightHoistedVariablesEnd > rightHoistedFunctionsEnd) {
19769                 left.splice.apply(left, __spreadArrays([leftHoistedFunctionsEnd, 0], declarations.slice(rightHoistedFunctionsEnd, rightHoistedVariablesEnd)));
19770             }
19771             if (rightHoistedFunctionsEnd > rightStandardPrologueEnd) {
19772                 left.splice.apply(left, __spreadArrays([leftStandardPrologueEnd, 0], declarations.slice(rightStandardPrologueEnd, rightHoistedFunctionsEnd)));
19773             }
19774             if (rightStandardPrologueEnd > 0) {
19775                 if (leftStandardPrologueEnd === 0) {
19776                     left.splice.apply(left, __spreadArrays([0, 0], declarations.slice(0, rightStandardPrologueEnd)));
19777                 }
19778                 else {
19779                     var leftPrologues = new ts.Map();
19780                     for (var i = 0; i < leftStandardPrologueEnd; i++) {
19781                         var leftPrologue = statements[i];
19782                         leftPrologues.set(leftPrologue.expression.text, true);
19783                     }
19784                     for (var i = rightStandardPrologueEnd - 1; i >= 0; i--) {
19785                         var rightPrologue = declarations[i];
19786                         if (!leftPrologues.has(rightPrologue.expression.text)) {
19787                             left.unshift(rightPrologue);
19788                         }
19789                     }
19790                 }
19791             }
19792             if (ts.isNodeArray(statements)) {
19793                 return ts.setTextRange(createNodeArray(left, statements.hasTrailingComma), statements);
19794             }
19795             return statements;
19796         }
19797         function updateModifiers(node, modifiers) {
19798             var _a;
19799             if (typeof modifiers === "number") {
19800                 modifiers = createModifiersFromModifierFlags(modifiers);
19801             }
19802             return ts.isParameter(node) ? updateParameterDeclaration(node, node.decorators, modifiers, node.dotDotDotToken, node.name, node.questionToken, node.type, node.initializer) :
19803                 ts.isPropertySignature(node) ? updatePropertySignature(node, modifiers, node.name, node.questionToken, node.type) :
19804                     ts.isPropertyDeclaration(node) ? updatePropertyDeclaration(node, node.decorators, modifiers, node.name, (_a = node.questionToken) !== null && _a !== void 0 ? _a : node.exclamationToken, node.type, node.initializer) :
19805                         ts.isMethodSignature(node) ? updateMethodSignature(node, modifiers, node.name, node.questionToken, node.typeParameters, node.parameters, node.type) :
19806                             ts.isMethodDeclaration(node) ? updateMethodDeclaration(node, node.decorators, modifiers, node.asteriskToken, node.name, node.questionToken, node.typeParameters, node.parameters, node.type, node.body) :
19807                                 ts.isConstructorDeclaration(node) ? updateConstructorDeclaration(node, node.decorators, modifiers, node.parameters, node.body) :
19808                                     ts.isGetAccessorDeclaration(node) ? updateGetAccessorDeclaration(node, node.decorators, modifiers, node.name, node.parameters, node.type, node.body) :
19809                                         ts.isSetAccessorDeclaration(node) ? updateSetAccessorDeclaration(node, node.decorators, modifiers, node.name, node.parameters, node.body) :
19810                                             ts.isIndexSignatureDeclaration(node) ? updateIndexSignature(node, node.decorators, modifiers, node.parameters, node.type) :
19811                                                 ts.isFunctionExpression(node) ? updateFunctionExpression(node, modifiers, node.asteriskToken, node.name, node.typeParameters, node.parameters, node.type, node.body) :
19812                                                     ts.isArrowFunction(node) ? updateArrowFunction(node, modifiers, node.typeParameters, node.parameters, node.type, node.equalsGreaterThanToken, node.body) :
19813                                                         ts.isClassExpression(node) ? updateClassExpression(node, node.decorators, modifiers, node.name, node.typeParameters, node.heritageClauses, node.members) :
19814                                                             ts.isVariableStatement(node) ? updateVariableStatement(node, modifiers, node.declarationList) :
19815                                                                 ts.isFunctionDeclaration(node) ? updateFunctionDeclaration(node, node.decorators, modifiers, node.asteriskToken, node.name, node.typeParameters, node.parameters, node.type, node.body) :
19816                                                                     ts.isClassDeclaration(node) ? updateClassDeclaration(node, node.decorators, modifiers, node.name, node.typeParameters, node.heritageClauses, node.members) :
19817                                                                         ts.isInterfaceDeclaration(node) ? updateInterfaceDeclaration(node, node.decorators, modifiers, node.name, node.typeParameters, node.heritageClauses, node.members) :
19818                                                                             ts.isTypeAliasDeclaration(node) ? updateTypeAliasDeclaration(node, node.decorators, modifiers, node.name, node.typeParameters, node.type) :
19819                                                                                 ts.isEnumDeclaration(node) ? updateEnumDeclaration(node, node.decorators, modifiers, node.name, node.members) :
19820                                                                                     ts.isModuleDeclaration(node) ? updateModuleDeclaration(node, node.decorators, modifiers, node.name, node.body) :
19821                                                                                         ts.isImportEqualsDeclaration(node) ? updateImportEqualsDeclaration(node, node.decorators, modifiers, node.name, node.moduleReference) :
19822                                                                                             ts.isImportDeclaration(node) ? updateImportDeclaration(node, node.decorators, modifiers, node.importClause, node.moduleSpecifier) :
19823                                                                                                 ts.isExportAssignment(node) ? updateExportAssignment(node, node.decorators, modifiers, node.expression) :
19824                                                                                                     ts.isExportDeclaration(node) ? updateExportDeclaration(node, node.decorators, modifiers, node.isTypeOnly, node.exportClause, node.moduleSpecifier) :
19825                                                                                                         ts.Debug.assertNever(node);
19826         }
19827         function asNodeArray(array) {
19828             return array ? createNodeArray(array) : undefined;
19829         }
19830         function asName(name) {
19831             return typeof name === "string" ? createIdentifier(name) :
19832                 name;
19833         }
19834         function asExpression(value) {
19835             return typeof value === "string" ? createStringLiteral(value) :
19836                 typeof value === "number" ? createNumericLiteral(value) :
19837                     typeof value === "boolean" ? value ? createTrue() : createFalse() :
19838                         value;
19839         }
19840         function asToken(value) {
19841             return typeof value === "number" ? createToken(value) : value;
19842         }
19843         function asEmbeddedStatement(statement) {
19844             return statement && ts.isNotEmittedStatement(statement) ? ts.setTextRange(setOriginalNode(createEmptyStatement(), statement), statement) : statement;
19845         }
19846     }
19847     ts.createNodeFactory = createNodeFactory;
19848     function updateWithoutOriginal(updated, original) {
19849         if (updated !== original) {
19850             ts.setTextRange(updated, original);
19851         }
19852         return updated;
19853     }
19854     function updateWithOriginal(updated, original) {
19855         if (updated !== original) {
19856             setOriginalNode(updated, original);
19857             ts.setTextRange(updated, original);
19858         }
19859         return updated;
19860     }
19861     function getDefaultTagNameForKind(kind) {
19862         switch (kind) {
19863             case 329: return "type";
19864             case 327: return "returns";
19865             case 328: return "this";
19866             case 325: return "enum";
19867             case 317: return "author";
19868             case 319: return "class";
19869             case 320: return "public";
19870             case 321: return "private";
19871             case 322: return "protected";
19872             case 323: return "readonly";
19873             case 330: return "template";
19874             case 331: return "typedef";
19875             case 326: return "param";
19876             case 333: return "prop";
19877             case 324: return "callback";
19878             case 315: return "augments";
19879             case 316: return "implements";
19880             default:
19881                 return ts.Debug.fail("Unsupported kind: " + ts.Debug.formatSyntaxKind(kind));
19882         }
19883     }
19884     var rawTextScanner;
19885     var invalidValueSentinel = {};
19886     function getCookedText(kind, rawText) {
19887         if (!rawTextScanner) {
19888             rawTextScanner = ts.createScanner(99, false, 0);
19889         }
19890         switch (kind) {
19891             case 14:
19892                 rawTextScanner.setText("`" + rawText + "`");
19893                 break;
19894             case 15:
19895                 rawTextScanner.setText("`" + rawText + "${");
19896                 break;
19897             case 16:
19898                 rawTextScanner.setText("}" + rawText + "${");
19899                 break;
19900             case 17:
19901                 rawTextScanner.setText("}" + rawText + "`");
19902                 break;
19903         }
19904         var token = rawTextScanner.scan();
19905         if (token === 23) {
19906             token = rawTextScanner.reScanTemplateToken(false);
19907         }
19908         if (rawTextScanner.isUnterminated()) {
19909             rawTextScanner.setText(undefined);
19910             return invalidValueSentinel;
19911         }
19912         var tokenValue;
19913         switch (token) {
19914             case 14:
19915             case 15:
19916             case 16:
19917             case 17:
19918                 tokenValue = rawTextScanner.getTokenValue();
19919                 break;
19920         }
19921         if (tokenValue === undefined || rawTextScanner.scan() !== 1) {
19922             rawTextScanner.setText(undefined);
19923             return invalidValueSentinel;
19924         }
19925         rawTextScanner.setText(undefined);
19926         return tokenValue;
19927     }
19928     function propagateIdentifierNameFlags(node) {
19929         return propagateChildFlags(node) & ~8388608;
19930     }
19931     function propagatePropertyNameFlagsOfChild(node, transformFlags) {
19932         return transformFlags | (node.transformFlags & 4096);
19933     }
19934     function propagateChildFlags(child) {
19935         if (!child)
19936             return 0;
19937         var childFlags = child.transformFlags & ~getTransformFlagsSubtreeExclusions(child.kind);
19938         return ts.isNamedDeclaration(child) && ts.isPropertyName(child.name) ? propagatePropertyNameFlagsOfChild(child.name, childFlags) : childFlags;
19939     }
19940     function propagateChildrenFlags(children) {
19941         return children ? children.transformFlags : 0;
19942     }
19943     function aggregateChildrenFlags(children) {
19944         var subtreeFlags = 0;
19945         for (var _i = 0, children_2 = children; _i < children_2.length; _i++) {
19946             var child = children_2[_i];
19947             subtreeFlags |= propagateChildFlags(child);
19948         }
19949         children.transformFlags = subtreeFlags;
19950     }
19951     function getTransformFlagsSubtreeExclusions(kind) {
19952         if (kind >= 172 && kind <= 195) {
19953             return -2;
19954         }
19955         switch (kind) {
19956             case 203:
19957             case 204:
19958             case 199:
19959                 return 536879104;
19960             case 256:
19961                 return 546379776;
19962             case 160:
19963                 return 536870912;
19964             case 209:
19965                 return 547309568;
19966             case 208:
19967             case 251:
19968                 return 547313664;
19969             case 250:
19970                 return 537018368;
19971             case 252:
19972             case 221:
19973                 return 536905728;
19974             case 166:
19975                 return 547311616;
19976             case 163:
19977                 return 536875008;
19978             case 165:
19979             case 167:
19980             case 168:
19981                 return 538923008;
19982             case 128:
19983             case 144:
19984             case 155:
19985             case 141:
19986             case 147:
19987             case 145:
19988             case 131:
19989             case 148:
19990             case 113:
19991             case 159:
19992             case 162:
19993             case 164:
19994             case 169:
19995             case 170:
19996             case 171:
19997             case 253:
19998             case 254:
19999                 return -2;
20000             case 200:
20001                 return 536922112;
20002             case 287:
20003                 return 536887296;
20004             case 196:
20005             case 197:
20006                 return 536879104;
20007             case 206:
20008             case 224:
20009             case 336:
20010             case 207:
20011             case 105:
20012                 return 536870912;
20013             case 201:
20014             case 202:
20015                 return 536870912;
20016             default:
20017                 return 536870912;
20018         }
20019     }
20020     ts.getTransformFlagsSubtreeExclusions = getTransformFlagsSubtreeExclusions;
20021     var baseFactory = ts.createBaseNodeFactory();
20022     function makeSynthetic(node) {
20023         node.flags |= 8;
20024         return node;
20025     }
20026     var syntheticFactory = {
20027         createBaseSourceFileNode: function (kind) { return makeSynthetic(baseFactory.createBaseSourceFileNode(kind)); },
20028         createBaseIdentifierNode: function (kind) { return makeSynthetic(baseFactory.createBaseIdentifierNode(kind)); },
20029         createBasePrivateIdentifierNode: function (kind) { return makeSynthetic(baseFactory.createBasePrivateIdentifierNode(kind)); },
20030         createBaseTokenNode: function (kind) { return makeSynthetic(baseFactory.createBaseTokenNode(kind)); },
20031         createBaseNode: function (kind) { return makeSynthetic(baseFactory.createBaseNode(kind)); },
20032     };
20033     ts.factory = createNodeFactory(4, syntheticFactory);
20034     function createUnparsedSourceFile(textOrInputFiles, mapPathOrType, mapTextOrStripInternal) {
20035         var stripInternal;
20036         var bundleFileInfo;
20037         var fileName;
20038         var text;
20039         var length;
20040         var sourceMapPath;
20041         var sourceMapText;
20042         var getText;
20043         var getSourceMapText;
20044         var oldFileOfCurrentEmit;
20045         if (!ts.isString(textOrInputFiles)) {
20046             ts.Debug.assert(mapPathOrType === "js" || mapPathOrType === "dts");
20047             fileName = (mapPathOrType === "js" ? textOrInputFiles.javascriptPath : textOrInputFiles.declarationPath) || "";
20048             sourceMapPath = mapPathOrType === "js" ? textOrInputFiles.javascriptMapPath : textOrInputFiles.declarationMapPath;
20049             getText = function () { return mapPathOrType === "js" ? textOrInputFiles.javascriptText : textOrInputFiles.declarationText; };
20050             getSourceMapText = function () { return mapPathOrType === "js" ? textOrInputFiles.javascriptMapText : textOrInputFiles.declarationMapText; };
20051             length = function () { return getText().length; };
20052             if (textOrInputFiles.buildInfo && textOrInputFiles.buildInfo.bundle) {
20053                 ts.Debug.assert(mapTextOrStripInternal === undefined || typeof mapTextOrStripInternal === "boolean");
20054                 stripInternal = mapTextOrStripInternal;
20055                 bundleFileInfo = mapPathOrType === "js" ? textOrInputFiles.buildInfo.bundle.js : textOrInputFiles.buildInfo.bundle.dts;
20056                 oldFileOfCurrentEmit = textOrInputFiles.oldFileOfCurrentEmit;
20057             }
20058         }
20059         else {
20060             fileName = "";
20061             text = textOrInputFiles;
20062             length = textOrInputFiles.length;
20063             sourceMapPath = mapPathOrType;
20064             sourceMapText = mapTextOrStripInternal;
20065         }
20066         var node = oldFileOfCurrentEmit ?
20067             parseOldFileOfCurrentEmit(ts.Debug.assertDefined(bundleFileInfo)) :
20068             parseUnparsedSourceFile(bundleFileInfo, stripInternal, length);
20069         node.fileName = fileName;
20070         node.sourceMapPath = sourceMapPath;
20071         node.oldFileOfCurrentEmit = oldFileOfCurrentEmit;
20072         if (getText && getSourceMapText) {
20073             Object.defineProperty(node, "text", { get: getText });
20074             Object.defineProperty(node, "sourceMapText", { get: getSourceMapText });
20075         }
20076         else {
20077             ts.Debug.assert(!oldFileOfCurrentEmit);
20078             node.text = text !== null && text !== void 0 ? text : "";
20079             node.sourceMapText = sourceMapText;
20080         }
20081         return node;
20082     }
20083     ts.createUnparsedSourceFile = createUnparsedSourceFile;
20084     function parseUnparsedSourceFile(bundleFileInfo, stripInternal, length) {
20085         var prologues;
20086         var helpers;
20087         var referencedFiles;
20088         var typeReferenceDirectives;
20089         var libReferenceDirectives;
20090         var prependChildren;
20091         var texts;
20092         var hasNoDefaultLib;
20093         for (var _i = 0, _a = bundleFileInfo ? bundleFileInfo.sections : ts.emptyArray; _i < _a.length; _i++) {
20094             var section = _a[_i];
20095             switch (section.kind) {
20096                 case "prologue":
20097                     prologues = ts.append(prologues, ts.setTextRange(ts.factory.createUnparsedPrologue(section.data), section));
20098                     break;
20099                 case "emitHelpers":
20100                     helpers = ts.append(helpers, ts.getAllUnscopedEmitHelpers().get(section.data));
20101                     break;
20102                 case "no-default-lib":
20103                     hasNoDefaultLib = true;
20104                     break;
20105                 case "reference":
20106                     referencedFiles = ts.append(referencedFiles, { pos: -1, end: -1, fileName: section.data });
20107                     break;
20108                 case "type":
20109                     typeReferenceDirectives = ts.append(typeReferenceDirectives, section.data);
20110                     break;
20111                 case "lib":
20112                     libReferenceDirectives = ts.append(libReferenceDirectives, { pos: -1, end: -1, fileName: section.data });
20113                     break;
20114                 case "prepend":
20115                     var prependTexts = void 0;
20116                     for (var _b = 0, _c = section.texts; _b < _c.length; _b++) {
20117                         var text = _c[_b];
20118                         if (!stripInternal || text.kind !== "internal") {
20119                             prependTexts = ts.append(prependTexts, ts.setTextRange(ts.factory.createUnparsedTextLike(text.data, text.kind === "internal"), text));
20120                         }
20121                     }
20122                     prependChildren = ts.addRange(prependChildren, prependTexts);
20123                     texts = ts.append(texts, ts.factory.createUnparsedPrepend(section.data, prependTexts !== null && prependTexts !== void 0 ? prependTexts : ts.emptyArray));
20124                     break;
20125                 case "internal":
20126                     if (stripInternal) {
20127                         if (!texts)
20128                             texts = [];
20129                         break;
20130                     }
20131                 case "text":
20132                     texts = ts.append(texts, ts.setTextRange(ts.factory.createUnparsedTextLike(section.data, section.kind === "internal"), section));
20133                     break;
20134                 default:
20135                     ts.Debug.assertNever(section);
20136             }
20137         }
20138         if (!texts) {
20139             var textNode = ts.factory.createUnparsedTextLike(undefined, false);
20140             ts.setTextRangePosWidth(textNode, 0, typeof length === "function" ? length() : length);
20141             texts = [textNode];
20142         }
20143         var node = ts.parseNodeFactory.createUnparsedSource(prologues !== null && prologues !== void 0 ? prologues : ts.emptyArray, undefined, texts);
20144         ts.setEachParent(prologues, node);
20145         ts.setEachParent(texts, node);
20146         ts.setEachParent(prependChildren, node);
20147         node.hasNoDefaultLib = hasNoDefaultLib;
20148         node.helpers = helpers;
20149         node.referencedFiles = referencedFiles || ts.emptyArray;
20150         node.typeReferenceDirectives = typeReferenceDirectives;
20151         node.libReferenceDirectives = libReferenceDirectives || ts.emptyArray;
20152         return node;
20153     }
20154     function parseOldFileOfCurrentEmit(bundleFileInfo) {
20155         var texts;
20156         var syntheticReferences;
20157         for (var _i = 0, _a = bundleFileInfo.sections; _i < _a.length; _i++) {
20158             var section = _a[_i];
20159             switch (section.kind) {
20160                 case "internal":
20161                 case "text":
20162                     texts = ts.append(texts, ts.setTextRange(ts.factory.createUnparsedTextLike(section.data, section.kind === "internal"), section));
20163                     break;
20164                 case "no-default-lib":
20165                 case "reference":
20166                 case "type":
20167                 case "lib":
20168                     syntheticReferences = ts.append(syntheticReferences, ts.setTextRange(ts.factory.createUnparsedSyntheticReference(section), section));
20169                     break;
20170                 case "prologue":
20171                 case "emitHelpers":
20172                 case "prepend":
20173                     break;
20174                 default:
20175                     ts.Debug.assertNever(section);
20176             }
20177         }
20178         var node = ts.factory.createUnparsedSource(ts.emptyArray, syntheticReferences, texts !== null && texts !== void 0 ? texts : ts.emptyArray);
20179         ts.setEachParent(syntheticReferences, node);
20180         ts.setEachParent(texts, node);
20181         node.helpers = ts.map(bundleFileInfo.sources && bundleFileInfo.sources.helpers, function (name) { return ts.getAllUnscopedEmitHelpers().get(name); });
20182         return node;
20183     }
20184     function createInputFiles(javascriptTextOrReadFileText, declarationTextOrJavascriptPath, javascriptMapPath, javascriptMapTextOrDeclarationPath, declarationMapPath, declarationMapTextOrBuildInfoPath, javascriptPath, declarationPath, buildInfoPath, buildInfo, oldFileOfCurrentEmit) {
20185         var node = ts.parseNodeFactory.createInputFiles();
20186         if (!ts.isString(javascriptTextOrReadFileText)) {
20187             var cache_1 = new ts.Map();
20188             var textGetter_1 = function (path) {
20189                 if (path === undefined)
20190                     return undefined;
20191                 var value = cache_1.get(path);
20192                 if (value === undefined) {
20193                     value = javascriptTextOrReadFileText(path);
20194                     cache_1.set(path, value !== undefined ? value : false);
20195                 }
20196                 return value !== false ? value : undefined;
20197             };
20198             var definedTextGetter_1 = function (path) {
20199                 var result = textGetter_1(path);
20200                 return result !== undefined ? result : "/* Input file " + path + " was missing */\r\n";
20201             };
20202             var buildInfo_1;
20203             var getAndCacheBuildInfo_1 = function (getText) {
20204                 if (buildInfo_1 === undefined) {
20205                     var result = getText();
20206                     buildInfo_1 = result !== undefined ? ts.getBuildInfo(result) : false;
20207                 }
20208                 return buildInfo_1 || undefined;
20209             };
20210             node.javascriptPath = declarationTextOrJavascriptPath;
20211             node.javascriptMapPath = javascriptMapPath;
20212             node.declarationPath = ts.Debug.assertDefined(javascriptMapTextOrDeclarationPath);
20213             node.declarationMapPath = declarationMapPath;
20214             node.buildInfoPath = declarationMapTextOrBuildInfoPath;
20215             Object.defineProperties(node, {
20216                 javascriptText: { get: function () { return definedTextGetter_1(declarationTextOrJavascriptPath); } },
20217                 javascriptMapText: { get: function () { return textGetter_1(javascriptMapPath); } },
20218                 declarationText: { get: function () { return definedTextGetter_1(ts.Debug.assertDefined(javascriptMapTextOrDeclarationPath)); } },
20219                 declarationMapText: { get: function () { return textGetter_1(declarationMapPath); } },
20220                 buildInfo: { get: function () { return getAndCacheBuildInfo_1(function () { return textGetter_1(declarationMapTextOrBuildInfoPath); }); } }
20221             });
20222         }
20223         else {
20224             node.javascriptText = javascriptTextOrReadFileText;
20225             node.javascriptMapPath = javascriptMapPath;
20226             node.javascriptMapText = javascriptMapTextOrDeclarationPath;
20227             node.declarationText = declarationTextOrJavascriptPath;
20228             node.declarationMapPath = declarationMapPath;
20229             node.declarationMapText = declarationMapTextOrBuildInfoPath;
20230             node.javascriptPath = javascriptPath;
20231             node.declarationPath = declarationPath;
20232             node.buildInfoPath = buildInfoPath;
20233             node.buildInfo = buildInfo;
20234             node.oldFileOfCurrentEmit = oldFileOfCurrentEmit;
20235         }
20236         return node;
20237     }
20238     ts.createInputFiles = createInputFiles;
20239     var SourceMapSource;
20240     function createSourceMapSource(fileName, text, skipTrivia) {
20241         return new (SourceMapSource || (SourceMapSource = ts.objectAllocator.getSourceMapSourceConstructor()))(fileName, text, skipTrivia);
20242     }
20243     ts.createSourceMapSource = createSourceMapSource;
20244     function setOriginalNode(node, original) {
20245         node.original = original;
20246         if (original) {
20247             var emitNode = original.emitNode;
20248             if (emitNode)
20249                 node.emitNode = mergeEmitNode(emitNode, node.emitNode);
20250         }
20251         return node;
20252     }
20253     ts.setOriginalNode = setOriginalNode;
20254     function mergeEmitNode(sourceEmitNode, destEmitNode) {
20255         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;
20256         if (!destEmitNode)
20257             destEmitNode = {};
20258         if (leadingComments)
20259             destEmitNode.leadingComments = ts.addRange(leadingComments.slice(), destEmitNode.leadingComments);
20260         if (trailingComments)
20261             destEmitNode.trailingComments = ts.addRange(trailingComments.slice(), destEmitNode.trailingComments);
20262         if (flags)
20263             destEmitNode.flags = flags;
20264         if (commentRange)
20265             destEmitNode.commentRange = commentRange;
20266         if (sourceMapRange)
20267             destEmitNode.sourceMapRange = sourceMapRange;
20268         if (tokenSourceMapRanges)
20269             destEmitNode.tokenSourceMapRanges = mergeTokenSourceMapRanges(tokenSourceMapRanges, destEmitNode.tokenSourceMapRanges);
20270         if (constantValue !== undefined)
20271             destEmitNode.constantValue = constantValue;
20272         if (helpers) {
20273             for (var _i = 0, helpers_1 = helpers; _i < helpers_1.length; _i++) {
20274                 var helper = helpers_1[_i];
20275                 destEmitNode.helpers = ts.appendIfUnique(destEmitNode.helpers, helper);
20276             }
20277         }
20278         if (startsOnNewLine !== undefined)
20279             destEmitNode.startsOnNewLine = startsOnNewLine;
20280         return destEmitNode;
20281     }
20282     function mergeTokenSourceMapRanges(sourceRanges, destRanges) {
20283         if (!destRanges)
20284             destRanges = [];
20285         for (var key in sourceRanges) {
20286             destRanges[key] = sourceRanges[key];
20287         }
20288         return destRanges;
20289     }
20290 })(ts || (ts = {}));
20291 var ts;
20292 (function (ts) {
20293     function getOrCreateEmitNode(node) {
20294         var _a;
20295         if (!node.emitNode) {
20296             if (ts.isParseTreeNode(node)) {
20297                 if (node.kind === 297) {
20298                     return node.emitNode = { annotatedNodes: [node] };
20299                 }
20300                 var sourceFile = (_a = ts.getSourceFileOfNode(ts.getParseTreeNode(ts.getSourceFileOfNode(node)))) !== null && _a !== void 0 ? _a : ts.Debug.fail("Could not determine parsed source file.");
20301                 getOrCreateEmitNode(sourceFile).annotatedNodes.push(node);
20302             }
20303             node.emitNode = {};
20304         }
20305         return node.emitNode;
20306     }
20307     ts.getOrCreateEmitNode = getOrCreateEmitNode;
20308     function disposeEmitNodes(sourceFile) {
20309         var _a, _b;
20310         var annotatedNodes = (_b = (_a = ts.getSourceFileOfNode(ts.getParseTreeNode(sourceFile))) === null || _a === void 0 ? void 0 : _a.emitNode) === null || _b === void 0 ? void 0 : _b.annotatedNodes;
20311         if (annotatedNodes) {
20312             for (var _i = 0, annotatedNodes_1 = annotatedNodes; _i < annotatedNodes_1.length; _i++) {
20313                 var node = annotatedNodes_1[_i];
20314                 node.emitNode = undefined;
20315             }
20316         }
20317     }
20318     ts.disposeEmitNodes = disposeEmitNodes;
20319     function removeAllComments(node) {
20320         var emitNode = getOrCreateEmitNode(node);
20321         emitNode.flags |= 1536;
20322         emitNode.leadingComments = undefined;
20323         emitNode.trailingComments = undefined;
20324         return node;
20325     }
20326     ts.removeAllComments = removeAllComments;
20327     function setEmitFlags(node, emitFlags) {
20328         getOrCreateEmitNode(node).flags = emitFlags;
20329         return node;
20330     }
20331     ts.setEmitFlags = setEmitFlags;
20332     function addEmitFlags(node, emitFlags) {
20333         var emitNode = getOrCreateEmitNode(node);
20334         emitNode.flags = emitNode.flags | emitFlags;
20335         return node;
20336     }
20337     ts.addEmitFlags = addEmitFlags;
20338     function getSourceMapRange(node) {
20339         var _a, _b;
20340         return (_b = (_a = node.emitNode) === null || _a === void 0 ? void 0 : _a.sourceMapRange) !== null && _b !== void 0 ? _b : node;
20341     }
20342     ts.getSourceMapRange = getSourceMapRange;
20343     function setSourceMapRange(node, range) {
20344         getOrCreateEmitNode(node).sourceMapRange = range;
20345         return node;
20346     }
20347     ts.setSourceMapRange = setSourceMapRange;
20348     function getTokenSourceMapRange(node, token) {
20349         var _a, _b;
20350         return (_b = (_a = node.emitNode) === null || _a === void 0 ? void 0 : _a.tokenSourceMapRanges) === null || _b === void 0 ? void 0 : _b[token];
20351     }
20352     ts.getTokenSourceMapRange = getTokenSourceMapRange;
20353     function setTokenSourceMapRange(node, token, range) {
20354         var _a;
20355         var emitNode = getOrCreateEmitNode(node);
20356         var tokenSourceMapRanges = (_a = emitNode.tokenSourceMapRanges) !== null && _a !== void 0 ? _a : (emitNode.tokenSourceMapRanges = []);
20357         tokenSourceMapRanges[token] = range;
20358         return node;
20359     }
20360     ts.setTokenSourceMapRange = setTokenSourceMapRange;
20361     function getStartsOnNewLine(node) {
20362         var _a;
20363         return (_a = node.emitNode) === null || _a === void 0 ? void 0 : _a.startsOnNewLine;
20364     }
20365     ts.getStartsOnNewLine = getStartsOnNewLine;
20366     function setStartsOnNewLine(node, newLine) {
20367         getOrCreateEmitNode(node).startsOnNewLine = newLine;
20368         return node;
20369     }
20370     ts.setStartsOnNewLine = setStartsOnNewLine;
20371     function getCommentRange(node) {
20372         var _a, _b;
20373         return (_b = (_a = node.emitNode) === null || _a === void 0 ? void 0 : _a.commentRange) !== null && _b !== void 0 ? _b : node;
20374     }
20375     ts.getCommentRange = getCommentRange;
20376     function setCommentRange(node, range) {
20377         getOrCreateEmitNode(node).commentRange = range;
20378         return node;
20379     }
20380     ts.setCommentRange = setCommentRange;
20381     function getSyntheticLeadingComments(node) {
20382         var _a;
20383         return (_a = node.emitNode) === null || _a === void 0 ? void 0 : _a.leadingComments;
20384     }
20385     ts.getSyntheticLeadingComments = getSyntheticLeadingComments;
20386     function setSyntheticLeadingComments(node, comments) {
20387         getOrCreateEmitNode(node).leadingComments = comments;
20388         return node;
20389     }
20390     ts.setSyntheticLeadingComments = setSyntheticLeadingComments;
20391     function addSyntheticLeadingComment(node, kind, text, hasTrailingNewLine) {
20392         return setSyntheticLeadingComments(node, ts.append(getSyntheticLeadingComments(node), { kind: kind, pos: -1, end: -1, hasTrailingNewLine: hasTrailingNewLine, text: text }));
20393     }
20394     ts.addSyntheticLeadingComment = addSyntheticLeadingComment;
20395     function getSyntheticTrailingComments(node) {
20396         var _a;
20397         return (_a = node.emitNode) === null || _a === void 0 ? void 0 : _a.trailingComments;
20398     }
20399     ts.getSyntheticTrailingComments = getSyntheticTrailingComments;
20400     function setSyntheticTrailingComments(node, comments) {
20401         getOrCreateEmitNode(node).trailingComments = comments;
20402         return node;
20403     }
20404     ts.setSyntheticTrailingComments = setSyntheticTrailingComments;
20405     function addSyntheticTrailingComment(node, kind, text, hasTrailingNewLine) {
20406         return setSyntheticTrailingComments(node, ts.append(getSyntheticTrailingComments(node), { kind: kind, pos: -1, end: -1, hasTrailingNewLine: hasTrailingNewLine, text: text }));
20407     }
20408     ts.addSyntheticTrailingComment = addSyntheticTrailingComment;
20409     function moveSyntheticComments(node, original) {
20410         setSyntheticLeadingComments(node, getSyntheticLeadingComments(original));
20411         setSyntheticTrailingComments(node, getSyntheticTrailingComments(original));
20412         var emit = getOrCreateEmitNode(original);
20413         emit.leadingComments = undefined;
20414         emit.trailingComments = undefined;
20415         return node;
20416     }
20417     ts.moveSyntheticComments = moveSyntheticComments;
20418     function getConstantValue(node) {
20419         var _a;
20420         return (_a = node.emitNode) === null || _a === void 0 ? void 0 : _a.constantValue;
20421     }
20422     ts.getConstantValue = getConstantValue;
20423     function setConstantValue(node, value) {
20424         var emitNode = getOrCreateEmitNode(node);
20425         emitNode.constantValue = value;
20426         return node;
20427     }
20428     ts.setConstantValue = setConstantValue;
20429     function addEmitHelper(node, helper) {
20430         var emitNode = getOrCreateEmitNode(node);
20431         emitNode.helpers = ts.append(emitNode.helpers, helper);
20432         return node;
20433     }
20434     ts.addEmitHelper = addEmitHelper;
20435     function addEmitHelpers(node, helpers) {
20436         if (ts.some(helpers)) {
20437             var emitNode = getOrCreateEmitNode(node);
20438             for (var _i = 0, helpers_2 = helpers; _i < helpers_2.length; _i++) {
20439                 var helper = helpers_2[_i];
20440                 emitNode.helpers = ts.appendIfUnique(emitNode.helpers, helper);
20441             }
20442         }
20443         return node;
20444     }
20445     ts.addEmitHelpers = addEmitHelpers;
20446     function removeEmitHelper(node, helper) {
20447         var _a;
20448         var helpers = (_a = node.emitNode) === null || _a === void 0 ? void 0 : _a.helpers;
20449         if (helpers) {
20450             return ts.orderedRemoveItem(helpers, helper);
20451         }
20452         return false;
20453     }
20454     ts.removeEmitHelper = removeEmitHelper;
20455     function getEmitHelpers(node) {
20456         var _a;
20457         return (_a = node.emitNode) === null || _a === void 0 ? void 0 : _a.helpers;
20458     }
20459     ts.getEmitHelpers = getEmitHelpers;
20460     function moveEmitHelpers(source, target, predicate) {
20461         var sourceEmitNode = source.emitNode;
20462         var sourceEmitHelpers = sourceEmitNode && sourceEmitNode.helpers;
20463         if (!ts.some(sourceEmitHelpers))
20464             return;
20465         var targetEmitNode = getOrCreateEmitNode(target);
20466         var helpersRemoved = 0;
20467         for (var i = 0; i < sourceEmitHelpers.length; i++) {
20468             var helper = sourceEmitHelpers[i];
20469             if (predicate(helper)) {
20470                 helpersRemoved++;
20471                 targetEmitNode.helpers = ts.appendIfUnique(targetEmitNode.helpers, helper);
20472             }
20473             else if (helpersRemoved > 0) {
20474                 sourceEmitHelpers[i - helpersRemoved] = helper;
20475             }
20476         }
20477         if (helpersRemoved > 0) {
20478             sourceEmitHelpers.length -= helpersRemoved;
20479         }
20480     }
20481     ts.moveEmitHelpers = moveEmitHelpers;
20482     function ignoreSourceNewlines(node) {
20483         getOrCreateEmitNode(node).flags |= 134217728;
20484         return node;
20485     }
20486     ts.ignoreSourceNewlines = ignoreSourceNewlines;
20487 })(ts || (ts = {}));
20488 var ts;
20489 (function (ts) {
20490     function createEmitHelperFactory(context) {
20491         var factory = context.factory;
20492         return {
20493             getUnscopedHelperName: getUnscopedHelperName,
20494             createDecorateHelper: createDecorateHelper,
20495             createMetadataHelper: createMetadataHelper,
20496             createParamHelper: createParamHelper,
20497             createAssignHelper: createAssignHelper,
20498             createAwaitHelper: createAwaitHelper,
20499             createAsyncGeneratorHelper: createAsyncGeneratorHelper,
20500             createAsyncDelegatorHelper: createAsyncDelegatorHelper,
20501             createAsyncValuesHelper: createAsyncValuesHelper,
20502             createRestHelper: createRestHelper,
20503             createAwaiterHelper: createAwaiterHelper,
20504             createExtendsHelper: createExtendsHelper,
20505             createTemplateObjectHelper: createTemplateObjectHelper,
20506             createSpreadHelper: createSpreadHelper,
20507             createSpreadArraysHelper: createSpreadArraysHelper,
20508             createValuesHelper: createValuesHelper,
20509             createReadHelper: createReadHelper,
20510             createGeneratorHelper: createGeneratorHelper,
20511             createCreateBindingHelper: createCreateBindingHelper,
20512             createImportStarHelper: createImportStarHelper,
20513             createImportStarCallbackHelper: createImportStarCallbackHelper,
20514             createImportDefaultHelper: createImportDefaultHelper,
20515             createExportStarHelper: createExportStarHelper,
20516             createClassPrivateFieldGetHelper: createClassPrivateFieldGetHelper,
20517             createClassPrivateFieldSetHelper: createClassPrivateFieldSetHelper,
20518         };
20519         function getUnscopedHelperName(name) {
20520             return ts.setEmitFlags(factory.createIdentifier(name), 4096 | 2);
20521         }
20522         function createDecorateHelper(decoratorExpressions, target, memberName, descriptor) {
20523             context.requestEmitHelper(ts.decorateHelper);
20524             var argumentsArray = [];
20525             argumentsArray.push(factory.createArrayLiteralExpression(decoratorExpressions, true));
20526             argumentsArray.push(target);
20527             if (memberName) {
20528                 argumentsArray.push(memberName);
20529                 if (descriptor) {
20530                     argumentsArray.push(descriptor);
20531                 }
20532             }
20533             return factory.createCallExpression(getUnscopedHelperName("__decorate"), undefined, argumentsArray);
20534         }
20535         function createMetadataHelper(metadataKey, metadataValue) {
20536             context.requestEmitHelper(ts.metadataHelper);
20537             return factory.createCallExpression(getUnscopedHelperName("__metadata"), undefined, [
20538                 factory.createStringLiteral(metadataKey),
20539                 metadataValue
20540             ]);
20541         }
20542         function createParamHelper(expression, parameterOffset, location) {
20543             context.requestEmitHelper(ts.paramHelper);
20544             return ts.setTextRange(factory.createCallExpression(getUnscopedHelperName("__param"), undefined, [
20545                 factory.createNumericLiteral(parameterOffset + ""),
20546                 expression
20547             ]), location);
20548         }
20549         function createAssignHelper(attributesSegments) {
20550             if (context.getCompilerOptions().target >= 2) {
20551                 return factory.createCallExpression(factory.createPropertyAccessExpression(factory.createIdentifier("Object"), "assign"), undefined, attributesSegments);
20552             }
20553             context.requestEmitHelper(ts.assignHelper);
20554             return factory.createCallExpression(getUnscopedHelperName("__assign"), undefined, attributesSegments);
20555         }
20556         function createAwaitHelper(expression) {
20557             context.requestEmitHelper(ts.awaitHelper);
20558             return factory.createCallExpression(getUnscopedHelperName("__await"), undefined, [expression]);
20559         }
20560         function createAsyncGeneratorHelper(generatorFunc, hasLexicalThis) {
20561             context.requestEmitHelper(ts.awaitHelper);
20562             context.requestEmitHelper(ts.asyncGeneratorHelper);
20563             (generatorFunc.emitNode || (generatorFunc.emitNode = {})).flags |= 262144 | 524288;
20564             return factory.createCallExpression(getUnscopedHelperName("__asyncGenerator"), undefined, [
20565                 hasLexicalThis ? factory.createThis() : factory.createVoidZero(),
20566                 factory.createIdentifier("arguments"),
20567                 generatorFunc
20568             ]);
20569         }
20570         function createAsyncDelegatorHelper(expression) {
20571             context.requestEmitHelper(ts.awaitHelper);
20572             context.requestEmitHelper(ts.asyncDelegator);
20573             return factory.createCallExpression(getUnscopedHelperName("__asyncDelegator"), undefined, [expression]);
20574         }
20575         function createAsyncValuesHelper(expression) {
20576             context.requestEmitHelper(ts.asyncValues);
20577             return factory.createCallExpression(getUnscopedHelperName("__asyncValues"), undefined, [expression]);
20578         }
20579         function createRestHelper(value, elements, computedTempVariables, location) {
20580             context.requestEmitHelper(ts.restHelper);
20581             var propertyNames = [];
20582             var computedTempVariableOffset = 0;
20583             for (var i = 0; i < elements.length - 1; i++) {
20584                 var propertyName = ts.getPropertyNameOfBindingOrAssignmentElement(elements[i]);
20585                 if (propertyName) {
20586                     if (ts.isComputedPropertyName(propertyName)) {
20587                         ts.Debug.assertIsDefined(computedTempVariables, "Encountered computed property name but 'computedTempVariables' argument was not provided.");
20588                         var temp = computedTempVariables[computedTempVariableOffset];
20589                         computedTempVariableOffset++;
20590                         propertyNames.push(factory.createConditionalExpression(factory.createTypeCheck(temp, "symbol"), undefined, temp, undefined, factory.createAdd(temp, factory.createStringLiteral(""))));
20591                     }
20592                     else {
20593                         propertyNames.push(factory.createStringLiteralFromNode(propertyName));
20594                     }
20595                 }
20596             }
20597             return factory.createCallExpression(getUnscopedHelperName("__rest"), undefined, [
20598                 value,
20599                 ts.setTextRange(factory.createArrayLiteralExpression(propertyNames), location)
20600             ]);
20601         }
20602         function createAwaiterHelper(hasLexicalThis, hasLexicalArguments, promiseConstructor, body) {
20603             context.requestEmitHelper(ts.awaiterHelper);
20604             var generatorFunc = factory.createFunctionExpression(undefined, factory.createToken(41), undefined, undefined, [], undefined, body);
20605             (generatorFunc.emitNode || (generatorFunc.emitNode = {})).flags |= 262144 | 524288;
20606             return factory.createCallExpression(getUnscopedHelperName("__awaiter"), undefined, [
20607                 hasLexicalThis ? factory.createThis() : factory.createVoidZero(),
20608                 hasLexicalArguments ? factory.createIdentifier("arguments") : factory.createVoidZero(),
20609                 promiseConstructor ? ts.createExpressionFromEntityName(factory, promiseConstructor) : factory.createVoidZero(),
20610                 generatorFunc
20611             ]);
20612         }
20613         function createExtendsHelper(name) {
20614             context.requestEmitHelper(ts.extendsHelper);
20615             return factory.createCallExpression(getUnscopedHelperName("__extends"), undefined, [name, factory.createUniqueName("_super", 16 | 32)]);
20616         }
20617         function createTemplateObjectHelper(cooked, raw) {
20618             context.requestEmitHelper(ts.templateObjectHelper);
20619             return factory.createCallExpression(getUnscopedHelperName("__makeTemplateObject"), undefined, [cooked, raw]);
20620         }
20621         function createSpreadHelper(argumentList) {
20622             context.requestEmitHelper(ts.readHelper);
20623             context.requestEmitHelper(ts.spreadHelper);
20624             return factory.createCallExpression(getUnscopedHelperName("__spread"), undefined, argumentList);
20625         }
20626         function createSpreadArraysHelper(argumentList) {
20627             context.requestEmitHelper(ts.spreadArraysHelper);
20628             return factory.createCallExpression(getUnscopedHelperName("__spreadArrays"), undefined, argumentList);
20629         }
20630         function createValuesHelper(expression) {
20631             context.requestEmitHelper(ts.valuesHelper);
20632             return factory.createCallExpression(getUnscopedHelperName("__values"), undefined, [expression]);
20633         }
20634         function createReadHelper(iteratorRecord, count) {
20635             context.requestEmitHelper(ts.readHelper);
20636             return factory.createCallExpression(getUnscopedHelperName("__read"), undefined, count !== undefined
20637                 ? [iteratorRecord, factory.createNumericLiteral(count + "")]
20638                 : [iteratorRecord]);
20639         }
20640         function createGeneratorHelper(body) {
20641             context.requestEmitHelper(ts.generatorHelper);
20642             return factory.createCallExpression(getUnscopedHelperName("__generator"), undefined, [factory.createThis(), body]);
20643         }
20644         function createCreateBindingHelper(module, inputName, outputName) {
20645             context.requestEmitHelper(ts.createBindingHelper);
20646             return factory.createCallExpression(getUnscopedHelperName("__createBinding"), undefined, __spreadArrays([factory.createIdentifier("exports"), module, inputName], (outputName ? [outputName] : [])));
20647         }
20648         function createImportStarHelper(expression) {
20649             context.requestEmitHelper(ts.importStarHelper);
20650             return factory.createCallExpression(getUnscopedHelperName("__importStar"), undefined, [expression]);
20651         }
20652         function createImportStarCallbackHelper() {
20653             context.requestEmitHelper(ts.importStarHelper);
20654             return getUnscopedHelperName("__importStar");
20655         }
20656         function createImportDefaultHelper(expression) {
20657             context.requestEmitHelper(ts.importDefaultHelper);
20658             return factory.createCallExpression(getUnscopedHelperName("__importDefault"), undefined, [expression]);
20659         }
20660         function createExportStarHelper(moduleExpression, exportsExpression) {
20661             if (exportsExpression === void 0) { exportsExpression = factory.createIdentifier("exports"); }
20662             context.requestEmitHelper(ts.exportStarHelper);
20663             context.requestEmitHelper(ts.createBindingHelper);
20664             return factory.createCallExpression(getUnscopedHelperName("__exportStar"), undefined, [moduleExpression, exportsExpression]);
20665         }
20666         function createClassPrivateFieldGetHelper(receiver, privateField) {
20667             context.requestEmitHelper(ts.classPrivateFieldGetHelper);
20668             return factory.createCallExpression(getUnscopedHelperName("__classPrivateFieldGet"), undefined, [receiver, privateField]);
20669         }
20670         function createClassPrivateFieldSetHelper(receiver, privateField, value) {
20671             context.requestEmitHelper(ts.classPrivateFieldSetHelper);
20672             return factory.createCallExpression(getUnscopedHelperName("__classPrivateFieldSet"), undefined, [receiver, privateField, value]);
20673         }
20674     }
20675     ts.createEmitHelperFactory = createEmitHelperFactory;
20676     function compareEmitHelpers(x, y) {
20677         if (x === y)
20678             return 0;
20679         if (x.priority === y.priority)
20680             return 0;
20681         if (x.priority === undefined)
20682             return 1;
20683         if (y.priority === undefined)
20684             return -1;
20685         return ts.compareValues(x.priority, y.priority);
20686     }
20687     ts.compareEmitHelpers = compareEmitHelpers;
20688     function helperString(input) {
20689         var args = [];
20690         for (var _i = 1; _i < arguments.length; _i++) {
20691             args[_i - 1] = arguments[_i];
20692         }
20693         return function (uniqueName) {
20694             var result = "";
20695             for (var i = 0; i < args.length; i++) {
20696                 result += input[i];
20697                 result += uniqueName(args[i]);
20698             }
20699             result += input[input.length - 1];
20700             return result;
20701         };
20702     }
20703     ts.helperString = helperString;
20704     ts.decorateHelper = {
20705         name: "typescript:decorate",
20706         importName: "__decorate",
20707         scoped: false,
20708         priority: 2,
20709         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            };"
20710     };
20711     ts.metadataHelper = {
20712         name: "typescript:metadata",
20713         importName: "__metadata",
20714         scoped: false,
20715         priority: 3,
20716         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            };"
20717     };
20718     ts.paramHelper = {
20719         name: "typescript:param",
20720         importName: "__param",
20721         scoped: false,
20722         priority: 4,
20723         text: "\n            var __param = (this && this.__param) || function (paramIndex, decorator) {\n                return function (target, key) { decorator(target, key, paramIndex); }\n            };"
20724     };
20725     ts.assignHelper = {
20726         name: "typescript:assign",
20727         importName: "__assign",
20728         scoped: false,
20729         priority: 1,
20730         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            };"
20731     };
20732     ts.awaitHelper = {
20733         name: "typescript:await",
20734         importName: "__await",
20735         scoped: false,
20736         text: "\n            var __await = (this && this.__await) || function (v) { return this instanceof __await ? (this.v = v, this) : new __await(v); }"
20737     };
20738     ts.asyncGeneratorHelper = {
20739         name: "typescript:asyncGenerator",
20740         importName: "__asyncGenerator",
20741         scoped: false,
20742         dependencies: [ts.awaitHelper],
20743         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            };"
20744     };
20745     ts.asyncDelegator = {
20746         name: "typescript:asyncDelegator",
20747         importName: "__asyncDelegator",
20748         scoped: false,
20749         dependencies: [ts.awaitHelper],
20750         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            };"
20751     };
20752     ts.asyncValues = {
20753         name: "typescript:asyncValues",
20754         importName: "__asyncValues",
20755         scoped: false,
20756         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            };"
20757     };
20758     ts.restHelper = {
20759         name: "typescript:rest",
20760         importName: "__rest",
20761         scoped: false,
20762         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            };"
20763     };
20764     ts.awaiterHelper = {
20765         name: "typescript:awaiter",
20766         importName: "__awaiter",
20767         scoped: false,
20768         priority: 5,
20769         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            };"
20770     };
20771     ts.extendsHelper = {
20772         name: "typescript:extends",
20773         importName: "__extends",
20774         scoped: false,
20775         priority: 0,
20776         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 (Object.prototype.hasOwnProperty.call(b, 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            })();"
20777     };
20778     ts.templateObjectHelper = {
20779         name: "typescript:makeTemplateObject",
20780         importName: "__makeTemplateObject",
20781         scoped: false,
20782         priority: 0,
20783         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            };"
20784     };
20785     ts.readHelper = {
20786         name: "typescript:read",
20787         importName: "__read",
20788         scoped: false,
20789         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            };"
20790     };
20791     ts.spreadHelper = {
20792         name: "typescript:spread",
20793         importName: "__spread",
20794         scoped: false,
20795         dependencies: [ts.readHelper],
20796         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            };"
20797     };
20798     ts.spreadArraysHelper = {
20799         name: "typescript:spreadArrays",
20800         importName: "__spreadArrays",
20801         scoped: false,
20802         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            };"
20803     };
20804     ts.valuesHelper = {
20805         name: "typescript:values",
20806         importName: "__values",
20807         scoped: false,
20808         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            };"
20809     };
20810     ts.generatorHelper = {
20811         name: "typescript:generator",
20812         importName: "__generator",
20813         scoped: false,
20814         priority: 6,
20815         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            };"
20816     };
20817     ts.createBindingHelper = {
20818         name: "typescript:commonjscreatebinding",
20819         importName: "__createBinding",
20820         scoped: false,
20821         priority: 1,
20822         text: "\n            var __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            }));"
20823     };
20824     ts.setModuleDefaultHelper = {
20825         name: "typescript:commonjscreatevalue",
20826         importName: "__setModuleDefault",
20827         scoped: false,
20828         priority: 1,
20829         text: "\n            var __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            });"
20830     };
20831     ts.importStarHelper = {
20832         name: "typescript:commonjsimportstar",
20833         importName: "__importStar",
20834         scoped: false,
20835         dependencies: [ts.createBindingHelper, ts.setModuleDefaultHelper],
20836         priority: 2,
20837         text: "\n            var __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.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);\n                __setModuleDefault(result, mod);\n                return result;\n            };"
20838     };
20839     ts.importDefaultHelper = {
20840         name: "typescript:commonjsimportdefault",
20841         importName: "__importDefault",
20842         scoped: false,
20843         text: "\n            var __importDefault = (this && this.__importDefault) || function (mod) {\n                return (mod && mod.__esModule) ? mod : { \"default\": mod };\n            };"
20844     };
20845     ts.exportStarHelper = {
20846         name: "typescript:export-star",
20847         importName: "__exportStar",
20848         scoped: false,
20849         dependencies: [ts.createBindingHelper],
20850         priority: 2,
20851         text: "\n            var __exportStar = (this && this.__exportStar) || function(m, exports) {\n                for (var p in m) if (p !== \"default\" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);\n            };"
20852     };
20853     ts.classPrivateFieldGetHelper = {
20854         name: "typescript:classPrivateFieldGet",
20855         importName: "__classPrivateFieldGet",
20856         scoped: false,
20857         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            };"
20858     };
20859     ts.classPrivateFieldSetHelper = {
20860         name: "typescript:classPrivateFieldSet",
20861         importName: "__classPrivateFieldSet",
20862         scoped: false,
20863         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            };"
20864     };
20865     var allUnscopedEmitHelpers;
20866     function getAllUnscopedEmitHelpers() {
20867         return allUnscopedEmitHelpers || (allUnscopedEmitHelpers = ts.arrayToMap([
20868             ts.decorateHelper,
20869             ts.metadataHelper,
20870             ts.paramHelper,
20871             ts.assignHelper,
20872             ts.awaitHelper,
20873             ts.asyncGeneratorHelper,
20874             ts.asyncDelegator,
20875             ts.asyncValues,
20876             ts.restHelper,
20877             ts.awaiterHelper,
20878             ts.extendsHelper,
20879             ts.templateObjectHelper,
20880             ts.spreadHelper,
20881             ts.spreadArraysHelper,
20882             ts.valuesHelper,
20883             ts.readHelper,
20884             ts.generatorHelper,
20885             ts.importStarHelper,
20886             ts.importDefaultHelper,
20887             ts.exportStarHelper,
20888             ts.classPrivateFieldGetHelper,
20889             ts.classPrivateFieldSetHelper,
20890             ts.createBindingHelper,
20891             ts.setModuleDefaultHelper
20892         ], function (helper) { return helper.name; }));
20893     }
20894     ts.getAllUnscopedEmitHelpers = getAllUnscopedEmitHelpers;
20895     ts.asyncSuperHelper = {
20896         name: "typescript:async-super",
20897         scoped: true,
20898         text: helperString(__makeTemplateObject(["\n            const ", " = name => super[name];"], ["\n            const ", " = name => super[name];"]), "_superIndex")
20899     };
20900     ts.advancedAsyncSuperHelper = {
20901         name: "typescript:advanced-async-super",
20902         scoped: true,
20903         text: 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")
20904     };
20905 })(ts || (ts = {}));
20906 var ts;
20907 (function (ts) {
20908     function isNumericLiteral(node) {
20909         return node.kind === 8;
20910     }
20911     ts.isNumericLiteral = isNumericLiteral;
20912     function isBigIntLiteral(node) {
20913         return node.kind === 9;
20914     }
20915     ts.isBigIntLiteral = isBigIntLiteral;
20916     function isStringLiteral(node) {
20917         return node.kind === 10;
20918     }
20919     ts.isStringLiteral = isStringLiteral;
20920     function isJsxText(node) {
20921         return node.kind === 11;
20922     }
20923     ts.isJsxText = isJsxText;
20924     function isRegularExpressionLiteral(node) {
20925         return node.kind === 13;
20926     }
20927     ts.isRegularExpressionLiteral = isRegularExpressionLiteral;
20928     function isNoSubstitutionTemplateLiteral(node) {
20929         return node.kind === 14;
20930     }
20931     ts.isNoSubstitutionTemplateLiteral = isNoSubstitutionTemplateLiteral;
20932     function isTemplateHead(node) {
20933         return node.kind === 15;
20934     }
20935     ts.isTemplateHead = isTemplateHead;
20936     function isTemplateMiddle(node) {
20937         return node.kind === 16;
20938     }
20939     ts.isTemplateMiddle = isTemplateMiddle;
20940     function isTemplateTail(node) {
20941         return node.kind === 17;
20942     }
20943     ts.isTemplateTail = isTemplateTail;
20944     function isIdentifier(node) {
20945         return node.kind === 78;
20946     }
20947     ts.isIdentifier = isIdentifier;
20948     function isQualifiedName(node) {
20949         return node.kind === 157;
20950     }
20951     ts.isQualifiedName = isQualifiedName;
20952     function isComputedPropertyName(node) {
20953         return node.kind === 158;
20954     }
20955     ts.isComputedPropertyName = isComputedPropertyName;
20956     function isPrivateIdentifier(node) {
20957         return node.kind === 79;
20958     }
20959     ts.isPrivateIdentifier = isPrivateIdentifier;
20960     function isSuperKeyword(node) {
20961         return node.kind === 105;
20962     }
20963     ts.isSuperKeyword = isSuperKeyword;
20964     function isImportKeyword(node) {
20965         return node.kind === 99;
20966     }
20967     ts.isImportKeyword = isImportKeyword;
20968     function isCommaToken(node) {
20969         return node.kind === 27;
20970     }
20971     ts.isCommaToken = isCommaToken;
20972     function isQuestionToken(node) {
20973         return node.kind === 57;
20974     }
20975     ts.isQuestionToken = isQuestionToken;
20976     function isExclamationToken(node) {
20977         return node.kind === 53;
20978     }
20979     ts.isExclamationToken = isExclamationToken;
20980     function isTypeParameterDeclaration(node) {
20981         return node.kind === 159;
20982     }
20983     ts.isTypeParameterDeclaration = isTypeParameterDeclaration;
20984     function isParameter(node) {
20985         return node.kind === 160;
20986     }
20987     ts.isParameter = isParameter;
20988     function isDecorator(node) {
20989         return node.kind === 161;
20990     }
20991     ts.isDecorator = isDecorator;
20992     function isPropertySignature(node) {
20993         return node.kind === 162;
20994     }
20995     ts.isPropertySignature = isPropertySignature;
20996     function isPropertyDeclaration(node) {
20997         return node.kind === 163;
20998     }
20999     ts.isPropertyDeclaration = isPropertyDeclaration;
21000     function isMethodSignature(node) {
21001         return node.kind === 164;
21002     }
21003     ts.isMethodSignature = isMethodSignature;
21004     function isMethodDeclaration(node) {
21005         return node.kind === 165;
21006     }
21007     ts.isMethodDeclaration = isMethodDeclaration;
21008     function isConstructorDeclaration(node) {
21009         return node.kind === 166;
21010     }
21011     ts.isConstructorDeclaration = isConstructorDeclaration;
21012     function isGetAccessorDeclaration(node) {
21013         return node.kind === 167;
21014     }
21015     ts.isGetAccessorDeclaration = isGetAccessorDeclaration;
21016     function isSetAccessorDeclaration(node) {
21017         return node.kind === 168;
21018     }
21019     ts.isSetAccessorDeclaration = isSetAccessorDeclaration;
21020     function isCallSignatureDeclaration(node) {
21021         return node.kind === 169;
21022     }
21023     ts.isCallSignatureDeclaration = isCallSignatureDeclaration;
21024     function isConstructSignatureDeclaration(node) {
21025         return node.kind === 170;
21026     }
21027     ts.isConstructSignatureDeclaration = isConstructSignatureDeclaration;
21028     function isIndexSignatureDeclaration(node) {
21029         return node.kind === 171;
21030     }
21031     ts.isIndexSignatureDeclaration = isIndexSignatureDeclaration;
21032     function isTypePredicateNode(node) {
21033         return node.kind === 172;
21034     }
21035     ts.isTypePredicateNode = isTypePredicateNode;
21036     function isTypeReferenceNode(node) {
21037         return node.kind === 173;
21038     }
21039     ts.isTypeReferenceNode = isTypeReferenceNode;
21040     function isFunctionTypeNode(node) {
21041         return node.kind === 174;
21042     }
21043     ts.isFunctionTypeNode = isFunctionTypeNode;
21044     function isConstructorTypeNode(node) {
21045         return node.kind === 175;
21046     }
21047     ts.isConstructorTypeNode = isConstructorTypeNode;
21048     function isTypeQueryNode(node) {
21049         return node.kind === 176;
21050     }
21051     ts.isTypeQueryNode = isTypeQueryNode;
21052     function isTypeLiteralNode(node) {
21053         return node.kind === 177;
21054     }
21055     ts.isTypeLiteralNode = isTypeLiteralNode;
21056     function isArrayTypeNode(node) {
21057         return node.kind === 178;
21058     }
21059     ts.isArrayTypeNode = isArrayTypeNode;
21060     function isTupleTypeNode(node) {
21061         return node.kind === 179;
21062     }
21063     ts.isTupleTypeNode = isTupleTypeNode;
21064     function isNamedTupleMember(node) {
21065         return node.kind === 192;
21066     }
21067     ts.isNamedTupleMember = isNamedTupleMember;
21068     function isOptionalTypeNode(node) {
21069         return node.kind === 180;
21070     }
21071     ts.isOptionalTypeNode = isOptionalTypeNode;
21072     function isRestTypeNode(node) {
21073         return node.kind === 181;
21074     }
21075     ts.isRestTypeNode = isRestTypeNode;
21076     function isUnionTypeNode(node) {
21077         return node.kind === 182;
21078     }
21079     ts.isUnionTypeNode = isUnionTypeNode;
21080     function isIntersectionTypeNode(node) {
21081         return node.kind === 183;
21082     }
21083     ts.isIntersectionTypeNode = isIntersectionTypeNode;
21084     function isConditionalTypeNode(node) {
21085         return node.kind === 184;
21086     }
21087     ts.isConditionalTypeNode = isConditionalTypeNode;
21088     function isInferTypeNode(node) {
21089         return node.kind === 185;
21090     }
21091     ts.isInferTypeNode = isInferTypeNode;
21092     function isParenthesizedTypeNode(node) {
21093         return node.kind === 186;
21094     }
21095     ts.isParenthesizedTypeNode = isParenthesizedTypeNode;
21096     function isThisTypeNode(node) {
21097         return node.kind === 187;
21098     }
21099     ts.isThisTypeNode = isThisTypeNode;
21100     function isTypeOperatorNode(node) {
21101         return node.kind === 188;
21102     }
21103     ts.isTypeOperatorNode = isTypeOperatorNode;
21104     function isIndexedAccessTypeNode(node) {
21105         return node.kind === 189;
21106     }
21107     ts.isIndexedAccessTypeNode = isIndexedAccessTypeNode;
21108     function isMappedTypeNode(node) {
21109         return node.kind === 190;
21110     }
21111     ts.isMappedTypeNode = isMappedTypeNode;
21112     function isLiteralTypeNode(node) {
21113         return node.kind === 191;
21114     }
21115     ts.isLiteralTypeNode = isLiteralTypeNode;
21116     function isImportTypeNode(node) {
21117         return node.kind === 195;
21118     }
21119     ts.isImportTypeNode = isImportTypeNode;
21120     function isTemplateLiteralTypeSpan(node) {
21121         return node.kind === 194;
21122     }
21123     ts.isTemplateLiteralTypeSpan = isTemplateLiteralTypeSpan;
21124     function isTemplateLiteralTypeNode(node) {
21125         return node.kind === 193;
21126     }
21127     ts.isTemplateLiteralTypeNode = isTemplateLiteralTypeNode;
21128     function isObjectBindingPattern(node) {
21129         return node.kind === 196;
21130     }
21131     ts.isObjectBindingPattern = isObjectBindingPattern;
21132     function isArrayBindingPattern(node) {
21133         return node.kind === 197;
21134     }
21135     ts.isArrayBindingPattern = isArrayBindingPattern;
21136     function isBindingElement(node) {
21137         return node.kind === 198;
21138     }
21139     ts.isBindingElement = isBindingElement;
21140     function isArrayLiteralExpression(node) {
21141         return node.kind === 199;
21142     }
21143     ts.isArrayLiteralExpression = isArrayLiteralExpression;
21144     function isObjectLiteralExpression(node) {
21145         return node.kind === 200;
21146     }
21147     ts.isObjectLiteralExpression = isObjectLiteralExpression;
21148     function isPropertyAccessExpression(node) {
21149         return node.kind === 201;
21150     }
21151     ts.isPropertyAccessExpression = isPropertyAccessExpression;
21152     function isElementAccessExpression(node) {
21153         return node.kind === 202;
21154     }
21155     ts.isElementAccessExpression = isElementAccessExpression;
21156     function isCallExpression(node) {
21157         return node.kind === 203;
21158     }
21159     ts.isCallExpression = isCallExpression;
21160     function isNewExpression(node) {
21161         return node.kind === 204;
21162     }
21163     ts.isNewExpression = isNewExpression;
21164     function isTaggedTemplateExpression(node) {
21165         return node.kind === 205;
21166     }
21167     ts.isTaggedTemplateExpression = isTaggedTemplateExpression;
21168     function isTypeAssertionExpression(node) {
21169         return node.kind === 206;
21170     }
21171     ts.isTypeAssertionExpression = isTypeAssertionExpression;
21172     function isParenthesizedExpression(node) {
21173         return node.kind === 207;
21174     }
21175     ts.isParenthesizedExpression = isParenthesizedExpression;
21176     function isFunctionExpression(node) {
21177         return node.kind === 208;
21178     }
21179     ts.isFunctionExpression = isFunctionExpression;
21180     function isArrowFunction(node) {
21181         return node.kind === 209;
21182     }
21183     ts.isArrowFunction = isArrowFunction;
21184     function isDeleteExpression(node) {
21185         return node.kind === 210;
21186     }
21187     ts.isDeleteExpression = isDeleteExpression;
21188     function isTypeOfExpression(node) {
21189         return node.kind === 211;
21190     }
21191     ts.isTypeOfExpression = isTypeOfExpression;
21192     function isVoidExpression(node) {
21193         return node.kind === 212;
21194     }
21195     ts.isVoidExpression = isVoidExpression;
21196     function isAwaitExpression(node) {
21197         return node.kind === 213;
21198     }
21199     ts.isAwaitExpression = isAwaitExpression;
21200     function isPrefixUnaryExpression(node) {
21201         return node.kind === 214;
21202     }
21203     ts.isPrefixUnaryExpression = isPrefixUnaryExpression;
21204     function isPostfixUnaryExpression(node) {
21205         return node.kind === 215;
21206     }
21207     ts.isPostfixUnaryExpression = isPostfixUnaryExpression;
21208     function isBinaryExpression(node) {
21209         return node.kind === 216;
21210     }
21211     ts.isBinaryExpression = isBinaryExpression;
21212     function isConditionalExpression(node) {
21213         return node.kind === 217;
21214     }
21215     ts.isConditionalExpression = isConditionalExpression;
21216     function isTemplateExpression(node) {
21217         return node.kind === 218;
21218     }
21219     ts.isTemplateExpression = isTemplateExpression;
21220     function isYieldExpression(node) {
21221         return node.kind === 219;
21222     }
21223     ts.isYieldExpression = isYieldExpression;
21224     function isSpreadElement(node) {
21225         return node.kind === 220;
21226     }
21227     ts.isSpreadElement = isSpreadElement;
21228     function isClassExpression(node) {
21229         return node.kind === 221;
21230     }
21231     ts.isClassExpression = isClassExpression;
21232     function isOmittedExpression(node) {
21233         return node.kind === 222;
21234     }
21235     ts.isOmittedExpression = isOmittedExpression;
21236     function isExpressionWithTypeArguments(node) {
21237         return node.kind === 223;
21238     }
21239     ts.isExpressionWithTypeArguments = isExpressionWithTypeArguments;
21240     function isAsExpression(node) {
21241         return node.kind === 224;
21242     }
21243     ts.isAsExpression = isAsExpression;
21244     function isNonNullExpression(node) {
21245         return node.kind === 225;
21246     }
21247     ts.isNonNullExpression = isNonNullExpression;
21248     function isMetaProperty(node) {
21249         return node.kind === 226;
21250     }
21251     ts.isMetaProperty = isMetaProperty;
21252     function isSyntheticExpression(node) {
21253         return node.kind === 227;
21254     }
21255     ts.isSyntheticExpression = isSyntheticExpression;
21256     function isPartiallyEmittedExpression(node) {
21257         return node.kind === 336;
21258     }
21259     ts.isPartiallyEmittedExpression = isPartiallyEmittedExpression;
21260     function isCommaListExpression(node) {
21261         return node.kind === 337;
21262     }
21263     ts.isCommaListExpression = isCommaListExpression;
21264     function isTemplateSpan(node) {
21265         return node.kind === 228;
21266     }
21267     ts.isTemplateSpan = isTemplateSpan;
21268     function isSemicolonClassElement(node) {
21269         return node.kind === 229;
21270     }
21271     ts.isSemicolonClassElement = isSemicolonClassElement;
21272     function isBlock(node) {
21273         return node.kind === 230;
21274     }
21275     ts.isBlock = isBlock;
21276     function isVariableStatement(node) {
21277         return node.kind === 232;
21278     }
21279     ts.isVariableStatement = isVariableStatement;
21280     function isEmptyStatement(node) {
21281         return node.kind === 231;
21282     }
21283     ts.isEmptyStatement = isEmptyStatement;
21284     function isExpressionStatement(node) {
21285         return node.kind === 233;
21286     }
21287     ts.isExpressionStatement = isExpressionStatement;
21288     function isIfStatement(node) {
21289         return node.kind === 234;
21290     }
21291     ts.isIfStatement = isIfStatement;
21292     function isDoStatement(node) {
21293         return node.kind === 235;
21294     }
21295     ts.isDoStatement = isDoStatement;
21296     function isWhileStatement(node) {
21297         return node.kind === 236;
21298     }
21299     ts.isWhileStatement = isWhileStatement;
21300     function isForStatement(node) {
21301         return node.kind === 237;
21302     }
21303     ts.isForStatement = isForStatement;
21304     function isForInStatement(node) {
21305         return node.kind === 238;
21306     }
21307     ts.isForInStatement = isForInStatement;
21308     function isForOfStatement(node) {
21309         return node.kind === 239;
21310     }
21311     ts.isForOfStatement = isForOfStatement;
21312     function isContinueStatement(node) {
21313         return node.kind === 240;
21314     }
21315     ts.isContinueStatement = isContinueStatement;
21316     function isBreakStatement(node) {
21317         return node.kind === 241;
21318     }
21319     ts.isBreakStatement = isBreakStatement;
21320     function isReturnStatement(node) {
21321         return node.kind === 242;
21322     }
21323     ts.isReturnStatement = isReturnStatement;
21324     function isWithStatement(node) {
21325         return node.kind === 243;
21326     }
21327     ts.isWithStatement = isWithStatement;
21328     function isSwitchStatement(node) {
21329         return node.kind === 244;
21330     }
21331     ts.isSwitchStatement = isSwitchStatement;
21332     function isLabeledStatement(node) {
21333         return node.kind === 245;
21334     }
21335     ts.isLabeledStatement = isLabeledStatement;
21336     function isThrowStatement(node) {
21337         return node.kind === 246;
21338     }
21339     ts.isThrowStatement = isThrowStatement;
21340     function isTryStatement(node) {
21341         return node.kind === 247;
21342     }
21343     ts.isTryStatement = isTryStatement;
21344     function isDebuggerStatement(node) {
21345         return node.kind === 248;
21346     }
21347     ts.isDebuggerStatement = isDebuggerStatement;
21348     function isVariableDeclaration(node) {
21349         return node.kind === 249;
21350     }
21351     ts.isVariableDeclaration = isVariableDeclaration;
21352     function isVariableDeclarationList(node) {
21353         return node.kind === 250;
21354     }
21355     ts.isVariableDeclarationList = isVariableDeclarationList;
21356     function isFunctionDeclaration(node) {
21357         return node.kind === 251;
21358     }
21359     ts.isFunctionDeclaration = isFunctionDeclaration;
21360     function isClassDeclaration(node) {
21361         return node.kind === 252;
21362     }
21363     ts.isClassDeclaration = isClassDeclaration;
21364     function isInterfaceDeclaration(node) {
21365         return node.kind === 253;
21366     }
21367     ts.isInterfaceDeclaration = isInterfaceDeclaration;
21368     function isTypeAliasDeclaration(node) {
21369         return node.kind === 254;
21370     }
21371     ts.isTypeAliasDeclaration = isTypeAliasDeclaration;
21372     function isEnumDeclaration(node) {
21373         return node.kind === 255;
21374     }
21375     ts.isEnumDeclaration = isEnumDeclaration;
21376     function isModuleDeclaration(node) {
21377         return node.kind === 256;
21378     }
21379     ts.isModuleDeclaration = isModuleDeclaration;
21380     function isModuleBlock(node) {
21381         return node.kind === 257;
21382     }
21383     ts.isModuleBlock = isModuleBlock;
21384     function isCaseBlock(node) {
21385         return node.kind === 258;
21386     }
21387     ts.isCaseBlock = isCaseBlock;
21388     function isNamespaceExportDeclaration(node) {
21389         return node.kind === 259;
21390     }
21391     ts.isNamespaceExportDeclaration = isNamespaceExportDeclaration;
21392     function isImportEqualsDeclaration(node) {
21393         return node.kind === 260;
21394     }
21395     ts.isImportEqualsDeclaration = isImportEqualsDeclaration;
21396     function isImportDeclaration(node) {
21397         return node.kind === 261;
21398     }
21399     ts.isImportDeclaration = isImportDeclaration;
21400     function isImportClause(node) {
21401         return node.kind === 262;
21402     }
21403     ts.isImportClause = isImportClause;
21404     function isNamespaceImport(node) {
21405         return node.kind === 263;
21406     }
21407     ts.isNamespaceImport = isNamespaceImport;
21408     function isNamespaceExport(node) {
21409         return node.kind === 269;
21410     }
21411     ts.isNamespaceExport = isNamespaceExport;
21412     function isNamedImports(node) {
21413         return node.kind === 264;
21414     }
21415     ts.isNamedImports = isNamedImports;
21416     function isImportSpecifier(node) {
21417         return node.kind === 265;
21418     }
21419     ts.isImportSpecifier = isImportSpecifier;
21420     function isExportAssignment(node) {
21421         return node.kind === 266;
21422     }
21423     ts.isExportAssignment = isExportAssignment;
21424     function isExportDeclaration(node) {
21425         return node.kind === 267;
21426     }
21427     ts.isExportDeclaration = isExportDeclaration;
21428     function isNamedExports(node) {
21429         return node.kind === 268;
21430     }
21431     ts.isNamedExports = isNamedExports;
21432     function isExportSpecifier(node) {
21433         return node.kind === 270;
21434     }
21435     ts.isExportSpecifier = isExportSpecifier;
21436     function isMissingDeclaration(node) {
21437         return node.kind === 271;
21438     }
21439     ts.isMissingDeclaration = isMissingDeclaration;
21440     function isNotEmittedStatement(node) {
21441         return node.kind === 335;
21442     }
21443     ts.isNotEmittedStatement = isNotEmittedStatement;
21444     function isSyntheticReference(node) {
21445         return node.kind === 340;
21446     }
21447     ts.isSyntheticReference = isSyntheticReference;
21448     function isMergeDeclarationMarker(node) {
21449         return node.kind === 338;
21450     }
21451     ts.isMergeDeclarationMarker = isMergeDeclarationMarker;
21452     function isEndOfDeclarationMarker(node) {
21453         return node.kind === 339;
21454     }
21455     ts.isEndOfDeclarationMarker = isEndOfDeclarationMarker;
21456     function isExternalModuleReference(node) {
21457         return node.kind === 272;
21458     }
21459     ts.isExternalModuleReference = isExternalModuleReference;
21460     function isJsxElement(node) {
21461         return node.kind === 273;
21462     }
21463     ts.isJsxElement = isJsxElement;
21464     function isJsxSelfClosingElement(node) {
21465         return node.kind === 274;
21466     }
21467     ts.isJsxSelfClosingElement = isJsxSelfClosingElement;
21468     function isJsxOpeningElement(node) {
21469         return node.kind === 275;
21470     }
21471     ts.isJsxOpeningElement = isJsxOpeningElement;
21472     function isJsxClosingElement(node) {
21473         return node.kind === 276;
21474     }
21475     ts.isJsxClosingElement = isJsxClosingElement;
21476     function isJsxFragment(node) {
21477         return node.kind === 277;
21478     }
21479     ts.isJsxFragment = isJsxFragment;
21480     function isJsxOpeningFragment(node) {
21481         return node.kind === 278;
21482     }
21483     ts.isJsxOpeningFragment = isJsxOpeningFragment;
21484     function isJsxClosingFragment(node) {
21485         return node.kind === 279;
21486     }
21487     ts.isJsxClosingFragment = isJsxClosingFragment;
21488     function isJsxAttribute(node) {
21489         return node.kind === 280;
21490     }
21491     ts.isJsxAttribute = isJsxAttribute;
21492     function isJsxAttributes(node) {
21493         return node.kind === 281;
21494     }
21495     ts.isJsxAttributes = isJsxAttributes;
21496     function isJsxSpreadAttribute(node) {
21497         return node.kind === 282;
21498     }
21499     ts.isJsxSpreadAttribute = isJsxSpreadAttribute;
21500     function isJsxExpression(node) {
21501         return node.kind === 283;
21502     }
21503     ts.isJsxExpression = isJsxExpression;
21504     function isCaseClause(node) {
21505         return node.kind === 284;
21506     }
21507     ts.isCaseClause = isCaseClause;
21508     function isDefaultClause(node) {
21509         return node.kind === 285;
21510     }
21511     ts.isDefaultClause = isDefaultClause;
21512     function isHeritageClause(node) {
21513         return node.kind === 286;
21514     }
21515     ts.isHeritageClause = isHeritageClause;
21516     function isCatchClause(node) {
21517         return node.kind === 287;
21518     }
21519     ts.isCatchClause = isCatchClause;
21520     function isPropertyAssignment(node) {
21521         return node.kind === 288;
21522     }
21523     ts.isPropertyAssignment = isPropertyAssignment;
21524     function isShorthandPropertyAssignment(node) {
21525         return node.kind === 289;
21526     }
21527     ts.isShorthandPropertyAssignment = isShorthandPropertyAssignment;
21528     function isSpreadAssignment(node) {
21529         return node.kind === 290;
21530     }
21531     ts.isSpreadAssignment = isSpreadAssignment;
21532     function isEnumMember(node) {
21533         return node.kind === 291;
21534     }
21535     ts.isEnumMember = isEnumMember;
21536     function isUnparsedPrepend(node) {
21537         return node.kind === 293;
21538     }
21539     ts.isUnparsedPrepend = isUnparsedPrepend;
21540     function isSourceFile(node) {
21541         return node.kind === 297;
21542     }
21543     ts.isSourceFile = isSourceFile;
21544     function isBundle(node) {
21545         return node.kind === 298;
21546     }
21547     ts.isBundle = isBundle;
21548     function isUnparsedSource(node) {
21549         return node.kind === 299;
21550     }
21551     ts.isUnparsedSource = isUnparsedSource;
21552     function isJSDocTypeExpression(node) {
21553         return node.kind === 301;
21554     }
21555     ts.isJSDocTypeExpression = isJSDocTypeExpression;
21556     function isJSDocNameReference(node) {
21557         return node.kind === 302;
21558     }
21559     ts.isJSDocNameReference = isJSDocNameReference;
21560     function isJSDocAllType(node) {
21561         return node.kind === 303;
21562     }
21563     ts.isJSDocAllType = isJSDocAllType;
21564     function isJSDocUnknownType(node) {
21565         return node.kind === 304;
21566     }
21567     ts.isJSDocUnknownType = isJSDocUnknownType;
21568     function isJSDocNullableType(node) {
21569         return node.kind === 305;
21570     }
21571     ts.isJSDocNullableType = isJSDocNullableType;
21572     function isJSDocNonNullableType(node) {
21573         return node.kind === 306;
21574     }
21575     ts.isJSDocNonNullableType = isJSDocNonNullableType;
21576     function isJSDocOptionalType(node) {
21577         return node.kind === 307;
21578     }
21579     ts.isJSDocOptionalType = isJSDocOptionalType;
21580     function isJSDocFunctionType(node) {
21581         return node.kind === 308;
21582     }
21583     ts.isJSDocFunctionType = isJSDocFunctionType;
21584     function isJSDocVariadicType(node) {
21585         return node.kind === 309;
21586     }
21587     ts.isJSDocVariadicType = isJSDocVariadicType;
21588     function isJSDocNamepathType(node) {
21589         return node.kind === 310;
21590     }
21591     ts.isJSDocNamepathType = isJSDocNamepathType;
21592     function isJSDoc(node) {
21593         return node.kind === 311;
21594     }
21595     ts.isJSDoc = isJSDoc;
21596     function isJSDocTypeLiteral(node) {
21597         return node.kind === 312;
21598     }
21599     ts.isJSDocTypeLiteral = isJSDocTypeLiteral;
21600     function isJSDocSignature(node) {
21601         return node.kind === 313;
21602     }
21603     ts.isJSDocSignature = isJSDocSignature;
21604     function isJSDocAugmentsTag(node) {
21605         return node.kind === 315;
21606     }
21607     ts.isJSDocAugmentsTag = isJSDocAugmentsTag;
21608     function isJSDocAuthorTag(node) {
21609         return node.kind === 317;
21610     }
21611     ts.isJSDocAuthorTag = isJSDocAuthorTag;
21612     function isJSDocClassTag(node) {
21613         return node.kind === 319;
21614     }
21615     ts.isJSDocClassTag = isJSDocClassTag;
21616     function isJSDocCallbackTag(node) {
21617         return node.kind === 324;
21618     }
21619     ts.isJSDocCallbackTag = isJSDocCallbackTag;
21620     function isJSDocPublicTag(node) {
21621         return node.kind === 320;
21622     }
21623     ts.isJSDocPublicTag = isJSDocPublicTag;
21624     function isJSDocPrivateTag(node) {
21625         return node.kind === 321;
21626     }
21627     ts.isJSDocPrivateTag = isJSDocPrivateTag;
21628     function isJSDocProtectedTag(node) {
21629         return node.kind === 322;
21630     }
21631     ts.isJSDocProtectedTag = isJSDocProtectedTag;
21632     function isJSDocReadonlyTag(node) {
21633         return node.kind === 323;
21634     }
21635     ts.isJSDocReadonlyTag = isJSDocReadonlyTag;
21636     function isJSDocDeprecatedTag(node) {
21637         return node.kind === 318;
21638     }
21639     ts.isJSDocDeprecatedTag = isJSDocDeprecatedTag;
21640     function isJSDocEnumTag(node) {
21641         return node.kind === 325;
21642     }
21643     ts.isJSDocEnumTag = isJSDocEnumTag;
21644     function isJSDocParameterTag(node) {
21645         return node.kind === 326;
21646     }
21647     ts.isJSDocParameterTag = isJSDocParameterTag;
21648     function isJSDocReturnTag(node) {
21649         return node.kind === 327;
21650     }
21651     ts.isJSDocReturnTag = isJSDocReturnTag;
21652     function isJSDocThisTag(node) {
21653         return node.kind === 328;
21654     }
21655     ts.isJSDocThisTag = isJSDocThisTag;
21656     function isJSDocTypeTag(node) {
21657         return node.kind === 329;
21658     }
21659     ts.isJSDocTypeTag = isJSDocTypeTag;
21660     function isJSDocTemplateTag(node) {
21661         return node.kind === 330;
21662     }
21663     ts.isJSDocTemplateTag = isJSDocTemplateTag;
21664     function isJSDocTypedefTag(node) {
21665         return node.kind === 331;
21666     }
21667     ts.isJSDocTypedefTag = isJSDocTypedefTag;
21668     function isJSDocUnknownTag(node) {
21669         return node.kind === 314;
21670     }
21671     ts.isJSDocUnknownTag = isJSDocUnknownTag;
21672     function isJSDocPropertyTag(node) {
21673         return node.kind === 333;
21674     }
21675     ts.isJSDocPropertyTag = isJSDocPropertyTag;
21676     function isJSDocImplementsTag(node) {
21677         return node.kind === 316;
21678     }
21679     ts.isJSDocImplementsTag = isJSDocImplementsTag;
21680     function isSyntaxList(n) {
21681         return n.kind === 334;
21682     }
21683     ts.isSyntaxList = isSyntaxList;
21684 })(ts || (ts = {}));
21685 var ts;
21686 (function (ts) {
21687     function createEmptyExports(factory) {
21688         return factory.createExportDeclaration(undefined, undefined, false, factory.createNamedExports([]), undefined);
21689     }
21690     ts.createEmptyExports = createEmptyExports;
21691     function createMemberAccessForPropertyName(factory, target, memberName, location) {
21692         if (ts.isComputedPropertyName(memberName)) {
21693             return ts.setTextRange(factory.createElementAccessExpression(target, memberName.expression), location);
21694         }
21695         else {
21696             var expression = ts.setTextRange(ts.isIdentifierOrPrivateIdentifier(memberName)
21697                 ? factory.createPropertyAccessExpression(target, memberName)
21698                 : factory.createElementAccessExpression(target, memberName), memberName);
21699             ts.getOrCreateEmitNode(expression).flags |= 64;
21700             return expression;
21701         }
21702     }
21703     ts.createMemberAccessForPropertyName = createMemberAccessForPropertyName;
21704     function createReactNamespace(reactNamespace, parent) {
21705         var react = ts.parseNodeFactory.createIdentifier(reactNamespace || "React");
21706         ts.setParent(react, ts.getParseTreeNode(parent));
21707         return react;
21708     }
21709     function createJsxFactoryExpressionFromEntityName(factory, jsxFactory, parent) {
21710         if (ts.isQualifiedName(jsxFactory)) {
21711             var left = createJsxFactoryExpressionFromEntityName(factory, jsxFactory.left, parent);
21712             var right = factory.createIdentifier(ts.idText(jsxFactory.right));
21713             right.escapedText = jsxFactory.right.escapedText;
21714             return factory.createPropertyAccessExpression(left, right);
21715         }
21716         else {
21717             return createReactNamespace(ts.idText(jsxFactory), parent);
21718         }
21719     }
21720     function createJsxFactoryExpression(factory, jsxFactoryEntity, reactNamespace, parent) {
21721         return jsxFactoryEntity ?
21722             createJsxFactoryExpressionFromEntityName(factory, jsxFactoryEntity, parent) :
21723             factory.createPropertyAccessExpression(createReactNamespace(reactNamespace, parent), "createElement");
21724     }
21725     ts.createJsxFactoryExpression = createJsxFactoryExpression;
21726     function createJsxFragmentFactoryExpression(factory, jsxFragmentFactoryEntity, reactNamespace, parent) {
21727         return jsxFragmentFactoryEntity ?
21728             createJsxFactoryExpressionFromEntityName(factory, jsxFragmentFactoryEntity, parent) :
21729             factory.createPropertyAccessExpression(createReactNamespace(reactNamespace, parent), "Fragment");
21730     }
21731     function createExpressionForJsxElement(factory, callee, tagName, props, children, location) {
21732         var argumentsList = [tagName];
21733         if (props) {
21734             argumentsList.push(props);
21735         }
21736         if (children && children.length > 0) {
21737             if (!props) {
21738                 argumentsList.push(factory.createNull());
21739             }
21740             if (children.length > 1) {
21741                 for (var _i = 0, children_3 = children; _i < children_3.length; _i++) {
21742                     var child = children_3[_i];
21743                     startOnNewLine(child);
21744                     argumentsList.push(child);
21745                 }
21746             }
21747             else {
21748                 argumentsList.push(children[0]);
21749             }
21750         }
21751         return ts.setTextRange(factory.createCallExpression(callee, undefined, argumentsList), location);
21752     }
21753     ts.createExpressionForJsxElement = createExpressionForJsxElement;
21754     function createExpressionForJsxFragment(factory, jsxFactoryEntity, jsxFragmentFactoryEntity, reactNamespace, children, parentElement, location) {
21755         var tagName = createJsxFragmentFactoryExpression(factory, jsxFragmentFactoryEntity, reactNamespace, parentElement);
21756         var argumentsList = [tagName, factory.createNull()];
21757         if (children && children.length > 0) {
21758             if (children.length > 1) {
21759                 for (var _i = 0, children_4 = children; _i < children_4.length; _i++) {
21760                     var child = children_4[_i];
21761                     startOnNewLine(child);
21762                     argumentsList.push(child);
21763                 }
21764             }
21765             else {
21766                 argumentsList.push(children[0]);
21767             }
21768         }
21769         return ts.setTextRange(factory.createCallExpression(createJsxFactoryExpression(factory, jsxFactoryEntity, reactNamespace, parentElement), undefined, argumentsList), location);
21770     }
21771     ts.createExpressionForJsxFragment = createExpressionForJsxFragment;
21772     function createForOfBindingStatement(factory, node, boundValue) {
21773         if (ts.isVariableDeclarationList(node)) {
21774             var firstDeclaration = ts.first(node.declarations);
21775             var updatedDeclaration = factory.updateVariableDeclaration(firstDeclaration, firstDeclaration.name, undefined, undefined, boundValue);
21776             return ts.setTextRange(factory.createVariableStatement(undefined, factory.updateVariableDeclarationList(node, [updatedDeclaration])), node);
21777         }
21778         else {
21779             var updatedExpression = ts.setTextRange(factory.createAssignment(node, boundValue), node);
21780             return ts.setTextRange(factory.createExpressionStatement(updatedExpression), node);
21781         }
21782     }
21783     ts.createForOfBindingStatement = createForOfBindingStatement;
21784     function insertLeadingStatement(factory, dest, source) {
21785         if (ts.isBlock(dest)) {
21786             return factory.updateBlock(dest, ts.setTextRange(factory.createNodeArray(__spreadArrays([source], dest.statements)), dest.statements));
21787         }
21788         else {
21789             return factory.createBlock(factory.createNodeArray([dest, source]), true);
21790         }
21791     }
21792     ts.insertLeadingStatement = insertLeadingStatement;
21793     function createExpressionFromEntityName(factory, node) {
21794         if (ts.isQualifiedName(node)) {
21795             var left = createExpressionFromEntityName(factory, node.left);
21796             var right = ts.setParent(ts.setTextRange(factory.cloneNode(node.right), node.right), node.right.parent);
21797             return ts.setTextRange(factory.createPropertyAccessExpression(left, right), node);
21798         }
21799         else {
21800             return ts.setParent(ts.setTextRange(factory.cloneNode(node), node), node.parent);
21801         }
21802     }
21803     ts.createExpressionFromEntityName = createExpressionFromEntityName;
21804     function createExpressionForPropertyName(factory, memberName) {
21805         if (ts.isIdentifier(memberName)) {
21806             return factory.createStringLiteralFromNode(memberName);
21807         }
21808         else if (ts.isComputedPropertyName(memberName)) {
21809             return ts.setParent(ts.setTextRange(factory.cloneNode(memberName.expression), memberName.expression), memberName.expression.parent);
21810         }
21811         else {
21812             return ts.setParent(ts.setTextRange(factory.cloneNode(memberName), memberName), memberName.parent);
21813         }
21814     }
21815     ts.createExpressionForPropertyName = createExpressionForPropertyName;
21816     function createExpressionForAccessorDeclaration(factory, properties, property, receiver, multiLine) {
21817         var _a = ts.getAllAccessorDeclarations(properties, property), firstAccessor = _a.firstAccessor, getAccessor = _a.getAccessor, setAccessor = _a.setAccessor;
21818         if (property === firstAccessor) {
21819             return ts.setTextRange(factory.createObjectDefinePropertyCall(receiver, createExpressionForPropertyName(factory, property.name), factory.createPropertyDescriptor({
21820                 enumerable: factory.createFalse(),
21821                 configurable: true,
21822                 get: getAccessor && ts.setTextRange(ts.setOriginalNode(factory.createFunctionExpression(getAccessor.modifiers, undefined, undefined, undefined, getAccessor.parameters, undefined, getAccessor.body), getAccessor), getAccessor),
21823                 set: setAccessor && ts.setTextRange(ts.setOriginalNode(factory.createFunctionExpression(setAccessor.modifiers, undefined, undefined, undefined, setAccessor.parameters, undefined, setAccessor.body), setAccessor), setAccessor)
21824             }, !multiLine)), firstAccessor);
21825         }
21826         return undefined;
21827     }
21828     function createExpressionForPropertyAssignment(factory, property, receiver) {
21829         return ts.setOriginalNode(ts.setTextRange(factory.createAssignment(createMemberAccessForPropertyName(factory, receiver, property.name, property.name), property.initializer), property), property);
21830     }
21831     function createExpressionForShorthandPropertyAssignment(factory, property, receiver) {
21832         return ts.setOriginalNode(ts.setTextRange(factory.createAssignment(createMemberAccessForPropertyName(factory, receiver, property.name, property.name), factory.cloneNode(property.name)), property), property);
21833     }
21834     function createExpressionForMethodDeclaration(factory, method, receiver) {
21835         return ts.setOriginalNode(ts.setTextRange(factory.createAssignment(createMemberAccessForPropertyName(factory, receiver, method.name, method.name), ts.setOriginalNode(ts.setTextRange(factory.createFunctionExpression(method.modifiers, method.asteriskToken, undefined, undefined, method.parameters, undefined, method.body), method), method)), method), method);
21836     }
21837     function createExpressionForObjectLiteralElementLike(factory, node, property, receiver) {
21838         if (property.name && ts.isPrivateIdentifier(property.name)) {
21839             ts.Debug.failBadSyntaxKind(property.name, "Private identifiers are not allowed in object literals.");
21840         }
21841         switch (property.kind) {
21842             case 167:
21843             case 168:
21844                 return createExpressionForAccessorDeclaration(factory, node.properties, property, receiver, !!node.multiLine);
21845             case 288:
21846                 return createExpressionForPropertyAssignment(factory, property, receiver);
21847             case 289:
21848                 return createExpressionForShorthandPropertyAssignment(factory, property, receiver);
21849             case 165:
21850                 return createExpressionForMethodDeclaration(factory, property, receiver);
21851         }
21852     }
21853     ts.createExpressionForObjectLiteralElementLike = createExpressionForObjectLiteralElementLike;
21854     function isInternalName(node) {
21855         return (ts.getEmitFlags(node) & 32768) !== 0;
21856     }
21857     ts.isInternalName = isInternalName;
21858     function isLocalName(node) {
21859         return (ts.getEmitFlags(node) & 16384) !== 0;
21860     }
21861     ts.isLocalName = isLocalName;
21862     function isExportName(node) {
21863         return (ts.getEmitFlags(node) & 8192) !== 0;
21864     }
21865     ts.isExportName = isExportName;
21866     function isUseStrictPrologue(node) {
21867         return ts.isStringLiteral(node.expression) && node.expression.text === "use strict";
21868     }
21869     function findUseStrictPrologue(statements) {
21870         for (var _i = 0, statements_1 = statements; _i < statements_1.length; _i++) {
21871             var statement = statements_1[_i];
21872             if (ts.isPrologueDirective(statement)) {
21873                 if (isUseStrictPrologue(statement)) {
21874                     return statement;
21875                 }
21876             }
21877             else {
21878                 break;
21879             }
21880         }
21881         return undefined;
21882     }
21883     ts.findUseStrictPrologue = findUseStrictPrologue;
21884     function startsWithUseStrict(statements) {
21885         var firstStatement = ts.firstOrUndefined(statements);
21886         return firstStatement !== undefined
21887             && ts.isPrologueDirective(firstStatement)
21888             && isUseStrictPrologue(firstStatement);
21889     }
21890     ts.startsWithUseStrict = startsWithUseStrict;
21891     function isCommaSequence(node) {
21892         return node.kind === 216 && node.operatorToken.kind === 27 ||
21893             node.kind === 337;
21894     }
21895     ts.isCommaSequence = isCommaSequence;
21896     function isOuterExpression(node, kinds) {
21897         if (kinds === void 0) { kinds = 15; }
21898         switch (node.kind) {
21899             case 207:
21900                 return (kinds & 1) !== 0;
21901             case 206:
21902             case 224:
21903                 return (kinds & 2) !== 0;
21904             case 225:
21905                 return (kinds & 4) !== 0;
21906             case 336:
21907                 return (kinds & 8) !== 0;
21908         }
21909         return false;
21910     }
21911     ts.isOuterExpression = isOuterExpression;
21912     function skipOuterExpressions(node, kinds) {
21913         if (kinds === void 0) { kinds = 15; }
21914         while (isOuterExpression(node, kinds)) {
21915             node = node.expression;
21916         }
21917         return node;
21918     }
21919     ts.skipOuterExpressions = skipOuterExpressions;
21920     function skipAssertions(node) {
21921         return skipOuterExpressions(node, 6);
21922     }
21923     ts.skipAssertions = skipAssertions;
21924     function startOnNewLine(node) {
21925         return ts.setStartsOnNewLine(node, true);
21926     }
21927     ts.startOnNewLine = startOnNewLine;
21928     function getExternalHelpersModuleName(node) {
21929         var parseNode = ts.getOriginalNode(node, ts.isSourceFile);
21930         var emitNode = parseNode && parseNode.emitNode;
21931         return emitNode && emitNode.externalHelpersModuleName;
21932     }
21933     ts.getExternalHelpersModuleName = getExternalHelpersModuleName;
21934     function hasRecordedExternalHelpers(sourceFile) {
21935         var parseNode = ts.getOriginalNode(sourceFile, ts.isSourceFile);
21936         var emitNode = parseNode && parseNode.emitNode;
21937         return !!emitNode && (!!emitNode.externalHelpersModuleName || !!emitNode.externalHelpers);
21938     }
21939     ts.hasRecordedExternalHelpers = hasRecordedExternalHelpers;
21940     function createExternalHelpersImportDeclarationIfNeeded(nodeFactory, helperFactory, sourceFile, compilerOptions, hasExportStarsToExportValues, hasImportStar, hasImportDefault) {
21941         if (compilerOptions.importHelpers && ts.isEffectiveExternalModule(sourceFile, compilerOptions)) {
21942             var namedBindings = void 0;
21943             var moduleKind = ts.getEmitModuleKind(compilerOptions);
21944             if (moduleKind >= ts.ModuleKind.ES2015 && moduleKind <= ts.ModuleKind.ESNext) {
21945                 var helpers = ts.getEmitHelpers(sourceFile);
21946                 if (helpers) {
21947                     var helperNames = [];
21948                     for (var _i = 0, helpers_3 = helpers; _i < helpers_3.length; _i++) {
21949                         var helper = helpers_3[_i];
21950                         if (!helper.scoped) {
21951                             var importName = helper.importName;
21952                             if (importName) {
21953                                 ts.pushIfUnique(helperNames, importName);
21954                             }
21955                         }
21956                     }
21957                     if (ts.some(helperNames)) {
21958                         helperNames.sort(ts.compareStringsCaseSensitive);
21959                         namedBindings = nodeFactory.createNamedImports(ts.map(helperNames, function (name) { return ts.isFileLevelUniqueName(sourceFile, name)
21960                             ? nodeFactory.createImportSpecifier(undefined, nodeFactory.createIdentifier(name))
21961                             : nodeFactory.createImportSpecifier(nodeFactory.createIdentifier(name), helperFactory.getUnscopedHelperName(name)); }));
21962                         var parseNode = ts.getOriginalNode(sourceFile, ts.isSourceFile);
21963                         var emitNode = ts.getOrCreateEmitNode(parseNode);
21964                         emitNode.externalHelpers = true;
21965                     }
21966                 }
21967             }
21968             else {
21969                 var externalHelpersModuleName = getOrCreateExternalHelpersModuleNameIfNeeded(nodeFactory, sourceFile, compilerOptions, hasExportStarsToExportValues, hasImportStar || hasImportDefault);
21970                 if (externalHelpersModuleName) {
21971                     namedBindings = nodeFactory.createNamespaceImport(externalHelpersModuleName);
21972                 }
21973             }
21974             if (namedBindings) {
21975                 var externalHelpersImportDeclaration = nodeFactory.createImportDeclaration(undefined, undefined, nodeFactory.createImportClause(false, undefined, namedBindings), nodeFactory.createStringLiteral(ts.externalHelpersModuleNameText));
21976                 ts.addEmitFlags(externalHelpersImportDeclaration, 67108864);
21977                 return externalHelpersImportDeclaration;
21978             }
21979         }
21980     }
21981     ts.createExternalHelpersImportDeclarationIfNeeded = createExternalHelpersImportDeclarationIfNeeded;
21982     function getOrCreateExternalHelpersModuleNameIfNeeded(factory, node, compilerOptions, hasExportStarsToExportValues, hasImportStarOrImportDefault) {
21983         if (compilerOptions.importHelpers && ts.isEffectiveExternalModule(node, compilerOptions)) {
21984             var externalHelpersModuleName = getExternalHelpersModuleName(node);
21985             if (externalHelpersModuleName) {
21986                 return externalHelpersModuleName;
21987             }
21988             var moduleKind = ts.getEmitModuleKind(compilerOptions);
21989             var create = (hasExportStarsToExportValues || (compilerOptions.esModuleInterop && hasImportStarOrImportDefault))
21990                 && moduleKind !== ts.ModuleKind.System
21991                 && moduleKind < ts.ModuleKind.ES2015;
21992             if (!create) {
21993                 var helpers = ts.getEmitHelpers(node);
21994                 if (helpers) {
21995                     for (var _i = 0, helpers_4 = helpers; _i < helpers_4.length; _i++) {
21996                         var helper = helpers_4[_i];
21997                         if (!helper.scoped) {
21998                             create = true;
21999                             break;
22000                         }
22001                     }
22002                 }
22003             }
22004             if (create) {
22005                 var parseNode = ts.getOriginalNode(node, ts.isSourceFile);
22006                 var emitNode = ts.getOrCreateEmitNode(parseNode);
22007                 return emitNode.externalHelpersModuleName || (emitNode.externalHelpersModuleName = factory.createUniqueName(ts.externalHelpersModuleNameText));
22008             }
22009         }
22010     }
22011     ts.getOrCreateExternalHelpersModuleNameIfNeeded = getOrCreateExternalHelpersModuleNameIfNeeded;
22012     function getLocalNameForExternalImport(factory, node, sourceFile) {
22013         var namespaceDeclaration = ts.getNamespaceDeclarationNode(node);
22014         if (namespaceDeclaration && !ts.isDefaultImport(node) && !ts.isExportNamespaceAsDefaultDeclaration(node)) {
22015             var name = namespaceDeclaration.name;
22016             return ts.isGeneratedIdentifier(name) ? name : factory.createIdentifier(ts.getSourceTextOfNodeFromSourceFile(sourceFile, name) || ts.idText(name));
22017         }
22018         if (node.kind === 261 && node.importClause) {
22019             return factory.getGeneratedNameForNode(node);
22020         }
22021         if (node.kind === 267 && node.moduleSpecifier) {
22022             return factory.getGeneratedNameForNode(node);
22023         }
22024         return undefined;
22025     }
22026     ts.getLocalNameForExternalImport = getLocalNameForExternalImport;
22027     function getExternalModuleNameLiteral(factory, importNode, sourceFile, host, resolver, compilerOptions) {
22028         var moduleName = ts.getExternalModuleName(importNode);
22029         if (moduleName.kind === 10) {
22030             return tryGetModuleNameFromDeclaration(importNode, host, factory, resolver, compilerOptions)
22031                 || tryRenameExternalModule(factory, moduleName, sourceFile)
22032                 || factory.cloneNode(moduleName);
22033         }
22034         return undefined;
22035     }
22036     ts.getExternalModuleNameLiteral = getExternalModuleNameLiteral;
22037     function tryRenameExternalModule(factory, moduleName, sourceFile) {
22038         var rename = sourceFile.renamedDependencies && sourceFile.renamedDependencies.get(moduleName.text);
22039         return rename && factory.createStringLiteral(rename);
22040     }
22041     function tryGetModuleNameFromFile(factory, file, host, options) {
22042         if (!file) {
22043             return undefined;
22044         }
22045         if (file.moduleName) {
22046             return factory.createStringLiteral(file.moduleName);
22047         }
22048         if (!file.isDeclarationFile && ts.outFile(options)) {
22049             return factory.createStringLiteral(ts.getExternalModuleNameFromPath(host, file.fileName));
22050         }
22051         return undefined;
22052     }
22053     ts.tryGetModuleNameFromFile = tryGetModuleNameFromFile;
22054     function tryGetModuleNameFromDeclaration(declaration, host, factory, resolver, compilerOptions) {
22055         return tryGetModuleNameFromFile(factory, resolver.getExternalModuleFileFromDeclaration(declaration), host, compilerOptions);
22056     }
22057     function getInitializerOfBindingOrAssignmentElement(bindingElement) {
22058         if (ts.isDeclarationBindingElement(bindingElement)) {
22059             return bindingElement.initializer;
22060         }
22061         if (ts.isPropertyAssignment(bindingElement)) {
22062             var initializer = bindingElement.initializer;
22063             return ts.isAssignmentExpression(initializer, true)
22064                 ? initializer.right
22065                 : undefined;
22066         }
22067         if (ts.isShorthandPropertyAssignment(bindingElement)) {
22068             return bindingElement.objectAssignmentInitializer;
22069         }
22070         if (ts.isAssignmentExpression(bindingElement, true)) {
22071             return bindingElement.right;
22072         }
22073         if (ts.isSpreadElement(bindingElement)) {
22074             return getInitializerOfBindingOrAssignmentElement(bindingElement.expression);
22075         }
22076     }
22077     ts.getInitializerOfBindingOrAssignmentElement = getInitializerOfBindingOrAssignmentElement;
22078     function getTargetOfBindingOrAssignmentElement(bindingElement) {
22079         if (ts.isDeclarationBindingElement(bindingElement)) {
22080             return bindingElement.name;
22081         }
22082         if (ts.isObjectLiteralElementLike(bindingElement)) {
22083             switch (bindingElement.kind) {
22084                 case 288:
22085                     return getTargetOfBindingOrAssignmentElement(bindingElement.initializer);
22086                 case 289:
22087                     return bindingElement.name;
22088                 case 290:
22089                     return getTargetOfBindingOrAssignmentElement(bindingElement.expression);
22090             }
22091             return undefined;
22092         }
22093         if (ts.isAssignmentExpression(bindingElement, true)) {
22094             return getTargetOfBindingOrAssignmentElement(bindingElement.left);
22095         }
22096         if (ts.isSpreadElement(bindingElement)) {
22097             return getTargetOfBindingOrAssignmentElement(bindingElement.expression);
22098         }
22099         return bindingElement;
22100     }
22101     ts.getTargetOfBindingOrAssignmentElement = getTargetOfBindingOrAssignmentElement;
22102     function getRestIndicatorOfBindingOrAssignmentElement(bindingElement) {
22103         switch (bindingElement.kind) {
22104             case 160:
22105             case 198:
22106                 return bindingElement.dotDotDotToken;
22107             case 220:
22108             case 290:
22109                 return bindingElement;
22110         }
22111         return undefined;
22112     }
22113     ts.getRestIndicatorOfBindingOrAssignmentElement = getRestIndicatorOfBindingOrAssignmentElement;
22114     function getPropertyNameOfBindingOrAssignmentElement(bindingElement) {
22115         var propertyName = tryGetPropertyNameOfBindingOrAssignmentElement(bindingElement);
22116         ts.Debug.assert(!!propertyName || ts.isSpreadAssignment(bindingElement), "Invalid property name for binding element.");
22117         return propertyName;
22118     }
22119     ts.getPropertyNameOfBindingOrAssignmentElement = getPropertyNameOfBindingOrAssignmentElement;
22120     function tryGetPropertyNameOfBindingOrAssignmentElement(bindingElement) {
22121         switch (bindingElement.kind) {
22122             case 198:
22123                 if (bindingElement.propertyName) {
22124                     var propertyName = bindingElement.propertyName;
22125                     if (ts.isPrivateIdentifier(propertyName)) {
22126                         return ts.Debug.failBadSyntaxKind(propertyName);
22127                     }
22128                     return ts.isComputedPropertyName(propertyName) && isStringOrNumericLiteral(propertyName.expression)
22129                         ? propertyName.expression
22130                         : propertyName;
22131                 }
22132                 break;
22133             case 288:
22134                 if (bindingElement.name) {
22135                     var propertyName = bindingElement.name;
22136                     if (ts.isPrivateIdentifier(propertyName)) {
22137                         return ts.Debug.failBadSyntaxKind(propertyName);
22138                     }
22139                     return ts.isComputedPropertyName(propertyName) && isStringOrNumericLiteral(propertyName.expression)
22140                         ? propertyName.expression
22141                         : propertyName;
22142                 }
22143                 break;
22144             case 290:
22145                 if (bindingElement.name && ts.isPrivateIdentifier(bindingElement.name)) {
22146                     return ts.Debug.failBadSyntaxKind(bindingElement.name);
22147                 }
22148                 return bindingElement.name;
22149         }
22150         var target = getTargetOfBindingOrAssignmentElement(bindingElement);
22151         if (target && ts.isPropertyName(target)) {
22152             return target;
22153         }
22154     }
22155     ts.tryGetPropertyNameOfBindingOrAssignmentElement = tryGetPropertyNameOfBindingOrAssignmentElement;
22156     function isStringOrNumericLiteral(node) {
22157         var kind = node.kind;
22158         return kind === 10
22159             || kind === 8;
22160     }
22161     function getElementsOfBindingOrAssignmentPattern(name) {
22162         switch (name.kind) {
22163             case 196:
22164             case 197:
22165             case 199:
22166                 return name.elements;
22167             case 200:
22168                 return name.properties;
22169         }
22170     }
22171     ts.getElementsOfBindingOrAssignmentPattern = getElementsOfBindingOrAssignmentPattern;
22172     function getJSDocTypeAliasName(fullName) {
22173         if (fullName) {
22174             var rightNode = fullName;
22175             while (true) {
22176                 if (ts.isIdentifier(rightNode) || !rightNode.body) {
22177                     return ts.isIdentifier(rightNode) ? rightNode : rightNode.name;
22178                 }
22179                 rightNode = rightNode.body;
22180             }
22181         }
22182     }
22183     ts.getJSDocTypeAliasName = getJSDocTypeAliasName;
22184     function canHaveModifiers(node) {
22185         var kind = node.kind;
22186         return kind === 160
22187             || kind === 162
22188             || kind === 163
22189             || kind === 164
22190             || kind === 165
22191             || kind === 166
22192             || kind === 167
22193             || kind === 168
22194             || kind === 171
22195             || kind === 208
22196             || kind === 209
22197             || kind === 221
22198             || kind === 232
22199             || kind === 251
22200             || kind === 252
22201             || kind === 253
22202             || kind === 254
22203             || kind === 255
22204             || kind === 256
22205             || kind === 260
22206             || kind === 261
22207             || kind === 266
22208             || kind === 267;
22209     }
22210     ts.canHaveModifiers = canHaveModifiers;
22211     function isExportModifier(node) {
22212         return node.kind === 92;
22213     }
22214     ts.isExportModifier = isExportModifier;
22215     function isAsyncModifier(node) {
22216         return node.kind === 129;
22217     }
22218     ts.isAsyncModifier = isAsyncModifier;
22219     function isStaticModifier(node) {
22220         return node.kind === 123;
22221     }
22222     ts.isStaticModifier = isStaticModifier;
22223 })(ts || (ts = {}));
22224 var ts;
22225 (function (ts) {
22226     function setTextRange(range, location) {
22227         return location ? ts.setTextRangePosEnd(range, location.pos, location.end) : range;
22228     }
22229     ts.setTextRange = setTextRange;
22230 })(ts || (ts = {}));
22231 var ts;
22232 (function (ts) {
22233     var NodeConstructor;
22234     var TokenConstructor;
22235     var IdentifierConstructor;
22236     var PrivateIdentifierConstructor;
22237     var SourceFileConstructor;
22238     ts.parseBaseNodeFactory = {
22239         createBaseSourceFileNode: function (kind) { return new (SourceFileConstructor || (SourceFileConstructor = ts.objectAllocator.getSourceFileConstructor()))(kind, -1, -1); },
22240         createBaseIdentifierNode: function (kind) { return new (IdentifierConstructor || (IdentifierConstructor = ts.objectAllocator.getIdentifierConstructor()))(kind, -1, -1); },
22241         createBasePrivateIdentifierNode: function (kind) { return new (PrivateIdentifierConstructor || (PrivateIdentifierConstructor = ts.objectAllocator.getPrivateIdentifierConstructor()))(kind, -1, -1); },
22242         createBaseTokenNode: function (kind) { return new (TokenConstructor || (TokenConstructor = ts.objectAllocator.getTokenConstructor()))(kind, -1, -1); },
22243         createBaseNode: function (kind) { return new (NodeConstructor || (NodeConstructor = ts.objectAllocator.getNodeConstructor()))(kind, -1, -1); },
22244     };
22245     ts.parseNodeFactory = ts.createNodeFactory(1, ts.parseBaseNodeFactory);
22246     function visitNode(cbNode, node) {
22247         return node && cbNode(node);
22248     }
22249     function visitNodes(cbNode, cbNodes, nodes) {
22250         if (nodes) {
22251             if (cbNodes) {
22252                 return cbNodes(nodes);
22253             }
22254             for (var _i = 0, nodes_1 = nodes; _i < nodes_1.length; _i++) {
22255                 var node = nodes_1[_i];
22256                 var result = cbNode(node);
22257                 if (result) {
22258                     return result;
22259                 }
22260             }
22261         }
22262     }
22263     function isJSDocLikeText(text, start) {
22264         return text.charCodeAt(start + 1) === 42 &&
22265             text.charCodeAt(start + 2) === 42 &&
22266             text.charCodeAt(start + 3) !== 47;
22267     }
22268     ts.isJSDocLikeText = isJSDocLikeText;
22269     function forEachChild(node, cbNode, cbNodes) {
22270         if (!node || node.kind <= 156) {
22271             return;
22272         }
22273         switch (node.kind) {
22274             case 157:
22275                 return visitNode(cbNode, node.left) ||
22276                     visitNode(cbNode, node.right);
22277             case 159:
22278                 return visitNode(cbNode, node.name) ||
22279                     visitNode(cbNode, node.constraint) ||
22280                     visitNode(cbNode, node.default) ||
22281                     visitNode(cbNode, node.expression);
22282             case 289:
22283                 return visitNodes(cbNode, cbNodes, node.decorators) ||
22284                     visitNodes(cbNode, cbNodes, node.modifiers) ||
22285                     visitNode(cbNode, node.name) ||
22286                     visitNode(cbNode, node.questionToken) ||
22287                     visitNode(cbNode, node.exclamationToken) ||
22288                     visitNode(cbNode, node.equalsToken) ||
22289                     visitNode(cbNode, node.objectAssignmentInitializer);
22290             case 290:
22291                 return visitNode(cbNode, node.expression);
22292             case 160:
22293                 return visitNodes(cbNode, cbNodes, node.decorators) ||
22294                     visitNodes(cbNode, cbNodes, node.modifiers) ||
22295                     visitNode(cbNode, node.dotDotDotToken) ||
22296                     visitNode(cbNode, node.name) ||
22297                     visitNode(cbNode, node.questionToken) ||
22298                     visitNode(cbNode, node.type) ||
22299                     visitNode(cbNode, node.initializer);
22300             case 163:
22301                 return visitNodes(cbNode, cbNodes, node.decorators) ||
22302                     visitNodes(cbNode, cbNodes, node.modifiers) ||
22303                     visitNode(cbNode, node.name) ||
22304                     visitNode(cbNode, node.questionToken) ||
22305                     visitNode(cbNode, node.exclamationToken) ||
22306                     visitNode(cbNode, node.type) ||
22307                     visitNode(cbNode, node.initializer);
22308             case 162:
22309                 return visitNodes(cbNode, cbNodes, node.decorators) ||
22310                     visitNodes(cbNode, cbNodes, node.modifiers) ||
22311                     visitNode(cbNode, node.name) ||
22312                     visitNode(cbNode, node.questionToken) ||
22313                     visitNode(cbNode, node.type) ||
22314                     visitNode(cbNode, node.initializer);
22315             case 288:
22316                 return visitNodes(cbNode, cbNodes, node.decorators) ||
22317                     visitNodes(cbNode, cbNodes, node.modifiers) ||
22318                     visitNode(cbNode, node.name) ||
22319                     visitNode(cbNode, node.questionToken) ||
22320                     visitNode(cbNode, node.initializer);
22321             case 249:
22322                 return visitNodes(cbNode, cbNodes, node.decorators) ||
22323                     visitNodes(cbNode, cbNodes, node.modifiers) ||
22324                     visitNode(cbNode, node.name) ||
22325                     visitNode(cbNode, node.exclamationToken) ||
22326                     visitNode(cbNode, node.type) ||
22327                     visitNode(cbNode, node.initializer);
22328             case 198:
22329                 return visitNodes(cbNode, cbNodes, node.decorators) ||
22330                     visitNodes(cbNode, cbNodes, node.modifiers) ||
22331                     visitNode(cbNode, node.dotDotDotToken) ||
22332                     visitNode(cbNode, node.propertyName) ||
22333                     visitNode(cbNode, node.name) ||
22334                     visitNode(cbNode, node.initializer);
22335             case 174:
22336             case 175:
22337             case 169:
22338             case 170:
22339             case 171:
22340                 return visitNodes(cbNode, cbNodes, node.decorators) ||
22341                     visitNodes(cbNode, cbNodes, node.modifiers) ||
22342                     visitNodes(cbNode, cbNodes, node.typeParameters) ||
22343                     visitNodes(cbNode, cbNodes, node.parameters) ||
22344                     visitNode(cbNode, node.type);
22345             case 165:
22346             case 164:
22347             case 166:
22348             case 167:
22349             case 168:
22350             case 208:
22351             case 251:
22352             case 209:
22353                 return visitNodes(cbNode, cbNodes, node.decorators) ||
22354                     visitNodes(cbNode, cbNodes, node.modifiers) ||
22355                     visitNode(cbNode, node.asteriskToken) ||
22356                     visitNode(cbNode, node.name) ||
22357                     visitNode(cbNode, node.questionToken) ||
22358                     visitNode(cbNode, node.exclamationToken) ||
22359                     visitNodes(cbNode, cbNodes, node.typeParameters) ||
22360                     visitNodes(cbNode, cbNodes, node.parameters) ||
22361                     visitNode(cbNode, node.type) ||
22362                     visitNode(cbNode, node.equalsGreaterThanToken) ||
22363                     visitNode(cbNode, node.body);
22364             case 173:
22365                 return visitNode(cbNode, node.typeName) ||
22366                     visitNodes(cbNode, cbNodes, node.typeArguments);
22367             case 172:
22368                 return visitNode(cbNode, node.assertsModifier) ||
22369                     visitNode(cbNode, node.parameterName) ||
22370                     visitNode(cbNode, node.type);
22371             case 176:
22372                 return visitNode(cbNode, node.exprName);
22373             case 177:
22374                 return visitNodes(cbNode, cbNodes, node.members);
22375             case 178:
22376                 return visitNode(cbNode, node.elementType);
22377             case 179:
22378                 return visitNodes(cbNode, cbNodes, node.elements);
22379             case 182:
22380             case 183:
22381                 return visitNodes(cbNode, cbNodes, node.types);
22382             case 184:
22383                 return visitNode(cbNode, node.checkType) ||
22384                     visitNode(cbNode, node.extendsType) ||
22385                     visitNode(cbNode, node.trueType) ||
22386                     visitNode(cbNode, node.falseType);
22387             case 185:
22388                 return visitNode(cbNode, node.typeParameter);
22389             case 195:
22390                 return visitNode(cbNode, node.argument) ||
22391                     visitNode(cbNode, node.qualifier) ||
22392                     visitNodes(cbNode, cbNodes, node.typeArguments);
22393             case 186:
22394             case 188:
22395                 return visitNode(cbNode, node.type);
22396             case 189:
22397                 return visitNode(cbNode, node.objectType) ||
22398                     visitNode(cbNode, node.indexType);
22399             case 190:
22400                 return visitNode(cbNode, node.readonlyToken) ||
22401                     visitNode(cbNode, node.typeParameter) ||
22402                     visitNode(cbNode, node.nameType) ||
22403                     visitNode(cbNode, node.questionToken) ||
22404                     visitNode(cbNode, node.type);
22405             case 191:
22406                 return visitNode(cbNode, node.literal);
22407             case 192:
22408                 return visitNode(cbNode, node.dotDotDotToken) ||
22409                     visitNode(cbNode, node.name) ||
22410                     visitNode(cbNode, node.questionToken) ||
22411                     visitNode(cbNode, node.type);
22412             case 196:
22413             case 197:
22414                 return visitNodes(cbNode, cbNodes, node.elements);
22415             case 199:
22416                 return visitNodes(cbNode, cbNodes, node.elements);
22417             case 200:
22418                 return visitNodes(cbNode, cbNodes, node.properties);
22419             case 201:
22420                 return visitNode(cbNode, node.expression) ||
22421                     visitNode(cbNode, node.questionDotToken) ||
22422                     visitNode(cbNode, node.name);
22423             case 202:
22424                 return visitNode(cbNode, node.expression) ||
22425                     visitNode(cbNode, node.questionDotToken) ||
22426                     visitNode(cbNode, node.argumentExpression);
22427             case 203:
22428             case 204:
22429                 return visitNode(cbNode, node.expression) ||
22430                     visitNode(cbNode, node.questionDotToken) ||
22431                     visitNodes(cbNode, cbNodes, node.typeArguments) ||
22432                     visitNodes(cbNode, cbNodes, node.arguments);
22433             case 205:
22434                 return visitNode(cbNode, node.tag) ||
22435                     visitNode(cbNode, node.questionDotToken) ||
22436                     visitNodes(cbNode, cbNodes, node.typeArguments) ||
22437                     visitNode(cbNode, node.template);
22438             case 206:
22439                 return visitNode(cbNode, node.type) ||
22440                     visitNode(cbNode, node.expression);
22441             case 207:
22442                 return visitNode(cbNode, node.expression);
22443             case 210:
22444                 return visitNode(cbNode, node.expression);
22445             case 211:
22446                 return visitNode(cbNode, node.expression);
22447             case 212:
22448                 return visitNode(cbNode, node.expression);
22449             case 214:
22450                 return visitNode(cbNode, node.operand);
22451             case 219:
22452                 return visitNode(cbNode, node.asteriskToken) ||
22453                     visitNode(cbNode, node.expression);
22454             case 213:
22455                 return visitNode(cbNode, node.expression);
22456             case 215:
22457                 return visitNode(cbNode, node.operand);
22458             case 216:
22459                 return visitNode(cbNode, node.left) ||
22460                     visitNode(cbNode, node.operatorToken) ||
22461                     visitNode(cbNode, node.right);
22462             case 224:
22463                 return visitNode(cbNode, node.expression) ||
22464                     visitNode(cbNode, node.type);
22465             case 225:
22466                 return visitNode(cbNode, node.expression);
22467             case 226:
22468                 return visitNode(cbNode, node.name);
22469             case 217:
22470                 return visitNode(cbNode, node.condition) ||
22471                     visitNode(cbNode, node.questionToken) ||
22472                     visitNode(cbNode, node.whenTrue) ||
22473                     visitNode(cbNode, node.colonToken) ||
22474                     visitNode(cbNode, node.whenFalse);
22475             case 220:
22476                 return visitNode(cbNode, node.expression);
22477             case 230:
22478             case 257:
22479                 return visitNodes(cbNode, cbNodes, node.statements);
22480             case 297:
22481                 return visitNodes(cbNode, cbNodes, node.statements) ||
22482                     visitNode(cbNode, node.endOfFileToken);
22483             case 232:
22484                 return visitNodes(cbNode, cbNodes, node.decorators) ||
22485                     visitNodes(cbNode, cbNodes, node.modifiers) ||
22486                     visitNode(cbNode, node.declarationList);
22487             case 250:
22488                 return visitNodes(cbNode, cbNodes, node.declarations);
22489             case 233:
22490                 return visitNode(cbNode, node.expression);
22491             case 234:
22492                 return visitNode(cbNode, node.expression) ||
22493                     visitNode(cbNode, node.thenStatement) ||
22494                     visitNode(cbNode, node.elseStatement);
22495             case 235:
22496                 return visitNode(cbNode, node.statement) ||
22497                     visitNode(cbNode, node.expression);
22498             case 236:
22499                 return visitNode(cbNode, node.expression) ||
22500                     visitNode(cbNode, node.statement);
22501             case 237:
22502                 return visitNode(cbNode, node.initializer) ||
22503                     visitNode(cbNode, node.condition) ||
22504                     visitNode(cbNode, node.incrementor) ||
22505                     visitNode(cbNode, node.statement);
22506             case 238:
22507                 return visitNode(cbNode, node.initializer) ||
22508                     visitNode(cbNode, node.expression) ||
22509                     visitNode(cbNode, node.statement);
22510             case 239:
22511                 return visitNode(cbNode, node.awaitModifier) ||
22512                     visitNode(cbNode, node.initializer) ||
22513                     visitNode(cbNode, node.expression) ||
22514                     visitNode(cbNode, node.statement);
22515             case 240:
22516             case 241:
22517                 return visitNode(cbNode, node.label);
22518             case 242:
22519                 return visitNode(cbNode, node.expression);
22520             case 243:
22521                 return visitNode(cbNode, node.expression) ||
22522                     visitNode(cbNode, node.statement);
22523             case 244:
22524                 return visitNode(cbNode, node.expression) ||
22525                     visitNode(cbNode, node.caseBlock);
22526             case 258:
22527                 return visitNodes(cbNode, cbNodes, node.clauses);
22528             case 284:
22529                 return visitNode(cbNode, node.expression) ||
22530                     visitNodes(cbNode, cbNodes, node.statements);
22531             case 285:
22532                 return visitNodes(cbNode, cbNodes, node.statements);
22533             case 245:
22534                 return visitNode(cbNode, node.label) ||
22535                     visitNode(cbNode, node.statement);
22536             case 246:
22537                 return visitNode(cbNode, node.expression);
22538             case 247:
22539                 return visitNode(cbNode, node.tryBlock) ||
22540                     visitNode(cbNode, node.catchClause) ||
22541                     visitNode(cbNode, node.finallyBlock);
22542             case 287:
22543                 return visitNode(cbNode, node.variableDeclaration) ||
22544                     visitNode(cbNode, node.block);
22545             case 161:
22546                 return visitNode(cbNode, node.expression);
22547             case 252:
22548             case 221:
22549                 return visitNodes(cbNode, cbNodes, node.decorators) ||
22550                     visitNodes(cbNode, cbNodes, node.modifiers) ||
22551                     visitNode(cbNode, node.name) ||
22552                     visitNodes(cbNode, cbNodes, node.typeParameters) ||
22553                     visitNodes(cbNode, cbNodes, node.heritageClauses) ||
22554                     visitNodes(cbNode, cbNodes, node.members);
22555             case 253:
22556                 return visitNodes(cbNode, cbNodes, node.decorators) ||
22557                     visitNodes(cbNode, cbNodes, node.modifiers) ||
22558                     visitNode(cbNode, node.name) ||
22559                     visitNodes(cbNode, cbNodes, node.typeParameters) ||
22560                     visitNodes(cbNode, cbNodes, node.heritageClauses) ||
22561                     visitNodes(cbNode, cbNodes, node.members);
22562             case 254:
22563                 return visitNodes(cbNode, cbNodes, node.decorators) ||
22564                     visitNodes(cbNode, cbNodes, node.modifiers) ||
22565                     visitNode(cbNode, node.name) ||
22566                     visitNodes(cbNode, cbNodes, node.typeParameters) ||
22567                     visitNode(cbNode, node.type);
22568             case 255:
22569                 return visitNodes(cbNode, cbNodes, node.decorators) ||
22570                     visitNodes(cbNode, cbNodes, node.modifiers) ||
22571                     visitNode(cbNode, node.name) ||
22572                     visitNodes(cbNode, cbNodes, node.members);
22573             case 291:
22574                 return visitNode(cbNode, node.name) ||
22575                     visitNode(cbNode, node.initializer);
22576             case 256:
22577                 return visitNodes(cbNode, cbNodes, node.decorators) ||
22578                     visitNodes(cbNode, cbNodes, node.modifiers) ||
22579                     visitNode(cbNode, node.name) ||
22580                     visitNode(cbNode, node.body);
22581             case 260:
22582                 return visitNodes(cbNode, cbNodes, node.decorators) ||
22583                     visitNodes(cbNode, cbNodes, node.modifiers) ||
22584                     visitNode(cbNode, node.name) ||
22585                     visitNode(cbNode, node.moduleReference);
22586             case 261:
22587                 return visitNodes(cbNode, cbNodes, node.decorators) ||
22588                     visitNodes(cbNode, cbNodes, node.modifiers) ||
22589                     visitNode(cbNode, node.importClause) ||
22590                     visitNode(cbNode, node.moduleSpecifier);
22591             case 262:
22592                 return visitNode(cbNode, node.name) ||
22593                     visitNode(cbNode, node.namedBindings);
22594             case 259:
22595                 return visitNode(cbNode, node.name);
22596             case 263:
22597                 return visitNode(cbNode, node.name);
22598             case 269:
22599                 return visitNode(cbNode, node.name);
22600             case 264:
22601             case 268:
22602                 return visitNodes(cbNode, cbNodes, node.elements);
22603             case 267:
22604                 return visitNodes(cbNode, cbNodes, node.decorators) ||
22605                     visitNodes(cbNode, cbNodes, node.modifiers) ||
22606                     visitNode(cbNode, node.exportClause) ||
22607                     visitNode(cbNode, node.moduleSpecifier);
22608             case 265:
22609             case 270:
22610                 return visitNode(cbNode, node.propertyName) ||
22611                     visitNode(cbNode, node.name);
22612             case 266:
22613                 return visitNodes(cbNode, cbNodes, node.decorators) ||
22614                     visitNodes(cbNode, cbNodes, node.modifiers) ||
22615                     visitNode(cbNode, node.expression);
22616             case 218:
22617                 return visitNode(cbNode, node.head) || visitNodes(cbNode, cbNodes, node.templateSpans);
22618             case 228:
22619                 return visitNode(cbNode, node.expression) || visitNode(cbNode, node.literal);
22620             case 193:
22621                 return visitNode(cbNode, node.head) || visitNodes(cbNode, cbNodes, node.templateSpans);
22622             case 194:
22623                 return visitNode(cbNode, node.type) || visitNode(cbNode, node.literal);
22624             case 158:
22625                 return visitNode(cbNode, node.expression);
22626             case 286:
22627                 return visitNodes(cbNode, cbNodes, node.types);
22628             case 223:
22629                 return visitNode(cbNode, node.expression) ||
22630                     visitNodes(cbNode, cbNodes, node.typeArguments);
22631             case 272:
22632                 return visitNode(cbNode, node.expression);
22633             case 271:
22634                 return visitNodes(cbNode, cbNodes, node.decorators);
22635             case 337:
22636                 return visitNodes(cbNode, cbNodes, node.elements);
22637             case 273:
22638                 return visitNode(cbNode, node.openingElement) ||
22639                     visitNodes(cbNode, cbNodes, node.children) ||
22640                     visitNode(cbNode, node.closingElement);
22641             case 277:
22642                 return visitNode(cbNode, node.openingFragment) ||
22643                     visitNodes(cbNode, cbNodes, node.children) ||
22644                     visitNode(cbNode, node.closingFragment);
22645             case 274:
22646             case 275:
22647                 return visitNode(cbNode, node.tagName) ||
22648                     visitNodes(cbNode, cbNodes, node.typeArguments) ||
22649                     visitNode(cbNode, node.attributes);
22650             case 281:
22651                 return visitNodes(cbNode, cbNodes, node.properties);
22652             case 280:
22653                 return visitNode(cbNode, node.name) ||
22654                     visitNode(cbNode, node.initializer);
22655             case 282:
22656                 return visitNode(cbNode, node.expression);
22657             case 283:
22658                 return visitNode(cbNode, node.dotDotDotToken) ||
22659                     visitNode(cbNode, node.expression);
22660             case 276:
22661                 return visitNode(cbNode, node.tagName);
22662             case 180:
22663             case 181:
22664             case 301:
22665             case 306:
22666             case 305:
22667             case 307:
22668             case 309:
22669                 return visitNode(cbNode, node.type);
22670             case 308:
22671                 return visitNodes(cbNode, cbNodes, node.parameters) ||
22672                     visitNode(cbNode, node.type);
22673             case 311:
22674                 return visitNodes(cbNode, cbNodes, node.tags);
22675             case 332:
22676                 return visitNode(cbNode, node.tagName) ||
22677                     visitNode(cbNode, node.name);
22678             case 302:
22679                 return visitNode(cbNode, node.name);
22680             case 326:
22681             case 333:
22682                 return visitNode(cbNode, node.tagName) ||
22683                     (node.isNameFirst
22684                         ? visitNode(cbNode, node.name) ||
22685                             visitNode(cbNode, node.typeExpression)
22686                         : visitNode(cbNode, node.typeExpression) ||
22687                             visitNode(cbNode, node.name));
22688             case 317:
22689                 return visitNode(cbNode, node.tagName);
22690             case 316:
22691                 return visitNode(cbNode, node.tagName) ||
22692                     visitNode(cbNode, node.class);
22693             case 315:
22694                 return visitNode(cbNode, node.tagName) ||
22695                     visitNode(cbNode, node.class);
22696             case 330:
22697                 return visitNode(cbNode, node.tagName) ||
22698                     visitNode(cbNode, node.constraint) ||
22699                     visitNodes(cbNode, cbNodes, node.typeParameters);
22700             case 331:
22701                 return visitNode(cbNode, node.tagName) ||
22702                     (node.typeExpression &&
22703                         node.typeExpression.kind === 301
22704                         ? visitNode(cbNode, node.typeExpression) ||
22705                             visitNode(cbNode, node.fullName)
22706                         : visitNode(cbNode, node.fullName) ||
22707                             visitNode(cbNode, node.typeExpression));
22708             case 324:
22709                 return visitNode(cbNode, node.tagName) ||
22710                     visitNode(cbNode, node.fullName) ||
22711                     visitNode(cbNode, node.typeExpression);
22712             case 327:
22713             case 329:
22714             case 328:
22715             case 325:
22716                 return visitNode(cbNode, node.tagName) ||
22717                     visitNode(cbNode, node.typeExpression);
22718             case 313:
22719                 return ts.forEach(node.typeParameters, cbNode) ||
22720                     ts.forEach(node.parameters, cbNode) ||
22721                     visitNode(cbNode, node.type);
22722             case 312:
22723                 return ts.forEach(node.jsDocPropertyTags, cbNode);
22724             case 314:
22725             case 319:
22726             case 320:
22727             case 321:
22728             case 322:
22729             case 323:
22730                 return visitNode(cbNode, node.tagName);
22731             case 336:
22732                 return visitNode(cbNode, node.expression);
22733         }
22734     }
22735     ts.forEachChild = forEachChild;
22736     function forEachChildRecursively(rootNode, cbNode, cbNodes) {
22737         var stack = [rootNode];
22738         while (stack.length) {
22739             var parent = stack.pop();
22740             var res = visitAllPossibleChildren(parent, gatherPossibleChildren(parent));
22741             if (res) {
22742                 return res;
22743             }
22744         }
22745         return;
22746         function gatherPossibleChildren(node) {
22747             var children = [];
22748             forEachChild(node, addWorkItem, addWorkItem);
22749             return children;
22750             function addWorkItem(n) {
22751                 children.unshift(n);
22752             }
22753         }
22754         function visitAllPossibleChildren(parent, children) {
22755             for (var _i = 0, children_5 = children; _i < children_5.length; _i++) {
22756                 var child = children_5[_i];
22757                 if (ts.isArray(child)) {
22758                     if (cbNodes) {
22759                         var res = cbNodes(child, parent);
22760                         if (res) {
22761                             if (res === "skip")
22762                                 continue;
22763                             return res;
22764                         }
22765                     }
22766                     for (var i = child.length - 1; i >= 0; i--) {
22767                         var realChild = child[i];
22768                         var res = cbNode(realChild, parent);
22769                         if (res) {
22770                             if (res === "skip")
22771                                 continue;
22772                             return res;
22773                         }
22774                         stack.push(realChild);
22775                     }
22776                 }
22777                 else {
22778                     stack.push(child);
22779                     var res = cbNode(child, parent);
22780                     if (res) {
22781                         if (res === "skip")
22782                             continue;
22783                         return res;
22784                     }
22785                 }
22786             }
22787         }
22788     }
22789     ts.forEachChildRecursively = forEachChildRecursively;
22790     function createSourceFile(fileName, sourceText, languageVersion, setParentNodes, scriptKind) {
22791         if (setParentNodes === void 0) { setParentNodes = false; }
22792         var tracingData = ["parse", "createSourceFile", { path: fileName }];
22793         ts.tracing.begin.apply(ts.tracing, tracingData);
22794         ts.performance.mark("beforeParse");
22795         var result;
22796         ts.perfLogger.logStartParseSourceFile(fileName);
22797         if (languageVersion === 100) {
22798             result = Parser.parseSourceFile(fileName, sourceText, languageVersion, undefined, setParentNodes, 6);
22799         }
22800         else {
22801             result = Parser.parseSourceFile(fileName, sourceText, languageVersion, undefined, setParentNodes, scriptKind);
22802         }
22803         ts.perfLogger.logStopParseSourceFile();
22804         ts.performance.mark("afterParse");
22805         ts.performance.measure("Parse", "beforeParse", "afterParse");
22806         ts.tracing.end.apply(ts.tracing, tracingData);
22807         return result;
22808     }
22809     ts.createSourceFile = createSourceFile;
22810     function parseIsolatedEntityName(text, languageVersion) {
22811         return Parser.parseIsolatedEntityName(text, languageVersion);
22812     }
22813     ts.parseIsolatedEntityName = parseIsolatedEntityName;
22814     function parseJsonText(fileName, sourceText) {
22815         return Parser.parseJsonText(fileName, sourceText);
22816     }
22817     ts.parseJsonText = parseJsonText;
22818     function isExternalModule(file) {
22819         return file.externalModuleIndicator !== undefined;
22820     }
22821     ts.isExternalModule = isExternalModule;
22822     function updateSourceFile(sourceFile, newText, textChangeRange, aggressiveChecks) {
22823         if (aggressiveChecks === void 0) { aggressiveChecks = false; }
22824         var newSourceFile = IncrementalParser.updateSourceFile(sourceFile, newText, textChangeRange, aggressiveChecks);
22825         newSourceFile.flags |= (sourceFile.flags & 3145728);
22826         return newSourceFile;
22827     }
22828     ts.updateSourceFile = updateSourceFile;
22829     function parseIsolatedJSDocComment(content, start, length) {
22830         var result = Parser.JSDocParser.parseIsolatedJSDocComment(content, start, length);
22831         if (result && result.jsDoc) {
22832             Parser.fixupParentReferences(result.jsDoc);
22833         }
22834         return result;
22835     }
22836     ts.parseIsolatedJSDocComment = parseIsolatedJSDocComment;
22837     function parseJSDocTypeExpressionForTests(content, start, length) {
22838         return Parser.JSDocParser.parseJSDocTypeExpressionForTests(content, start, length);
22839     }
22840     ts.parseJSDocTypeExpressionForTests = parseJSDocTypeExpressionForTests;
22841     var Parser;
22842     (function (Parser) {
22843         var scanner = ts.createScanner(99, true);
22844         var disallowInAndDecoratorContext = 4096 | 16384;
22845         var NodeConstructor;
22846         var TokenConstructor;
22847         var IdentifierConstructor;
22848         var PrivateIdentifierConstructor;
22849         var SourceFileConstructor;
22850         function countNode(node) {
22851             nodeCount++;
22852             return node;
22853         }
22854         var baseNodeFactory = {
22855             createBaseSourceFileNode: function (kind) { return countNode(new SourceFileConstructor(kind, 0, 0)); },
22856             createBaseIdentifierNode: function (kind) { return countNode(new IdentifierConstructor(kind, 0, 0)); },
22857             createBasePrivateIdentifierNode: function (kind) { return countNode(new PrivateIdentifierConstructor(kind, 0, 0)); },
22858             createBaseTokenNode: function (kind) { return countNode(new TokenConstructor(kind, 0, 0)); },
22859             createBaseNode: function (kind) { return countNode(new NodeConstructor(kind, 0, 0)); }
22860         };
22861         var factory = ts.createNodeFactory(1 | 2 | 8, baseNodeFactory);
22862         var fileName;
22863         var sourceFlags;
22864         var sourceText;
22865         var languageVersion;
22866         var scriptKind;
22867         var languageVariant;
22868         var parseDiagnostics;
22869         var jsDocDiagnostics;
22870         var syntaxCursor;
22871         var currentToken;
22872         var nodeCount;
22873         var identifiers;
22874         var privateIdentifiers;
22875         var identifierCount;
22876         var parsingContext;
22877         var notParenthesizedArrow;
22878         var contextFlags;
22879         var topLevel = true;
22880         var parseErrorBeforeNextFinishedNode = false;
22881         function parseSourceFile(fileName, sourceText, languageVersion, syntaxCursor, setParentNodes, scriptKind) {
22882             if (setParentNodes === void 0) { setParentNodes = false; }
22883             scriptKind = ts.ensureScriptKind(fileName, scriptKind);
22884             if (scriptKind === 6) {
22885                 var result_3 = parseJsonText(fileName, sourceText, languageVersion, syntaxCursor, setParentNodes);
22886                 ts.convertToObjectWorker(result_3, result_3.parseDiagnostics, false, undefined, undefined);
22887                 result_3.referencedFiles = ts.emptyArray;
22888                 result_3.typeReferenceDirectives = ts.emptyArray;
22889                 result_3.libReferenceDirectives = ts.emptyArray;
22890                 result_3.amdDependencies = ts.emptyArray;
22891                 result_3.hasNoDefaultLib = false;
22892                 result_3.pragmas = ts.emptyMap;
22893                 return result_3;
22894             }
22895             initializeState(fileName, sourceText, languageVersion, syntaxCursor, scriptKind);
22896             var result = parseSourceFileWorker(languageVersion, setParentNodes, scriptKind);
22897             clearState();
22898             return result;
22899         }
22900         Parser.parseSourceFile = parseSourceFile;
22901         function parseIsolatedEntityName(content, languageVersion) {
22902             initializeState("", content, languageVersion, undefined, 1);
22903             nextToken();
22904             var entityName = parseEntityName(true);
22905             var isInvalid = token() === 1 && !parseDiagnostics.length;
22906             clearState();
22907             return isInvalid ? entityName : undefined;
22908         }
22909         Parser.parseIsolatedEntityName = parseIsolatedEntityName;
22910         function parseJsonText(fileName, sourceText, languageVersion, syntaxCursor, setParentNodes) {
22911             if (languageVersion === void 0) { languageVersion = 2; }
22912             if (setParentNodes === void 0) { setParentNodes = false; }
22913             initializeState(fileName, sourceText, languageVersion, syntaxCursor, 6);
22914             sourceFlags = contextFlags;
22915             nextToken();
22916             var pos = getNodePos();
22917             var statements, endOfFileToken;
22918             if (token() === 1) {
22919                 statements = createNodeArray([], pos, pos);
22920                 endOfFileToken = parseTokenNode();
22921             }
22922             else {
22923                 var expression = void 0;
22924                 switch (token()) {
22925                     case 22:
22926                         expression = parseArrayLiteralExpression();
22927                         break;
22928                     case 109:
22929                     case 94:
22930                     case 103:
22931                         expression = parseTokenNode();
22932                         break;
22933                     case 40:
22934                         if (lookAhead(function () { return nextToken() === 8 && nextToken() !== 58; })) {
22935                             expression = parsePrefixUnaryExpression();
22936                         }
22937                         else {
22938                             expression = parseObjectLiteralExpression();
22939                         }
22940                         break;
22941                     case 8:
22942                     case 10:
22943                         if (lookAhead(function () { return nextToken() !== 58; })) {
22944                             expression = parseLiteralNode();
22945                             break;
22946                         }
22947                     default:
22948                         expression = parseObjectLiteralExpression();
22949                         break;
22950                 }
22951                 var statement = factory.createExpressionStatement(expression);
22952                 finishNode(statement, pos);
22953                 statements = createNodeArray([statement], pos);
22954                 endOfFileToken = parseExpectedToken(1, ts.Diagnostics.Unexpected_token);
22955             }
22956             var sourceFile = createSourceFile(fileName, 2, 6, false, statements, endOfFileToken, sourceFlags);
22957             if (setParentNodes) {
22958                 fixupParentReferences(sourceFile);
22959             }
22960             sourceFile.nodeCount = nodeCount;
22961             sourceFile.identifierCount = identifierCount;
22962             sourceFile.identifiers = identifiers;
22963             sourceFile.parseDiagnostics = ts.attachFileToDiagnostics(parseDiagnostics, sourceFile);
22964             if (jsDocDiagnostics) {
22965                 sourceFile.jsDocDiagnostics = ts.attachFileToDiagnostics(jsDocDiagnostics, sourceFile);
22966             }
22967             var result = sourceFile;
22968             clearState();
22969             return result;
22970         }
22971         Parser.parseJsonText = parseJsonText;
22972         function initializeState(_fileName, _sourceText, _languageVersion, _syntaxCursor, _scriptKind) {
22973             NodeConstructor = ts.objectAllocator.getNodeConstructor();
22974             TokenConstructor = ts.objectAllocator.getTokenConstructor();
22975             IdentifierConstructor = ts.objectAllocator.getIdentifierConstructor();
22976             PrivateIdentifierConstructor = ts.objectAllocator.getPrivateIdentifierConstructor();
22977             SourceFileConstructor = ts.objectAllocator.getSourceFileConstructor();
22978             fileName = ts.normalizePath(_fileName);
22979             sourceText = _sourceText;
22980             languageVersion = _languageVersion;
22981             syntaxCursor = _syntaxCursor;
22982             scriptKind = _scriptKind;
22983             languageVariant = ts.getLanguageVariant(_scriptKind);
22984             parseDiagnostics = [];
22985             parsingContext = 0;
22986             identifiers = new ts.Map();
22987             privateIdentifiers = new ts.Map();
22988             identifierCount = 0;
22989             nodeCount = 0;
22990             sourceFlags = 0;
22991             topLevel = true;
22992             switch (scriptKind) {
22993                 case 1:
22994                 case 2:
22995                     contextFlags = 131072;
22996                     break;
22997                 case 6:
22998                     contextFlags = 131072 | 33554432;
22999                     break;
23000                 default:
23001                     contextFlags = 0;
23002                     break;
23003             }
23004             parseErrorBeforeNextFinishedNode = false;
23005             scanner.setText(sourceText);
23006             scanner.setOnError(scanError);
23007             scanner.setScriptTarget(languageVersion);
23008             scanner.setLanguageVariant(languageVariant);
23009         }
23010         function clearState() {
23011             scanner.clearCommentDirectives();
23012             scanner.setText("");
23013             scanner.setOnError(undefined);
23014             sourceText = undefined;
23015             languageVersion = undefined;
23016             syntaxCursor = undefined;
23017             scriptKind = undefined;
23018             languageVariant = undefined;
23019             sourceFlags = 0;
23020             parseDiagnostics = undefined;
23021             jsDocDiagnostics = undefined;
23022             parsingContext = 0;
23023             identifiers = undefined;
23024             notParenthesizedArrow = undefined;
23025             topLevel = true;
23026         }
23027         function parseSourceFileWorker(languageVersion, setParentNodes, scriptKind) {
23028             var isDeclarationFile = isDeclarationFileName(fileName);
23029             if (isDeclarationFile) {
23030                 contextFlags |= 8388608;
23031             }
23032             sourceFlags = contextFlags;
23033             nextToken();
23034             var statements = parseList(0, parseStatement);
23035             ts.Debug.assert(token() === 1);
23036             var endOfFileToken = addJSDocComment(parseTokenNode());
23037             var sourceFile = createSourceFile(fileName, languageVersion, scriptKind, isDeclarationFile, statements, endOfFileToken, sourceFlags);
23038             processCommentPragmas(sourceFile, sourceText);
23039             processPragmasIntoFields(sourceFile, reportPragmaDiagnostic);
23040             sourceFile.commentDirectives = scanner.getCommentDirectives();
23041             sourceFile.nodeCount = nodeCount;
23042             sourceFile.identifierCount = identifierCount;
23043             sourceFile.identifiers = identifiers;
23044             sourceFile.parseDiagnostics = ts.attachFileToDiagnostics(parseDiagnostics, sourceFile);
23045             if (jsDocDiagnostics) {
23046                 sourceFile.jsDocDiagnostics = ts.attachFileToDiagnostics(jsDocDiagnostics, sourceFile);
23047             }
23048             if (setParentNodes) {
23049                 fixupParentReferences(sourceFile);
23050             }
23051             return sourceFile;
23052             function reportPragmaDiagnostic(pos, end, diagnostic) {
23053                 parseDiagnostics.push(ts.createDetachedDiagnostic(fileName, pos, end, diagnostic));
23054             }
23055         }
23056         function withJSDoc(node, hasJSDoc) {
23057             return hasJSDoc ? addJSDocComment(node) : node;
23058         }
23059         var hasDeprecatedTag = false;
23060         function addJSDocComment(node) {
23061             ts.Debug.assert(!node.jsDoc);
23062             var jsDoc = ts.mapDefined(ts.getJSDocCommentRanges(node, sourceText), function (comment) { return JSDocParser.parseJSDocComment(node, comment.pos, comment.end - comment.pos); });
23063             if (jsDoc.length)
23064                 node.jsDoc = jsDoc;
23065             if (hasDeprecatedTag) {
23066                 hasDeprecatedTag = false;
23067                 node.flags |= 134217728;
23068             }
23069             return node;
23070         }
23071         function reparseTopLevelAwait(sourceFile) {
23072             var savedSyntaxCursor = syntaxCursor;
23073             var baseSyntaxCursor = IncrementalParser.createSyntaxCursor(sourceFile);
23074             syntaxCursor = { currentNode: currentNode };
23075             var statements = [];
23076             var savedParseDiagnostics = parseDiagnostics;
23077             parseDiagnostics = [];
23078             var pos = 0;
23079             var start = findNextStatementWithAwait(sourceFile.statements, 0);
23080             var _loop_3 = function () {
23081                 var prevStatement = sourceFile.statements[pos];
23082                 var nextStatement = sourceFile.statements[start];
23083                 ts.addRange(statements, sourceFile.statements, pos, start);
23084                 pos = findNextStatementWithoutAwait(sourceFile.statements, start);
23085                 var diagnosticStart = ts.findIndex(savedParseDiagnostics, function (diagnostic) { return diagnostic.start >= prevStatement.pos; });
23086                 var diagnosticEnd = diagnosticStart >= 0 ? ts.findIndex(savedParseDiagnostics, function (diagnostic) { return diagnostic.start >= nextStatement.pos; }, diagnosticStart) : -1;
23087                 if (diagnosticStart >= 0) {
23088                     ts.addRange(parseDiagnostics, savedParseDiagnostics, diagnosticStart, diagnosticEnd >= 0 ? diagnosticEnd : undefined);
23089                 }
23090                 speculationHelper(function () {
23091                     var savedContextFlags = contextFlags;
23092                     contextFlags |= 32768;
23093                     scanner.setTextPos(nextStatement.pos);
23094                     nextToken();
23095                     while (token() !== 1) {
23096                         var startPos = scanner.getStartPos();
23097                         var statement = parseListElement(0, parseStatement);
23098                         statements.push(statement);
23099                         if (startPos === scanner.getStartPos()) {
23100                             nextToken();
23101                         }
23102                         if (pos >= 0) {
23103                             var nonAwaitStatement = sourceFile.statements[pos];
23104                             if (statement.end === nonAwaitStatement.pos) {
23105                                 break;
23106                             }
23107                             if (statement.end > nonAwaitStatement.pos) {
23108                                 pos = findNextStatementWithoutAwait(sourceFile.statements, pos + 1);
23109                             }
23110                         }
23111                     }
23112                     contextFlags = savedContextFlags;
23113                 }, 2);
23114                 start = pos >= 0 ? findNextStatementWithAwait(sourceFile.statements, pos) : -1;
23115             };
23116             while (start !== -1) {
23117                 _loop_3();
23118             }
23119             if (pos >= 0) {
23120                 var prevStatement_1 = sourceFile.statements[pos];
23121                 ts.addRange(statements, sourceFile.statements, pos);
23122                 var diagnosticStart = ts.findIndex(savedParseDiagnostics, function (diagnostic) { return diagnostic.start >= prevStatement_1.pos; });
23123                 if (diagnosticStart >= 0) {
23124                     ts.addRange(parseDiagnostics, savedParseDiagnostics, diagnosticStart);
23125                 }
23126             }
23127             syntaxCursor = savedSyntaxCursor;
23128             return factory.updateSourceFile(sourceFile, ts.setTextRange(factory.createNodeArray(statements), sourceFile.statements));
23129             function containsPossibleTopLevelAwait(node) {
23130                 return !(node.flags & 32768)
23131                     && !!(node.transformFlags & 8388608);
23132             }
23133             function findNextStatementWithAwait(statements, start) {
23134                 for (var i = start; i < statements.length; i++) {
23135                     if (containsPossibleTopLevelAwait(statements[i])) {
23136                         return i;
23137                     }
23138                 }
23139                 return -1;
23140             }
23141             function findNextStatementWithoutAwait(statements, start) {
23142                 for (var i = start; i < statements.length; i++) {
23143                     if (!containsPossibleTopLevelAwait(statements[i])) {
23144                         return i;
23145                     }
23146                 }
23147                 return -1;
23148             }
23149             function currentNode(position) {
23150                 var node = baseSyntaxCursor.currentNode(position);
23151                 if (topLevel && node && containsPossibleTopLevelAwait(node)) {
23152                     node.intersectsChange = true;
23153                 }
23154                 return node;
23155             }
23156         }
23157         function fixupParentReferences(rootNode) {
23158             ts.setParentRecursive(rootNode, true);
23159         }
23160         Parser.fixupParentReferences = fixupParentReferences;
23161         function createSourceFile(fileName, languageVersion, scriptKind, isDeclarationFile, statements, endOfFileToken, flags) {
23162             var sourceFile = factory.createSourceFile(statements, endOfFileToken, flags);
23163             ts.setTextRangePosWidth(sourceFile, 0, sourceText.length);
23164             setExternalModuleIndicator(sourceFile);
23165             if (!isDeclarationFile && isExternalModule(sourceFile) && sourceFile.transformFlags & 8388608) {
23166                 sourceFile = reparseTopLevelAwait(sourceFile);
23167             }
23168             sourceFile.text = sourceText;
23169             sourceFile.bindDiagnostics = [];
23170             sourceFile.bindSuggestionDiagnostics = undefined;
23171             sourceFile.languageVersion = languageVersion;
23172             sourceFile.fileName = fileName;
23173             sourceFile.languageVariant = ts.getLanguageVariant(scriptKind);
23174             sourceFile.isDeclarationFile = isDeclarationFile;
23175             sourceFile.scriptKind = scriptKind;
23176             return sourceFile;
23177         }
23178         function setContextFlag(val, flag) {
23179             if (val) {
23180                 contextFlags |= flag;
23181             }
23182             else {
23183                 contextFlags &= ~flag;
23184             }
23185         }
23186         function setDisallowInContext(val) {
23187             setContextFlag(val, 4096);
23188         }
23189         function setYieldContext(val) {
23190             setContextFlag(val, 8192);
23191         }
23192         function setDecoratorContext(val) {
23193             setContextFlag(val, 16384);
23194         }
23195         function setAwaitContext(val) {
23196             setContextFlag(val, 32768);
23197         }
23198         function doOutsideOfContext(context, func) {
23199             var contextFlagsToClear = context & contextFlags;
23200             if (contextFlagsToClear) {
23201                 setContextFlag(false, contextFlagsToClear);
23202                 var result = func();
23203                 setContextFlag(true, contextFlagsToClear);
23204                 return result;
23205             }
23206             return func();
23207         }
23208         function doInsideOfContext(context, func) {
23209             var contextFlagsToSet = context & ~contextFlags;
23210             if (contextFlagsToSet) {
23211                 setContextFlag(true, contextFlagsToSet);
23212                 var result = func();
23213                 setContextFlag(false, contextFlagsToSet);
23214                 return result;
23215             }
23216             return func();
23217         }
23218         function allowInAnd(func) {
23219             return doOutsideOfContext(4096, func);
23220         }
23221         function disallowInAnd(func) {
23222             return doInsideOfContext(4096, func);
23223         }
23224         function doInYieldContext(func) {
23225             return doInsideOfContext(8192, func);
23226         }
23227         function doInDecoratorContext(func) {
23228             return doInsideOfContext(16384, func);
23229         }
23230         function doInAwaitContext(func) {
23231             return doInsideOfContext(32768, func);
23232         }
23233         function doOutsideOfAwaitContext(func) {
23234             return doOutsideOfContext(32768, func);
23235         }
23236         function doInYieldAndAwaitContext(func) {
23237             return doInsideOfContext(8192 | 32768, func);
23238         }
23239         function doOutsideOfYieldAndAwaitContext(func) {
23240             return doOutsideOfContext(8192 | 32768, func);
23241         }
23242         function inContext(flags) {
23243             return (contextFlags & flags) !== 0;
23244         }
23245         function inYieldContext() {
23246             return inContext(8192);
23247         }
23248         function inDisallowInContext() {
23249             return inContext(4096);
23250         }
23251         function inDecoratorContext() {
23252             return inContext(16384);
23253         }
23254         function inAwaitContext() {
23255             return inContext(32768);
23256         }
23257         function parseErrorAtCurrentToken(message, arg0) {
23258             parseErrorAt(scanner.getTokenPos(), scanner.getTextPos(), message, arg0);
23259         }
23260         function parseErrorAtPosition(start, length, message, arg0) {
23261             var lastError = ts.lastOrUndefined(parseDiagnostics);
23262             if (!lastError || start !== lastError.start) {
23263                 parseDiagnostics.push(ts.createDetachedDiagnostic(fileName, start, length, message, arg0));
23264             }
23265             parseErrorBeforeNextFinishedNode = true;
23266         }
23267         function parseErrorAt(start, end, message, arg0) {
23268             parseErrorAtPosition(start, end - start, message, arg0);
23269         }
23270         function parseErrorAtRange(range, message, arg0) {
23271             parseErrorAt(range.pos, range.end, message, arg0);
23272         }
23273         function scanError(message, length) {
23274             parseErrorAtPosition(scanner.getTextPos(), length, message);
23275         }
23276         function getNodePos() {
23277             return scanner.getStartPos();
23278         }
23279         function hasPrecedingJSDocComment() {
23280             return scanner.hasPrecedingJSDocComment();
23281         }
23282         function token() {
23283             return currentToken;
23284         }
23285         function nextTokenWithoutCheck() {
23286             return currentToken = scanner.scan();
23287         }
23288         function nextTokenAnd(func) {
23289             nextToken();
23290             return func();
23291         }
23292         function nextToken() {
23293             if (ts.isKeyword(currentToken) && (scanner.hasUnicodeEscape() || scanner.hasExtendedUnicodeEscape())) {
23294                 parseErrorAt(scanner.getTokenPos(), scanner.getTextPos(), ts.Diagnostics.Keywords_cannot_contain_escape_characters);
23295             }
23296             return nextTokenWithoutCheck();
23297         }
23298         function nextTokenJSDoc() {
23299             return currentToken = scanner.scanJsDocToken();
23300         }
23301         function reScanGreaterToken() {
23302             return currentToken = scanner.reScanGreaterToken();
23303         }
23304         function reScanSlashToken() {
23305             return currentToken = scanner.reScanSlashToken();
23306         }
23307         function reScanTemplateToken(isTaggedTemplate) {
23308             return currentToken = scanner.reScanTemplateToken(isTaggedTemplate);
23309         }
23310         function reScanTemplateHeadOrNoSubstitutionTemplate() {
23311             return currentToken = scanner.reScanTemplateHeadOrNoSubstitutionTemplate();
23312         }
23313         function reScanLessThanToken() {
23314             return currentToken = scanner.reScanLessThanToken();
23315         }
23316         function scanJsxIdentifier() {
23317             return currentToken = scanner.scanJsxIdentifier();
23318         }
23319         function scanJsxText() {
23320             return currentToken = scanner.scanJsxToken();
23321         }
23322         function scanJsxAttributeValue() {
23323             return currentToken = scanner.scanJsxAttributeValue();
23324         }
23325         function speculationHelper(callback, speculationKind) {
23326             var saveToken = currentToken;
23327             var saveParseDiagnosticsLength = parseDiagnostics.length;
23328             var saveParseErrorBeforeNextFinishedNode = parseErrorBeforeNextFinishedNode;
23329             var saveContextFlags = contextFlags;
23330             var result = speculationKind !== 0
23331                 ? scanner.lookAhead(callback)
23332                 : scanner.tryScan(callback);
23333             ts.Debug.assert(saveContextFlags === contextFlags);
23334             if (!result || speculationKind !== 0) {
23335                 currentToken = saveToken;
23336                 if (speculationKind !== 2) {
23337                     parseDiagnostics.length = saveParseDiagnosticsLength;
23338                 }
23339                 parseErrorBeforeNextFinishedNode = saveParseErrorBeforeNextFinishedNode;
23340             }
23341             return result;
23342         }
23343         function lookAhead(callback) {
23344             return speculationHelper(callback, 1);
23345         }
23346         function tryParse(callback) {
23347             return speculationHelper(callback, 0);
23348         }
23349         function isBindingIdentifier() {
23350             if (token() === 78) {
23351                 return true;
23352             }
23353             return token() > 115;
23354         }
23355         function isIdentifier() {
23356             if (token() === 78) {
23357                 return true;
23358             }
23359             if (token() === 124 && inYieldContext()) {
23360                 return false;
23361             }
23362             if (token() === 130 && inAwaitContext()) {
23363                 return false;
23364             }
23365             return token() > 115;
23366         }
23367         function parseExpected(kind, diagnosticMessage, shouldAdvance) {
23368             if (shouldAdvance === void 0) { shouldAdvance = true; }
23369             if (token() === kind) {
23370                 if (shouldAdvance) {
23371                     nextToken();
23372                 }
23373                 return true;
23374             }
23375             if (diagnosticMessage) {
23376                 parseErrorAtCurrentToken(diagnosticMessage);
23377             }
23378             else {
23379                 parseErrorAtCurrentToken(ts.Diagnostics._0_expected, ts.tokenToString(kind));
23380             }
23381             return false;
23382         }
23383         function parseExpectedJSDoc(kind) {
23384             if (token() === kind) {
23385                 nextTokenJSDoc();
23386                 return true;
23387             }
23388             parseErrorAtCurrentToken(ts.Diagnostics._0_expected, ts.tokenToString(kind));
23389             return false;
23390         }
23391         function parseOptional(t) {
23392             if (token() === t) {
23393                 nextToken();
23394                 return true;
23395             }
23396             return false;
23397         }
23398         function parseOptionalToken(t) {
23399             if (token() === t) {
23400                 return parseTokenNode();
23401             }
23402             return undefined;
23403         }
23404         function parseOptionalTokenJSDoc(t) {
23405             if (token() === t) {
23406                 return parseTokenNodeJSDoc();
23407             }
23408             return undefined;
23409         }
23410         function parseExpectedToken(t, diagnosticMessage, arg0) {
23411             return parseOptionalToken(t) ||
23412                 createMissingNode(t, false, diagnosticMessage || ts.Diagnostics._0_expected, arg0 || ts.tokenToString(t));
23413         }
23414         function parseExpectedTokenJSDoc(t) {
23415             return parseOptionalTokenJSDoc(t) ||
23416                 createMissingNode(t, false, ts.Diagnostics._0_expected, ts.tokenToString(t));
23417         }
23418         function parseTokenNode() {
23419             var pos = getNodePos();
23420             var kind = token();
23421             nextToken();
23422             return finishNode(factory.createToken(kind), pos);
23423         }
23424         function parseTokenNodeJSDoc() {
23425             var pos = getNodePos();
23426             var kind = token();
23427             nextTokenJSDoc();
23428             return finishNode(factory.createToken(kind), pos);
23429         }
23430         function canParseSemicolon() {
23431             if (token() === 26) {
23432                 return true;
23433             }
23434             return token() === 19 || token() === 1 || scanner.hasPrecedingLineBreak();
23435         }
23436         function parseSemicolon() {
23437             if (canParseSemicolon()) {
23438                 if (token() === 26) {
23439                     nextToken();
23440                 }
23441                 return true;
23442             }
23443             else {
23444                 return parseExpected(26);
23445             }
23446         }
23447         function createNodeArray(elements, pos, end, hasTrailingComma) {
23448             var array = factory.createNodeArray(elements, hasTrailingComma);
23449             ts.setTextRangePosEnd(array, pos, end !== null && end !== void 0 ? end : scanner.getStartPos());
23450             return array;
23451         }
23452         function finishNode(node, pos, end) {
23453             ts.setTextRangePosEnd(node, pos, end !== null && end !== void 0 ? end : scanner.getStartPos());
23454             if (contextFlags) {
23455                 node.flags |= contextFlags;
23456             }
23457             if (parseErrorBeforeNextFinishedNode) {
23458                 parseErrorBeforeNextFinishedNode = false;
23459                 node.flags |= 65536;
23460             }
23461             return node;
23462         }
23463         function createMissingNode(kind, reportAtCurrentPosition, diagnosticMessage, arg0) {
23464             if (reportAtCurrentPosition) {
23465                 parseErrorAtPosition(scanner.getStartPos(), 0, diagnosticMessage, arg0);
23466             }
23467             else if (diagnosticMessage) {
23468                 parseErrorAtCurrentToken(diagnosticMessage, arg0);
23469             }
23470             var pos = getNodePos();
23471             var result = kind === 78 ? factory.createIdentifier("", undefined, undefined) :
23472                 ts.isTemplateLiteralKind(kind) ? factory.createTemplateLiteralLikeNode(kind, "", "", undefined) :
23473                     kind === 8 ? factory.createNumericLiteral("", undefined) :
23474                         kind === 10 ? factory.createStringLiteral("", undefined) :
23475                             kind === 271 ? factory.createMissingDeclaration() :
23476                                 factory.createToken(kind);
23477             return finishNode(result, pos);
23478         }
23479         function internIdentifier(text) {
23480             var identifier = identifiers.get(text);
23481             if (identifier === undefined) {
23482                 identifiers.set(text, identifier = text);
23483             }
23484             return identifier;
23485         }
23486         function createIdentifier(isIdentifier, diagnosticMessage, privateIdentifierDiagnosticMessage) {
23487             identifierCount++;
23488             if (isIdentifier) {
23489                 var pos = getNodePos();
23490                 var originalKeywordKind = token();
23491                 var text = internIdentifier(scanner.getTokenValue());
23492                 nextTokenWithoutCheck();
23493                 return finishNode(factory.createIdentifier(text, undefined, originalKeywordKind), pos);
23494             }
23495             if (token() === 79) {
23496                 parseErrorAtCurrentToken(privateIdentifierDiagnosticMessage || ts.Diagnostics.Private_identifiers_are_not_allowed_outside_class_bodies);
23497                 return createIdentifier(true);
23498             }
23499             var reportAtCurrentPosition = token() === 1;
23500             var isReservedWord = scanner.isReservedWord();
23501             var msgArg = scanner.getTokenText();
23502             var defaultMessage = isReservedWord ?
23503                 ts.Diagnostics.Identifier_expected_0_is_a_reserved_word_that_cannot_be_used_here :
23504                 ts.Diagnostics.Identifier_expected;
23505             return createMissingNode(78, reportAtCurrentPosition, diagnosticMessage || defaultMessage, msgArg);
23506         }
23507         function parseBindingIdentifier(privateIdentifierDiagnosticMessage) {
23508             return createIdentifier(isBindingIdentifier(), undefined, privateIdentifierDiagnosticMessage);
23509         }
23510         function parseIdentifier(diagnosticMessage, privateIdentifierDiagnosticMessage) {
23511             return createIdentifier(isIdentifier(), diagnosticMessage, privateIdentifierDiagnosticMessage);
23512         }
23513         function parseIdentifierName(diagnosticMessage) {
23514             return createIdentifier(ts.tokenIsIdentifierOrKeyword(token()), diagnosticMessage);
23515         }
23516         function isLiteralPropertyName() {
23517             return ts.tokenIsIdentifierOrKeyword(token()) ||
23518                 token() === 10 ||
23519                 token() === 8;
23520         }
23521         function parsePropertyNameWorker(allowComputedPropertyNames) {
23522             if (token() === 10 || token() === 8) {
23523                 var node = parseLiteralNode();
23524                 node.text = internIdentifier(node.text);
23525                 return node;
23526             }
23527             if (allowComputedPropertyNames && token() === 22) {
23528                 return parseComputedPropertyName();
23529             }
23530             if (token() === 79) {
23531                 return parsePrivateIdentifier();
23532             }
23533             return parseIdentifierName();
23534         }
23535         function parsePropertyName() {
23536             return parsePropertyNameWorker(true);
23537         }
23538         function parseComputedPropertyName() {
23539             var pos = getNodePos();
23540             parseExpected(22);
23541             var expression = allowInAnd(parseExpression);
23542             parseExpected(23);
23543             return finishNode(factory.createComputedPropertyName(expression), pos);
23544         }
23545         function internPrivateIdentifier(text) {
23546             var privateIdentifier = privateIdentifiers.get(text);
23547             if (privateIdentifier === undefined) {
23548                 privateIdentifiers.set(text, privateIdentifier = text);
23549             }
23550             return privateIdentifier;
23551         }
23552         function parsePrivateIdentifier() {
23553             var pos = getNodePos();
23554             var node = factory.createPrivateIdentifier(internPrivateIdentifier(scanner.getTokenText()));
23555             nextToken();
23556             return finishNode(node, pos);
23557         }
23558         function parseContextualModifier(t) {
23559             return token() === t && tryParse(nextTokenCanFollowModifier);
23560         }
23561         function nextTokenIsOnSameLineAndCanFollowModifier() {
23562             nextToken();
23563             if (scanner.hasPrecedingLineBreak()) {
23564                 return false;
23565             }
23566             return canFollowModifier();
23567         }
23568         function nextTokenCanFollowModifier() {
23569             switch (token()) {
23570                 case 84:
23571                     return nextToken() === 91;
23572                 case 92:
23573                     nextToken();
23574                     if (token() === 87) {
23575                         return lookAhead(nextTokenCanFollowDefaultKeyword);
23576                     }
23577                     if (token() === 149) {
23578                         return lookAhead(nextTokenCanFollowExportModifier);
23579                     }
23580                     return canFollowExportModifier();
23581                 case 87:
23582                     return nextTokenCanFollowDefaultKeyword();
23583                 case 123:
23584                 case 134:
23585                 case 146:
23586                     nextToken();
23587                     return canFollowModifier();
23588                 default:
23589                     return nextTokenIsOnSameLineAndCanFollowModifier();
23590             }
23591         }
23592         function canFollowExportModifier() {
23593             return token() !== 41
23594                 && token() !== 126
23595                 && token() !== 18
23596                 && canFollowModifier();
23597         }
23598         function nextTokenCanFollowExportModifier() {
23599             nextToken();
23600             return canFollowExportModifier();
23601         }
23602         function parseAnyContextualModifier() {
23603             return ts.isModifierKind(token()) && tryParse(nextTokenCanFollowModifier);
23604         }
23605         function canFollowModifier() {
23606             return token() === 22
23607                 || token() === 18
23608                 || token() === 41
23609                 || token() === 25
23610                 || isLiteralPropertyName();
23611         }
23612         function nextTokenCanFollowDefaultKeyword() {
23613             nextToken();
23614             return token() === 83 || token() === 97 ||
23615                 token() === 117 ||
23616                 (token() === 125 && lookAhead(nextTokenIsClassKeywordOnSameLine)) ||
23617                 (token() === 129 && lookAhead(nextTokenIsFunctionKeywordOnSameLine));
23618         }
23619         function isListElement(parsingContext, inErrorRecovery) {
23620             var node = currentNode(parsingContext);
23621             if (node) {
23622                 return true;
23623             }
23624             switch (parsingContext) {
23625                 case 0:
23626                 case 1:
23627                 case 3:
23628                     return !(token() === 26 && inErrorRecovery) && isStartOfStatement();
23629                 case 2:
23630                     return token() === 81 || token() === 87;
23631                 case 4:
23632                     return lookAhead(isTypeMemberStart);
23633                 case 5:
23634                     return lookAhead(isClassMemberStart) || (token() === 26 && !inErrorRecovery);
23635                 case 6:
23636                     return token() === 22 || isLiteralPropertyName();
23637                 case 12:
23638                     switch (token()) {
23639                         case 22:
23640                         case 41:
23641                         case 25:
23642                         case 24:
23643                             return true;
23644                         default:
23645                             return isLiteralPropertyName();
23646                     }
23647                 case 18:
23648                     return isLiteralPropertyName();
23649                 case 9:
23650                     return token() === 22 || token() === 25 || isLiteralPropertyName();
23651                 case 7:
23652                     if (token() === 18) {
23653                         return lookAhead(isValidHeritageClauseObjectLiteral);
23654                     }
23655                     if (!inErrorRecovery) {
23656                         return isStartOfLeftHandSideExpression() && !isHeritageClauseExtendsOrImplementsKeyword();
23657                     }
23658                     else {
23659                         return isIdentifier() && !isHeritageClauseExtendsOrImplementsKeyword();
23660                     }
23661                 case 8:
23662                     return isBindingIdentifierOrPrivateIdentifierOrPattern();
23663                 case 10:
23664                     return token() === 27 || token() === 25 || isBindingIdentifierOrPrivateIdentifierOrPattern();
23665                 case 19:
23666                     return isIdentifier();
23667                 case 15:
23668                     switch (token()) {
23669                         case 27:
23670                         case 24:
23671                             return true;
23672                     }
23673                 case 11:
23674                     return token() === 25 || isStartOfExpression();
23675                 case 16:
23676                     return isStartOfParameter(false);
23677                 case 17:
23678                     return isStartOfParameter(true);
23679                 case 20:
23680                 case 21:
23681                     return token() === 27 || isStartOfType();
23682                 case 22:
23683                     return isHeritageClause();
23684                 case 23:
23685                     return ts.tokenIsIdentifierOrKeyword(token());
23686                 case 13:
23687                     return ts.tokenIsIdentifierOrKeyword(token()) || token() === 18;
23688                 case 14:
23689                     return true;
23690             }
23691             return ts.Debug.fail("Non-exhaustive case in 'isListElement'.");
23692         }
23693         function isValidHeritageClauseObjectLiteral() {
23694             ts.Debug.assert(token() === 18);
23695             if (nextToken() === 19) {
23696                 var next = nextToken();
23697                 return next === 27 || next === 18 || next === 93 || next === 116;
23698             }
23699             return true;
23700         }
23701         function nextTokenIsIdentifier() {
23702             nextToken();
23703             return isIdentifier();
23704         }
23705         function nextTokenIsIdentifierOrKeyword() {
23706             nextToken();
23707             return ts.tokenIsIdentifierOrKeyword(token());
23708         }
23709         function nextTokenIsIdentifierOrKeywordOrGreaterThan() {
23710             nextToken();
23711             return ts.tokenIsIdentifierOrKeywordOrGreaterThan(token());
23712         }
23713         function isHeritageClauseExtendsOrImplementsKeyword() {
23714             if (token() === 116 ||
23715                 token() === 93) {
23716                 return lookAhead(nextTokenIsStartOfExpression);
23717             }
23718             return false;
23719         }
23720         function nextTokenIsStartOfExpression() {
23721             nextToken();
23722             return isStartOfExpression();
23723         }
23724         function nextTokenIsStartOfType() {
23725             nextToken();
23726             return isStartOfType();
23727         }
23728         function isListTerminator(kind) {
23729             if (token() === 1) {
23730                 return true;
23731             }
23732             switch (kind) {
23733                 case 1:
23734                 case 2:
23735                 case 4:
23736                 case 5:
23737                 case 6:
23738                 case 12:
23739                 case 9:
23740                 case 23:
23741                     return token() === 19;
23742                 case 3:
23743                     return token() === 19 || token() === 81 || token() === 87;
23744                 case 7:
23745                     return token() === 18 || token() === 93 || token() === 116;
23746                 case 8:
23747                     return isVariableDeclaratorListTerminator();
23748                 case 19:
23749                     return token() === 31 || token() === 20 || token() === 18 || token() === 93 || token() === 116;
23750                 case 11:
23751                     return token() === 21 || token() === 26;
23752                 case 15:
23753                 case 21:
23754                 case 10:
23755                     return token() === 23;
23756                 case 17:
23757                 case 16:
23758                 case 18:
23759                     return token() === 21 || token() === 23;
23760                 case 20:
23761                     return token() !== 27;
23762                 case 22:
23763                     return token() === 18 || token() === 19;
23764                 case 13:
23765                     return token() === 31 || token() === 43;
23766                 case 14:
23767                     return token() === 29 && lookAhead(nextTokenIsSlash);
23768                 default:
23769                     return false;
23770             }
23771         }
23772         function isVariableDeclaratorListTerminator() {
23773             if (canParseSemicolon()) {
23774                 return true;
23775             }
23776             if (isInOrOfKeyword(token())) {
23777                 return true;
23778             }
23779             if (token() === 38) {
23780                 return true;
23781             }
23782             return false;
23783         }
23784         function isInSomeParsingContext() {
23785             for (var kind = 0; kind < 24; kind++) {
23786                 if (parsingContext & (1 << kind)) {
23787                     if (isListElement(kind, true) || isListTerminator(kind)) {
23788                         return true;
23789                     }
23790                 }
23791             }
23792             return false;
23793         }
23794         function parseList(kind, parseElement) {
23795             var saveParsingContext = parsingContext;
23796             parsingContext |= 1 << kind;
23797             var list = [];
23798             var listPos = getNodePos();
23799             while (!isListTerminator(kind)) {
23800                 if (isListElement(kind, false)) {
23801                     var element = parseListElement(kind, parseElement);
23802                     list.push(element);
23803                     continue;
23804                 }
23805                 if (abortParsingListOrMoveToNextToken(kind)) {
23806                     break;
23807                 }
23808             }
23809             parsingContext = saveParsingContext;
23810             return createNodeArray(list, listPos);
23811         }
23812         function parseListElement(parsingContext, parseElement) {
23813             var node = currentNode(parsingContext);
23814             if (node) {
23815                 return consumeNode(node);
23816             }
23817             return parseElement();
23818         }
23819         function currentNode(parsingContext) {
23820             if (!syntaxCursor || !isReusableParsingContext(parsingContext) || parseErrorBeforeNextFinishedNode) {
23821                 return undefined;
23822             }
23823             var node = syntaxCursor.currentNode(scanner.getStartPos());
23824             if (ts.nodeIsMissing(node) || node.intersectsChange || ts.containsParseError(node)) {
23825                 return undefined;
23826             }
23827             var nodeContextFlags = node.flags & 25358336;
23828             if (nodeContextFlags !== contextFlags) {
23829                 return undefined;
23830             }
23831             if (!canReuseNode(node, parsingContext)) {
23832                 return undefined;
23833             }
23834             if (node.jsDocCache) {
23835                 node.jsDocCache = undefined;
23836             }
23837             return node;
23838         }
23839         function consumeNode(node) {
23840             scanner.setTextPos(node.end);
23841             nextToken();
23842             return node;
23843         }
23844         function isReusableParsingContext(parsingContext) {
23845             switch (parsingContext) {
23846                 case 5:
23847                 case 2:
23848                 case 0:
23849                 case 1:
23850                 case 3:
23851                 case 6:
23852                 case 4:
23853                 case 8:
23854                 case 17:
23855                 case 16:
23856                     return true;
23857             }
23858             return false;
23859         }
23860         function canReuseNode(node, parsingContext) {
23861             switch (parsingContext) {
23862                 case 5:
23863                     return isReusableClassMember(node);
23864                 case 2:
23865                     return isReusableSwitchClause(node);
23866                 case 0:
23867                 case 1:
23868                 case 3:
23869                     return isReusableStatement(node);
23870                 case 6:
23871                     return isReusableEnumMember(node);
23872                 case 4:
23873                     return isReusableTypeMember(node);
23874                 case 8:
23875                     return isReusableVariableDeclaration(node);
23876                 case 17:
23877                 case 16:
23878                     return isReusableParameter(node);
23879             }
23880             return false;
23881         }
23882         function isReusableClassMember(node) {
23883             if (node) {
23884                 switch (node.kind) {
23885                     case 166:
23886                     case 171:
23887                     case 167:
23888                     case 168:
23889                     case 163:
23890                     case 229:
23891                         return true;
23892                     case 165:
23893                         var methodDeclaration = node;
23894                         var nameIsConstructor = methodDeclaration.name.kind === 78 &&
23895                             methodDeclaration.name.originalKeywordKind === 132;
23896                         return !nameIsConstructor;
23897                 }
23898             }
23899             return false;
23900         }
23901         function isReusableSwitchClause(node) {
23902             if (node) {
23903                 switch (node.kind) {
23904                     case 284:
23905                     case 285:
23906                         return true;
23907                 }
23908             }
23909             return false;
23910         }
23911         function isReusableStatement(node) {
23912             if (node) {
23913                 switch (node.kind) {
23914                     case 251:
23915                     case 232:
23916                     case 230:
23917                     case 234:
23918                     case 233:
23919                     case 246:
23920                     case 242:
23921                     case 244:
23922                     case 241:
23923                     case 240:
23924                     case 238:
23925                     case 239:
23926                     case 237:
23927                     case 236:
23928                     case 243:
23929                     case 231:
23930                     case 247:
23931                     case 245:
23932                     case 235:
23933                     case 248:
23934                     case 261:
23935                     case 260:
23936                     case 267:
23937                     case 266:
23938                     case 256:
23939                     case 252:
23940                     case 253:
23941                     case 255:
23942                     case 254:
23943                         return true;
23944                 }
23945             }
23946             return false;
23947         }
23948         function isReusableEnumMember(node) {
23949             return node.kind === 291;
23950         }
23951         function isReusableTypeMember(node) {
23952             if (node) {
23953                 switch (node.kind) {
23954                     case 170:
23955                     case 164:
23956                     case 171:
23957                     case 162:
23958                     case 169:
23959                         return true;
23960                 }
23961             }
23962             return false;
23963         }
23964         function isReusableVariableDeclaration(node) {
23965             if (node.kind !== 249) {
23966                 return false;
23967             }
23968             var variableDeclarator = node;
23969             return variableDeclarator.initializer === undefined;
23970         }
23971         function isReusableParameter(node) {
23972             if (node.kind !== 160) {
23973                 return false;
23974             }
23975             var parameter = node;
23976             return parameter.initializer === undefined;
23977         }
23978         function abortParsingListOrMoveToNextToken(kind) {
23979             parsingContextErrors(kind);
23980             if (isInSomeParsingContext()) {
23981                 return true;
23982             }
23983             nextToken();
23984             return false;
23985         }
23986         function parsingContextErrors(context) {
23987             switch (context) {
23988                 case 0: return parseErrorAtCurrentToken(ts.Diagnostics.Declaration_or_statement_expected);
23989                 case 1: return parseErrorAtCurrentToken(ts.Diagnostics.Declaration_or_statement_expected);
23990                 case 2: return parseErrorAtCurrentToken(ts.Diagnostics.case_or_default_expected);
23991                 case 3: return parseErrorAtCurrentToken(ts.Diagnostics.Statement_expected);
23992                 case 18:
23993                 case 4: return parseErrorAtCurrentToken(ts.Diagnostics.Property_or_signature_expected);
23994                 case 5: return parseErrorAtCurrentToken(ts.Diagnostics.Unexpected_token_A_constructor_method_accessor_or_property_was_expected);
23995                 case 6: return parseErrorAtCurrentToken(ts.Diagnostics.Enum_member_expected);
23996                 case 7: return parseErrorAtCurrentToken(ts.Diagnostics.Expression_expected);
23997                 case 8:
23998                     return ts.isKeyword(token())
23999                         ? parseErrorAtCurrentToken(ts.Diagnostics._0_is_not_allowed_as_a_variable_declaration_name, ts.tokenToString(token()))
24000                         : parseErrorAtCurrentToken(ts.Diagnostics.Variable_declaration_expected);
24001                 case 9: return parseErrorAtCurrentToken(ts.Diagnostics.Property_destructuring_pattern_expected);
24002                 case 10: return parseErrorAtCurrentToken(ts.Diagnostics.Array_element_destructuring_pattern_expected);
24003                 case 11: return parseErrorAtCurrentToken(ts.Diagnostics.Argument_expression_expected);
24004                 case 12: return parseErrorAtCurrentToken(ts.Diagnostics.Property_assignment_expected);
24005                 case 15: return parseErrorAtCurrentToken(ts.Diagnostics.Expression_or_comma_expected);
24006                 case 17: return parseErrorAtCurrentToken(ts.Diagnostics.Parameter_declaration_expected);
24007                 case 16: return parseErrorAtCurrentToken(ts.Diagnostics.Parameter_declaration_expected);
24008                 case 19: return parseErrorAtCurrentToken(ts.Diagnostics.Type_parameter_declaration_expected);
24009                 case 20: return parseErrorAtCurrentToken(ts.Diagnostics.Type_argument_expected);
24010                 case 21: return parseErrorAtCurrentToken(ts.Diagnostics.Type_expected);
24011                 case 22: return parseErrorAtCurrentToken(ts.Diagnostics.Unexpected_token_expected);
24012                 case 23: return parseErrorAtCurrentToken(ts.Diagnostics.Identifier_expected);
24013                 case 13: return parseErrorAtCurrentToken(ts.Diagnostics.Identifier_expected);
24014                 case 14: return parseErrorAtCurrentToken(ts.Diagnostics.Identifier_expected);
24015                 default: return [undefined];
24016             }
24017         }
24018         function parseDelimitedList(kind, parseElement, considerSemicolonAsDelimiter) {
24019             var saveParsingContext = parsingContext;
24020             parsingContext |= 1 << kind;
24021             var list = [];
24022             var listPos = getNodePos();
24023             var commaStart = -1;
24024             while (true) {
24025                 if (isListElement(kind, false)) {
24026                     var startPos = scanner.getStartPos();
24027                     list.push(parseListElement(kind, parseElement));
24028                     commaStart = scanner.getTokenPos();
24029                     if (parseOptional(27)) {
24030                         continue;
24031                     }
24032                     commaStart = -1;
24033                     if (isListTerminator(kind)) {
24034                         break;
24035                     }
24036                     parseExpected(27, getExpectedCommaDiagnostic(kind));
24037                     if (considerSemicolonAsDelimiter && token() === 26 && !scanner.hasPrecedingLineBreak()) {
24038                         nextToken();
24039                     }
24040                     if (startPos === scanner.getStartPos()) {
24041                         nextToken();
24042                     }
24043                     continue;
24044                 }
24045                 if (isListTerminator(kind)) {
24046                     break;
24047                 }
24048                 if (abortParsingListOrMoveToNextToken(kind)) {
24049                     break;
24050                 }
24051             }
24052             parsingContext = saveParsingContext;
24053             return createNodeArray(list, listPos, undefined, commaStart >= 0);
24054         }
24055         function getExpectedCommaDiagnostic(kind) {
24056             return kind === 6 ? ts.Diagnostics.An_enum_member_name_must_be_followed_by_a_or : undefined;
24057         }
24058         function createMissingList() {
24059             var list = createNodeArray([], getNodePos());
24060             list.isMissingList = true;
24061             return list;
24062         }
24063         function isMissingList(arr) {
24064             return !!arr.isMissingList;
24065         }
24066         function parseBracketedList(kind, parseElement, open, close) {
24067             if (parseExpected(open)) {
24068                 var result = parseDelimitedList(kind, parseElement);
24069                 parseExpected(close);
24070                 return result;
24071             }
24072             return createMissingList();
24073         }
24074         function parseEntityName(allowReservedWords, diagnosticMessage) {
24075             var pos = getNodePos();
24076             var entity = allowReservedWords ? parseIdentifierName(diagnosticMessage) : parseIdentifier(diagnosticMessage);
24077             var dotPos = getNodePos();
24078             while (parseOptional(24)) {
24079                 if (token() === 29) {
24080                     entity.jsdocDotPos = dotPos;
24081                     break;
24082                 }
24083                 dotPos = getNodePos();
24084                 entity = finishNode(factory.createQualifiedName(entity, parseRightSideOfDot(allowReservedWords, false)), pos);
24085             }
24086             return entity;
24087         }
24088         function createQualifiedName(entity, name) {
24089             return finishNode(factory.createQualifiedName(entity, name), entity.pos);
24090         }
24091         function parseRightSideOfDot(allowIdentifierNames, allowPrivateIdentifiers) {
24092             if (scanner.hasPrecedingLineBreak() && ts.tokenIsIdentifierOrKeyword(token())) {
24093                 var matchesPattern = lookAhead(nextTokenIsIdentifierOrKeywordOnSameLine);
24094                 if (matchesPattern) {
24095                     return createMissingNode(78, true, ts.Diagnostics.Identifier_expected);
24096                 }
24097             }
24098             if (token() === 79) {
24099                 var node = parsePrivateIdentifier();
24100                 return allowPrivateIdentifiers ? node : createMissingNode(78, true, ts.Diagnostics.Identifier_expected);
24101             }
24102             return allowIdentifierNames ? parseIdentifierName() : parseIdentifier();
24103         }
24104         function parseTemplateSpans(isTaggedTemplate) {
24105             var pos = getNodePos();
24106             var list = [];
24107             var node;
24108             do {
24109                 node = parseTemplateSpan(isTaggedTemplate);
24110                 list.push(node);
24111             } while (node.literal.kind === 16);
24112             return createNodeArray(list, pos);
24113         }
24114         function parseTemplateExpression(isTaggedTemplate) {
24115             var pos = getNodePos();
24116             return finishNode(factory.createTemplateExpression(parseTemplateHead(isTaggedTemplate), parseTemplateSpans(isTaggedTemplate)), pos);
24117         }
24118         function parseTemplateType() {
24119             var pos = getNodePos();
24120             return finishNode(factory.createTemplateLiteralType(parseTemplateHead(false), parseTemplateTypeSpans()), pos);
24121         }
24122         function parseTemplateTypeSpans() {
24123             var pos = getNodePos();
24124             var list = [];
24125             var node;
24126             do {
24127                 node = parseTemplateTypeSpan();
24128                 list.push(node);
24129             } while (node.literal.kind === 16);
24130             return createNodeArray(list, pos);
24131         }
24132         function parseTemplateTypeSpan() {
24133             var pos = getNodePos();
24134             return finishNode(factory.createTemplateLiteralTypeSpan(parseType(), parseLiteralOfTemplateSpan(false)), pos);
24135         }
24136         function parseLiteralOfTemplateSpan(isTaggedTemplate) {
24137             if (token() === 19) {
24138                 reScanTemplateToken(isTaggedTemplate);
24139                 return parseTemplateMiddleOrTemplateTail();
24140             }
24141             else {
24142                 return parseExpectedToken(17, ts.Diagnostics._0_expected, ts.tokenToString(19));
24143             }
24144         }
24145         function parseTemplateSpan(isTaggedTemplate) {
24146             var pos = getNodePos();
24147             return finishNode(factory.createTemplateSpan(allowInAnd(parseExpression), parseLiteralOfTemplateSpan(isTaggedTemplate)), pos);
24148         }
24149         function parseLiteralNode() {
24150             return parseLiteralLikeNode(token());
24151         }
24152         function parseTemplateHead(isTaggedTemplate) {
24153             if (isTaggedTemplate) {
24154                 reScanTemplateHeadOrNoSubstitutionTemplate();
24155             }
24156             var fragment = parseLiteralLikeNode(token());
24157             ts.Debug.assert(fragment.kind === 15, "Template head has wrong token kind");
24158             return fragment;
24159         }
24160         function parseTemplateMiddleOrTemplateTail() {
24161             var fragment = parseLiteralLikeNode(token());
24162             ts.Debug.assert(fragment.kind === 16 || fragment.kind === 17, "Template fragment has wrong token kind");
24163             return fragment;
24164         }
24165         function getTemplateLiteralRawText(kind) {
24166             var isLast = kind === 14 || kind === 17;
24167             var tokenText = scanner.getTokenText();
24168             return tokenText.substring(1, tokenText.length - (scanner.isUnterminated() ? 0 : isLast ? 1 : 2));
24169         }
24170         function parseLiteralLikeNode(kind) {
24171             var pos = getNodePos();
24172             var node = ts.isTemplateLiteralKind(kind) ? factory.createTemplateLiteralLikeNode(kind, scanner.getTokenValue(), getTemplateLiteralRawText(kind), scanner.getTokenFlags() & 2048) :
24173                 kind === 8 ? factory.createNumericLiteral(scanner.getTokenValue(), scanner.getNumericLiteralFlags()) :
24174                     kind === 10 ? factory.createStringLiteral(scanner.getTokenValue(), undefined, scanner.hasExtendedUnicodeEscape()) :
24175                         ts.isLiteralKind(kind) ? factory.createLiteralLikeNode(kind, scanner.getTokenValue()) :
24176                             ts.Debug.fail();
24177             if (scanner.hasExtendedUnicodeEscape()) {
24178                 node.hasExtendedUnicodeEscape = true;
24179             }
24180             if (scanner.isUnterminated()) {
24181                 node.isUnterminated = true;
24182             }
24183             nextToken();
24184             return finishNode(node, pos);
24185         }
24186         function parseEntityNameOfTypeReference() {
24187             return parseEntityName(true, ts.Diagnostics.Type_expected);
24188         }
24189         function parseTypeArgumentsOfTypeReference() {
24190             if (!scanner.hasPrecedingLineBreak() && reScanLessThanToken() === 29) {
24191                 return parseBracketedList(20, parseType, 29, 31);
24192             }
24193         }
24194         function parseTypeReference() {
24195             var pos = getNodePos();
24196             return finishNode(factory.createTypeReferenceNode(parseEntityNameOfTypeReference(), parseTypeArgumentsOfTypeReference()), pos);
24197         }
24198         function typeHasArrowFunctionBlockingParseError(node) {
24199             switch (node.kind) {
24200                 case 173:
24201                     return ts.nodeIsMissing(node.typeName);
24202                 case 174:
24203                 case 175: {
24204                     var _a = node, parameters = _a.parameters, type = _a.type;
24205                     return isMissingList(parameters) || typeHasArrowFunctionBlockingParseError(type);
24206                 }
24207                 case 186:
24208                     return typeHasArrowFunctionBlockingParseError(node.type);
24209                 default:
24210                     return false;
24211             }
24212         }
24213         function parseThisTypePredicate(lhs) {
24214             nextToken();
24215             return finishNode(factory.createTypePredicateNode(undefined, lhs, parseType()), lhs.pos);
24216         }
24217         function parseThisTypeNode() {
24218             var pos = getNodePos();
24219             nextToken();
24220             return finishNode(factory.createThisTypeNode(), pos);
24221         }
24222         function parseJSDocAllType() {
24223             var pos = getNodePos();
24224             nextToken();
24225             return finishNode(factory.createJSDocAllType(), pos);
24226         }
24227         function parseJSDocNonNullableType() {
24228             var pos = getNodePos();
24229             nextToken();
24230             return finishNode(factory.createJSDocNonNullableType(parseNonArrayType()), pos);
24231         }
24232         function parseJSDocUnknownOrNullableType() {
24233             var pos = getNodePos();
24234             nextToken();
24235             if (token() === 27 ||
24236                 token() === 19 ||
24237                 token() === 21 ||
24238                 token() === 31 ||
24239                 token() === 62 ||
24240                 token() === 51) {
24241                 return finishNode(factory.createJSDocUnknownType(), pos);
24242             }
24243             else {
24244                 return finishNode(factory.createJSDocNullableType(parseType()), pos);
24245             }
24246         }
24247         function parseJSDocFunctionType() {
24248             var pos = getNodePos();
24249             var hasJSDoc = hasPrecedingJSDocComment();
24250             if (lookAhead(nextTokenIsOpenParen)) {
24251                 nextToken();
24252                 var parameters = parseParameters(4 | 32);
24253                 var type = parseReturnType(58, false);
24254                 return withJSDoc(finishNode(factory.createJSDocFunctionType(parameters, type), pos), hasJSDoc);
24255             }
24256             return finishNode(factory.createTypeReferenceNode(parseIdentifierName(), undefined), pos);
24257         }
24258         function parseJSDocParameter() {
24259             var pos = getNodePos();
24260             var name;
24261             if (token() === 107 || token() === 102) {
24262                 name = parseIdentifierName();
24263                 parseExpected(58);
24264             }
24265             return finishNode(factory.createParameterDeclaration(undefined, undefined, undefined, name, undefined, parseJSDocType(), undefined), pos);
24266         }
24267         function parseJSDocType() {
24268             scanner.setInJSDocType(true);
24269             var pos = getNodePos();
24270             if (parseOptional(139)) {
24271                 var moduleTag = factory.createJSDocNamepathType(undefined);
24272                 terminate: while (true) {
24273                     switch (token()) {
24274                         case 19:
24275                         case 1:
24276                         case 27:
24277                         case 5:
24278                             break terminate;
24279                         default:
24280                             nextTokenJSDoc();
24281                     }
24282                 }
24283                 scanner.setInJSDocType(false);
24284                 return finishNode(moduleTag, pos);
24285             }
24286             var hasDotDotDot = parseOptional(25);
24287             var type = parseTypeOrTypePredicate();
24288             scanner.setInJSDocType(false);
24289             if (hasDotDotDot) {
24290                 type = finishNode(factory.createJSDocVariadicType(type), pos);
24291             }
24292             if (token() === 62) {
24293                 nextToken();
24294                 return finishNode(factory.createJSDocOptionalType(type), pos);
24295             }
24296             return type;
24297         }
24298         function parseTypeQuery() {
24299             var pos = getNodePos();
24300             parseExpected(111);
24301             return finishNode(factory.createTypeQueryNode(parseEntityName(true)), pos);
24302         }
24303         function parseTypeParameter() {
24304             var pos = getNodePos();
24305             var name = parseIdentifier();
24306             var constraint;
24307             var expression;
24308             if (parseOptional(93)) {
24309                 if (isStartOfType() || !isStartOfExpression()) {
24310                     constraint = parseType();
24311                 }
24312                 else {
24313                     expression = parseUnaryExpressionOrHigher();
24314                 }
24315             }
24316             var defaultType = parseOptional(62) ? parseType() : undefined;
24317             var node = factory.createTypeParameterDeclaration(name, constraint, defaultType);
24318             node.expression = expression;
24319             return finishNode(node, pos);
24320         }
24321         function parseTypeParameters() {
24322             if (token() === 29) {
24323                 return parseBracketedList(19, parseTypeParameter, 29, 31);
24324             }
24325         }
24326         function isStartOfParameter(isJSDocParameter) {
24327             return token() === 25 ||
24328                 isBindingIdentifierOrPrivateIdentifierOrPattern() ||
24329                 ts.isModifierKind(token()) ||
24330                 token() === 59 ||
24331                 isStartOfType(!isJSDocParameter);
24332         }
24333         function parseNameOfParameter(modifiers) {
24334             var name = parseIdentifierOrPattern(ts.Diagnostics.Private_identifiers_cannot_be_used_as_parameters);
24335             if (ts.getFullWidth(name) === 0 && !ts.some(modifiers) && ts.isModifierKind(token())) {
24336                 nextToken();
24337             }
24338             return name;
24339         }
24340         function parseParameterInOuterAwaitContext() {
24341             return parseParameterWorker(true);
24342         }
24343         function parseParameter() {
24344             return parseParameterWorker(false);
24345         }
24346         function parseParameterWorker(inOuterAwaitContext) {
24347             var pos = getNodePos();
24348             var hasJSDoc = hasPrecedingJSDocComment();
24349             if (token() === 107) {
24350                 var node_1 = factory.createParameterDeclaration(undefined, undefined, undefined, createIdentifier(true), undefined, parseTypeAnnotation(), undefined);
24351                 return withJSDoc(finishNode(node_1, pos), hasJSDoc);
24352             }
24353             var decorators = inOuterAwaitContext ? doInAwaitContext(parseDecorators) : parseDecorators();
24354             var savedTopLevel = topLevel;
24355             topLevel = false;
24356             var modifiers = parseModifiers();
24357             var node = withJSDoc(finishNode(factory.createParameterDeclaration(decorators, modifiers, parseOptionalToken(25), parseNameOfParameter(modifiers), parseOptionalToken(57), parseTypeAnnotation(), parseInitializer()), pos), hasJSDoc);
24358             topLevel = savedTopLevel;
24359             return node;
24360         }
24361         function parseReturnType(returnToken, isType) {
24362             if (shouldParseReturnType(returnToken, isType)) {
24363                 return parseTypeOrTypePredicate();
24364             }
24365         }
24366         function shouldParseReturnType(returnToken, isType) {
24367             if (returnToken === 38) {
24368                 parseExpected(returnToken);
24369                 return true;
24370             }
24371             else if (parseOptional(58)) {
24372                 return true;
24373             }
24374             else if (isType && token() === 38) {
24375                 parseErrorAtCurrentToken(ts.Diagnostics._0_expected, ts.tokenToString(58));
24376                 nextToken();
24377                 return true;
24378             }
24379             return false;
24380         }
24381         function parseParametersWorker(flags) {
24382             var savedYieldContext = inYieldContext();
24383             var savedAwaitContext = inAwaitContext();
24384             setYieldContext(!!(flags & 1));
24385             setAwaitContext(!!(flags & 2));
24386             var parameters = flags & 32 ?
24387                 parseDelimitedList(17, parseJSDocParameter) :
24388                 parseDelimitedList(16, savedAwaitContext ? parseParameterInOuterAwaitContext : parseParameter);
24389             setYieldContext(savedYieldContext);
24390             setAwaitContext(savedAwaitContext);
24391             return parameters;
24392         }
24393         function parseParameters(flags) {
24394             if (!parseExpected(20)) {
24395                 return createMissingList();
24396             }
24397             var parameters = parseParametersWorker(flags);
24398             parseExpected(21);
24399             return parameters;
24400         }
24401         function parseTypeMemberSemicolon() {
24402             if (parseOptional(27)) {
24403                 return;
24404             }
24405             parseSemicolon();
24406         }
24407         function parseSignatureMember(kind) {
24408             var pos = getNodePos();
24409             var hasJSDoc = hasPrecedingJSDocComment();
24410             if (kind === 170) {
24411                 parseExpected(102);
24412             }
24413             var typeParameters = parseTypeParameters();
24414             var parameters = parseParameters(4);
24415             var type = parseReturnType(58, true);
24416             parseTypeMemberSemicolon();
24417             var node = kind === 169
24418                 ? factory.createCallSignature(typeParameters, parameters, type)
24419                 : factory.createConstructSignature(typeParameters, parameters, type);
24420             return withJSDoc(finishNode(node, pos), hasJSDoc);
24421         }
24422         function isIndexSignature() {
24423             return token() === 22 && lookAhead(isUnambiguouslyIndexSignature);
24424         }
24425         function isUnambiguouslyIndexSignature() {
24426             nextToken();
24427             if (token() === 25 || token() === 23) {
24428                 return true;
24429             }
24430             if (ts.isModifierKind(token())) {
24431                 nextToken();
24432                 if (isIdentifier()) {
24433                     return true;
24434                 }
24435             }
24436             else if (!isIdentifier()) {
24437                 return false;
24438             }
24439             else {
24440                 nextToken();
24441             }
24442             if (token() === 58 || token() === 27) {
24443                 return true;
24444             }
24445             if (token() !== 57) {
24446                 return false;
24447             }
24448             nextToken();
24449             return token() === 58 || token() === 27 || token() === 23;
24450         }
24451         function parseIndexSignatureDeclaration(pos, hasJSDoc, decorators, modifiers) {
24452             var parameters = parseBracketedList(16, parseParameter, 22, 23);
24453             var type = parseTypeAnnotation();
24454             parseTypeMemberSemicolon();
24455             var node = factory.createIndexSignature(decorators, modifiers, parameters, type);
24456             return withJSDoc(finishNode(node, pos), hasJSDoc);
24457         }
24458         function parsePropertyOrMethodSignature(pos, hasJSDoc, modifiers) {
24459             var name = parsePropertyName();
24460             var questionToken = parseOptionalToken(57);
24461             var node;
24462             if (token() === 20 || token() === 29) {
24463                 var typeParameters = parseTypeParameters();
24464                 var parameters = parseParameters(4);
24465                 var type = parseReturnType(58, true);
24466                 node = factory.createMethodSignature(modifiers, name, questionToken, typeParameters, parameters, type);
24467             }
24468             else {
24469                 var type = parseTypeAnnotation();
24470                 node = factory.createPropertySignature(modifiers, name, questionToken, type);
24471                 if (token() === 62)
24472                     node.initializer = parseInitializer();
24473             }
24474             parseTypeMemberSemicolon();
24475             return withJSDoc(finishNode(node, pos), hasJSDoc);
24476         }
24477         function isTypeMemberStart() {
24478             if (token() === 20 || token() === 29) {
24479                 return true;
24480             }
24481             var idToken = false;
24482             while (ts.isModifierKind(token())) {
24483                 idToken = true;
24484                 nextToken();
24485             }
24486             if (token() === 22) {
24487                 return true;
24488             }
24489             if (isLiteralPropertyName()) {
24490                 idToken = true;
24491                 nextToken();
24492             }
24493             if (idToken) {
24494                 return token() === 20 ||
24495                     token() === 29 ||
24496                     token() === 57 ||
24497                     token() === 58 ||
24498                     token() === 27 ||
24499                     canParseSemicolon();
24500             }
24501             return false;
24502         }
24503         function parseTypeMember() {
24504             if (token() === 20 || token() === 29) {
24505                 return parseSignatureMember(169);
24506             }
24507             if (token() === 102 && lookAhead(nextTokenIsOpenParenOrLessThan)) {
24508                 return parseSignatureMember(170);
24509             }
24510             var pos = getNodePos();
24511             var hasJSDoc = hasPrecedingJSDocComment();
24512             var modifiers = parseModifiers();
24513             if (isIndexSignature()) {
24514                 return parseIndexSignatureDeclaration(pos, hasJSDoc, undefined, modifiers);
24515             }
24516             return parsePropertyOrMethodSignature(pos, hasJSDoc, modifiers);
24517         }
24518         function nextTokenIsOpenParenOrLessThan() {
24519             nextToken();
24520             return token() === 20 || token() === 29;
24521         }
24522         function nextTokenIsDot() {
24523             return nextToken() === 24;
24524         }
24525         function nextTokenIsOpenParenOrLessThanOrDot() {
24526             switch (nextToken()) {
24527                 case 20:
24528                 case 29:
24529                 case 24:
24530                     return true;
24531             }
24532             return false;
24533         }
24534         function parseTypeLiteral() {
24535             var pos = getNodePos();
24536             return finishNode(factory.createTypeLiteralNode(parseObjectTypeMembers()), pos);
24537         }
24538         function parseObjectTypeMembers() {
24539             var members;
24540             if (parseExpected(18)) {
24541                 members = parseList(4, parseTypeMember);
24542                 parseExpected(19);
24543             }
24544             else {
24545                 members = createMissingList();
24546             }
24547             return members;
24548         }
24549         function isStartOfMappedType() {
24550             nextToken();
24551             if (token() === 39 || token() === 40) {
24552                 return nextToken() === 142;
24553             }
24554             if (token() === 142) {
24555                 nextToken();
24556             }
24557             return token() === 22 && nextTokenIsIdentifier() && nextToken() === 100;
24558         }
24559         function parseMappedTypeParameter() {
24560             var pos = getNodePos();
24561             var name = parseIdentifierName();
24562             parseExpected(100);
24563             var type = parseType();
24564             return finishNode(factory.createTypeParameterDeclaration(name, type, undefined), pos);
24565         }
24566         function parseMappedType() {
24567             var pos = getNodePos();
24568             parseExpected(18);
24569             var readonlyToken;
24570             if (token() === 142 || token() === 39 || token() === 40) {
24571                 readonlyToken = parseTokenNode();
24572                 if (readonlyToken.kind !== 142) {
24573                     parseExpected(142);
24574                 }
24575             }
24576             parseExpected(22);
24577             var typeParameter = parseMappedTypeParameter();
24578             var nameType = parseOptional(126) ? parseType() : undefined;
24579             parseExpected(23);
24580             var questionToken;
24581             if (token() === 57 || token() === 39 || token() === 40) {
24582                 questionToken = parseTokenNode();
24583                 if (questionToken.kind !== 57) {
24584                     parseExpected(57);
24585                 }
24586             }
24587             var type = parseTypeAnnotation();
24588             parseSemicolon();
24589             parseExpected(19);
24590             return finishNode(factory.createMappedTypeNode(readonlyToken, typeParameter, nameType, questionToken, type), pos);
24591         }
24592         function parseTupleElementType() {
24593             var pos = getNodePos();
24594             if (parseOptional(25)) {
24595                 return finishNode(factory.createRestTypeNode(parseType()), pos);
24596             }
24597             var type = parseType();
24598             if (ts.isJSDocNullableType(type) && type.pos === type.type.pos) {
24599                 var node = factory.createOptionalTypeNode(type.type);
24600                 ts.setTextRange(node, type);
24601                 node.flags = type.flags;
24602                 return node;
24603             }
24604             return type;
24605         }
24606         function isNextTokenColonOrQuestionColon() {
24607             return nextToken() === 58 || (token() === 57 && nextToken() === 58);
24608         }
24609         function isTupleElementName() {
24610             if (token() === 25) {
24611                 return ts.tokenIsIdentifierOrKeyword(nextToken()) && isNextTokenColonOrQuestionColon();
24612             }
24613             return ts.tokenIsIdentifierOrKeyword(token()) && isNextTokenColonOrQuestionColon();
24614         }
24615         function parseTupleElementNameOrTupleElementType() {
24616             if (lookAhead(isTupleElementName)) {
24617                 var pos = getNodePos();
24618                 var hasJSDoc = hasPrecedingJSDocComment();
24619                 var dotDotDotToken = parseOptionalToken(25);
24620                 var name = parseIdentifierName();
24621                 var questionToken = parseOptionalToken(57);
24622                 parseExpected(58);
24623                 var type = parseTupleElementType();
24624                 var node = factory.createNamedTupleMember(dotDotDotToken, name, questionToken, type);
24625                 return withJSDoc(finishNode(node, pos), hasJSDoc);
24626             }
24627             return parseTupleElementType();
24628         }
24629         function parseTupleType() {
24630             var pos = getNodePos();
24631             return finishNode(factory.createTupleTypeNode(parseBracketedList(21, parseTupleElementNameOrTupleElementType, 22, 23)), pos);
24632         }
24633         function parseParenthesizedType() {
24634             var pos = getNodePos();
24635             parseExpected(20);
24636             var type = parseType();
24637             parseExpected(21);
24638             return finishNode(factory.createParenthesizedType(type), pos);
24639         }
24640         function parseFunctionOrConstructorType() {
24641             var pos = getNodePos();
24642             var hasJSDoc = hasPrecedingJSDocComment();
24643             var isConstructorType = parseOptional(102);
24644             var typeParameters = parseTypeParameters();
24645             var parameters = parseParameters(4);
24646             var type = parseReturnType(38, false);
24647             var node = isConstructorType
24648                 ? factory.createConstructorTypeNode(typeParameters, parameters, type)
24649                 : factory.createFunctionTypeNode(typeParameters, parameters, type);
24650             return withJSDoc(finishNode(node, pos), hasJSDoc);
24651         }
24652         function parseKeywordAndNoDot() {
24653             var node = parseTokenNode();
24654             return token() === 24 ? undefined : node;
24655         }
24656         function parseLiteralTypeNode(negative) {
24657             var pos = getNodePos();
24658             if (negative) {
24659                 nextToken();
24660             }
24661             var expression = token() === 109 || token() === 94 || token() === 103 ?
24662                 parseTokenNode() :
24663                 parseLiteralLikeNode(token());
24664             if (negative) {
24665                 expression = finishNode(factory.createPrefixUnaryExpression(40, expression), pos);
24666             }
24667             return finishNode(factory.createLiteralTypeNode(expression), pos);
24668         }
24669         function isStartOfTypeOfImportType() {
24670             nextToken();
24671             return token() === 99;
24672         }
24673         function parseImportType() {
24674             sourceFlags |= 1048576;
24675             var pos = getNodePos();
24676             var isTypeOf = parseOptional(111);
24677             parseExpected(99);
24678             parseExpected(20);
24679             var type = parseType();
24680             parseExpected(21);
24681             var qualifier = parseOptional(24) ? parseEntityNameOfTypeReference() : undefined;
24682             var typeArguments = parseTypeArgumentsOfTypeReference();
24683             return finishNode(factory.createImportTypeNode(type, qualifier, typeArguments, isTypeOf), pos);
24684         }
24685         function nextTokenIsNumericOrBigIntLiteral() {
24686             nextToken();
24687             return token() === 8 || token() === 9;
24688         }
24689         function parseNonArrayType() {
24690             switch (token()) {
24691                 case 128:
24692                 case 152:
24693                 case 147:
24694                 case 144:
24695                 case 155:
24696                 case 148:
24697                 case 131:
24698                 case 150:
24699                 case 141:
24700                 case 145:
24701                     return tryParse(parseKeywordAndNoDot) || parseTypeReference();
24702                 case 65:
24703                     scanner.reScanAsteriskEqualsToken();
24704                 case 41:
24705                     return parseJSDocAllType();
24706                 case 60:
24707                     scanner.reScanQuestionToken();
24708                 case 57:
24709                     return parseJSDocUnknownOrNullableType();
24710                 case 97:
24711                     return parseJSDocFunctionType();
24712                 case 53:
24713                     return parseJSDocNonNullableType();
24714                 case 14:
24715                 case 10:
24716                 case 8:
24717                 case 9:
24718                 case 109:
24719                 case 94:
24720                 case 103:
24721                     return parseLiteralTypeNode();
24722                 case 40:
24723                     return lookAhead(nextTokenIsNumericOrBigIntLiteral) ? parseLiteralTypeNode(true) : parseTypeReference();
24724                 case 113:
24725                     return parseTokenNode();
24726                 case 107: {
24727                     var thisKeyword = parseThisTypeNode();
24728                     if (token() === 137 && !scanner.hasPrecedingLineBreak()) {
24729                         return parseThisTypePredicate(thisKeyword);
24730                     }
24731                     else {
24732                         return thisKeyword;
24733                     }
24734                 }
24735                 case 111:
24736                     return lookAhead(isStartOfTypeOfImportType) ? parseImportType() : parseTypeQuery();
24737                 case 18:
24738                     return lookAhead(isStartOfMappedType) ? parseMappedType() : parseTypeLiteral();
24739                 case 22:
24740                     return parseTupleType();
24741                 case 20:
24742                     return parseParenthesizedType();
24743                 case 99:
24744                     return parseImportType();
24745                 case 127:
24746                     return lookAhead(nextTokenIsIdentifierOrKeywordOnSameLine) ? parseAssertsTypePredicate() : parseTypeReference();
24747                 case 15:
24748                     return parseTemplateType();
24749                 default:
24750                     return parseTypeReference();
24751             }
24752         }
24753         function isStartOfType(inStartOfParameter) {
24754             switch (token()) {
24755                 case 128:
24756                 case 152:
24757                 case 147:
24758                 case 144:
24759                 case 155:
24760                 case 131:
24761                 case 142:
24762                 case 148:
24763                 case 151:
24764                 case 113:
24765                 case 150:
24766                 case 103:
24767                 case 107:
24768                 case 111:
24769                 case 141:
24770                 case 18:
24771                 case 22:
24772                 case 29:
24773                 case 51:
24774                 case 50:
24775                 case 102:
24776                 case 10:
24777                 case 8:
24778                 case 9:
24779                 case 109:
24780                 case 94:
24781                 case 145:
24782                 case 41:
24783                 case 57:
24784                 case 53:
24785                 case 25:
24786                 case 135:
24787                 case 99:
24788                 case 127:
24789                 case 14:
24790                 case 15:
24791                     return true;
24792                 case 97:
24793                     return !inStartOfParameter;
24794                 case 40:
24795                     return !inStartOfParameter && lookAhead(nextTokenIsNumericOrBigIntLiteral);
24796                 case 20:
24797                     return !inStartOfParameter && lookAhead(isStartOfParenthesizedOrFunctionType);
24798                 default:
24799                     return isIdentifier();
24800             }
24801         }
24802         function isStartOfParenthesizedOrFunctionType() {
24803             nextToken();
24804             return token() === 21 || isStartOfParameter(false) || isStartOfType();
24805         }
24806         function parsePostfixTypeOrHigher() {
24807             var pos = getNodePos();
24808             var type = parseNonArrayType();
24809             while (!scanner.hasPrecedingLineBreak()) {
24810                 switch (token()) {
24811                     case 53:
24812                         nextToken();
24813                         type = finishNode(factory.createJSDocNonNullableType(type), pos);
24814                         break;
24815                     case 57:
24816                         if (lookAhead(nextTokenIsStartOfType)) {
24817                             return type;
24818                         }
24819                         nextToken();
24820                         type = finishNode(factory.createJSDocNullableType(type), pos);
24821                         break;
24822                     case 22:
24823                         parseExpected(22);
24824                         if (isStartOfType()) {
24825                             var indexType = parseType();
24826                             parseExpected(23);
24827                             type = finishNode(factory.createIndexedAccessTypeNode(type, indexType), pos);
24828                         }
24829                         else {
24830                             parseExpected(23);
24831                             type = finishNode(factory.createArrayTypeNode(type), pos);
24832                         }
24833                         break;
24834                     default:
24835                         return type;
24836                 }
24837             }
24838             return type;
24839         }
24840         function parseTypeOperator(operator) {
24841             var pos = getNodePos();
24842             parseExpected(operator);
24843             return finishNode(factory.createTypeOperatorNode(operator, parseTypeOperatorOrHigher()), pos);
24844         }
24845         function parseTypeParameterOfInferType() {
24846             var pos = getNodePos();
24847             return finishNode(factory.createTypeParameterDeclaration(parseIdentifier(), undefined, undefined), pos);
24848         }
24849         function parseInferType() {
24850             var pos = getNodePos();
24851             parseExpected(135);
24852             return finishNode(factory.createInferTypeNode(parseTypeParameterOfInferType()), pos);
24853         }
24854         function parseTypeOperatorOrHigher() {
24855             var operator = token();
24856             switch (operator) {
24857                 case 138:
24858                 case 151:
24859                 case 142:
24860                     return parseTypeOperator(operator);
24861                 case 135:
24862                     return parseInferType();
24863             }
24864             return parsePostfixTypeOrHigher();
24865         }
24866         function parseFunctionOrConstructorTypeToError(isInUnionType) {
24867             if (isStartOfFunctionTypeOrConstructorType()) {
24868                 var type = parseFunctionOrConstructorType();
24869                 var diagnostic = void 0;
24870                 if (ts.isFunctionTypeNode(type)) {
24871                     diagnostic = isInUnionType
24872                         ? ts.Diagnostics.Function_type_notation_must_be_parenthesized_when_used_in_a_union_type
24873                         : ts.Diagnostics.Function_type_notation_must_be_parenthesized_when_used_in_an_intersection_type;
24874                 }
24875                 else {
24876                     diagnostic = isInUnionType
24877                         ? ts.Diagnostics.Constructor_type_notation_must_be_parenthesized_when_used_in_a_union_type
24878                         : ts.Diagnostics.Constructor_type_notation_must_be_parenthesized_when_used_in_an_intersection_type;
24879                 }
24880                 parseErrorAtRange(type, diagnostic);
24881                 return type;
24882             }
24883             return undefined;
24884         }
24885         function parseUnionOrIntersectionType(operator, parseConstituentType, createTypeNode) {
24886             var pos = getNodePos();
24887             var isUnionType = operator === 51;
24888             var hasLeadingOperator = parseOptional(operator);
24889             var type = hasLeadingOperator && parseFunctionOrConstructorTypeToError(isUnionType)
24890                 || parseConstituentType();
24891             if (token() === operator || hasLeadingOperator) {
24892                 var types = [type];
24893                 while (parseOptional(operator)) {
24894                     types.push(parseFunctionOrConstructorTypeToError(isUnionType) || parseConstituentType());
24895                 }
24896                 type = finishNode(createTypeNode(createNodeArray(types, pos)), pos);
24897             }
24898             return type;
24899         }
24900         function parseIntersectionTypeOrHigher() {
24901             return parseUnionOrIntersectionType(50, parseTypeOperatorOrHigher, factory.createIntersectionTypeNode);
24902         }
24903         function parseUnionTypeOrHigher() {
24904             return parseUnionOrIntersectionType(51, parseIntersectionTypeOrHigher, factory.createUnionTypeNode);
24905         }
24906         function isStartOfFunctionTypeOrConstructorType() {
24907             if (token() === 29) {
24908                 return true;
24909             }
24910             if (token() === 20 && lookAhead(isUnambiguouslyStartOfFunctionType)) {
24911                 return true;
24912             }
24913             return token() === 102;
24914         }
24915         function skipParameterStart() {
24916             if (ts.isModifierKind(token())) {
24917                 parseModifiers();
24918             }
24919             if (isIdentifier() || token() === 107) {
24920                 nextToken();
24921                 return true;
24922             }
24923             if (token() === 22 || token() === 18) {
24924                 var previousErrorCount = parseDiagnostics.length;
24925                 parseIdentifierOrPattern();
24926                 return previousErrorCount === parseDiagnostics.length;
24927             }
24928             return false;
24929         }
24930         function isUnambiguouslyStartOfFunctionType() {
24931             nextToken();
24932             if (token() === 21 || token() === 25) {
24933                 return true;
24934             }
24935             if (skipParameterStart()) {
24936                 if (token() === 58 || token() === 27 ||
24937                     token() === 57 || token() === 62) {
24938                     return true;
24939                 }
24940                 if (token() === 21) {
24941                     nextToken();
24942                     if (token() === 38) {
24943                         return true;
24944                     }
24945                 }
24946             }
24947             return false;
24948         }
24949         function parseTypeOrTypePredicate() {
24950             var pos = getNodePos();
24951             var typePredicateVariable = isIdentifier() && tryParse(parseTypePredicatePrefix);
24952             var type = parseType();
24953             if (typePredicateVariable) {
24954                 return finishNode(factory.createTypePredicateNode(undefined, typePredicateVariable, type), pos);
24955             }
24956             else {
24957                 return type;
24958             }
24959         }
24960         function parseTypePredicatePrefix() {
24961             var id = parseIdentifier();
24962             if (token() === 137 && !scanner.hasPrecedingLineBreak()) {
24963                 nextToken();
24964                 return id;
24965             }
24966         }
24967         function parseAssertsTypePredicate() {
24968             var pos = getNodePos();
24969             var assertsModifier = parseExpectedToken(127);
24970             var parameterName = token() === 107 ? parseThisTypeNode() : parseIdentifier();
24971             var type = parseOptional(137) ? parseType() : undefined;
24972             return finishNode(factory.createTypePredicateNode(assertsModifier, parameterName, type), pos);
24973         }
24974         function parseType() {
24975             return doOutsideOfContext(40960, parseTypeWorker);
24976         }
24977         function parseTypeWorker(noConditionalTypes) {
24978             if (isStartOfFunctionTypeOrConstructorType()) {
24979                 return parseFunctionOrConstructorType();
24980             }
24981             var pos = getNodePos();
24982             var type = parseUnionTypeOrHigher();
24983             if (!noConditionalTypes && !scanner.hasPrecedingLineBreak() && parseOptional(93)) {
24984                 var extendsType = parseTypeWorker(true);
24985                 parseExpected(57);
24986                 var trueType = parseTypeWorker();
24987                 parseExpected(58);
24988                 var falseType = parseTypeWorker();
24989                 return finishNode(factory.createConditionalTypeNode(type, extendsType, trueType, falseType), pos);
24990             }
24991             return type;
24992         }
24993         function parseTypeAnnotation() {
24994             return parseOptional(58) ? parseType() : undefined;
24995         }
24996         function isStartOfLeftHandSideExpression() {
24997             switch (token()) {
24998                 case 107:
24999                 case 105:
25000                 case 103:
25001                 case 109:
25002                 case 94:
25003                 case 8:
25004                 case 9:
25005                 case 10:
25006                 case 14:
25007                 case 15:
25008                 case 20:
25009                 case 22:
25010                 case 18:
25011                 case 97:
25012                 case 83:
25013                 case 102:
25014                 case 43:
25015                 case 67:
25016                 case 78:
25017                     return true;
25018                 case 99:
25019                     return lookAhead(nextTokenIsOpenParenOrLessThanOrDot);
25020                 default:
25021                     return isIdentifier();
25022             }
25023         }
25024         function isStartOfExpression() {
25025             if (isStartOfLeftHandSideExpression()) {
25026                 return true;
25027             }
25028             switch (token()) {
25029                 case 39:
25030                 case 40:
25031                 case 54:
25032                 case 53:
25033                 case 88:
25034                 case 111:
25035                 case 113:
25036                 case 45:
25037                 case 46:
25038                 case 29:
25039                 case 130:
25040                 case 124:
25041                 case 79:
25042                     return true;
25043                 default:
25044                     if (isBinaryOperator()) {
25045                         return true;
25046                     }
25047                     return isIdentifier();
25048             }
25049         }
25050         function isStartOfExpressionStatement() {
25051             return token() !== 18 &&
25052                 token() !== 97 &&
25053                 token() !== 83 &&
25054                 token() !== 59 &&
25055                 isStartOfExpression();
25056         }
25057         function parseExpression() {
25058             var saveDecoratorContext = inDecoratorContext();
25059             if (saveDecoratorContext) {
25060                 setDecoratorContext(false);
25061             }
25062             var pos = getNodePos();
25063             var expr = parseAssignmentExpressionOrHigher();
25064             var operatorToken;
25065             while ((operatorToken = parseOptionalToken(27))) {
25066                 expr = makeBinaryExpression(expr, operatorToken, parseAssignmentExpressionOrHigher(), pos);
25067             }
25068             if (saveDecoratorContext) {
25069                 setDecoratorContext(true);
25070             }
25071             return expr;
25072         }
25073         function parseInitializer() {
25074             return parseOptional(62) ? parseAssignmentExpressionOrHigher() : undefined;
25075         }
25076         function parseAssignmentExpressionOrHigher() {
25077             if (isYieldExpression()) {
25078                 return parseYieldExpression();
25079             }
25080             var arrowExpression = tryParseParenthesizedArrowFunctionExpression() || tryParseAsyncSimpleArrowFunctionExpression();
25081             if (arrowExpression) {
25082                 return arrowExpression;
25083             }
25084             var pos = getNodePos();
25085             var expr = parseBinaryExpressionOrHigher(0);
25086             if (expr.kind === 78 && token() === 38) {
25087                 return parseSimpleArrowFunctionExpression(pos, expr, undefined);
25088             }
25089             if (ts.isLeftHandSideExpression(expr) && ts.isAssignmentOperator(reScanGreaterToken())) {
25090                 return makeBinaryExpression(expr, parseTokenNode(), parseAssignmentExpressionOrHigher(), pos);
25091             }
25092             return parseConditionalExpressionRest(expr, pos);
25093         }
25094         function isYieldExpression() {
25095             if (token() === 124) {
25096                 if (inYieldContext()) {
25097                     return true;
25098                 }
25099                 return lookAhead(nextTokenIsIdentifierOrKeywordOrLiteralOnSameLine);
25100             }
25101             return false;
25102         }
25103         function nextTokenIsIdentifierOnSameLine() {
25104             nextToken();
25105             return !scanner.hasPrecedingLineBreak() && isIdentifier();
25106         }
25107         function parseYieldExpression() {
25108             var pos = getNodePos();
25109             nextToken();
25110             if (!scanner.hasPrecedingLineBreak() &&
25111                 (token() === 41 || isStartOfExpression())) {
25112                 return finishNode(factory.createYieldExpression(parseOptionalToken(41), parseAssignmentExpressionOrHigher()), pos);
25113             }
25114             else {
25115                 return finishNode(factory.createYieldExpression(undefined, undefined), pos);
25116             }
25117         }
25118         function parseSimpleArrowFunctionExpression(pos, identifier, asyncModifier) {
25119             ts.Debug.assert(token() === 38, "parseSimpleArrowFunctionExpression should only have been called if we had a =>");
25120             var parameter = factory.createParameterDeclaration(undefined, undefined, undefined, identifier, undefined, undefined, undefined);
25121             finishNode(parameter, identifier.pos);
25122             var parameters = createNodeArray([parameter], parameter.pos, parameter.end);
25123             var equalsGreaterThanToken = parseExpectedToken(38);
25124             var body = parseArrowFunctionExpressionBody(!!asyncModifier);
25125             var node = factory.createArrowFunction(asyncModifier, undefined, parameters, undefined, equalsGreaterThanToken, body);
25126             return addJSDocComment(finishNode(node, pos));
25127         }
25128         function tryParseParenthesizedArrowFunctionExpression() {
25129             var triState = isParenthesizedArrowFunctionExpression();
25130             if (triState === 0) {
25131                 return undefined;
25132             }
25133             return triState === 1 ?
25134                 parseParenthesizedArrowFunctionExpression(true) :
25135                 tryParse(parsePossibleParenthesizedArrowFunctionExpression);
25136         }
25137         function isParenthesizedArrowFunctionExpression() {
25138             if (token() === 20 || token() === 29 || token() === 129) {
25139                 return lookAhead(isParenthesizedArrowFunctionExpressionWorker);
25140             }
25141             if (token() === 38) {
25142                 return 1;
25143             }
25144             return 0;
25145         }
25146         function isParenthesizedArrowFunctionExpressionWorker() {
25147             if (token() === 129) {
25148                 nextToken();
25149                 if (scanner.hasPrecedingLineBreak()) {
25150                     return 0;
25151                 }
25152                 if (token() !== 20 && token() !== 29) {
25153                     return 0;
25154                 }
25155             }
25156             var first = token();
25157             var second = nextToken();
25158             if (first === 20) {
25159                 if (second === 21) {
25160                     var third = nextToken();
25161                     switch (third) {
25162                         case 38:
25163                         case 58:
25164                         case 18:
25165                             return 1;
25166                         default:
25167                             return 0;
25168                     }
25169                 }
25170                 if (second === 22 || second === 18) {
25171                     return 2;
25172                 }
25173                 if (second === 25) {
25174                     return 1;
25175                 }
25176                 if (ts.isModifierKind(second) && second !== 129 && lookAhead(nextTokenIsIdentifier)) {
25177                     return 1;
25178                 }
25179                 if (!isIdentifier() && second !== 107) {
25180                     return 0;
25181                 }
25182                 switch (nextToken()) {
25183                     case 58:
25184                         return 1;
25185                     case 57:
25186                         nextToken();
25187                         if (token() === 58 || token() === 27 || token() === 62 || token() === 21) {
25188                             return 1;
25189                         }
25190                         return 0;
25191                     case 27:
25192                     case 62:
25193                     case 21:
25194                         return 2;
25195                 }
25196                 return 0;
25197             }
25198             else {
25199                 ts.Debug.assert(first === 29);
25200                 if (!isIdentifier()) {
25201                     return 0;
25202                 }
25203                 if (languageVariant === 1) {
25204                     var isArrowFunctionInJsx = lookAhead(function () {
25205                         var third = nextToken();
25206                         if (third === 93) {
25207                             var fourth = nextToken();
25208                             switch (fourth) {
25209                                 case 62:
25210                                 case 31:
25211                                     return false;
25212                                 default:
25213                                     return true;
25214                             }
25215                         }
25216                         else if (third === 27) {
25217                             return true;
25218                         }
25219                         return false;
25220                     });
25221                     if (isArrowFunctionInJsx) {
25222                         return 1;
25223                     }
25224                     return 0;
25225                 }
25226                 return 2;
25227             }
25228         }
25229         function parsePossibleParenthesizedArrowFunctionExpression() {
25230             var tokenPos = scanner.getTokenPos();
25231             if (notParenthesizedArrow === null || notParenthesizedArrow === void 0 ? void 0 : notParenthesizedArrow.has(tokenPos)) {
25232                 return undefined;
25233             }
25234             var result = parseParenthesizedArrowFunctionExpression(false);
25235             if (!result) {
25236                 (notParenthesizedArrow || (notParenthesizedArrow = new ts.Set())).add(tokenPos);
25237             }
25238             return result;
25239         }
25240         function tryParseAsyncSimpleArrowFunctionExpression() {
25241             if (token() === 129) {
25242                 if (lookAhead(isUnParenthesizedAsyncArrowFunctionWorker) === 1) {
25243                     var pos = getNodePos();
25244                     var asyncModifier = parseModifiersForArrowFunction();
25245                     var expr = parseBinaryExpressionOrHigher(0);
25246                     return parseSimpleArrowFunctionExpression(pos, expr, asyncModifier);
25247                 }
25248             }
25249             return undefined;
25250         }
25251         function isUnParenthesizedAsyncArrowFunctionWorker() {
25252             if (token() === 129) {
25253                 nextToken();
25254                 if (scanner.hasPrecedingLineBreak() || token() === 38) {
25255                     return 0;
25256                 }
25257                 var expr = parseBinaryExpressionOrHigher(0);
25258                 if (!scanner.hasPrecedingLineBreak() && expr.kind === 78 && token() === 38) {
25259                     return 1;
25260                 }
25261             }
25262             return 0;
25263         }
25264         function parseParenthesizedArrowFunctionExpression(allowAmbiguity) {
25265             var pos = getNodePos();
25266             var hasJSDoc = hasPrecedingJSDocComment();
25267             var modifiers = parseModifiersForArrowFunction();
25268             var isAsync = ts.some(modifiers, ts.isAsyncModifier) ? 2 : 0;
25269             var typeParameters = parseTypeParameters();
25270             var parameters;
25271             if (!parseExpected(20)) {
25272                 if (!allowAmbiguity) {
25273                     return undefined;
25274                 }
25275                 parameters = createMissingList();
25276             }
25277             else {
25278                 parameters = parseParametersWorker(isAsync);
25279                 if (!parseExpected(21) && !allowAmbiguity) {
25280                     return undefined;
25281                 }
25282             }
25283             var type = parseReturnType(58, false);
25284             if (type && !allowAmbiguity && typeHasArrowFunctionBlockingParseError(type)) {
25285                 return undefined;
25286             }
25287             var hasJSDocFunctionType = type && ts.isJSDocFunctionType(type);
25288             if (!allowAmbiguity && token() !== 38 && (hasJSDocFunctionType || token() !== 18)) {
25289                 return undefined;
25290             }
25291             var lastToken = token();
25292             var equalsGreaterThanToken = parseExpectedToken(38);
25293             var body = (lastToken === 38 || lastToken === 18)
25294                 ? parseArrowFunctionExpressionBody(ts.some(modifiers, ts.isAsyncModifier))
25295                 : parseIdentifier();
25296             var node = factory.createArrowFunction(modifiers, typeParameters, parameters, type, equalsGreaterThanToken, body);
25297             return withJSDoc(finishNode(node, pos), hasJSDoc);
25298         }
25299         function parseArrowFunctionExpressionBody(isAsync) {
25300             if (token() === 18) {
25301                 return parseFunctionBlock(isAsync ? 2 : 0);
25302             }
25303             if (token() !== 26 &&
25304                 token() !== 97 &&
25305                 token() !== 83 &&
25306                 isStartOfStatement() &&
25307                 !isStartOfExpressionStatement()) {
25308                 return parseFunctionBlock(16 | (isAsync ? 2 : 0));
25309             }
25310             var savedTopLevel = topLevel;
25311             topLevel = false;
25312             var node = isAsync
25313                 ? doInAwaitContext(parseAssignmentExpressionOrHigher)
25314                 : doOutsideOfAwaitContext(parseAssignmentExpressionOrHigher);
25315             topLevel = savedTopLevel;
25316             return node;
25317         }
25318         function parseConditionalExpressionRest(leftOperand, pos) {
25319             var questionToken = parseOptionalToken(57);
25320             if (!questionToken) {
25321                 return leftOperand;
25322             }
25323             var colonToken;
25324             return finishNode(factory.createConditionalExpression(leftOperand, questionToken, doOutsideOfContext(disallowInAndDecoratorContext, parseAssignmentExpressionOrHigher), colonToken = parseExpectedToken(58), ts.nodeIsPresent(colonToken)
25325                 ? parseAssignmentExpressionOrHigher()
25326                 : createMissingNode(78, false, ts.Diagnostics._0_expected, ts.tokenToString(58))), pos);
25327         }
25328         function parseBinaryExpressionOrHigher(precedence) {
25329             var pos = getNodePos();
25330             var leftOperand = parseUnaryExpressionOrHigher();
25331             return parseBinaryExpressionRest(precedence, leftOperand, pos);
25332         }
25333         function isInOrOfKeyword(t) {
25334             return t === 100 || t === 156;
25335         }
25336         function parseBinaryExpressionRest(precedence, leftOperand, pos) {
25337             while (true) {
25338                 reScanGreaterToken();
25339                 var newPrecedence = ts.getBinaryOperatorPrecedence(token());
25340                 var consumeCurrentOperator = token() === 42 ?
25341                     newPrecedence >= precedence :
25342                     newPrecedence > precedence;
25343                 if (!consumeCurrentOperator) {
25344                     break;
25345                 }
25346                 if (token() === 100 && inDisallowInContext()) {
25347                     break;
25348                 }
25349                 if (token() === 126) {
25350                     if (scanner.hasPrecedingLineBreak()) {
25351                         break;
25352                     }
25353                     else {
25354                         nextToken();
25355                         leftOperand = makeAsExpression(leftOperand, parseType());
25356                     }
25357                 }
25358                 else {
25359                     leftOperand = makeBinaryExpression(leftOperand, parseTokenNode(), parseBinaryExpressionOrHigher(newPrecedence), pos);
25360                 }
25361             }
25362             return leftOperand;
25363         }
25364         function isBinaryOperator() {
25365             if (inDisallowInContext() && token() === 100) {
25366                 return false;
25367             }
25368             return ts.getBinaryOperatorPrecedence(token()) > 0;
25369         }
25370         function makeBinaryExpression(left, operatorToken, right, pos) {
25371             return finishNode(factory.createBinaryExpression(left, operatorToken, right), pos);
25372         }
25373         function makeAsExpression(left, right) {
25374             return finishNode(factory.createAsExpression(left, right), left.pos);
25375         }
25376         function parsePrefixUnaryExpression() {
25377             var pos = getNodePos();
25378             return finishNode(factory.createPrefixUnaryExpression(token(), nextTokenAnd(parseSimpleUnaryExpression)), pos);
25379         }
25380         function parseDeleteExpression() {
25381             var pos = getNodePos();
25382             return finishNode(factory.createDeleteExpression(nextTokenAnd(parseSimpleUnaryExpression)), pos);
25383         }
25384         function parseTypeOfExpression() {
25385             var pos = getNodePos();
25386             return finishNode(factory.createTypeOfExpression(nextTokenAnd(parseSimpleUnaryExpression)), pos);
25387         }
25388         function parseVoidExpression() {
25389             var pos = getNodePos();
25390             return finishNode(factory.createVoidExpression(nextTokenAnd(parseSimpleUnaryExpression)), pos);
25391         }
25392         function isAwaitExpression() {
25393             if (token() === 130) {
25394                 if (inAwaitContext()) {
25395                     return true;
25396                 }
25397                 return lookAhead(nextTokenIsIdentifierOrKeywordOrLiteralOnSameLine);
25398             }
25399             return false;
25400         }
25401         function parseAwaitExpression() {
25402             var pos = getNodePos();
25403             return finishNode(factory.createAwaitExpression(nextTokenAnd(parseSimpleUnaryExpression)), pos);
25404         }
25405         function parseUnaryExpressionOrHigher() {
25406             if (isUpdateExpression()) {
25407                 var pos = getNodePos();
25408                 var updateExpression = parseUpdateExpression();
25409                 return token() === 42 ?
25410                     parseBinaryExpressionRest(ts.getBinaryOperatorPrecedence(token()), updateExpression, pos) :
25411                     updateExpression;
25412             }
25413             var unaryOperator = token();
25414             var simpleUnaryExpression = parseSimpleUnaryExpression();
25415             if (token() === 42) {
25416                 var pos = ts.skipTrivia(sourceText, simpleUnaryExpression.pos);
25417                 var end = simpleUnaryExpression.end;
25418                 if (simpleUnaryExpression.kind === 206) {
25419                     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);
25420                 }
25421                 else {
25422                     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));
25423                 }
25424             }
25425             return simpleUnaryExpression;
25426         }
25427         function parseSimpleUnaryExpression() {
25428             switch (token()) {
25429                 case 39:
25430                 case 40:
25431                 case 54:
25432                 case 53:
25433                     return parsePrefixUnaryExpression();
25434                 case 88:
25435                     return parseDeleteExpression();
25436                 case 111:
25437                     return parseTypeOfExpression();
25438                 case 113:
25439                     return parseVoidExpression();
25440                 case 29:
25441                     return parseTypeAssertion();
25442                 case 130:
25443                     if (isAwaitExpression()) {
25444                         return parseAwaitExpression();
25445                     }
25446                 default:
25447                     return parseUpdateExpression();
25448             }
25449         }
25450         function isUpdateExpression() {
25451             switch (token()) {
25452                 case 39:
25453                 case 40:
25454                 case 54:
25455                 case 53:
25456                 case 88:
25457                 case 111:
25458                 case 113:
25459                 case 130:
25460                     return false;
25461                 case 29:
25462                     if (languageVariant !== 1) {
25463                         return false;
25464                     }
25465                 default:
25466                     return true;
25467             }
25468         }
25469         function parseUpdateExpression() {
25470             if (token() === 45 || token() === 46) {
25471                 var pos = getNodePos();
25472                 return finishNode(factory.createPrefixUnaryExpression(token(), nextTokenAnd(parseLeftHandSideExpressionOrHigher)), pos);
25473             }
25474             else if (languageVariant === 1 && token() === 29 && lookAhead(nextTokenIsIdentifierOrKeywordOrGreaterThan)) {
25475                 return parseJsxElementOrSelfClosingElementOrFragment(true);
25476             }
25477             var expression = parseLeftHandSideExpressionOrHigher();
25478             ts.Debug.assert(ts.isLeftHandSideExpression(expression));
25479             if ((token() === 45 || token() === 46) && !scanner.hasPrecedingLineBreak()) {
25480                 var operator = token();
25481                 nextToken();
25482                 return finishNode(factory.createPostfixUnaryExpression(expression, operator), expression.pos);
25483             }
25484             return expression;
25485         }
25486         function parseLeftHandSideExpressionOrHigher() {
25487             var pos = getNodePos();
25488             var expression;
25489             if (token() === 99) {
25490                 if (lookAhead(nextTokenIsOpenParenOrLessThan)) {
25491                     sourceFlags |= 1048576;
25492                     expression = parseTokenNode();
25493                 }
25494                 else if (lookAhead(nextTokenIsDot)) {
25495                     nextToken();
25496                     nextToken();
25497                     expression = finishNode(factory.createMetaProperty(99, parseIdentifierName()), pos);
25498                     sourceFlags |= 2097152;
25499                 }
25500                 else {
25501                     expression = parseMemberExpressionOrHigher();
25502                 }
25503             }
25504             else {
25505                 expression = token() === 105 ? parseSuperExpression() : parseMemberExpressionOrHigher();
25506             }
25507             return parseCallExpressionRest(pos, expression);
25508         }
25509         function parseMemberExpressionOrHigher() {
25510             var pos = getNodePos();
25511             var expression = parsePrimaryExpression();
25512             return parseMemberExpressionRest(pos, expression, true);
25513         }
25514         function parseSuperExpression() {
25515             var pos = getNodePos();
25516             var expression = parseTokenNode();
25517             if (token() === 29) {
25518                 var startPos = getNodePos();
25519                 var typeArguments = tryParse(parseTypeArgumentsInExpression);
25520                 if (typeArguments !== undefined) {
25521                     parseErrorAt(startPos, getNodePos(), ts.Diagnostics.super_may_not_use_type_arguments);
25522                 }
25523             }
25524             if (token() === 20 || token() === 24 || token() === 22) {
25525                 return expression;
25526             }
25527             parseExpectedToken(24, ts.Diagnostics.super_must_be_followed_by_an_argument_list_or_member_access);
25528             return finishNode(factory.createPropertyAccessExpression(expression, parseRightSideOfDot(true, true)), pos);
25529         }
25530         function parseJsxElementOrSelfClosingElementOrFragment(inExpressionContext, topInvalidNodePosition) {
25531             var pos = getNodePos();
25532             var opening = parseJsxOpeningOrSelfClosingElementOrOpeningFragment(inExpressionContext);
25533             var result;
25534             if (opening.kind === 275) {
25535                 var children = parseJsxChildren(opening);
25536                 var closingElement = parseJsxClosingElement(inExpressionContext);
25537                 if (!tagNamesAreEquivalent(opening.tagName, closingElement.tagName)) {
25538                     parseErrorAtRange(closingElement, ts.Diagnostics.Expected_corresponding_JSX_closing_tag_for_0, ts.getTextOfNodeFromSourceText(sourceText, opening.tagName));
25539                 }
25540                 result = finishNode(factory.createJsxElement(opening, children, closingElement), pos);
25541             }
25542             else if (opening.kind === 278) {
25543                 result = finishNode(factory.createJsxFragment(opening, parseJsxChildren(opening), parseJsxClosingFragment(inExpressionContext)), pos);
25544             }
25545             else {
25546                 ts.Debug.assert(opening.kind === 274);
25547                 result = opening;
25548             }
25549             if (inExpressionContext && token() === 29) {
25550                 var topBadPos_1 = typeof topInvalidNodePosition === "undefined" ? result.pos : topInvalidNodePosition;
25551                 var invalidElement = tryParse(function () { return parseJsxElementOrSelfClosingElementOrFragment(true, topBadPos_1); });
25552                 if (invalidElement) {
25553                     var operatorToken = createMissingNode(27, false);
25554                     ts.setTextRangePosWidth(operatorToken, invalidElement.pos, 0);
25555                     parseErrorAt(ts.skipTrivia(sourceText, topBadPos_1), invalidElement.end, ts.Diagnostics.JSX_expressions_must_have_one_parent_element);
25556                     return finishNode(factory.createBinaryExpression(result, operatorToken, invalidElement), pos);
25557                 }
25558             }
25559             return result;
25560         }
25561         function parseJsxText() {
25562             var pos = getNodePos();
25563             var node = factory.createJsxText(scanner.getTokenValue(), currentToken === 12);
25564             currentToken = scanner.scanJsxToken();
25565             return finishNode(node, pos);
25566         }
25567         function parseJsxChild(openingTag, token) {
25568             switch (token) {
25569                 case 1:
25570                     if (ts.isJsxOpeningFragment(openingTag)) {
25571                         parseErrorAtRange(openingTag, ts.Diagnostics.JSX_fragment_has_no_corresponding_closing_tag);
25572                     }
25573                     else {
25574                         var tag = openingTag.tagName;
25575                         var start = ts.skipTrivia(sourceText, tag.pos);
25576                         parseErrorAt(start, tag.end, ts.Diagnostics.JSX_element_0_has_no_corresponding_closing_tag, ts.getTextOfNodeFromSourceText(sourceText, openingTag.tagName));
25577                     }
25578                     return undefined;
25579                 case 30:
25580                 case 7:
25581                     return undefined;
25582                 case 11:
25583                 case 12:
25584                     return parseJsxText();
25585                 case 18:
25586                     return parseJsxExpression(false);
25587                 case 29:
25588                     return parseJsxElementOrSelfClosingElementOrFragment(false);
25589                 default:
25590                     return ts.Debug.assertNever(token);
25591             }
25592         }
25593         function parseJsxChildren(openingTag) {
25594             var list = [];
25595             var listPos = getNodePos();
25596             var saveParsingContext = parsingContext;
25597             parsingContext |= 1 << 14;
25598             while (true) {
25599                 var child = parseJsxChild(openingTag, currentToken = scanner.reScanJsxToken());
25600                 if (!child)
25601                     break;
25602                 list.push(child);
25603             }
25604             parsingContext = saveParsingContext;
25605             return createNodeArray(list, listPos);
25606         }
25607         function parseJsxAttributes() {
25608             var pos = getNodePos();
25609             return finishNode(factory.createJsxAttributes(parseList(13, parseJsxAttribute)), pos);
25610         }
25611         function parseJsxOpeningOrSelfClosingElementOrOpeningFragment(inExpressionContext) {
25612             var pos = getNodePos();
25613             parseExpected(29);
25614             if (token() === 31) {
25615                 scanJsxText();
25616                 return finishNode(factory.createJsxOpeningFragment(), pos);
25617             }
25618             var tagName = parseJsxElementName();
25619             var typeArguments = tryParseTypeArguments();
25620             var attributes = parseJsxAttributes();
25621             var node;
25622             if (token() === 31) {
25623                 scanJsxText();
25624                 node = factory.createJsxOpeningElement(tagName, typeArguments, attributes);
25625             }
25626             else {
25627                 parseExpected(43);
25628                 if (inExpressionContext) {
25629                     parseExpected(31);
25630                 }
25631                 else {
25632                     parseExpected(31, undefined, false);
25633                     scanJsxText();
25634                 }
25635                 node = factory.createJsxSelfClosingElement(tagName, typeArguments, attributes);
25636             }
25637             return finishNode(node, pos);
25638         }
25639         function parseJsxElementName() {
25640             var pos = getNodePos();
25641             scanJsxIdentifier();
25642             var expression = token() === 107 ?
25643                 parseTokenNode() : parseIdentifierName();
25644             while (parseOptional(24)) {
25645                 expression = finishNode(factory.createPropertyAccessExpression(expression, parseRightSideOfDot(true, false)), pos);
25646             }
25647             return expression;
25648         }
25649         function parseJsxExpression(inExpressionContext) {
25650             var pos = getNodePos();
25651             if (!parseExpected(18)) {
25652                 return undefined;
25653             }
25654             var dotDotDotToken;
25655             var expression;
25656             if (token() !== 19) {
25657                 dotDotDotToken = parseOptionalToken(25);
25658                 expression = parseExpression();
25659             }
25660             if (inExpressionContext) {
25661                 parseExpected(19);
25662             }
25663             else {
25664                 if (parseExpected(19, undefined, false)) {
25665                     scanJsxText();
25666                 }
25667             }
25668             return finishNode(factory.createJsxExpression(dotDotDotToken, expression), pos);
25669         }
25670         function parseJsxAttribute() {
25671             if (token() === 18) {
25672                 return parseJsxSpreadAttribute();
25673             }
25674             scanJsxIdentifier();
25675             var pos = getNodePos();
25676             return finishNode(factory.createJsxAttribute(parseIdentifierName(), token() !== 62 ? undefined :
25677                 scanJsxAttributeValue() === 10 ? parseLiteralNode() :
25678                     parseJsxExpression(true)), pos);
25679         }
25680         function parseJsxSpreadAttribute() {
25681             var pos = getNodePos();
25682             parseExpected(18);
25683             parseExpected(25);
25684             var expression = parseExpression();
25685             parseExpected(19);
25686             return finishNode(factory.createJsxSpreadAttribute(expression), pos);
25687         }
25688         function parseJsxClosingElement(inExpressionContext) {
25689             var pos = getNodePos();
25690             parseExpected(30);
25691             var tagName = parseJsxElementName();
25692             if (inExpressionContext) {
25693                 parseExpected(31);
25694             }
25695             else {
25696                 parseExpected(31, undefined, false);
25697                 scanJsxText();
25698             }
25699             return finishNode(factory.createJsxClosingElement(tagName), pos);
25700         }
25701         function parseJsxClosingFragment(inExpressionContext) {
25702             var pos = getNodePos();
25703             parseExpected(30);
25704             if (ts.tokenIsIdentifierOrKeyword(token())) {
25705                 parseErrorAtRange(parseJsxElementName(), ts.Diagnostics.Expected_corresponding_closing_tag_for_JSX_fragment);
25706             }
25707             if (inExpressionContext) {
25708                 parseExpected(31);
25709             }
25710             else {
25711                 parseExpected(31, undefined, false);
25712                 scanJsxText();
25713             }
25714             return finishNode(factory.createJsxJsxClosingFragment(), pos);
25715         }
25716         function parseTypeAssertion() {
25717             var pos = getNodePos();
25718             parseExpected(29);
25719             var type = parseType();
25720             parseExpected(31);
25721             var expression = parseSimpleUnaryExpression();
25722             return finishNode(factory.createTypeAssertion(type, expression), pos);
25723         }
25724         function nextTokenIsIdentifierOrKeywordOrOpenBracketOrTemplate() {
25725             nextToken();
25726             return ts.tokenIsIdentifierOrKeyword(token())
25727                 || token() === 22
25728                 || isTemplateStartOfTaggedTemplate();
25729         }
25730         function isStartOfOptionalPropertyOrElementAccessChain() {
25731             return token() === 28
25732                 && lookAhead(nextTokenIsIdentifierOrKeywordOrOpenBracketOrTemplate);
25733         }
25734         function tryReparseOptionalChain(node) {
25735             if (node.flags & 32) {
25736                 return true;
25737             }
25738             if (ts.isNonNullExpression(node)) {
25739                 var expr = node.expression;
25740                 while (ts.isNonNullExpression(expr) && !(expr.flags & 32)) {
25741                     expr = expr.expression;
25742                 }
25743                 if (expr.flags & 32) {
25744                     while (ts.isNonNullExpression(node)) {
25745                         node.flags |= 32;
25746                         node = node.expression;
25747                     }
25748                     return true;
25749                 }
25750             }
25751             return false;
25752         }
25753         function parsePropertyAccessExpressionRest(pos, expression, questionDotToken) {
25754             var name = parseRightSideOfDot(true, true);
25755             var isOptionalChain = questionDotToken || tryReparseOptionalChain(expression);
25756             var propertyAccess = isOptionalChain ?
25757                 factory.createPropertyAccessChain(expression, questionDotToken, name) :
25758                 factory.createPropertyAccessExpression(expression, name);
25759             if (isOptionalChain && ts.isPrivateIdentifier(propertyAccess.name)) {
25760                 parseErrorAtRange(propertyAccess.name, ts.Diagnostics.An_optional_chain_cannot_contain_private_identifiers);
25761             }
25762             return finishNode(propertyAccess, pos);
25763         }
25764         function parseElementAccessExpressionRest(pos, expression, questionDotToken) {
25765             var argumentExpression;
25766             if (token() === 23) {
25767                 argumentExpression = createMissingNode(78, true, ts.Diagnostics.An_element_access_expression_should_take_an_argument);
25768             }
25769             else {
25770                 var argument = allowInAnd(parseExpression);
25771                 if (ts.isStringOrNumericLiteralLike(argument)) {
25772                     argument.text = internIdentifier(argument.text);
25773                 }
25774                 argumentExpression = argument;
25775             }
25776             parseExpected(23);
25777             var indexedAccess = questionDotToken || tryReparseOptionalChain(expression) ?
25778                 factory.createElementAccessChain(expression, questionDotToken, argumentExpression) :
25779                 factory.createElementAccessExpression(expression, argumentExpression);
25780             return finishNode(indexedAccess, pos);
25781         }
25782         function parseMemberExpressionRest(pos, expression, allowOptionalChain) {
25783             while (true) {
25784                 var questionDotToken = void 0;
25785                 var isPropertyAccess = false;
25786                 if (allowOptionalChain && isStartOfOptionalPropertyOrElementAccessChain()) {
25787                     questionDotToken = parseExpectedToken(28);
25788                     isPropertyAccess = ts.tokenIsIdentifierOrKeyword(token());
25789                 }
25790                 else {
25791                     isPropertyAccess = parseOptional(24);
25792                 }
25793                 if (isPropertyAccess) {
25794                     expression = parsePropertyAccessExpressionRest(pos, expression, questionDotToken);
25795                     continue;
25796                 }
25797                 if (!questionDotToken && token() === 53 && !scanner.hasPrecedingLineBreak()) {
25798                     nextToken();
25799                     expression = finishNode(factory.createNonNullExpression(expression), pos);
25800                     continue;
25801                 }
25802                 if ((questionDotToken || !inDecoratorContext()) && parseOptional(22)) {
25803                     expression = parseElementAccessExpressionRest(pos, expression, questionDotToken);
25804                     continue;
25805                 }
25806                 if (isTemplateStartOfTaggedTemplate()) {
25807                     expression = parseTaggedTemplateRest(pos, expression, questionDotToken, undefined);
25808                     continue;
25809                 }
25810                 return expression;
25811             }
25812         }
25813         function isTemplateStartOfTaggedTemplate() {
25814             return token() === 14 || token() === 15;
25815         }
25816         function parseTaggedTemplateRest(pos, tag, questionDotToken, typeArguments) {
25817             var tagExpression = factory.createTaggedTemplateExpression(tag, typeArguments, token() === 14 ?
25818                 (reScanTemplateHeadOrNoSubstitutionTemplate(), parseLiteralNode()) :
25819                 parseTemplateExpression(true));
25820             if (questionDotToken || tag.flags & 32) {
25821                 tagExpression.flags |= 32;
25822             }
25823             tagExpression.questionDotToken = questionDotToken;
25824             return finishNode(tagExpression, pos);
25825         }
25826         function parseCallExpressionRest(pos, expression) {
25827             while (true) {
25828                 expression = parseMemberExpressionRest(pos, expression, true);
25829                 var questionDotToken = parseOptionalToken(28);
25830                 if (token() === 29 || token() === 47) {
25831                     var typeArguments = tryParse(parseTypeArgumentsInExpression);
25832                     if (typeArguments) {
25833                         if (isTemplateStartOfTaggedTemplate()) {
25834                             expression = parseTaggedTemplateRest(pos, expression, questionDotToken, typeArguments);
25835                             continue;
25836                         }
25837                         var argumentList = parseArgumentList();
25838                         var callExpr = questionDotToken || tryReparseOptionalChain(expression) ?
25839                             factory.createCallChain(expression, questionDotToken, typeArguments, argumentList) :
25840                             factory.createCallExpression(expression, typeArguments, argumentList);
25841                         expression = finishNode(callExpr, pos);
25842                         continue;
25843                     }
25844                 }
25845                 else if (token() === 20) {
25846                     var argumentList = parseArgumentList();
25847                     var callExpr = questionDotToken || tryReparseOptionalChain(expression) ?
25848                         factory.createCallChain(expression, questionDotToken, undefined, argumentList) :
25849                         factory.createCallExpression(expression, undefined, argumentList);
25850                     expression = finishNode(callExpr, pos);
25851                     continue;
25852                 }
25853                 if (questionDotToken) {
25854                     var name = createMissingNode(78, false, ts.Diagnostics.Identifier_expected);
25855                     expression = finishNode(factory.createPropertyAccessChain(expression, questionDotToken, name), pos);
25856                 }
25857                 break;
25858             }
25859             return expression;
25860         }
25861         function parseArgumentList() {
25862             parseExpected(20);
25863             var result = parseDelimitedList(11, parseArgumentExpression);
25864             parseExpected(21);
25865             return result;
25866         }
25867         function parseTypeArgumentsInExpression() {
25868             if (reScanLessThanToken() !== 29) {
25869                 return undefined;
25870             }
25871             nextToken();
25872             var typeArguments = parseDelimitedList(20, parseType);
25873             if (!parseExpected(31)) {
25874                 return undefined;
25875             }
25876             return typeArguments && canFollowTypeArgumentsInExpression()
25877                 ? typeArguments
25878                 : undefined;
25879         }
25880         function canFollowTypeArgumentsInExpression() {
25881             switch (token()) {
25882                 case 20:
25883                 case 14:
25884                 case 15:
25885                 case 24:
25886                 case 21:
25887                 case 23:
25888                 case 58:
25889                 case 26:
25890                 case 57:
25891                 case 34:
25892                 case 36:
25893                 case 35:
25894                 case 37:
25895                 case 55:
25896                 case 56:
25897                 case 60:
25898                 case 52:
25899                 case 50:
25900                 case 51:
25901                 case 19:
25902                 case 1:
25903                     return true;
25904                 case 27:
25905                 case 18:
25906                 default:
25907                     return false;
25908             }
25909         }
25910         function parsePrimaryExpression() {
25911             switch (token()) {
25912                 case 8:
25913                 case 9:
25914                 case 10:
25915                 case 14:
25916                     return parseLiteralNode();
25917                 case 107:
25918                 case 105:
25919                 case 103:
25920                 case 109:
25921                 case 94:
25922                     return parseTokenNode();
25923                 case 20:
25924                     return parseParenthesizedExpression();
25925                 case 22:
25926                     return parseArrayLiteralExpression();
25927                 case 18:
25928                     return parseObjectLiteralExpression();
25929                 case 129:
25930                     if (!lookAhead(nextTokenIsFunctionKeywordOnSameLine)) {
25931                         break;
25932                     }
25933                     return parseFunctionExpression();
25934                 case 83:
25935                     return parseClassExpression();
25936                 case 97:
25937                     return parseFunctionExpression();
25938                 case 102:
25939                     return parseNewExpressionOrNewDotTarget();
25940                 case 43:
25941                 case 67:
25942                     if (reScanSlashToken() === 13) {
25943                         return parseLiteralNode();
25944                     }
25945                     break;
25946                 case 15:
25947                     return parseTemplateExpression(false);
25948             }
25949             return parseIdentifier(ts.Diagnostics.Expression_expected);
25950         }
25951         function parseParenthesizedExpression() {
25952             var pos = getNodePos();
25953             var hasJSDoc = hasPrecedingJSDocComment();
25954             parseExpected(20);
25955             var expression = allowInAnd(parseExpression);
25956             parseExpected(21);
25957             return withJSDoc(finishNode(factory.createParenthesizedExpression(expression), pos), hasJSDoc);
25958         }
25959         function parseSpreadElement() {
25960             var pos = getNodePos();
25961             parseExpected(25);
25962             var expression = parseAssignmentExpressionOrHigher();
25963             return finishNode(factory.createSpreadElement(expression), pos);
25964         }
25965         function parseArgumentOrArrayLiteralElement() {
25966             return token() === 25 ? parseSpreadElement() :
25967                 token() === 27 ? finishNode(factory.createOmittedExpression(), getNodePos()) :
25968                     parseAssignmentExpressionOrHigher();
25969         }
25970         function parseArgumentExpression() {
25971             return doOutsideOfContext(disallowInAndDecoratorContext, parseArgumentOrArrayLiteralElement);
25972         }
25973         function parseArrayLiteralExpression() {
25974             var pos = getNodePos();
25975             parseExpected(22);
25976             var multiLine = scanner.hasPrecedingLineBreak();
25977             var elements = parseDelimitedList(15, parseArgumentOrArrayLiteralElement);
25978             parseExpected(23);
25979             return finishNode(factory.createArrayLiteralExpression(elements, multiLine), pos);
25980         }
25981         function parseObjectLiteralElement() {
25982             var pos = getNodePos();
25983             var hasJSDoc = hasPrecedingJSDocComment();
25984             if (parseOptionalToken(25)) {
25985                 var expression = parseAssignmentExpressionOrHigher();
25986                 return withJSDoc(finishNode(factory.createSpreadAssignment(expression), pos), hasJSDoc);
25987             }
25988             var decorators = parseDecorators();
25989             var modifiers = parseModifiers();
25990             if (parseContextualModifier(134)) {
25991                 return parseAccessorDeclaration(pos, hasJSDoc, decorators, modifiers, 167);
25992             }
25993             if (parseContextualModifier(146)) {
25994                 return parseAccessorDeclaration(pos, hasJSDoc, decorators, modifiers, 168);
25995             }
25996             var asteriskToken = parseOptionalToken(41);
25997             var tokenIsIdentifier = isIdentifier();
25998             var name = parsePropertyName();
25999             var questionToken = parseOptionalToken(57);
26000             var exclamationToken = parseOptionalToken(53);
26001             if (asteriskToken || token() === 20 || token() === 29) {
26002                 return parseMethodDeclaration(pos, hasJSDoc, decorators, modifiers, asteriskToken, name, questionToken, exclamationToken);
26003             }
26004             var node;
26005             var isShorthandPropertyAssignment = tokenIsIdentifier && (token() !== 58);
26006             if (isShorthandPropertyAssignment) {
26007                 var equalsToken = parseOptionalToken(62);
26008                 var objectAssignmentInitializer = equalsToken ? allowInAnd(parseAssignmentExpressionOrHigher) : undefined;
26009                 node = factory.createShorthandPropertyAssignment(name, objectAssignmentInitializer);
26010                 node.equalsToken = equalsToken;
26011             }
26012             else {
26013                 parseExpected(58);
26014                 var initializer = allowInAnd(parseAssignmentExpressionOrHigher);
26015                 node = factory.createPropertyAssignment(name, initializer);
26016             }
26017             node.decorators = decorators;
26018             node.modifiers = modifiers;
26019             node.questionToken = questionToken;
26020             node.exclamationToken = exclamationToken;
26021             return withJSDoc(finishNode(node, pos), hasJSDoc);
26022         }
26023         function parseObjectLiteralExpression() {
26024             var pos = getNodePos();
26025             var openBracePosition = scanner.getTokenPos();
26026             parseExpected(18);
26027             var multiLine = scanner.hasPrecedingLineBreak();
26028             var properties = parseDelimitedList(12, parseObjectLiteralElement, true);
26029             if (!parseExpected(19)) {
26030                 var lastError = ts.lastOrUndefined(parseDiagnostics);
26031                 if (lastError && lastError.code === ts.Diagnostics._0_expected.code) {
26032                     ts.addRelatedInfo(lastError, ts.createDetachedDiagnostic(fileName, openBracePosition, 1, ts.Diagnostics.The_parser_expected_to_find_a_to_match_the_token_here));
26033                 }
26034             }
26035             return finishNode(factory.createObjectLiteralExpression(properties, multiLine), pos);
26036         }
26037         function parseFunctionExpression() {
26038             var saveDecoratorContext = inDecoratorContext();
26039             if (saveDecoratorContext) {
26040                 setDecoratorContext(false);
26041             }
26042             var pos = getNodePos();
26043             var hasJSDoc = hasPrecedingJSDocComment();
26044             var modifiers = parseModifiers();
26045             parseExpected(97);
26046             var asteriskToken = parseOptionalToken(41);
26047             var isGenerator = asteriskToken ? 1 : 0;
26048             var isAsync = ts.some(modifiers, ts.isAsyncModifier) ? 2 : 0;
26049             var name = isGenerator && isAsync ? doInYieldAndAwaitContext(parseOptionalBindingIdentifier) :
26050                 isGenerator ? doInYieldContext(parseOptionalBindingIdentifier) :
26051                     isAsync ? doInAwaitContext(parseOptionalBindingIdentifier) :
26052                         parseOptionalBindingIdentifier();
26053             var typeParameters = parseTypeParameters();
26054             var parameters = parseParameters(isGenerator | isAsync);
26055             var type = parseReturnType(58, false);
26056             var body = parseFunctionBlock(isGenerator | isAsync);
26057             if (saveDecoratorContext) {
26058                 setDecoratorContext(true);
26059             }
26060             var node = factory.createFunctionExpression(modifiers, asteriskToken, name, typeParameters, parameters, type, body);
26061             return withJSDoc(finishNode(node, pos), hasJSDoc);
26062         }
26063         function parseOptionalBindingIdentifier() {
26064             return isBindingIdentifier() ? parseBindingIdentifier() : undefined;
26065         }
26066         function parseNewExpressionOrNewDotTarget() {
26067             var pos = getNodePos();
26068             parseExpected(102);
26069             if (parseOptional(24)) {
26070                 var name = parseIdentifierName();
26071                 return finishNode(factory.createMetaProperty(102, name), pos);
26072             }
26073             var expressionPos = getNodePos();
26074             var expression = parsePrimaryExpression();
26075             var typeArguments;
26076             while (true) {
26077                 expression = parseMemberExpressionRest(expressionPos, expression, false);
26078                 typeArguments = tryParse(parseTypeArgumentsInExpression);
26079                 if (isTemplateStartOfTaggedTemplate()) {
26080                     ts.Debug.assert(!!typeArguments, "Expected a type argument list; all plain tagged template starts should be consumed in 'parseMemberExpressionRest'");
26081                     expression = parseTaggedTemplateRest(expressionPos, expression, undefined, typeArguments);
26082                     typeArguments = undefined;
26083                 }
26084                 break;
26085             }
26086             var argumentsArray;
26087             if (token() === 20) {
26088                 argumentsArray = parseArgumentList();
26089             }
26090             else if (typeArguments) {
26091                 parseErrorAt(pos, scanner.getStartPos(), ts.Diagnostics.A_new_expression_with_type_arguments_must_always_be_followed_by_a_parenthesized_argument_list);
26092             }
26093             return finishNode(factory.createNewExpression(expression, typeArguments, argumentsArray), pos);
26094         }
26095         function parseBlock(ignoreMissingOpenBrace, diagnosticMessage) {
26096             var pos = getNodePos();
26097             var openBracePosition = scanner.getTokenPos();
26098             if (parseExpected(18, diagnosticMessage) || ignoreMissingOpenBrace) {
26099                 var multiLine = scanner.hasPrecedingLineBreak();
26100                 var statements = parseList(1, parseStatement);
26101                 if (!parseExpected(19)) {
26102                     var lastError = ts.lastOrUndefined(parseDiagnostics);
26103                     if (lastError && lastError.code === ts.Diagnostics._0_expected.code) {
26104                         ts.addRelatedInfo(lastError, ts.createDetachedDiagnostic(fileName, openBracePosition, 1, ts.Diagnostics.The_parser_expected_to_find_a_to_match_the_token_here));
26105                     }
26106                 }
26107                 return finishNode(factory.createBlock(statements, multiLine), pos);
26108             }
26109             else {
26110                 var statements = createMissingList();
26111                 return finishNode(factory.createBlock(statements, undefined), pos);
26112             }
26113         }
26114         function parseFunctionBlock(flags, diagnosticMessage) {
26115             var savedYieldContext = inYieldContext();
26116             setYieldContext(!!(flags & 1));
26117             var savedAwaitContext = inAwaitContext();
26118             setAwaitContext(!!(flags & 2));
26119             var savedTopLevel = topLevel;
26120             topLevel = false;
26121             var saveDecoratorContext = inDecoratorContext();
26122             if (saveDecoratorContext) {
26123                 setDecoratorContext(false);
26124             }
26125             var block = parseBlock(!!(flags & 16), diagnosticMessage);
26126             if (saveDecoratorContext) {
26127                 setDecoratorContext(true);
26128             }
26129             topLevel = savedTopLevel;
26130             setYieldContext(savedYieldContext);
26131             setAwaitContext(savedAwaitContext);
26132             return block;
26133         }
26134         function parseEmptyStatement() {
26135             var pos = getNodePos();
26136             parseExpected(26);
26137             return finishNode(factory.createEmptyStatement(), pos);
26138         }
26139         function parseIfStatement() {
26140             var pos = getNodePos();
26141             parseExpected(98);
26142             parseExpected(20);
26143             var expression = allowInAnd(parseExpression);
26144             parseExpected(21);
26145             var thenStatement = parseStatement();
26146             var elseStatement = parseOptional(90) ? parseStatement() : undefined;
26147             return finishNode(factory.createIfStatement(expression, thenStatement, elseStatement), pos);
26148         }
26149         function parseDoStatement() {
26150             var pos = getNodePos();
26151             parseExpected(89);
26152             var statement = parseStatement();
26153             parseExpected(114);
26154             parseExpected(20);
26155             var expression = allowInAnd(parseExpression);
26156             parseExpected(21);
26157             parseOptional(26);
26158             return finishNode(factory.createDoStatement(statement, expression), pos);
26159         }
26160         function parseWhileStatement() {
26161             var pos = getNodePos();
26162             parseExpected(114);
26163             parseExpected(20);
26164             var expression = allowInAnd(parseExpression);
26165             parseExpected(21);
26166             var statement = parseStatement();
26167             return finishNode(factory.createWhileStatement(expression, statement), pos);
26168         }
26169         function parseForOrForInOrForOfStatement() {
26170             var pos = getNodePos();
26171             parseExpected(96);
26172             var awaitToken = parseOptionalToken(130);
26173             parseExpected(20);
26174             var initializer;
26175             if (token() !== 26) {
26176                 if (token() === 112 || token() === 118 || token() === 84) {
26177                     initializer = parseVariableDeclarationList(true);
26178                 }
26179                 else {
26180                     initializer = disallowInAnd(parseExpression);
26181                 }
26182             }
26183             var node;
26184             if (awaitToken ? parseExpected(156) : parseOptional(156)) {
26185                 var expression = allowInAnd(parseAssignmentExpressionOrHigher);
26186                 parseExpected(21);
26187                 node = factory.createForOfStatement(awaitToken, initializer, expression, parseStatement());
26188             }
26189             else if (parseOptional(100)) {
26190                 var expression = allowInAnd(parseExpression);
26191                 parseExpected(21);
26192                 node = factory.createForInStatement(initializer, expression, parseStatement());
26193             }
26194             else {
26195                 parseExpected(26);
26196                 var condition = token() !== 26 && token() !== 21
26197                     ? allowInAnd(parseExpression)
26198                     : undefined;
26199                 parseExpected(26);
26200                 var incrementor = token() !== 21
26201                     ? allowInAnd(parseExpression)
26202                     : undefined;
26203                 parseExpected(21);
26204                 node = factory.createForStatement(initializer, condition, incrementor, parseStatement());
26205             }
26206             return finishNode(node, pos);
26207         }
26208         function parseBreakOrContinueStatement(kind) {
26209             var pos = getNodePos();
26210             parseExpected(kind === 241 ? 80 : 85);
26211             var label = canParseSemicolon() ? undefined : parseIdentifier();
26212             parseSemicolon();
26213             var node = kind === 241
26214                 ? factory.createBreakStatement(label)
26215                 : factory.createContinueStatement(label);
26216             return finishNode(node, pos);
26217         }
26218         function parseReturnStatement() {
26219             var pos = getNodePos();
26220             parseExpected(104);
26221             var expression = canParseSemicolon() ? undefined : allowInAnd(parseExpression);
26222             parseSemicolon();
26223             return finishNode(factory.createReturnStatement(expression), pos);
26224         }
26225         function parseWithStatement() {
26226             var pos = getNodePos();
26227             parseExpected(115);
26228             parseExpected(20);
26229             var expression = allowInAnd(parseExpression);
26230             parseExpected(21);
26231             var statement = doInsideOfContext(16777216, parseStatement);
26232             return finishNode(factory.createWithStatement(expression, statement), pos);
26233         }
26234         function parseCaseClause() {
26235             var pos = getNodePos();
26236             parseExpected(81);
26237             var expression = allowInAnd(parseExpression);
26238             parseExpected(58);
26239             var statements = parseList(3, parseStatement);
26240             return finishNode(factory.createCaseClause(expression, statements), pos);
26241         }
26242         function parseDefaultClause() {
26243             var pos = getNodePos();
26244             parseExpected(87);
26245             parseExpected(58);
26246             var statements = parseList(3, parseStatement);
26247             return finishNode(factory.createDefaultClause(statements), pos);
26248         }
26249         function parseCaseOrDefaultClause() {
26250             return token() === 81 ? parseCaseClause() : parseDefaultClause();
26251         }
26252         function parseCaseBlock() {
26253             var pos = getNodePos();
26254             parseExpected(18);
26255             var clauses = parseList(2, parseCaseOrDefaultClause);
26256             parseExpected(19);
26257             return finishNode(factory.createCaseBlock(clauses), pos);
26258         }
26259         function parseSwitchStatement() {
26260             var pos = getNodePos();
26261             parseExpected(106);
26262             parseExpected(20);
26263             var expression = allowInAnd(parseExpression);
26264             parseExpected(21);
26265             var caseBlock = parseCaseBlock();
26266             return finishNode(factory.createSwitchStatement(expression, caseBlock), pos);
26267         }
26268         function parseThrowStatement() {
26269             var pos = getNodePos();
26270             parseExpected(108);
26271             var expression = scanner.hasPrecedingLineBreak() ? undefined : allowInAnd(parseExpression);
26272             if (expression === undefined) {
26273                 identifierCount++;
26274                 expression = finishNode(factory.createIdentifier(""), getNodePos());
26275             }
26276             parseSemicolon();
26277             return finishNode(factory.createThrowStatement(expression), pos);
26278         }
26279         function parseTryStatement() {
26280             var pos = getNodePos();
26281             parseExpected(110);
26282             var tryBlock = parseBlock(false);
26283             var catchClause = token() === 82 ? parseCatchClause() : undefined;
26284             var finallyBlock;
26285             if (!catchClause || token() === 95) {
26286                 parseExpected(95);
26287                 finallyBlock = parseBlock(false);
26288             }
26289             return finishNode(factory.createTryStatement(tryBlock, catchClause, finallyBlock), pos);
26290         }
26291         function parseCatchClause() {
26292             var pos = getNodePos();
26293             parseExpected(82);
26294             var variableDeclaration;
26295             if (parseOptional(20)) {
26296                 variableDeclaration = parseVariableDeclaration();
26297                 parseExpected(21);
26298             }
26299             else {
26300                 variableDeclaration = undefined;
26301             }
26302             var block = parseBlock(false);
26303             return finishNode(factory.createCatchClause(variableDeclaration, block), pos);
26304         }
26305         function parseDebuggerStatement() {
26306             var pos = getNodePos();
26307             parseExpected(86);
26308             parseSemicolon();
26309             return finishNode(factory.createDebuggerStatement(), pos);
26310         }
26311         function parseExpressionOrLabeledStatement() {
26312             var pos = getNodePos();
26313             var hasJSDoc = hasPrecedingJSDocComment();
26314             var node;
26315             var hasParen = token() === 20;
26316             var expression = allowInAnd(parseExpression);
26317             if (ts.isIdentifier(expression) && parseOptional(58)) {
26318                 node = factory.createLabeledStatement(expression, parseStatement());
26319             }
26320             else {
26321                 parseSemicolon();
26322                 node = factory.createExpressionStatement(expression);
26323                 if (hasParen) {
26324                     hasJSDoc = false;
26325                 }
26326             }
26327             return withJSDoc(finishNode(node, pos), hasJSDoc);
26328         }
26329         function nextTokenIsIdentifierOrKeywordOnSameLine() {
26330             nextToken();
26331             return ts.tokenIsIdentifierOrKeyword(token()) && !scanner.hasPrecedingLineBreak();
26332         }
26333         function nextTokenIsClassKeywordOnSameLine() {
26334             nextToken();
26335             return token() === 83 && !scanner.hasPrecedingLineBreak();
26336         }
26337         function nextTokenIsFunctionKeywordOnSameLine() {
26338             nextToken();
26339             return token() === 97 && !scanner.hasPrecedingLineBreak();
26340         }
26341         function nextTokenIsIdentifierOrKeywordOrLiteralOnSameLine() {
26342             nextToken();
26343             return (ts.tokenIsIdentifierOrKeyword(token()) || token() === 8 || token() === 9 || token() === 10) && !scanner.hasPrecedingLineBreak();
26344         }
26345         function isDeclaration() {
26346             while (true) {
26347                 switch (token()) {
26348                     case 112:
26349                     case 118:
26350                     case 84:
26351                     case 97:
26352                     case 83:
26353                     case 91:
26354                         return true;
26355                     case 117:
26356                     case 149:
26357                         return nextTokenIsIdentifierOnSameLine();
26358                     case 139:
26359                     case 140:
26360                         return nextTokenIsIdentifierOrStringLiteralOnSameLine();
26361                     case 125:
26362                     case 129:
26363                     case 133:
26364                     case 120:
26365                     case 121:
26366                     case 122:
26367                     case 142:
26368                         nextToken();
26369                         if (scanner.hasPrecedingLineBreak()) {
26370                             return false;
26371                         }
26372                         continue;
26373                     case 154:
26374                         nextToken();
26375                         return token() === 18 || token() === 78 || token() === 92;
26376                     case 99:
26377                         nextToken();
26378                         return token() === 10 || token() === 41 ||
26379                             token() === 18 || ts.tokenIsIdentifierOrKeyword(token());
26380                     case 92:
26381                         var currentToken_1 = nextToken();
26382                         if (currentToken_1 === 149) {
26383                             currentToken_1 = lookAhead(nextToken);
26384                         }
26385                         if (currentToken_1 === 62 || currentToken_1 === 41 ||
26386                             currentToken_1 === 18 || currentToken_1 === 87 ||
26387                             currentToken_1 === 126) {
26388                             return true;
26389                         }
26390                         continue;
26391                     case 123:
26392                         nextToken();
26393                         continue;
26394                     default:
26395                         return false;
26396                 }
26397             }
26398         }
26399         function isStartOfDeclaration() {
26400             return lookAhead(isDeclaration);
26401         }
26402         function isStartOfStatement() {
26403             switch (token()) {
26404                 case 59:
26405                 case 26:
26406                 case 18:
26407                 case 112:
26408                 case 118:
26409                 case 97:
26410                 case 83:
26411                 case 91:
26412                 case 98:
26413                 case 89:
26414                 case 114:
26415                 case 96:
26416                 case 85:
26417                 case 80:
26418                 case 104:
26419                 case 115:
26420                 case 106:
26421                 case 108:
26422                 case 110:
26423                 case 86:
26424                 case 82:
26425                 case 95:
26426                     return true;
26427                 case 99:
26428                     return isStartOfDeclaration() || lookAhead(nextTokenIsOpenParenOrLessThanOrDot);
26429                 case 84:
26430                 case 92:
26431                     return isStartOfDeclaration();
26432                 case 129:
26433                 case 133:
26434                 case 117:
26435                 case 139:
26436                 case 140:
26437                 case 149:
26438                 case 154:
26439                     return true;
26440                 case 122:
26441                 case 120:
26442                 case 121:
26443                 case 123:
26444                 case 142:
26445                     return isStartOfDeclaration() || !lookAhead(nextTokenIsIdentifierOrKeywordOnSameLine);
26446                 default:
26447                     return isStartOfExpression();
26448             }
26449         }
26450         function nextTokenIsIdentifierOrStartOfDestructuring() {
26451             nextToken();
26452             return isIdentifier() || token() === 18 || token() === 22;
26453         }
26454         function isLetDeclaration() {
26455             return lookAhead(nextTokenIsIdentifierOrStartOfDestructuring);
26456         }
26457         function parseStatement() {
26458             switch (token()) {
26459                 case 26:
26460                     return parseEmptyStatement();
26461                 case 18:
26462                     return parseBlock(false);
26463                 case 112:
26464                     return parseVariableStatement(getNodePos(), hasPrecedingJSDocComment(), undefined, undefined);
26465                 case 118:
26466                     if (isLetDeclaration()) {
26467                         return parseVariableStatement(getNodePos(), hasPrecedingJSDocComment(), undefined, undefined);
26468                     }
26469                     break;
26470                 case 97:
26471                     return parseFunctionDeclaration(getNodePos(), hasPrecedingJSDocComment(), undefined, undefined);
26472                 case 83:
26473                     return parseClassDeclaration(getNodePos(), hasPrecedingJSDocComment(), undefined, undefined);
26474                 case 98:
26475                     return parseIfStatement();
26476                 case 89:
26477                     return parseDoStatement();
26478                 case 114:
26479                     return parseWhileStatement();
26480                 case 96:
26481                     return parseForOrForInOrForOfStatement();
26482                 case 85:
26483                     return parseBreakOrContinueStatement(240);
26484                 case 80:
26485                     return parseBreakOrContinueStatement(241);
26486                 case 104:
26487                     return parseReturnStatement();
26488                 case 115:
26489                     return parseWithStatement();
26490                 case 106:
26491                     return parseSwitchStatement();
26492                 case 108:
26493                     return parseThrowStatement();
26494                 case 110:
26495                 case 82:
26496                 case 95:
26497                     return parseTryStatement();
26498                 case 86:
26499                     return parseDebuggerStatement();
26500                 case 59:
26501                     return parseDeclaration();
26502                 case 129:
26503                 case 117:
26504                 case 149:
26505                 case 139:
26506                 case 140:
26507                 case 133:
26508                 case 84:
26509                 case 91:
26510                 case 92:
26511                 case 99:
26512                 case 120:
26513                 case 121:
26514                 case 122:
26515                 case 125:
26516                 case 123:
26517                 case 142:
26518                 case 154:
26519                     if (isStartOfDeclaration()) {
26520                         return parseDeclaration();
26521                     }
26522                     break;
26523             }
26524             return parseExpressionOrLabeledStatement();
26525         }
26526         function isDeclareModifier(modifier) {
26527             return modifier.kind === 133;
26528         }
26529         function parseDeclaration() {
26530             var isAmbient = ts.some(lookAhead(function () { return (parseDecorators(), parseModifiers()); }), isDeclareModifier);
26531             if (isAmbient) {
26532                 var node = tryReuseAmbientDeclaration();
26533                 if (node) {
26534                     return node;
26535                 }
26536             }
26537             var pos = getNodePos();
26538             var hasJSDoc = hasPrecedingJSDocComment();
26539             var decorators = parseDecorators();
26540             var modifiers = parseModifiers();
26541             if (isAmbient) {
26542                 for (var _i = 0, _a = modifiers; _i < _a.length; _i++) {
26543                     var m = _a[_i];
26544                     m.flags |= 8388608;
26545                 }
26546                 return doInsideOfContext(8388608, function () { return parseDeclarationWorker(pos, hasJSDoc, decorators, modifiers); });
26547             }
26548             else {
26549                 return parseDeclarationWorker(pos, hasJSDoc, decorators, modifiers);
26550             }
26551         }
26552         function tryReuseAmbientDeclaration() {
26553             return doInsideOfContext(8388608, function () {
26554                 var node = currentNode(parsingContext);
26555                 if (node) {
26556                     return consumeNode(node);
26557                 }
26558             });
26559         }
26560         function parseDeclarationWorker(pos, hasJSDoc, decorators, modifiers) {
26561             switch (token()) {
26562                 case 112:
26563                 case 118:
26564                 case 84:
26565                     return parseVariableStatement(pos, hasJSDoc, decorators, modifiers);
26566                 case 97:
26567                     return parseFunctionDeclaration(pos, hasJSDoc, decorators, modifiers);
26568                 case 83:
26569                     return parseClassDeclaration(pos, hasJSDoc, decorators, modifiers);
26570                 case 117:
26571                     return parseInterfaceDeclaration(pos, hasJSDoc, decorators, modifiers);
26572                 case 149:
26573                     return parseTypeAliasDeclaration(pos, hasJSDoc, decorators, modifiers);
26574                 case 91:
26575                     return parseEnumDeclaration(pos, hasJSDoc, decorators, modifiers);
26576                 case 154:
26577                 case 139:
26578                 case 140:
26579                     return parseModuleDeclaration(pos, hasJSDoc, decorators, modifiers);
26580                 case 99:
26581                     return parseImportDeclarationOrImportEqualsDeclaration(pos, hasJSDoc, decorators, modifiers);
26582                 case 92:
26583                     nextToken();
26584                     switch (token()) {
26585                         case 87:
26586                         case 62:
26587                             return parseExportAssignment(pos, hasJSDoc, decorators, modifiers);
26588                         case 126:
26589                             return parseNamespaceExportDeclaration(pos, hasJSDoc, decorators, modifiers);
26590                         default:
26591                             return parseExportDeclaration(pos, hasJSDoc, decorators, modifiers);
26592                     }
26593                 default:
26594                     if (decorators || modifiers) {
26595                         var missing = createMissingNode(271, true, ts.Diagnostics.Declaration_expected);
26596                         ts.setTextRangePos(missing, pos);
26597                         missing.decorators = decorators;
26598                         missing.modifiers = modifiers;
26599                         return missing;
26600                     }
26601                     return undefined;
26602             }
26603         }
26604         function nextTokenIsIdentifierOrStringLiteralOnSameLine() {
26605             nextToken();
26606             return !scanner.hasPrecedingLineBreak() && (isIdentifier() || token() === 10);
26607         }
26608         function parseFunctionBlockOrSemicolon(flags, diagnosticMessage) {
26609             if (token() !== 18 && canParseSemicolon()) {
26610                 parseSemicolon();
26611                 return;
26612             }
26613             return parseFunctionBlock(flags, diagnosticMessage);
26614         }
26615         function parseArrayBindingElement() {
26616             var pos = getNodePos();
26617             if (token() === 27) {
26618                 return finishNode(factory.createOmittedExpression(), pos);
26619             }
26620             var dotDotDotToken = parseOptionalToken(25);
26621             var name = parseIdentifierOrPattern();
26622             var initializer = parseInitializer();
26623             return finishNode(factory.createBindingElement(dotDotDotToken, undefined, name, initializer), pos);
26624         }
26625         function parseObjectBindingElement() {
26626             var pos = getNodePos();
26627             var dotDotDotToken = parseOptionalToken(25);
26628             var tokenIsIdentifier = isBindingIdentifier();
26629             var propertyName = parsePropertyName();
26630             var name;
26631             if (tokenIsIdentifier && token() !== 58) {
26632                 name = propertyName;
26633                 propertyName = undefined;
26634             }
26635             else {
26636                 parseExpected(58);
26637                 name = parseIdentifierOrPattern();
26638             }
26639             var initializer = parseInitializer();
26640             return finishNode(factory.createBindingElement(dotDotDotToken, propertyName, name, initializer), pos);
26641         }
26642         function parseObjectBindingPattern() {
26643             var pos = getNodePos();
26644             parseExpected(18);
26645             var elements = parseDelimitedList(9, parseObjectBindingElement);
26646             parseExpected(19);
26647             return finishNode(factory.createObjectBindingPattern(elements), pos);
26648         }
26649         function parseArrayBindingPattern() {
26650             var pos = getNodePos();
26651             parseExpected(22);
26652             var elements = parseDelimitedList(10, parseArrayBindingElement);
26653             parseExpected(23);
26654             return finishNode(factory.createArrayBindingPattern(elements), pos);
26655         }
26656         function isBindingIdentifierOrPrivateIdentifierOrPattern() {
26657             return token() === 18
26658                 || token() === 22
26659                 || token() === 79
26660                 || isBindingIdentifier();
26661         }
26662         function parseIdentifierOrPattern(privateIdentifierDiagnosticMessage) {
26663             if (token() === 22) {
26664                 return parseArrayBindingPattern();
26665             }
26666             if (token() === 18) {
26667                 return parseObjectBindingPattern();
26668             }
26669             return parseBindingIdentifier(privateIdentifierDiagnosticMessage);
26670         }
26671         function parseVariableDeclarationAllowExclamation() {
26672             return parseVariableDeclaration(true);
26673         }
26674         function parseVariableDeclaration(allowExclamation) {
26675             var pos = getNodePos();
26676             var name = parseIdentifierOrPattern(ts.Diagnostics.Private_identifiers_are_not_allowed_in_variable_declarations);
26677             var exclamationToken;
26678             if (allowExclamation && name.kind === 78 &&
26679                 token() === 53 && !scanner.hasPrecedingLineBreak()) {
26680                 exclamationToken = parseTokenNode();
26681             }
26682             var type = parseTypeAnnotation();
26683             var initializer = isInOrOfKeyword(token()) ? undefined : parseInitializer();
26684             var node = factory.createVariableDeclaration(name, exclamationToken, type, initializer);
26685             return finishNode(node, pos);
26686         }
26687         function parseVariableDeclarationList(inForStatementInitializer) {
26688             var pos = getNodePos();
26689             var flags = 0;
26690             switch (token()) {
26691                 case 112:
26692                     break;
26693                 case 118:
26694                     flags |= 1;
26695                     break;
26696                 case 84:
26697                     flags |= 2;
26698                     break;
26699                 default:
26700                     ts.Debug.fail();
26701             }
26702             nextToken();
26703             var declarations;
26704             if (token() === 156 && lookAhead(canFollowContextualOfKeyword)) {
26705                 declarations = createMissingList();
26706             }
26707             else {
26708                 var savedDisallowIn = inDisallowInContext();
26709                 setDisallowInContext(inForStatementInitializer);
26710                 declarations = parseDelimitedList(8, inForStatementInitializer ? parseVariableDeclaration : parseVariableDeclarationAllowExclamation);
26711                 setDisallowInContext(savedDisallowIn);
26712             }
26713             return finishNode(factory.createVariableDeclarationList(declarations, flags), pos);
26714         }
26715         function canFollowContextualOfKeyword() {
26716             return nextTokenIsIdentifier() && nextToken() === 21;
26717         }
26718         function parseVariableStatement(pos, hasJSDoc, decorators, modifiers) {
26719             var declarationList = parseVariableDeclarationList(false);
26720             parseSemicolon();
26721             var node = factory.createVariableStatement(modifiers, declarationList);
26722             node.decorators = decorators;
26723             return withJSDoc(finishNode(node, pos), hasJSDoc);
26724         }
26725         function parseFunctionDeclaration(pos, hasJSDoc, decorators, modifiers) {
26726             var savedAwaitContext = inAwaitContext();
26727             var modifierFlags = ts.modifiersToFlags(modifiers);
26728             parseExpected(97);
26729             var asteriskToken = parseOptionalToken(41);
26730             var name = modifierFlags & 512 ? parseOptionalBindingIdentifier() : parseBindingIdentifier();
26731             var isGenerator = asteriskToken ? 1 : 0;
26732             var isAsync = modifierFlags & 256 ? 2 : 0;
26733             var typeParameters = parseTypeParameters();
26734             if (modifierFlags & 1)
26735                 setAwaitContext(true);
26736             var parameters = parseParameters(isGenerator | isAsync);
26737             var type = parseReturnType(58, false);
26738             var body = parseFunctionBlockOrSemicolon(isGenerator | isAsync, ts.Diagnostics.or_expected);
26739             setAwaitContext(savedAwaitContext);
26740             var node = factory.createFunctionDeclaration(decorators, modifiers, asteriskToken, name, typeParameters, parameters, type, body);
26741             return withJSDoc(finishNode(node, pos), hasJSDoc);
26742         }
26743         function parseConstructorName() {
26744             if (token() === 132) {
26745                 return parseExpected(132);
26746             }
26747             if (token() === 10 && lookAhead(nextToken) === 20) {
26748                 return tryParse(function () {
26749                     var literalNode = parseLiteralNode();
26750                     return literalNode.text === "constructor" ? literalNode : undefined;
26751                 });
26752             }
26753         }
26754         function tryParseConstructorDeclaration(pos, hasJSDoc, decorators, modifiers) {
26755             return tryParse(function () {
26756                 if (parseConstructorName()) {
26757                     var typeParameters = parseTypeParameters();
26758                     var parameters = parseParameters(0);
26759                     var type = parseReturnType(58, false);
26760                     var body = parseFunctionBlockOrSemicolon(0, ts.Diagnostics.or_expected);
26761                     var node = factory.createConstructorDeclaration(decorators, modifiers, parameters, body);
26762                     node.typeParameters = typeParameters;
26763                     node.type = type;
26764                     return withJSDoc(finishNode(node, pos), hasJSDoc);
26765                 }
26766             });
26767         }
26768         function parseMethodDeclaration(pos, hasJSDoc, decorators, modifiers, asteriskToken, name, questionToken, exclamationToken, diagnosticMessage) {
26769             var isGenerator = asteriskToken ? 1 : 0;
26770             var isAsync = ts.some(modifiers, ts.isAsyncModifier) ? 2 : 0;
26771             var typeParameters = parseTypeParameters();
26772             var parameters = parseParameters(isGenerator | isAsync);
26773             var type = parseReturnType(58, false);
26774             var body = parseFunctionBlockOrSemicolon(isGenerator | isAsync, diagnosticMessage);
26775             var node = factory.createMethodDeclaration(decorators, modifiers, asteriskToken, name, questionToken, typeParameters, parameters, type, body);
26776             node.exclamationToken = exclamationToken;
26777             return withJSDoc(finishNode(node, pos), hasJSDoc);
26778         }
26779         function parsePropertyDeclaration(pos, hasJSDoc, decorators, modifiers, name, questionToken) {
26780             var exclamationToken = !questionToken && !scanner.hasPrecedingLineBreak() ? parseOptionalToken(53) : undefined;
26781             var type = parseTypeAnnotation();
26782             var initializer = doOutsideOfContext(8192 | 32768 | 4096, parseInitializer);
26783             parseSemicolon();
26784             var node = factory.createPropertyDeclaration(decorators, modifiers, name, questionToken || exclamationToken, type, initializer);
26785             return withJSDoc(finishNode(node, pos), hasJSDoc);
26786         }
26787         function parsePropertyOrMethodDeclaration(pos, hasJSDoc, decorators, modifiers) {
26788             var asteriskToken = parseOptionalToken(41);
26789             var name = parsePropertyName();
26790             var questionToken = parseOptionalToken(57);
26791             if (asteriskToken || token() === 20 || token() === 29) {
26792                 return parseMethodDeclaration(pos, hasJSDoc, decorators, modifiers, asteriskToken, name, questionToken, undefined, ts.Diagnostics.or_expected);
26793             }
26794             return parsePropertyDeclaration(pos, hasJSDoc, decorators, modifiers, name, questionToken);
26795         }
26796         function parseAccessorDeclaration(pos, hasJSDoc, decorators, modifiers, kind) {
26797             var name = parsePropertyName();
26798             var typeParameters = parseTypeParameters();
26799             var parameters = parseParameters(0);
26800             var type = parseReturnType(58, false);
26801             var body = parseFunctionBlockOrSemicolon(0);
26802             var node = kind === 167
26803                 ? factory.createGetAccessorDeclaration(decorators, modifiers, name, parameters, type, body)
26804                 : factory.createSetAccessorDeclaration(decorators, modifiers, name, parameters, body);
26805             node.typeParameters = typeParameters;
26806             if (type && node.kind === 168)
26807                 node.type = type;
26808             return withJSDoc(finishNode(node, pos), hasJSDoc);
26809         }
26810         function isClassMemberStart() {
26811             var idToken;
26812             if (token() === 59) {
26813                 return true;
26814             }
26815             while (ts.isModifierKind(token())) {
26816                 idToken = token();
26817                 if (ts.isClassMemberModifier(idToken)) {
26818                     return true;
26819                 }
26820                 nextToken();
26821             }
26822             if (token() === 41) {
26823                 return true;
26824             }
26825             if (isLiteralPropertyName()) {
26826                 idToken = token();
26827                 nextToken();
26828             }
26829             if (token() === 22) {
26830                 return true;
26831             }
26832             if (idToken !== undefined) {
26833                 if (!ts.isKeyword(idToken) || idToken === 146 || idToken === 134) {
26834                     return true;
26835                 }
26836                 switch (token()) {
26837                     case 20:
26838                     case 29:
26839                     case 53:
26840                     case 58:
26841                     case 62:
26842                     case 57:
26843                         return true;
26844                     default:
26845                         return canParseSemicolon();
26846                 }
26847             }
26848             return false;
26849         }
26850         function parseDecoratorExpression() {
26851             if (inAwaitContext() && token() === 130) {
26852                 var pos = getNodePos();
26853                 var awaitExpression = parseIdentifier(ts.Diagnostics.Expression_expected);
26854                 nextToken();
26855                 var memberExpression = parseMemberExpressionRest(pos, awaitExpression, true);
26856                 return parseCallExpressionRest(pos, memberExpression);
26857             }
26858             return parseLeftHandSideExpressionOrHigher();
26859         }
26860         function tryParseDecorator() {
26861             var pos = getNodePos();
26862             if (!parseOptional(59)) {
26863                 return undefined;
26864             }
26865             var expression = doInDecoratorContext(parseDecoratorExpression);
26866             return finishNode(factory.createDecorator(expression), pos);
26867         }
26868         function parseDecorators() {
26869             var pos = getNodePos();
26870             var list, decorator;
26871             while (decorator = tryParseDecorator()) {
26872                 list = ts.append(list, decorator);
26873             }
26874             return list && createNodeArray(list, pos);
26875         }
26876         function tryParseModifier(permitInvalidConstAsModifier) {
26877             var pos = getNodePos();
26878             var kind = token();
26879             if (token() === 84 && permitInvalidConstAsModifier) {
26880                 if (!tryParse(nextTokenIsOnSameLineAndCanFollowModifier)) {
26881                     return undefined;
26882                 }
26883             }
26884             else {
26885                 if (!parseAnyContextualModifier()) {
26886                     return undefined;
26887                 }
26888             }
26889             return finishNode(factory.createToken(kind), pos);
26890         }
26891         function parseModifiers(permitInvalidConstAsModifier) {
26892             var pos = getNodePos();
26893             var list, modifier;
26894             while (modifier = tryParseModifier(permitInvalidConstAsModifier)) {
26895                 list = ts.append(list, modifier);
26896             }
26897             return list && createNodeArray(list, pos);
26898         }
26899         function parseModifiersForArrowFunction() {
26900             var modifiers;
26901             if (token() === 129) {
26902                 var pos = getNodePos();
26903                 nextToken();
26904                 var modifier = finishNode(factory.createToken(129), pos);
26905                 modifiers = createNodeArray([modifier], pos);
26906             }
26907             return modifiers;
26908         }
26909         function parseClassElement() {
26910             var pos = getNodePos();
26911             if (token() === 26) {
26912                 nextToken();
26913                 return finishNode(factory.createSemicolonClassElement(), pos);
26914             }
26915             var hasJSDoc = hasPrecedingJSDocComment();
26916             var decorators = parseDecorators();
26917             var modifiers = parseModifiers(true);
26918             if (parseContextualModifier(134)) {
26919                 return parseAccessorDeclaration(pos, hasJSDoc, decorators, modifiers, 167);
26920             }
26921             if (parseContextualModifier(146)) {
26922                 return parseAccessorDeclaration(pos, hasJSDoc, decorators, modifiers, 168);
26923             }
26924             if (token() === 132 || token() === 10) {
26925                 var constructorDeclaration = tryParseConstructorDeclaration(pos, hasJSDoc, decorators, modifiers);
26926                 if (constructorDeclaration) {
26927                     return constructorDeclaration;
26928                 }
26929             }
26930             if (isIndexSignature()) {
26931                 return parseIndexSignatureDeclaration(pos, hasJSDoc, decorators, modifiers);
26932             }
26933             if (ts.tokenIsIdentifierOrKeyword(token()) ||
26934                 token() === 10 ||
26935                 token() === 8 ||
26936                 token() === 41 ||
26937                 token() === 22) {
26938                 var isAmbient = ts.some(modifiers, isDeclareModifier);
26939                 if (isAmbient) {
26940                     for (var _i = 0, _a = modifiers; _i < _a.length; _i++) {
26941                         var m = _a[_i];
26942                         m.flags |= 8388608;
26943                     }
26944                     return doInsideOfContext(8388608, function () { return parsePropertyOrMethodDeclaration(pos, hasJSDoc, decorators, modifiers); });
26945                 }
26946                 else {
26947                     return parsePropertyOrMethodDeclaration(pos, hasJSDoc, decorators, modifiers);
26948                 }
26949             }
26950             if (decorators || modifiers) {
26951                 var name = createMissingNode(78, true, ts.Diagnostics.Declaration_expected);
26952                 return parsePropertyDeclaration(pos, hasJSDoc, decorators, modifiers, name, undefined);
26953             }
26954             return ts.Debug.fail("Should not have attempted to parse class member declaration.");
26955         }
26956         function parseClassExpression() {
26957             return parseClassDeclarationOrExpression(getNodePos(), hasPrecedingJSDocComment(), undefined, undefined, 221);
26958         }
26959         function parseClassDeclaration(pos, hasJSDoc, decorators, modifiers) {
26960             return parseClassDeclarationOrExpression(pos, hasJSDoc, decorators, modifiers, 252);
26961         }
26962         function parseClassDeclarationOrExpression(pos, hasJSDoc, decorators, modifiers, kind) {
26963             var savedAwaitContext = inAwaitContext();
26964             parseExpected(83);
26965             var name = parseNameOfClassDeclarationOrExpression();
26966             var typeParameters = parseTypeParameters();
26967             if (ts.some(modifiers, ts.isExportModifier))
26968                 setAwaitContext(true);
26969             var heritageClauses = parseHeritageClauses();
26970             var members;
26971             if (parseExpected(18)) {
26972                 members = parseClassMembers();
26973                 parseExpected(19);
26974             }
26975             else {
26976                 members = createMissingList();
26977             }
26978             setAwaitContext(savedAwaitContext);
26979             var node = kind === 252
26980                 ? factory.createClassDeclaration(decorators, modifiers, name, typeParameters, heritageClauses, members)
26981                 : factory.createClassExpression(decorators, modifiers, name, typeParameters, heritageClauses, members);
26982             return withJSDoc(finishNode(node, pos), hasJSDoc);
26983         }
26984         function parseNameOfClassDeclarationOrExpression() {
26985             return isBindingIdentifier() && !isImplementsClause()
26986                 ? createIdentifier(isBindingIdentifier())
26987                 : undefined;
26988         }
26989         function isImplementsClause() {
26990             return token() === 116 && lookAhead(nextTokenIsIdentifierOrKeyword);
26991         }
26992         function parseHeritageClauses() {
26993             if (isHeritageClause()) {
26994                 return parseList(22, parseHeritageClause);
26995             }
26996             return undefined;
26997         }
26998         function parseHeritageClause() {
26999             var pos = getNodePos();
27000             var tok = token();
27001             ts.Debug.assert(tok === 93 || tok === 116);
27002             nextToken();
27003             var types = parseDelimitedList(7, parseExpressionWithTypeArguments);
27004             return finishNode(factory.createHeritageClause(tok, types), pos);
27005         }
27006         function parseExpressionWithTypeArguments() {
27007             var pos = getNodePos();
27008             var expression = parseLeftHandSideExpressionOrHigher();
27009             var typeArguments = tryParseTypeArguments();
27010             return finishNode(factory.createExpressionWithTypeArguments(expression, typeArguments), pos);
27011         }
27012         function tryParseTypeArguments() {
27013             return token() === 29 ?
27014                 parseBracketedList(20, parseType, 29, 31) : undefined;
27015         }
27016         function isHeritageClause() {
27017             return token() === 93 || token() === 116;
27018         }
27019         function parseClassMembers() {
27020             return parseList(5, parseClassElement);
27021         }
27022         function parseInterfaceDeclaration(pos, hasJSDoc, decorators, modifiers) {
27023             parseExpected(117);
27024             var name = parseIdentifier();
27025             var typeParameters = parseTypeParameters();
27026             var heritageClauses = parseHeritageClauses();
27027             var members = parseObjectTypeMembers();
27028             var node = factory.createInterfaceDeclaration(decorators, modifiers, name, typeParameters, heritageClauses, members);
27029             return withJSDoc(finishNode(node, pos), hasJSDoc);
27030         }
27031         function parseTypeAliasDeclaration(pos, hasJSDoc, decorators, modifiers) {
27032             parseExpected(149);
27033             var name = parseIdentifier();
27034             var typeParameters = parseTypeParameters();
27035             parseExpected(62);
27036             var type = token() === 136 && tryParse(parseKeywordAndNoDot) || parseType();
27037             parseSemicolon();
27038             var node = factory.createTypeAliasDeclaration(decorators, modifiers, name, typeParameters, type);
27039             return withJSDoc(finishNode(node, pos), hasJSDoc);
27040         }
27041         function parseEnumMember() {
27042             var pos = getNodePos();
27043             var hasJSDoc = hasPrecedingJSDocComment();
27044             var name = parsePropertyName();
27045             var initializer = allowInAnd(parseInitializer);
27046             return withJSDoc(finishNode(factory.createEnumMember(name, initializer), pos), hasJSDoc);
27047         }
27048         function parseEnumDeclaration(pos, hasJSDoc, decorators, modifiers) {
27049             parseExpected(91);
27050             var name = parseIdentifier();
27051             var members;
27052             if (parseExpected(18)) {
27053                 members = doOutsideOfYieldAndAwaitContext(function () { return parseDelimitedList(6, parseEnumMember); });
27054                 parseExpected(19);
27055             }
27056             else {
27057                 members = createMissingList();
27058             }
27059             var node = factory.createEnumDeclaration(decorators, modifiers, name, members);
27060             return withJSDoc(finishNode(node, pos), hasJSDoc);
27061         }
27062         function parseModuleBlock() {
27063             var pos = getNodePos();
27064             var statements;
27065             if (parseExpected(18)) {
27066                 statements = parseList(1, parseStatement);
27067                 parseExpected(19);
27068             }
27069             else {
27070                 statements = createMissingList();
27071             }
27072             return finishNode(factory.createModuleBlock(statements), pos);
27073         }
27074         function parseModuleOrNamespaceDeclaration(pos, hasJSDoc, decorators, modifiers, flags) {
27075             var namespaceFlag = flags & 16;
27076             var name = parseIdentifier();
27077             var body = parseOptional(24)
27078                 ? parseModuleOrNamespaceDeclaration(getNodePos(), false, undefined, undefined, 4 | namespaceFlag)
27079                 : parseModuleBlock();
27080             var node = factory.createModuleDeclaration(decorators, modifiers, name, body, flags);
27081             return withJSDoc(finishNode(node, pos), hasJSDoc);
27082         }
27083         function parseAmbientExternalModuleDeclaration(pos, hasJSDoc, decorators, modifiers) {
27084             var flags = 0;
27085             var name;
27086             if (token() === 154) {
27087                 name = parseIdentifier();
27088                 flags |= 1024;
27089             }
27090             else {
27091                 name = parseLiteralNode();
27092                 name.text = internIdentifier(name.text);
27093             }
27094             var body;
27095             if (token() === 18) {
27096                 body = parseModuleBlock();
27097             }
27098             else {
27099                 parseSemicolon();
27100             }
27101             var node = factory.createModuleDeclaration(decorators, modifiers, name, body, flags);
27102             return withJSDoc(finishNode(node, pos), hasJSDoc);
27103         }
27104         function parseModuleDeclaration(pos, hasJSDoc, decorators, modifiers) {
27105             var flags = 0;
27106             if (token() === 154) {
27107                 return parseAmbientExternalModuleDeclaration(pos, hasJSDoc, decorators, modifiers);
27108             }
27109             else if (parseOptional(140)) {
27110                 flags |= 16;
27111             }
27112             else {
27113                 parseExpected(139);
27114                 if (token() === 10) {
27115                     return parseAmbientExternalModuleDeclaration(pos, hasJSDoc, decorators, modifiers);
27116                 }
27117             }
27118             return parseModuleOrNamespaceDeclaration(pos, hasJSDoc, decorators, modifiers, flags);
27119         }
27120         function isExternalModuleReference() {
27121             return token() === 143 &&
27122                 lookAhead(nextTokenIsOpenParen);
27123         }
27124         function nextTokenIsOpenParen() {
27125             return nextToken() === 20;
27126         }
27127         function nextTokenIsSlash() {
27128             return nextToken() === 43;
27129         }
27130         function parseNamespaceExportDeclaration(pos, hasJSDoc, decorators, modifiers) {
27131             parseExpected(126);
27132             parseExpected(140);
27133             var name = parseIdentifier();
27134             parseSemicolon();
27135             var node = factory.createNamespaceExportDeclaration(name);
27136             node.decorators = decorators;
27137             node.modifiers = modifiers;
27138             return withJSDoc(finishNode(node, pos), hasJSDoc);
27139         }
27140         function parseImportDeclarationOrImportEqualsDeclaration(pos, hasJSDoc, decorators, modifiers) {
27141             parseExpected(99);
27142             var afterImportPos = scanner.getStartPos();
27143             var identifier;
27144             if (isIdentifier()) {
27145                 identifier = parseIdentifier();
27146             }
27147             var isTypeOnly = false;
27148             if (token() !== 153 &&
27149                 (identifier === null || identifier === void 0 ? void 0 : identifier.escapedText) === "type" &&
27150                 (isIdentifier() || tokenAfterImportDefinitelyProducesImportDeclaration())) {
27151                 isTypeOnly = true;
27152                 identifier = isIdentifier() ? parseIdentifier() : undefined;
27153             }
27154             if (identifier && !tokenAfterImportedIdentifierDefinitelyProducesImportDeclaration()) {
27155                 return parseImportEqualsDeclaration(pos, hasJSDoc, decorators, modifiers, identifier, isTypeOnly);
27156             }
27157             var importClause;
27158             if (identifier ||
27159                 token() === 41 ||
27160                 token() === 18) {
27161                 importClause = parseImportClause(identifier, afterImportPos, isTypeOnly);
27162                 parseExpected(153);
27163             }
27164             var moduleSpecifier = parseModuleSpecifier();
27165             parseSemicolon();
27166             var node = factory.createImportDeclaration(decorators, modifiers, importClause, moduleSpecifier);
27167             return withJSDoc(finishNode(node, pos), hasJSDoc);
27168         }
27169         function tokenAfterImportDefinitelyProducesImportDeclaration() {
27170             return token() === 41 || token() === 18;
27171         }
27172         function tokenAfterImportedIdentifierDefinitelyProducesImportDeclaration() {
27173             return token() === 27 || token() === 153;
27174         }
27175         function parseImportEqualsDeclaration(pos, hasJSDoc, decorators, modifiers, identifier, isTypeOnly) {
27176             parseExpected(62);
27177             var moduleReference = parseModuleReference();
27178             parseSemicolon();
27179             var node = factory.createImportEqualsDeclaration(decorators, modifiers, identifier, moduleReference);
27180             var finished = withJSDoc(finishNode(node, pos), hasJSDoc);
27181             if (isTypeOnly) {
27182                 parseErrorAtRange(finished, ts.Diagnostics.Only_ECMAScript_imports_may_use_import_type);
27183             }
27184             return finished;
27185         }
27186         function parseImportClause(identifier, pos, isTypeOnly) {
27187             var namedBindings;
27188             if (!identifier ||
27189                 parseOptional(27)) {
27190                 namedBindings = token() === 41 ? parseNamespaceImport() : parseNamedImportsOrExports(264);
27191             }
27192             return finishNode(factory.createImportClause(isTypeOnly, identifier, namedBindings), pos);
27193         }
27194         function parseModuleReference() {
27195             return isExternalModuleReference()
27196                 ? parseExternalModuleReference()
27197                 : parseEntityName(false);
27198         }
27199         function parseExternalModuleReference() {
27200             var pos = getNodePos();
27201             parseExpected(143);
27202             parseExpected(20);
27203             var expression = parseModuleSpecifier();
27204             parseExpected(21);
27205             return finishNode(factory.createExternalModuleReference(expression), pos);
27206         }
27207         function parseModuleSpecifier() {
27208             if (token() === 10) {
27209                 var result = parseLiteralNode();
27210                 result.text = internIdentifier(result.text);
27211                 return result;
27212             }
27213             else {
27214                 return parseExpression();
27215             }
27216         }
27217         function parseNamespaceImport() {
27218             var pos = getNodePos();
27219             parseExpected(41);
27220             parseExpected(126);
27221             var name = parseIdentifier();
27222             return finishNode(factory.createNamespaceImport(name), pos);
27223         }
27224         function parseNamedImportsOrExports(kind) {
27225             var pos = getNodePos();
27226             var node = kind === 264
27227                 ? factory.createNamedImports(parseBracketedList(23, parseImportSpecifier, 18, 19))
27228                 : factory.createNamedExports(parseBracketedList(23, parseExportSpecifier, 18, 19));
27229             return finishNode(node, pos);
27230         }
27231         function parseExportSpecifier() {
27232             return parseImportOrExportSpecifier(270);
27233         }
27234         function parseImportSpecifier() {
27235             return parseImportOrExportSpecifier(265);
27236         }
27237         function parseImportOrExportSpecifier(kind) {
27238             var pos = getNodePos();
27239             var checkIdentifierIsKeyword = ts.isKeyword(token()) && !isIdentifier();
27240             var checkIdentifierStart = scanner.getTokenPos();
27241             var checkIdentifierEnd = scanner.getTextPos();
27242             var identifierName = parseIdentifierName();
27243             var propertyName;
27244             var name;
27245             if (token() === 126) {
27246                 propertyName = identifierName;
27247                 parseExpected(126);
27248                 checkIdentifierIsKeyword = ts.isKeyword(token()) && !isIdentifier();
27249                 checkIdentifierStart = scanner.getTokenPos();
27250                 checkIdentifierEnd = scanner.getTextPos();
27251                 name = parseIdentifierName();
27252             }
27253             else {
27254                 name = identifierName;
27255             }
27256             if (kind === 265 && checkIdentifierIsKeyword) {
27257                 parseErrorAt(checkIdentifierStart, checkIdentifierEnd, ts.Diagnostics.Identifier_expected);
27258             }
27259             var node = kind === 265
27260                 ? factory.createImportSpecifier(propertyName, name)
27261                 : factory.createExportSpecifier(propertyName, name);
27262             return finishNode(node, pos);
27263         }
27264         function parseNamespaceExport(pos) {
27265             return finishNode(factory.createNamespaceExport(parseIdentifierName()), pos);
27266         }
27267         function parseExportDeclaration(pos, hasJSDoc, decorators, modifiers) {
27268             var savedAwaitContext = inAwaitContext();
27269             setAwaitContext(true);
27270             var exportClause;
27271             var moduleSpecifier;
27272             var isTypeOnly = parseOptional(149);
27273             var namespaceExportPos = getNodePos();
27274             if (parseOptional(41)) {
27275                 if (parseOptional(126)) {
27276                     exportClause = parseNamespaceExport(namespaceExportPos);
27277                 }
27278                 parseExpected(153);
27279                 moduleSpecifier = parseModuleSpecifier();
27280             }
27281             else {
27282                 exportClause = parseNamedImportsOrExports(268);
27283                 if (token() === 153 || (token() === 10 && !scanner.hasPrecedingLineBreak())) {
27284                     parseExpected(153);
27285                     moduleSpecifier = parseModuleSpecifier();
27286                 }
27287             }
27288             parseSemicolon();
27289             setAwaitContext(savedAwaitContext);
27290             var node = factory.createExportDeclaration(decorators, modifiers, isTypeOnly, exportClause, moduleSpecifier);
27291             return withJSDoc(finishNode(node, pos), hasJSDoc);
27292         }
27293         function parseExportAssignment(pos, hasJSDoc, decorators, modifiers) {
27294             var savedAwaitContext = inAwaitContext();
27295             setAwaitContext(true);
27296             var isExportEquals;
27297             if (parseOptional(62)) {
27298                 isExportEquals = true;
27299             }
27300             else {
27301                 parseExpected(87);
27302             }
27303             var expression = parseAssignmentExpressionOrHigher();
27304             parseSemicolon();
27305             setAwaitContext(savedAwaitContext);
27306             var node = factory.createExportAssignment(decorators, modifiers, isExportEquals, expression);
27307             return withJSDoc(finishNode(node, pos), hasJSDoc);
27308         }
27309         function setExternalModuleIndicator(sourceFile) {
27310             sourceFile.externalModuleIndicator =
27311                 ts.forEach(sourceFile.statements, isAnExternalModuleIndicatorNode) ||
27312                     getImportMetaIfNecessary(sourceFile);
27313         }
27314         function isAnExternalModuleIndicatorNode(node) {
27315             return hasModifierOfKind(node, 92)
27316                 || ts.isImportEqualsDeclaration(node) && ts.isExternalModuleReference(node.moduleReference)
27317                 || ts.isImportDeclaration(node)
27318                 || ts.isExportAssignment(node)
27319                 || ts.isExportDeclaration(node) ? node : undefined;
27320         }
27321         function getImportMetaIfNecessary(sourceFile) {
27322             return sourceFile.flags & 2097152 ?
27323                 walkTreeForExternalModuleIndicators(sourceFile) :
27324                 undefined;
27325         }
27326         function walkTreeForExternalModuleIndicators(node) {
27327             return isImportMeta(node) ? node : forEachChild(node, walkTreeForExternalModuleIndicators);
27328         }
27329         function hasModifierOfKind(node, kind) {
27330             return ts.some(node.modifiers, function (m) { return m.kind === kind; });
27331         }
27332         function isImportMeta(node) {
27333             return ts.isMetaProperty(node) && node.keywordToken === 99 && node.name.escapedText === "meta";
27334         }
27335         var JSDocParser;
27336         (function (JSDocParser) {
27337             function parseJSDocTypeExpressionForTests(content, start, length) {
27338                 initializeState("file.js", content, 99, undefined, 1);
27339                 scanner.setText(content, start, length);
27340                 currentToken = scanner.scan();
27341                 var jsDocTypeExpression = parseJSDocTypeExpression();
27342                 var sourceFile = createSourceFile("file.js", 99, 1, false, [], factory.createToken(1), 0);
27343                 var diagnostics = ts.attachFileToDiagnostics(parseDiagnostics, sourceFile);
27344                 if (jsDocDiagnostics) {
27345                     sourceFile.jsDocDiagnostics = ts.attachFileToDiagnostics(jsDocDiagnostics, sourceFile);
27346                 }
27347                 clearState();
27348                 return jsDocTypeExpression ? { jsDocTypeExpression: jsDocTypeExpression, diagnostics: diagnostics } : undefined;
27349             }
27350             JSDocParser.parseJSDocTypeExpressionForTests = parseJSDocTypeExpressionForTests;
27351             function parseJSDocTypeExpression(mayOmitBraces) {
27352                 var pos = getNodePos();
27353                 var hasBrace = (mayOmitBraces ? parseOptional : parseExpected)(18);
27354                 var type = doInsideOfContext(4194304, parseJSDocType);
27355                 if (!mayOmitBraces || hasBrace) {
27356                     parseExpectedJSDoc(19);
27357                 }
27358                 var result = factory.createJSDocTypeExpression(type);
27359                 fixupParentReferences(result);
27360                 return finishNode(result, pos);
27361             }
27362             JSDocParser.parseJSDocTypeExpression = parseJSDocTypeExpression;
27363             function parseJSDocNameReference() {
27364                 var pos = getNodePos();
27365                 var hasBrace = parseOptional(18);
27366                 var entityName = parseEntityName(false);
27367                 if (hasBrace) {
27368                     parseExpectedJSDoc(19);
27369                 }
27370                 var result = factory.createJSDocNameReference(entityName);
27371                 fixupParentReferences(result);
27372                 return finishNode(result, pos);
27373             }
27374             JSDocParser.parseJSDocNameReference = parseJSDocNameReference;
27375             function parseIsolatedJSDocComment(content, start, length) {
27376                 initializeState("", content, 99, undefined, 1);
27377                 var jsDoc = doInsideOfContext(4194304, function () { return parseJSDocCommentWorker(start, length); });
27378                 var sourceFile = { languageVariant: 0, text: content };
27379                 var diagnostics = ts.attachFileToDiagnostics(parseDiagnostics, sourceFile);
27380                 clearState();
27381                 return jsDoc ? { jsDoc: jsDoc, diagnostics: diagnostics } : undefined;
27382             }
27383             JSDocParser.parseIsolatedJSDocComment = parseIsolatedJSDocComment;
27384             function parseJSDocComment(parent, start, length) {
27385                 var saveToken = currentToken;
27386                 var saveParseDiagnosticsLength = parseDiagnostics.length;
27387                 var saveParseErrorBeforeNextFinishedNode = parseErrorBeforeNextFinishedNode;
27388                 var comment = doInsideOfContext(4194304, function () { return parseJSDocCommentWorker(start, length); });
27389                 ts.setParent(comment, parent);
27390                 if (contextFlags & 131072) {
27391                     if (!jsDocDiagnostics) {
27392                         jsDocDiagnostics = [];
27393                     }
27394                     jsDocDiagnostics.push.apply(jsDocDiagnostics, parseDiagnostics);
27395                 }
27396                 currentToken = saveToken;
27397                 parseDiagnostics.length = saveParseDiagnosticsLength;
27398                 parseErrorBeforeNextFinishedNode = saveParseErrorBeforeNextFinishedNode;
27399                 return comment;
27400             }
27401             JSDocParser.parseJSDocComment = parseJSDocComment;
27402             function parseJSDocCommentWorker(start, length) {
27403                 if (start === void 0) { start = 0; }
27404                 var content = sourceText;
27405                 var end = length === undefined ? content.length : start + length;
27406                 length = end - start;
27407                 ts.Debug.assert(start >= 0);
27408                 ts.Debug.assert(start <= end);
27409                 ts.Debug.assert(end <= content.length);
27410                 if (!isJSDocLikeText(content, start)) {
27411                     return undefined;
27412                 }
27413                 var tags;
27414                 var tagsPos;
27415                 var tagsEnd;
27416                 var comments = [];
27417                 return scanner.scanRange(start + 3, length - 5, function () {
27418                     var state = 1;
27419                     var margin;
27420                     var indent = start - (content.lastIndexOf("\n", start) + 1) + 4;
27421                     function pushComment(text) {
27422                         if (!margin) {
27423                             margin = indent;
27424                         }
27425                         comments.push(text);
27426                         indent += text.length;
27427                     }
27428                     nextTokenJSDoc();
27429                     while (parseOptionalJsdoc(5))
27430                         ;
27431                     if (parseOptionalJsdoc(4)) {
27432                         state = 0;
27433                         indent = 0;
27434                     }
27435                     loop: while (true) {
27436                         switch (token()) {
27437                             case 59:
27438                                 if (state === 0 || state === 1) {
27439                                     removeTrailingWhitespace(comments);
27440                                     addTag(parseTag(indent));
27441                                     state = 0;
27442                                     margin = undefined;
27443                                 }
27444                                 else {
27445                                     pushComment(scanner.getTokenText());
27446                                 }
27447                                 break;
27448                             case 4:
27449                                 comments.push(scanner.getTokenText());
27450                                 state = 0;
27451                                 indent = 0;
27452                                 break;
27453                             case 41:
27454                                 var asterisk = scanner.getTokenText();
27455                                 if (state === 1 || state === 2) {
27456                                     state = 2;
27457                                     pushComment(asterisk);
27458                                 }
27459                                 else {
27460                                     state = 1;
27461                                     indent += asterisk.length;
27462                                 }
27463                                 break;
27464                             case 5:
27465                                 var whitespace = scanner.getTokenText();
27466                                 if (state === 2) {
27467                                     comments.push(whitespace);
27468                                 }
27469                                 else if (margin !== undefined && indent + whitespace.length > margin) {
27470                                     comments.push(whitespace.slice(margin - indent));
27471                                 }
27472                                 indent += whitespace.length;
27473                                 break;
27474                             case 1:
27475                                 break loop;
27476                             default:
27477                                 state = 2;
27478                                 pushComment(scanner.getTokenText());
27479                                 break;
27480                         }
27481                         nextTokenJSDoc();
27482                     }
27483                     removeLeadingNewlines(comments);
27484                     removeTrailingWhitespace(comments);
27485                     return createJSDocComment();
27486                 });
27487                 function removeLeadingNewlines(comments) {
27488                     while (comments.length && (comments[0] === "\n" || comments[0] === "\r")) {
27489                         comments.shift();
27490                     }
27491                 }
27492                 function removeTrailingWhitespace(comments) {
27493                     while (comments.length && comments[comments.length - 1].trim() === "") {
27494                         comments.pop();
27495                     }
27496                 }
27497                 function createJSDocComment() {
27498                     var comment = comments.length ? comments.join("") : undefined;
27499                     var tagsArray = tags && createNodeArray(tags, tagsPos, tagsEnd);
27500                     return finishNode(factory.createJSDocComment(comment, tagsArray), start, end);
27501                 }
27502                 function isNextNonwhitespaceTokenEndOfFile() {
27503                     while (true) {
27504                         nextTokenJSDoc();
27505                         if (token() === 1) {
27506                             return true;
27507                         }
27508                         if (!(token() === 5 || token() === 4)) {
27509                             return false;
27510                         }
27511                     }
27512                 }
27513                 function skipWhitespace() {
27514                     if (token() === 5 || token() === 4) {
27515                         if (lookAhead(isNextNonwhitespaceTokenEndOfFile)) {
27516                             return;
27517                         }
27518                     }
27519                     while (token() === 5 || token() === 4) {
27520                         nextTokenJSDoc();
27521                     }
27522                 }
27523                 function skipWhitespaceOrAsterisk() {
27524                     if (token() === 5 || token() === 4) {
27525                         if (lookAhead(isNextNonwhitespaceTokenEndOfFile)) {
27526                             return "";
27527                         }
27528                     }
27529                     var precedingLineBreak = scanner.hasPrecedingLineBreak();
27530                     var seenLineBreak = false;
27531                     var indentText = "";
27532                     while ((precedingLineBreak && token() === 41) || token() === 5 || token() === 4) {
27533                         indentText += scanner.getTokenText();
27534                         if (token() === 4) {
27535                             precedingLineBreak = true;
27536                             seenLineBreak = true;
27537                             indentText = "";
27538                         }
27539                         else if (token() === 41) {
27540                             precedingLineBreak = false;
27541                         }
27542                         nextTokenJSDoc();
27543                     }
27544                     return seenLineBreak ? indentText : "";
27545                 }
27546                 function parseTag(margin) {
27547                     ts.Debug.assert(token() === 59);
27548                     var start = scanner.getTokenPos();
27549                     nextTokenJSDoc();
27550                     var tagName = parseJSDocIdentifierName(undefined);
27551                     var indentText = skipWhitespaceOrAsterisk();
27552                     var tag;
27553                     switch (tagName.escapedText) {
27554                         case "author":
27555                             tag = parseAuthorTag(start, tagName, margin, indentText);
27556                             break;
27557                         case "implements":
27558                             tag = parseImplementsTag(start, tagName, margin, indentText);
27559                             break;
27560                         case "augments":
27561                         case "extends":
27562                             tag = parseAugmentsTag(start, tagName, margin, indentText);
27563                             break;
27564                         case "class":
27565                         case "constructor":
27566                             tag = parseSimpleTag(start, factory.createJSDocClassTag, tagName, margin, indentText);
27567                             break;
27568                         case "public":
27569                             tag = parseSimpleTag(start, factory.createJSDocPublicTag, tagName, margin, indentText);
27570                             break;
27571                         case "private":
27572                             tag = parseSimpleTag(start, factory.createJSDocPrivateTag, tagName, margin, indentText);
27573                             break;
27574                         case "protected":
27575                             tag = parseSimpleTag(start, factory.createJSDocProtectedTag, tagName, margin, indentText);
27576                             break;
27577                         case "readonly":
27578                             tag = parseSimpleTag(start, factory.createJSDocReadonlyTag, tagName, margin, indentText);
27579                             break;
27580                         case "deprecated":
27581                             hasDeprecatedTag = true;
27582                             tag = parseSimpleTag(start, factory.createJSDocDeprecatedTag, tagName, margin, indentText);
27583                             break;
27584                         case "this":
27585                             tag = parseThisTag(start, tagName, margin, indentText);
27586                             break;
27587                         case "enum":
27588                             tag = parseEnumTag(start, tagName, margin, indentText);
27589                             break;
27590                         case "arg":
27591                         case "argument":
27592                         case "param":
27593                             return parseParameterOrPropertyTag(start, tagName, 2, margin);
27594                         case "return":
27595                         case "returns":
27596                             tag = parseReturnTag(start, tagName, margin, indentText);
27597                             break;
27598                         case "template":
27599                             tag = parseTemplateTag(start, tagName, margin, indentText);
27600                             break;
27601                         case "type":
27602                             tag = parseTypeTag(start, tagName, margin, indentText);
27603                             break;
27604                         case "typedef":
27605                             tag = parseTypedefTag(start, tagName, margin, indentText);
27606                             break;
27607                         case "callback":
27608                             tag = parseCallbackTag(start, tagName, margin, indentText);
27609                             break;
27610                         case "see":
27611                             tag = parseSeeTag(start, tagName, margin, indentText);
27612                             break;
27613                         default:
27614                             tag = parseUnknownTag(start, tagName, margin, indentText);
27615                             break;
27616                     }
27617                     return tag;
27618                 }
27619                 function parseTrailingTagComments(pos, end, margin, indentText) {
27620                     if (!indentText) {
27621                         margin += end - pos;
27622                     }
27623                     return parseTagComments(margin, indentText.slice(margin));
27624                 }
27625                 function parseTagComments(indent, initialMargin) {
27626                     var comments = [];
27627                     var state = 0;
27628                     var margin;
27629                     function pushComment(text) {
27630                         if (!margin) {
27631                             margin = indent;
27632                         }
27633                         comments.push(text);
27634                         indent += text.length;
27635                     }
27636                     if (initialMargin !== undefined) {
27637                         if (initialMargin !== "") {
27638                             pushComment(initialMargin);
27639                         }
27640                         state = 1;
27641                     }
27642                     var tok = token();
27643                     loop: while (true) {
27644                         switch (tok) {
27645                             case 4:
27646                                 state = 0;
27647                                 comments.push(scanner.getTokenText());
27648                                 indent = 0;
27649                                 break;
27650                             case 59:
27651                                 if (state === 3) {
27652                                     comments.push(scanner.getTokenText());
27653                                     break;
27654                                 }
27655                                 scanner.setTextPos(scanner.getTextPos() - 1);
27656                             case 1:
27657                                 break loop;
27658                             case 5:
27659                                 if (state === 2 || state === 3) {
27660                                     pushComment(scanner.getTokenText());
27661                                 }
27662                                 else {
27663                                     var whitespace = scanner.getTokenText();
27664                                     if (margin !== undefined && indent + whitespace.length > margin) {
27665                                         comments.push(whitespace.slice(margin - indent));
27666                                     }
27667                                     indent += whitespace.length;
27668                                 }
27669                                 break;
27670                             case 18:
27671                                 state = 2;
27672                                 if (lookAhead(function () { return nextTokenJSDoc() === 59 && ts.tokenIsIdentifierOrKeyword(nextTokenJSDoc()) && scanner.getTokenText() === "link"; })) {
27673                                     pushComment(scanner.getTokenText());
27674                                     nextTokenJSDoc();
27675                                     pushComment(scanner.getTokenText());
27676                                     nextTokenJSDoc();
27677                                 }
27678                                 pushComment(scanner.getTokenText());
27679                                 break;
27680                             case 61:
27681                                 if (state === 3) {
27682                                     state = 2;
27683                                 }
27684                                 else {
27685                                     state = 3;
27686                                 }
27687                                 pushComment(scanner.getTokenText());
27688                                 break;
27689                             case 41:
27690                                 if (state === 0) {
27691                                     state = 1;
27692                                     indent += 1;
27693                                     break;
27694                                 }
27695                             default:
27696                                 if (state !== 3) {
27697                                     state = 2;
27698                                 }
27699                                 pushComment(scanner.getTokenText());
27700                                 break;
27701                         }
27702                         tok = nextTokenJSDoc();
27703                     }
27704                     removeLeadingNewlines(comments);
27705                     removeTrailingWhitespace(comments);
27706                     return comments.length === 0 ? undefined : comments.join("");
27707                 }
27708                 function parseUnknownTag(start, tagName, indent, indentText) {
27709                     var end = getNodePos();
27710                     return finishNode(factory.createJSDocUnknownTag(tagName, parseTrailingTagComments(start, end, indent, indentText)), start, end);
27711                 }
27712                 function addTag(tag) {
27713                     if (!tag) {
27714                         return;
27715                     }
27716                     if (!tags) {
27717                         tags = [tag];
27718                         tagsPos = tag.pos;
27719                     }
27720                     else {
27721                         tags.push(tag);
27722                     }
27723                     tagsEnd = tag.end;
27724                 }
27725                 function tryParseTypeExpression() {
27726                     skipWhitespaceOrAsterisk();
27727                     return token() === 18 ? parseJSDocTypeExpression() : undefined;
27728                 }
27729                 function parseBracketNameInPropertyAndParamTag() {
27730                     var isBracketed = parseOptionalJsdoc(22);
27731                     if (isBracketed) {
27732                         skipWhitespace();
27733                     }
27734                     var isBackquoted = parseOptionalJsdoc(61);
27735                     var name = parseJSDocEntityName();
27736                     if (isBackquoted) {
27737                         parseExpectedTokenJSDoc(61);
27738                     }
27739                     if (isBracketed) {
27740                         skipWhitespace();
27741                         if (parseOptionalToken(62)) {
27742                             parseExpression();
27743                         }
27744                         parseExpected(23);
27745                     }
27746                     return { name: name, isBracketed: isBracketed };
27747                 }
27748                 function isObjectOrObjectArrayTypeReference(node) {
27749                     switch (node.kind) {
27750                         case 145:
27751                             return true;
27752                         case 178:
27753                             return isObjectOrObjectArrayTypeReference(node.elementType);
27754                         default:
27755                             return ts.isTypeReferenceNode(node) && ts.isIdentifier(node.typeName) && node.typeName.escapedText === "Object" && !node.typeArguments;
27756                     }
27757                 }
27758                 function parseParameterOrPropertyTag(start, tagName, target, indent) {
27759                     var typeExpression = tryParseTypeExpression();
27760                     var isNameFirst = !typeExpression;
27761                     skipWhitespaceOrAsterisk();
27762                     var _a = parseBracketNameInPropertyAndParamTag(), name = _a.name, isBracketed = _a.isBracketed;
27763                     skipWhitespace();
27764                     if (isNameFirst) {
27765                         typeExpression = tryParseTypeExpression();
27766                     }
27767                     var comment = parseTagComments(indent + scanner.getStartPos() - start);
27768                     var nestedTypeLiteral = target !== 4 && parseNestedTypeLiteral(typeExpression, name, target, indent);
27769                     if (nestedTypeLiteral) {
27770                         typeExpression = nestedTypeLiteral;
27771                         isNameFirst = true;
27772                     }
27773                     var result = target === 1
27774                         ? factory.createJSDocPropertyTag(tagName, name, isBracketed, typeExpression, isNameFirst, comment)
27775                         : factory.createJSDocParameterTag(tagName, name, isBracketed, typeExpression, isNameFirst, comment);
27776                     return finishNode(result, start);
27777                 }
27778                 function parseNestedTypeLiteral(typeExpression, name, target, indent) {
27779                     if (typeExpression && isObjectOrObjectArrayTypeReference(typeExpression.type)) {
27780                         var pos = getNodePos();
27781                         var child = void 0;
27782                         var children = void 0;
27783                         while (child = tryParse(function () { return parseChildParameterOrPropertyTag(target, indent, name); })) {
27784                             if (child.kind === 326 || child.kind === 333) {
27785                                 children = ts.append(children, child);
27786                             }
27787                         }
27788                         if (children) {
27789                             var literal = finishNode(factory.createJSDocTypeLiteral(children, typeExpression.type.kind === 178), pos);
27790                             return finishNode(factory.createJSDocTypeExpression(literal), pos);
27791                         }
27792                     }
27793                 }
27794                 function parseReturnTag(start, tagName, indent, indentText) {
27795                     if (ts.some(tags, ts.isJSDocReturnTag)) {
27796                         parseErrorAt(tagName.pos, scanner.getTokenPos(), ts.Diagnostics._0_tag_already_specified, tagName.escapedText);
27797                     }
27798                     var typeExpression = tryParseTypeExpression();
27799                     var end = getNodePos();
27800                     return finishNode(factory.createJSDocReturnTag(tagName, typeExpression, parseTrailingTagComments(start, end, indent, indentText)), start, end);
27801                 }
27802                 function parseTypeTag(start, tagName, indent, indentText) {
27803                     if (ts.some(tags, ts.isJSDocTypeTag)) {
27804                         parseErrorAt(tagName.pos, scanner.getTokenPos(), ts.Diagnostics._0_tag_already_specified, tagName.escapedText);
27805                     }
27806                     var typeExpression = parseJSDocTypeExpression(true);
27807                     var end = getNodePos();
27808                     var comments = indent !== undefined && indentText !== undefined ? parseTrailingTagComments(start, end, indent, indentText) : undefined;
27809                     return finishNode(factory.createJSDocTypeTag(tagName, typeExpression, comments), start, end);
27810                 }
27811                 function parseSeeTag(start, tagName, indent, indentText) {
27812                     var nameExpression = parseJSDocNameReference();
27813                     var end = getNodePos();
27814                     var comments = indent !== undefined && indentText !== undefined ? parseTrailingTagComments(start, end, indent, indentText) : undefined;
27815                     return finishNode(factory.createJSDocSeeTag(tagName, nameExpression, comments), start, end);
27816                 }
27817                 function parseAuthorTag(start, tagName, indent, indentText) {
27818                     var authorInfoWithEmail = tryParse(function () { return tryParseAuthorNameAndEmail(); });
27819                     if (!authorInfoWithEmail) {
27820                         var end_1 = getNodePos();
27821                         return finishNode(factory.createJSDocAuthorTag(tagName, parseTrailingTagComments(start, end_1, indent, indentText)), start, end_1);
27822                     }
27823                     var comments = authorInfoWithEmail;
27824                     if (lookAhead(function () { return nextToken() !== 4; })) {
27825                         var comment = parseTagComments(indent);
27826                         if (comment) {
27827                             comments += comment;
27828                         }
27829                     }
27830                     return finishNode(factory.createJSDocAuthorTag(tagName, comments), start);
27831                 }
27832                 function tryParseAuthorNameAndEmail() {
27833                     var comments = [];
27834                     var seenLessThan = false;
27835                     var seenGreaterThan = false;
27836                     var token = scanner.getToken();
27837                     loop: while (true) {
27838                         switch (token) {
27839                             case 78:
27840                             case 5:
27841                             case 24:
27842                             case 59:
27843                                 comments.push(scanner.getTokenText());
27844                                 break;
27845                             case 29:
27846                                 if (seenLessThan || seenGreaterThan) {
27847                                     return;
27848                                 }
27849                                 seenLessThan = true;
27850                                 comments.push(scanner.getTokenText());
27851                                 break;
27852                             case 31:
27853                                 if (!seenLessThan || seenGreaterThan) {
27854                                     return;
27855                                 }
27856                                 seenGreaterThan = true;
27857                                 comments.push(scanner.getTokenText());
27858                                 scanner.setTextPos(scanner.getTokenPos() + 1);
27859                                 break loop;
27860                             case 4:
27861                             case 1:
27862                                 break loop;
27863                         }
27864                         token = nextTokenJSDoc();
27865                     }
27866                     if (seenLessThan && seenGreaterThan) {
27867                         return comments.length === 0 ? undefined : comments.join("");
27868                     }
27869                 }
27870                 function parseImplementsTag(start, tagName, margin, indentText) {
27871                     var className = parseExpressionWithTypeArgumentsForAugments();
27872                     var end = getNodePos();
27873                     return finishNode(factory.createJSDocImplementsTag(tagName, className, parseTrailingTagComments(start, end, margin, indentText)), start, end);
27874                 }
27875                 function parseAugmentsTag(start, tagName, margin, indentText) {
27876                     var className = parseExpressionWithTypeArgumentsForAugments();
27877                     var end = getNodePos();
27878                     return finishNode(factory.createJSDocAugmentsTag(tagName, className, parseTrailingTagComments(start, end, margin, indentText)), start, end);
27879                 }
27880                 function parseExpressionWithTypeArgumentsForAugments() {
27881                     var usedBrace = parseOptional(18);
27882                     var pos = getNodePos();
27883                     var expression = parsePropertyAccessEntityNameExpression();
27884                     var typeArguments = tryParseTypeArguments();
27885                     var node = factory.createExpressionWithTypeArguments(expression, typeArguments);
27886                     var res = finishNode(node, pos);
27887                     if (usedBrace) {
27888                         parseExpected(19);
27889                     }
27890                     return res;
27891                 }
27892                 function parsePropertyAccessEntityNameExpression() {
27893                     var pos = getNodePos();
27894                     var node = parseJSDocIdentifierName();
27895                     while (parseOptional(24)) {
27896                         var name = parseJSDocIdentifierName();
27897                         node = finishNode(factory.createPropertyAccessExpression(node, name), pos);
27898                     }
27899                     return node;
27900                 }
27901                 function parseSimpleTag(start, createTag, tagName, margin, indentText) {
27902                     var end = getNodePos();
27903                     return finishNode(createTag(tagName, parseTrailingTagComments(start, end, margin, indentText)), start, end);
27904                 }
27905                 function parseThisTag(start, tagName, margin, indentText) {
27906                     var typeExpression = parseJSDocTypeExpression(true);
27907                     skipWhitespace();
27908                     var end = getNodePos();
27909                     return finishNode(factory.createJSDocThisTag(tagName, typeExpression, parseTrailingTagComments(start, end, margin, indentText)), start, end);
27910                 }
27911                 function parseEnumTag(start, tagName, margin, indentText) {
27912                     var typeExpression = parseJSDocTypeExpression(true);
27913                     skipWhitespace();
27914                     var end = getNodePos();
27915                     return finishNode(factory.createJSDocEnumTag(tagName, typeExpression, parseTrailingTagComments(start, end, margin, indentText)), start, end);
27916                 }
27917                 function parseTypedefTag(start, tagName, indent, indentText) {
27918                     var _a;
27919                     var typeExpression = tryParseTypeExpression();
27920                     skipWhitespaceOrAsterisk();
27921                     var fullName = parseJSDocTypeNameWithNamespace();
27922                     skipWhitespace();
27923                     var comment = parseTagComments(indent);
27924                     var end;
27925                     if (!typeExpression || isObjectOrObjectArrayTypeReference(typeExpression.type)) {
27926                         var child = void 0;
27927                         var childTypeTag = void 0;
27928                         var jsDocPropertyTags = void 0;
27929                         var hasChildren = false;
27930                         while (child = tryParse(function () { return parseChildPropertyTag(indent); })) {
27931                             hasChildren = true;
27932                             if (child.kind === 329) {
27933                                 if (childTypeTag) {
27934                                     parseErrorAtCurrentToken(ts.Diagnostics.A_JSDoc_typedef_comment_may_not_contain_multiple_type_tags);
27935                                     var lastError = ts.lastOrUndefined(parseDiagnostics);
27936                                     if (lastError) {
27937                                         ts.addRelatedInfo(lastError, ts.createDetachedDiagnostic(fileName, 0, 0, ts.Diagnostics.The_tag_was_first_specified_here));
27938                                     }
27939                                     break;
27940                                 }
27941                                 else {
27942                                     childTypeTag = child;
27943                                 }
27944                             }
27945                             else {
27946                                 jsDocPropertyTags = ts.append(jsDocPropertyTags, child);
27947                             }
27948                         }
27949                         if (hasChildren) {
27950                             var isArrayType = typeExpression && typeExpression.type.kind === 178;
27951                             var jsdocTypeLiteral = factory.createJSDocTypeLiteral(jsDocPropertyTags, isArrayType);
27952                             typeExpression = childTypeTag && childTypeTag.typeExpression && !isObjectOrObjectArrayTypeReference(childTypeTag.typeExpression.type) ?
27953                                 childTypeTag.typeExpression :
27954                                 finishNode(jsdocTypeLiteral, start);
27955                             end = typeExpression.end;
27956                         }
27957                     }
27958                     end = end || comment !== undefined ?
27959                         getNodePos() :
27960                         ((_a = fullName !== null && fullName !== void 0 ? fullName : typeExpression) !== null && _a !== void 0 ? _a : tagName).end;
27961                     if (!comment) {
27962                         comment = parseTrailingTagComments(start, end, indent, indentText);
27963                     }
27964                     var typedefTag = factory.createJSDocTypedefTag(tagName, typeExpression, fullName, comment);
27965                     return finishNode(typedefTag, start, end);
27966                 }
27967                 function parseJSDocTypeNameWithNamespace(nested) {
27968                     var pos = scanner.getTokenPos();
27969                     if (!ts.tokenIsIdentifierOrKeyword(token())) {
27970                         return undefined;
27971                     }
27972                     var typeNameOrNamespaceName = parseJSDocIdentifierName();
27973                     if (parseOptional(24)) {
27974                         var body = parseJSDocTypeNameWithNamespace(true);
27975                         var jsDocNamespaceNode = factory.createModuleDeclaration(undefined, undefined, typeNameOrNamespaceName, body, nested ? 4 : undefined);
27976                         return finishNode(jsDocNamespaceNode, pos);
27977                     }
27978                     if (nested) {
27979                         typeNameOrNamespaceName.isInJSDocNamespace = true;
27980                     }
27981                     return typeNameOrNamespaceName;
27982                 }
27983                 function parseCallbackTagParameters(indent) {
27984                     var pos = getNodePos();
27985                     var child;
27986                     var parameters;
27987                     while (child = tryParse(function () { return parseChildParameterOrPropertyTag(4, indent); })) {
27988                         parameters = ts.append(parameters, child);
27989                     }
27990                     return createNodeArray(parameters || [], pos);
27991                 }
27992                 function parseCallbackTag(start, tagName, indent, indentText) {
27993                     var fullName = parseJSDocTypeNameWithNamespace();
27994                     skipWhitespace();
27995                     var comment = parseTagComments(indent);
27996                     var parameters = parseCallbackTagParameters(indent);
27997                     var returnTag = tryParse(function () {
27998                         if (parseOptionalJsdoc(59)) {
27999                             var tag = parseTag(indent);
28000                             if (tag && tag.kind === 327) {
28001                                 return tag;
28002                             }
28003                         }
28004                     });
28005                     var typeExpression = finishNode(factory.createJSDocSignature(undefined, parameters, returnTag), start);
28006                     var end = getNodePos();
28007                     if (!comment) {
28008                         comment = parseTrailingTagComments(start, end, indent, indentText);
28009                     }
28010                     return finishNode(factory.createJSDocCallbackTag(tagName, typeExpression, fullName, comment), start, end);
28011                 }
28012                 function escapedTextsEqual(a, b) {
28013                     while (!ts.isIdentifier(a) || !ts.isIdentifier(b)) {
28014                         if (!ts.isIdentifier(a) && !ts.isIdentifier(b) && a.right.escapedText === b.right.escapedText) {
28015                             a = a.left;
28016                             b = b.left;
28017                         }
28018                         else {
28019                             return false;
28020                         }
28021                     }
28022                     return a.escapedText === b.escapedText;
28023                 }
28024                 function parseChildPropertyTag(indent) {
28025                     return parseChildParameterOrPropertyTag(1, indent);
28026                 }
28027                 function parseChildParameterOrPropertyTag(target, indent, name) {
28028                     var canParseTag = true;
28029                     var seenAsterisk = false;
28030                     while (true) {
28031                         switch (nextTokenJSDoc()) {
28032                             case 59:
28033                                 if (canParseTag) {
28034                                     var child = tryParseChildTag(target, indent);
28035                                     if (child && (child.kind === 326 || child.kind === 333) &&
28036                                         target !== 4 &&
28037                                         name && (ts.isIdentifier(child.name) || !escapedTextsEqual(name, child.name.left))) {
28038                                         return false;
28039                                     }
28040                                     return child;
28041                                 }
28042                                 seenAsterisk = false;
28043                                 break;
28044                             case 4:
28045                                 canParseTag = true;
28046                                 seenAsterisk = false;
28047                                 break;
28048                             case 41:
28049                                 if (seenAsterisk) {
28050                                     canParseTag = false;
28051                                 }
28052                                 seenAsterisk = true;
28053                                 break;
28054                             case 78:
28055                                 canParseTag = false;
28056                                 break;
28057                             case 1:
28058                                 return false;
28059                         }
28060                     }
28061                 }
28062                 function tryParseChildTag(target, indent) {
28063                     ts.Debug.assert(token() === 59);
28064                     var start = scanner.getStartPos();
28065                     nextTokenJSDoc();
28066                     var tagName = parseJSDocIdentifierName();
28067                     skipWhitespace();
28068                     var t;
28069                     switch (tagName.escapedText) {
28070                         case "type":
28071                             return target === 1 && parseTypeTag(start, tagName);
28072                         case "prop":
28073                         case "property":
28074                             t = 1;
28075                             break;
28076                         case "arg":
28077                         case "argument":
28078                         case "param":
28079                             t = 2 | 4;
28080                             break;
28081                         default:
28082                             return false;
28083                     }
28084                     if (!(target & t)) {
28085                         return false;
28086                     }
28087                     return parseParameterOrPropertyTag(start, tagName, target, indent);
28088                 }
28089                 function parseTemplateTagTypeParameter() {
28090                     var typeParameterPos = getNodePos();
28091                     var name = parseJSDocIdentifierName(ts.Diagnostics.Unexpected_token_A_type_parameter_name_was_expected_without_curly_braces);
28092                     return finishNode(factory.createTypeParameterDeclaration(name, undefined, undefined), typeParameterPos);
28093                 }
28094                 function parseTemplateTagTypeParameters() {
28095                     var pos = getNodePos();
28096                     var typeParameters = [];
28097                     do {
28098                         skipWhitespace();
28099                         typeParameters.push(parseTemplateTagTypeParameter());
28100                         skipWhitespaceOrAsterisk();
28101                     } while (parseOptionalJsdoc(27));
28102                     return createNodeArray(typeParameters, pos);
28103                 }
28104                 function parseTemplateTag(start, tagName, indent, indentText) {
28105                     var constraint = token() === 18 ? parseJSDocTypeExpression() : undefined;
28106                     var typeParameters = parseTemplateTagTypeParameters();
28107                     var end = getNodePos();
28108                     return finishNode(factory.createJSDocTemplateTag(tagName, constraint, typeParameters, parseTrailingTagComments(start, end, indent, indentText)), start, end);
28109                 }
28110                 function parseOptionalJsdoc(t) {
28111                     if (token() === t) {
28112                         nextTokenJSDoc();
28113                         return true;
28114                     }
28115                     return false;
28116                 }
28117                 function parseJSDocEntityName() {
28118                     var entity = parseJSDocIdentifierName();
28119                     if (parseOptional(22)) {
28120                         parseExpected(23);
28121                     }
28122                     while (parseOptional(24)) {
28123                         var name = parseJSDocIdentifierName();
28124                         if (parseOptional(22)) {
28125                             parseExpected(23);
28126                         }
28127                         entity = createQualifiedName(entity, name);
28128                     }
28129                     return entity;
28130                 }
28131                 function parseJSDocIdentifierName(message) {
28132                     if (!ts.tokenIsIdentifierOrKeyword(token())) {
28133                         return createMissingNode(78, !message, message || ts.Diagnostics.Identifier_expected);
28134                     }
28135                     identifierCount++;
28136                     var pos = scanner.getTokenPos();
28137                     var end = scanner.getTextPos();
28138                     var originalKeywordKind = token();
28139                     var text = internIdentifier(scanner.getTokenValue());
28140                     var result = finishNode(factory.createIdentifier(text, undefined, originalKeywordKind), pos, end);
28141                     nextTokenJSDoc();
28142                     return result;
28143                 }
28144             }
28145         })(JSDocParser = Parser.JSDocParser || (Parser.JSDocParser = {}));
28146     })(Parser || (Parser = {}));
28147     var IncrementalParser;
28148     (function (IncrementalParser) {
28149         function updateSourceFile(sourceFile, newText, textChangeRange, aggressiveChecks) {
28150             aggressiveChecks = aggressiveChecks || ts.Debug.shouldAssert(2);
28151             checkChangeRange(sourceFile, newText, textChangeRange, aggressiveChecks);
28152             if (ts.textChangeRangeIsUnchanged(textChangeRange)) {
28153                 return sourceFile;
28154             }
28155             if (sourceFile.statements.length === 0) {
28156                 return Parser.parseSourceFile(sourceFile.fileName, newText, sourceFile.languageVersion, undefined, true, sourceFile.scriptKind);
28157             }
28158             var incrementalSourceFile = sourceFile;
28159             ts.Debug.assert(!incrementalSourceFile.hasBeenIncrementallyParsed);
28160             incrementalSourceFile.hasBeenIncrementallyParsed = true;
28161             Parser.fixupParentReferences(incrementalSourceFile);
28162             var oldText = sourceFile.text;
28163             var syntaxCursor = createSyntaxCursor(sourceFile);
28164             var changeRange = extendToAffectedRange(sourceFile, textChangeRange);
28165             checkChangeRange(sourceFile, newText, changeRange, aggressiveChecks);
28166             ts.Debug.assert(changeRange.span.start <= textChangeRange.span.start);
28167             ts.Debug.assert(ts.textSpanEnd(changeRange.span) === ts.textSpanEnd(textChangeRange.span));
28168             ts.Debug.assert(ts.textSpanEnd(ts.textChangeRangeNewSpan(changeRange)) === ts.textSpanEnd(ts.textChangeRangeNewSpan(textChangeRange)));
28169             var delta = ts.textChangeRangeNewSpan(changeRange).length - changeRange.span.length;
28170             updateTokenPositionsAndMarkElements(incrementalSourceFile, changeRange.span.start, ts.textSpanEnd(changeRange.span), ts.textSpanEnd(ts.textChangeRangeNewSpan(changeRange)), delta, oldText, newText, aggressiveChecks);
28171             var result = Parser.parseSourceFile(sourceFile.fileName, newText, sourceFile.languageVersion, syntaxCursor, true, sourceFile.scriptKind);
28172             result.commentDirectives = getNewCommentDirectives(sourceFile.commentDirectives, result.commentDirectives, changeRange.span.start, ts.textSpanEnd(changeRange.span), delta, oldText, newText, aggressiveChecks);
28173             return result;
28174         }
28175         IncrementalParser.updateSourceFile = updateSourceFile;
28176         function getNewCommentDirectives(oldDirectives, newDirectives, changeStart, changeRangeOldEnd, delta, oldText, newText, aggressiveChecks) {
28177             if (!oldDirectives)
28178                 return newDirectives;
28179             var commentDirectives;
28180             var addedNewlyScannedDirectives = false;
28181             for (var _i = 0, oldDirectives_1 = oldDirectives; _i < oldDirectives_1.length; _i++) {
28182                 var directive = oldDirectives_1[_i];
28183                 var range = directive.range, type = directive.type;
28184                 if (range.end < changeStart) {
28185                     commentDirectives = ts.append(commentDirectives, directive);
28186                 }
28187                 else if (range.pos > changeRangeOldEnd) {
28188                     addNewlyScannedDirectives();
28189                     var updatedDirective = {
28190                         range: { pos: range.pos + delta, end: range.end + delta },
28191                         type: type
28192                     };
28193                     commentDirectives = ts.append(commentDirectives, updatedDirective);
28194                     if (aggressiveChecks) {
28195                         ts.Debug.assert(oldText.substring(range.pos, range.end) === newText.substring(updatedDirective.range.pos, updatedDirective.range.end));
28196                     }
28197                 }
28198             }
28199             addNewlyScannedDirectives();
28200             return commentDirectives;
28201             function addNewlyScannedDirectives() {
28202                 if (addedNewlyScannedDirectives)
28203                     return;
28204                 addedNewlyScannedDirectives = true;
28205                 if (!commentDirectives) {
28206                     commentDirectives = newDirectives;
28207                 }
28208                 else if (newDirectives) {
28209                     commentDirectives.push.apply(commentDirectives, newDirectives);
28210                 }
28211             }
28212         }
28213         function moveElementEntirelyPastChangeRange(element, isArray, delta, oldText, newText, aggressiveChecks) {
28214             if (isArray) {
28215                 visitArray(element);
28216             }
28217             else {
28218                 visitNode(element);
28219             }
28220             return;
28221             function visitNode(node) {
28222                 var text = "";
28223                 if (aggressiveChecks && shouldCheckNode(node)) {
28224                     text = oldText.substring(node.pos, node.end);
28225                 }
28226                 if (node._children) {
28227                     node._children = undefined;
28228                 }
28229                 ts.setTextRangePosEnd(node, node.pos + delta, node.end + delta);
28230                 if (aggressiveChecks && shouldCheckNode(node)) {
28231                     ts.Debug.assert(text === newText.substring(node.pos, node.end));
28232                 }
28233                 forEachChild(node, visitNode, visitArray);
28234                 if (ts.hasJSDocNodes(node)) {
28235                     for (var _i = 0, _a = node.jsDoc; _i < _a.length; _i++) {
28236                         var jsDocComment = _a[_i];
28237                         visitNode(jsDocComment);
28238                     }
28239                 }
28240                 checkNodePositions(node, aggressiveChecks);
28241             }
28242             function visitArray(array) {
28243                 array._children = undefined;
28244                 ts.setTextRangePosEnd(array, array.pos + delta, array.end + delta);
28245                 for (var _i = 0, array_8 = array; _i < array_8.length; _i++) {
28246                     var node = array_8[_i];
28247                     visitNode(node);
28248                 }
28249             }
28250         }
28251         function shouldCheckNode(node) {
28252             switch (node.kind) {
28253                 case 10:
28254                 case 8:
28255                 case 78:
28256                     return true;
28257             }
28258             return false;
28259         }
28260         function adjustIntersectingElement(element, changeStart, changeRangeOldEnd, changeRangeNewEnd, delta) {
28261             ts.Debug.assert(element.end >= changeStart, "Adjusting an element that was entirely before the change range");
28262             ts.Debug.assert(element.pos <= changeRangeOldEnd, "Adjusting an element that was entirely after the change range");
28263             ts.Debug.assert(element.pos <= element.end);
28264             var pos = Math.min(element.pos, changeRangeNewEnd);
28265             var end = element.end >= changeRangeOldEnd ?
28266                 element.end + delta :
28267                 Math.min(element.end, changeRangeNewEnd);
28268             ts.Debug.assert(pos <= end);
28269             if (element.parent) {
28270                 ts.Debug.assertGreaterThanOrEqual(pos, element.parent.pos);
28271                 ts.Debug.assertLessThanOrEqual(end, element.parent.end);
28272             }
28273             ts.setTextRangePosEnd(element, pos, end);
28274         }
28275         function checkNodePositions(node, aggressiveChecks) {
28276             if (aggressiveChecks) {
28277                 var pos_2 = node.pos;
28278                 var visitNode_1 = function (child) {
28279                     ts.Debug.assert(child.pos >= pos_2);
28280                     pos_2 = child.end;
28281                 };
28282                 if (ts.hasJSDocNodes(node)) {
28283                     for (var _i = 0, _a = node.jsDoc; _i < _a.length; _i++) {
28284                         var jsDocComment = _a[_i];
28285                         visitNode_1(jsDocComment);
28286                     }
28287                 }
28288                 forEachChild(node, visitNode_1);
28289                 ts.Debug.assert(pos_2 <= node.end);
28290             }
28291         }
28292         function updateTokenPositionsAndMarkElements(sourceFile, changeStart, changeRangeOldEnd, changeRangeNewEnd, delta, oldText, newText, aggressiveChecks) {
28293             visitNode(sourceFile);
28294             return;
28295             function visitNode(child) {
28296                 ts.Debug.assert(child.pos <= child.end);
28297                 if (child.pos > changeRangeOldEnd) {
28298                     moveElementEntirelyPastChangeRange(child, false, delta, oldText, newText, aggressiveChecks);
28299                     return;
28300                 }
28301                 var fullEnd = child.end;
28302                 if (fullEnd >= changeStart) {
28303                     child.intersectsChange = true;
28304                     child._children = undefined;
28305                     adjustIntersectingElement(child, changeStart, changeRangeOldEnd, changeRangeNewEnd, delta);
28306                     forEachChild(child, visitNode, visitArray);
28307                     if (ts.hasJSDocNodes(child)) {
28308                         for (var _i = 0, _a = child.jsDoc; _i < _a.length; _i++) {
28309                             var jsDocComment = _a[_i];
28310                             visitNode(jsDocComment);
28311                         }
28312                     }
28313                     checkNodePositions(child, aggressiveChecks);
28314                     return;
28315                 }
28316                 ts.Debug.assert(fullEnd < changeStart);
28317             }
28318             function visitArray(array) {
28319                 ts.Debug.assert(array.pos <= array.end);
28320                 if (array.pos > changeRangeOldEnd) {
28321                     moveElementEntirelyPastChangeRange(array, true, delta, oldText, newText, aggressiveChecks);
28322                     return;
28323                 }
28324                 var fullEnd = array.end;
28325                 if (fullEnd >= changeStart) {
28326                     array.intersectsChange = true;
28327                     array._children = undefined;
28328                     adjustIntersectingElement(array, changeStart, changeRangeOldEnd, changeRangeNewEnd, delta);
28329                     for (var _i = 0, array_9 = array; _i < array_9.length; _i++) {
28330                         var node = array_9[_i];
28331                         visitNode(node);
28332                     }
28333                     return;
28334                 }
28335                 ts.Debug.assert(fullEnd < changeStart);
28336             }
28337         }
28338         function extendToAffectedRange(sourceFile, changeRange) {
28339             var maxLookahead = 1;
28340             var start = changeRange.span.start;
28341             for (var i = 0; start > 0 && i <= maxLookahead; i++) {
28342                 var nearestNode = findNearestNodeStartingBeforeOrAtPosition(sourceFile, start);
28343                 ts.Debug.assert(nearestNode.pos <= start);
28344                 var position = nearestNode.pos;
28345                 start = Math.max(0, position - 1);
28346             }
28347             var finalSpan = ts.createTextSpanFromBounds(start, ts.textSpanEnd(changeRange.span));
28348             var finalLength = changeRange.newLength + (changeRange.span.start - start);
28349             return ts.createTextChangeRange(finalSpan, finalLength);
28350         }
28351         function findNearestNodeStartingBeforeOrAtPosition(sourceFile, position) {
28352             var bestResult = sourceFile;
28353             var lastNodeEntirelyBeforePosition;
28354             forEachChild(sourceFile, visit);
28355             if (lastNodeEntirelyBeforePosition) {
28356                 var lastChildOfLastEntireNodeBeforePosition = getLastDescendant(lastNodeEntirelyBeforePosition);
28357                 if (lastChildOfLastEntireNodeBeforePosition.pos > bestResult.pos) {
28358                     bestResult = lastChildOfLastEntireNodeBeforePosition;
28359                 }
28360             }
28361             return bestResult;
28362             function getLastDescendant(node) {
28363                 while (true) {
28364                     var lastChild = ts.getLastChild(node);
28365                     if (lastChild) {
28366                         node = lastChild;
28367                     }
28368                     else {
28369                         return node;
28370                     }
28371                 }
28372             }
28373             function visit(child) {
28374                 if (ts.nodeIsMissing(child)) {
28375                     return;
28376                 }
28377                 if (child.pos <= position) {
28378                     if (child.pos >= bestResult.pos) {
28379                         bestResult = child;
28380                     }
28381                     if (position < child.end) {
28382                         forEachChild(child, visit);
28383                         return true;
28384                     }
28385                     else {
28386                         ts.Debug.assert(child.end <= position);
28387                         lastNodeEntirelyBeforePosition = child;
28388                     }
28389                 }
28390                 else {
28391                     ts.Debug.assert(child.pos > position);
28392                     return true;
28393                 }
28394             }
28395         }
28396         function checkChangeRange(sourceFile, newText, textChangeRange, aggressiveChecks) {
28397             var oldText = sourceFile.text;
28398             if (textChangeRange) {
28399                 ts.Debug.assert((oldText.length - textChangeRange.span.length + textChangeRange.newLength) === newText.length);
28400                 if (aggressiveChecks || ts.Debug.shouldAssert(3)) {
28401                     var oldTextPrefix = oldText.substr(0, textChangeRange.span.start);
28402                     var newTextPrefix = newText.substr(0, textChangeRange.span.start);
28403                     ts.Debug.assert(oldTextPrefix === newTextPrefix);
28404                     var oldTextSuffix = oldText.substring(ts.textSpanEnd(textChangeRange.span), oldText.length);
28405                     var newTextSuffix = newText.substring(ts.textSpanEnd(ts.textChangeRangeNewSpan(textChangeRange)), newText.length);
28406                     ts.Debug.assert(oldTextSuffix === newTextSuffix);
28407                 }
28408             }
28409         }
28410         function createSyntaxCursor(sourceFile) {
28411             var currentArray = sourceFile.statements;
28412             var currentArrayIndex = 0;
28413             ts.Debug.assert(currentArrayIndex < currentArray.length);
28414             var current = currentArray[currentArrayIndex];
28415             var lastQueriedPosition = -1;
28416             return {
28417                 currentNode: function (position) {
28418                     if (position !== lastQueriedPosition) {
28419                         if (current && current.end === position && currentArrayIndex < (currentArray.length - 1)) {
28420                             currentArrayIndex++;
28421                             current = currentArray[currentArrayIndex];
28422                         }
28423                         if (!current || current.pos !== position) {
28424                             findHighestListElementThatStartsAtPosition(position);
28425                         }
28426                     }
28427                     lastQueriedPosition = position;
28428                     ts.Debug.assert(!current || current.pos === position);
28429                     return current;
28430                 }
28431             };
28432             function findHighestListElementThatStartsAtPosition(position) {
28433                 currentArray = undefined;
28434                 currentArrayIndex = -1;
28435                 current = undefined;
28436                 forEachChild(sourceFile, visitNode, visitArray);
28437                 return;
28438                 function visitNode(node) {
28439                     if (position >= node.pos && position < node.end) {
28440                         forEachChild(node, visitNode, visitArray);
28441                         return true;
28442                     }
28443                     return false;
28444                 }
28445                 function visitArray(array) {
28446                     if (position >= array.pos && position < array.end) {
28447                         for (var i = 0; i < array.length; i++) {
28448                             var child = array[i];
28449                             if (child) {
28450                                 if (child.pos === position) {
28451                                     currentArray = array;
28452                                     currentArrayIndex = i;
28453                                     current = child;
28454                                     return true;
28455                                 }
28456                                 else {
28457                                     if (child.pos < position && position < child.end) {
28458                                         forEachChild(child, visitNode, visitArray);
28459                                         return true;
28460                                     }
28461                                 }
28462                             }
28463                         }
28464                     }
28465                     return false;
28466                 }
28467             }
28468         }
28469         IncrementalParser.createSyntaxCursor = createSyntaxCursor;
28470     })(IncrementalParser || (IncrementalParser = {}));
28471     function isDeclarationFileName(fileName) {
28472         return ts.fileExtensionIs(fileName, ".d.ts");
28473     }
28474     ts.isDeclarationFileName = isDeclarationFileName;
28475     function processCommentPragmas(context, sourceText) {
28476         var pragmas = [];
28477         for (var _i = 0, _a = ts.getLeadingCommentRanges(sourceText, 0) || ts.emptyArray; _i < _a.length; _i++) {
28478             var range = _a[_i];
28479             var comment = sourceText.substring(range.pos, range.end);
28480             extractPragmas(pragmas, range, comment);
28481         }
28482         context.pragmas = new ts.Map();
28483         for (var _b = 0, pragmas_1 = pragmas; _b < pragmas_1.length; _b++) {
28484             var pragma = pragmas_1[_b];
28485             if (context.pragmas.has(pragma.name)) {
28486                 var currentValue = context.pragmas.get(pragma.name);
28487                 if (currentValue instanceof Array) {
28488                     currentValue.push(pragma.args);
28489                 }
28490                 else {
28491                     context.pragmas.set(pragma.name, [currentValue, pragma.args]);
28492                 }
28493                 continue;
28494             }
28495             context.pragmas.set(pragma.name, pragma.args);
28496         }
28497     }
28498     ts.processCommentPragmas = processCommentPragmas;
28499     function processPragmasIntoFields(context, reportDiagnostic) {
28500         context.checkJsDirective = undefined;
28501         context.referencedFiles = [];
28502         context.typeReferenceDirectives = [];
28503         context.libReferenceDirectives = [];
28504         context.amdDependencies = [];
28505         context.hasNoDefaultLib = false;
28506         context.pragmas.forEach(function (entryOrList, key) {
28507             switch (key) {
28508                 case "reference": {
28509                     var referencedFiles_1 = context.referencedFiles;
28510                     var typeReferenceDirectives_1 = context.typeReferenceDirectives;
28511                     var libReferenceDirectives_1 = context.libReferenceDirectives;
28512                     ts.forEach(ts.toArray(entryOrList), function (arg) {
28513                         var _a = arg.arguments, types = _a.types, lib = _a.lib, path = _a.path;
28514                         if (arg.arguments["no-default-lib"]) {
28515                             context.hasNoDefaultLib = true;
28516                         }
28517                         else if (types) {
28518                             typeReferenceDirectives_1.push({ pos: types.pos, end: types.end, fileName: types.value });
28519                         }
28520                         else if (lib) {
28521                             libReferenceDirectives_1.push({ pos: lib.pos, end: lib.end, fileName: lib.value });
28522                         }
28523                         else if (path) {
28524                             referencedFiles_1.push({ pos: path.pos, end: path.end, fileName: path.value });
28525                         }
28526                         else {
28527                             reportDiagnostic(arg.range.pos, arg.range.end - arg.range.pos, ts.Diagnostics.Invalid_reference_directive_syntax);
28528                         }
28529                     });
28530                     break;
28531                 }
28532                 case "amd-dependency": {
28533                     context.amdDependencies = ts.map(ts.toArray(entryOrList), function (x) { return ({ name: x.arguments.name, path: x.arguments.path }); });
28534                     break;
28535                 }
28536                 case "amd-module": {
28537                     if (entryOrList instanceof Array) {
28538                         for (var _i = 0, entryOrList_1 = entryOrList; _i < entryOrList_1.length; _i++) {
28539                             var entry = entryOrList_1[_i];
28540                             if (context.moduleName) {
28541                                 reportDiagnostic(entry.range.pos, entry.range.end - entry.range.pos, ts.Diagnostics.An_AMD_module_cannot_have_multiple_name_assignments);
28542                             }
28543                             context.moduleName = entry.arguments.name;
28544                         }
28545                     }
28546                     else {
28547                         context.moduleName = entryOrList.arguments.name;
28548                     }
28549                     break;
28550                 }
28551                 case "ts-nocheck":
28552                 case "ts-check": {
28553                     ts.forEach(ts.toArray(entryOrList), function (entry) {
28554                         if (!context.checkJsDirective || entry.range.pos > context.checkJsDirective.pos) {
28555                             context.checkJsDirective = {
28556                                 enabled: key === "ts-check",
28557                                 end: entry.range.end,
28558                                 pos: entry.range.pos
28559                             };
28560                         }
28561                     });
28562                     break;
28563                 }
28564                 case "jsx":
28565                 case "jsxfrag":
28566                 case "jsximportsource":
28567                 case "jsxruntime":
28568                     return;
28569                 default: ts.Debug.fail("Unhandled pragma kind");
28570             }
28571         });
28572     }
28573     ts.processPragmasIntoFields = processPragmasIntoFields;
28574     var namedArgRegExCache = new ts.Map();
28575     function getNamedArgRegEx(name) {
28576         if (namedArgRegExCache.has(name)) {
28577             return namedArgRegExCache.get(name);
28578         }
28579         var result = new RegExp("(\\s" + name + "\\s*=\\s*)('|\")(.+?)\\2", "im");
28580         namedArgRegExCache.set(name, result);
28581         return result;
28582     }
28583     var tripleSlashXMLCommentStartRegEx = /^\/\/\/\s*<(\S+)\s.*?\/>/im;
28584     var singleLinePragmaRegEx = /^\/\/\/?\s*@(\S+)\s*(.*)\s*$/im;
28585     function extractPragmas(pragmas, range, text) {
28586         var tripleSlash = range.kind === 2 && tripleSlashXMLCommentStartRegEx.exec(text);
28587         if (tripleSlash) {
28588             var name = tripleSlash[1].toLowerCase();
28589             var pragma = ts.commentPragmas[name];
28590             if (!pragma || !(pragma.kind & 1)) {
28591                 return;
28592             }
28593             if (pragma.args) {
28594                 var argument = {};
28595                 for (var _i = 0, _a = pragma.args; _i < _a.length; _i++) {
28596                     var arg = _a[_i];
28597                     var matcher = getNamedArgRegEx(arg.name);
28598                     var matchResult = matcher.exec(text);
28599                     if (!matchResult && !arg.optional) {
28600                         return;
28601                     }
28602                     else if (matchResult) {
28603                         if (arg.captureSpan) {
28604                             var startPos = range.pos + matchResult.index + matchResult[1].length + matchResult[2].length;
28605                             argument[arg.name] = {
28606                                 value: matchResult[3],
28607                                 pos: startPos,
28608                                 end: startPos + matchResult[3].length
28609                             };
28610                         }
28611                         else {
28612                             argument[arg.name] = matchResult[3];
28613                         }
28614                     }
28615                 }
28616                 pragmas.push({ name: name, args: { arguments: argument, range: range } });
28617             }
28618             else {
28619                 pragmas.push({ name: name, args: { arguments: {}, range: range } });
28620             }
28621             return;
28622         }
28623         var singleLine = range.kind === 2 && singleLinePragmaRegEx.exec(text);
28624         if (singleLine) {
28625             return addPragmaForMatch(pragmas, range, 2, singleLine);
28626         }
28627         if (range.kind === 3) {
28628             var multiLinePragmaRegEx = /\s*@(\S+)\s*(.*)\s*$/gim;
28629             var multiLineMatch = void 0;
28630             while (multiLineMatch = multiLinePragmaRegEx.exec(text)) {
28631                 addPragmaForMatch(pragmas, range, 4, multiLineMatch);
28632             }
28633         }
28634     }
28635     function addPragmaForMatch(pragmas, range, kind, match) {
28636         if (!match)
28637             return;
28638         var name = match[1].toLowerCase();
28639         var pragma = ts.commentPragmas[name];
28640         if (!pragma || !(pragma.kind & kind)) {
28641             return;
28642         }
28643         var args = match[2];
28644         var argument = getNamedPragmaArguments(pragma, args);
28645         if (argument === "fail")
28646             return;
28647         pragmas.push({ name: name, args: { arguments: argument, range: range } });
28648         return;
28649     }
28650     function getNamedPragmaArguments(pragma, text) {
28651         if (!text)
28652             return {};
28653         if (!pragma.args)
28654             return {};
28655         var args = text.split(/\s+/);
28656         var argMap = {};
28657         for (var i = 0; i < pragma.args.length; i++) {
28658             var argument = pragma.args[i];
28659             if (!args[i] && !argument.optional) {
28660                 return "fail";
28661             }
28662             if (argument.captureSpan) {
28663                 return ts.Debug.fail("Capture spans not yet implemented for non-xml pragmas");
28664             }
28665             argMap[argument.name] = args[i];
28666         }
28667         return argMap;
28668     }
28669     function tagNamesAreEquivalent(lhs, rhs) {
28670         if (lhs.kind !== rhs.kind) {
28671             return false;
28672         }
28673         if (lhs.kind === 78) {
28674             return lhs.escapedText === rhs.escapedText;
28675         }
28676         if (lhs.kind === 107) {
28677             return true;
28678         }
28679         return lhs.name.escapedText === rhs.name.escapedText &&
28680             tagNamesAreEquivalent(lhs.expression, rhs.expression);
28681     }
28682     ts.tagNamesAreEquivalent = tagNamesAreEquivalent;
28683 })(ts || (ts = {}));
28684 var ts;
28685 (function (ts) {
28686     ts.compileOnSaveCommandLineOption = { name: "compileOnSave", type: "boolean" };
28687     var jsxOptionMap = new ts.Map(ts.getEntries({
28688         "preserve": 1,
28689         "react-native": 3,
28690         "react": 2,
28691         "react-jsx": 4,
28692         "react-jsxdev": 5,
28693     }));
28694     ts.inverseJsxOptionMap = new ts.Map(ts.arrayFrom(ts.mapIterator(jsxOptionMap.entries(), function (_a) {
28695         var key = _a[0], value = _a[1];
28696         return ["" + value, key];
28697     })));
28698     var libEntries = [
28699         ["es5", "lib.es5.d.ts"],
28700         ["es6", "lib.es2015.d.ts"],
28701         ["es2015", "lib.es2015.d.ts"],
28702         ["es7", "lib.es2016.d.ts"],
28703         ["es2016", "lib.es2016.d.ts"],
28704         ["es2017", "lib.es2017.d.ts"],
28705         ["es2018", "lib.es2018.d.ts"],
28706         ["es2019", "lib.es2019.d.ts"],
28707         ["es2020", "lib.es2020.d.ts"],
28708         ["esnext", "lib.esnext.d.ts"],
28709         ["dom", "lib.dom.d.ts"],
28710         ["dom.iterable", "lib.dom.iterable.d.ts"],
28711         ["webworker", "lib.webworker.d.ts"],
28712         ["webworker.importscripts", "lib.webworker.importscripts.d.ts"],
28713         ["webworker.iterable", "lib.webworker.iterable.d.ts"],
28714         ["scripthost", "lib.scripthost.d.ts"],
28715         ["es2015.core", "lib.es2015.core.d.ts"],
28716         ["es2015.collection", "lib.es2015.collection.d.ts"],
28717         ["es2015.generator", "lib.es2015.generator.d.ts"],
28718         ["es2015.iterable", "lib.es2015.iterable.d.ts"],
28719         ["es2015.promise", "lib.es2015.promise.d.ts"],
28720         ["es2015.proxy", "lib.es2015.proxy.d.ts"],
28721         ["es2015.reflect", "lib.es2015.reflect.d.ts"],
28722         ["es2015.symbol", "lib.es2015.symbol.d.ts"],
28723         ["es2015.symbol.wellknown", "lib.es2015.symbol.wellknown.d.ts"],
28724         ["es2016.array.include", "lib.es2016.array.include.d.ts"],
28725         ["es2017.object", "lib.es2017.object.d.ts"],
28726         ["es2017.sharedmemory", "lib.es2017.sharedmemory.d.ts"],
28727         ["es2017.string", "lib.es2017.string.d.ts"],
28728         ["es2017.intl", "lib.es2017.intl.d.ts"],
28729         ["es2017.typedarrays", "lib.es2017.typedarrays.d.ts"],
28730         ["es2018.asyncgenerator", "lib.es2018.asyncgenerator.d.ts"],
28731         ["es2018.asynciterable", "lib.es2018.asynciterable.d.ts"],
28732         ["es2018.intl", "lib.es2018.intl.d.ts"],
28733         ["es2018.promise", "lib.es2018.promise.d.ts"],
28734         ["es2018.regexp", "lib.es2018.regexp.d.ts"],
28735         ["es2019.array", "lib.es2019.array.d.ts"],
28736         ["es2019.object", "lib.es2019.object.d.ts"],
28737         ["es2019.string", "lib.es2019.string.d.ts"],
28738         ["es2019.symbol", "lib.es2019.symbol.d.ts"],
28739         ["es2020.bigint", "lib.es2020.bigint.d.ts"],
28740         ["es2020.promise", "lib.es2020.promise.d.ts"],
28741         ["es2020.sharedmemory", "lib.es2020.sharedmemory.d.ts"],
28742         ["es2020.string", "lib.es2020.string.d.ts"],
28743         ["es2020.symbol.wellknown", "lib.es2020.symbol.wellknown.d.ts"],
28744         ["es2020.intl", "lib.es2020.intl.d.ts"],
28745         ["esnext.array", "lib.es2019.array.d.ts"],
28746         ["esnext.symbol", "lib.es2019.symbol.d.ts"],
28747         ["esnext.asynciterable", "lib.es2018.asynciterable.d.ts"],
28748         ["esnext.intl", "lib.esnext.intl.d.ts"],
28749         ["esnext.bigint", "lib.es2020.bigint.d.ts"],
28750         ["esnext.string", "lib.esnext.string.d.ts"],
28751         ["esnext.promise", "lib.esnext.promise.d.ts"],
28752         ["esnext.weakref", "lib.esnext.weakref.d.ts"]
28753     ];
28754     ts.libs = libEntries.map(function (entry) { return entry[0]; });
28755     ts.libMap = new ts.Map(libEntries);
28756     ts.optionsForWatch = [
28757         {
28758             name: "watchFile",
28759             type: new ts.Map(ts.getEntries({
28760                 fixedpollinginterval: ts.WatchFileKind.FixedPollingInterval,
28761                 prioritypollinginterval: ts.WatchFileKind.PriorityPollingInterval,
28762                 dynamicprioritypolling: ts.WatchFileKind.DynamicPriorityPolling,
28763                 usefsevents: ts.WatchFileKind.UseFsEvents,
28764                 usefseventsonparentdirectory: ts.WatchFileKind.UseFsEventsOnParentDirectory,
28765             })),
28766             category: ts.Diagnostics.Advanced_Options,
28767             description: ts.Diagnostics.Specify_strategy_for_watching_file_Colon_FixedPollingInterval_default_PriorityPollingInterval_DynamicPriorityPolling_UseFsEvents_UseFsEventsOnParentDirectory,
28768         },
28769         {
28770             name: "watchDirectory",
28771             type: new ts.Map(ts.getEntries({
28772                 usefsevents: ts.WatchDirectoryKind.UseFsEvents,
28773                 fixedpollinginterval: ts.WatchDirectoryKind.FixedPollingInterval,
28774                 dynamicprioritypolling: ts.WatchDirectoryKind.DynamicPriorityPolling,
28775             })),
28776             category: ts.Diagnostics.Advanced_Options,
28777             description: ts.Diagnostics.Specify_strategy_for_watching_directory_on_platforms_that_don_t_support_recursive_watching_natively_Colon_UseFsEvents_default_FixedPollingInterval_DynamicPriorityPolling,
28778         },
28779         {
28780             name: "fallbackPolling",
28781             type: new ts.Map(ts.getEntries({
28782                 fixedinterval: ts.PollingWatchKind.FixedInterval,
28783                 priorityinterval: ts.PollingWatchKind.PriorityInterval,
28784                 dynamicpriority: ts.PollingWatchKind.DynamicPriority,
28785             })),
28786             category: ts.Diagnostics.Advanced_Options,
28787             description: ts.Diagnostics.Specify_strategy_for_creating_a_polling_watch_when_it_fails_to_create_using_file_system_events_Colon_FixedInterval_default_PriorityInterval_DynamicPriority,
28788         },
28789         {
28790             name: "synchronousWatchDirectory",
28791             type: "boolean",
28792             category: ts.Diagnostics.Advanced_Options,
28793             description: ts.Diagnostics.Synchronously_call_callbacks_and_update_the_state_of_directory_watchers_on_platforms_that_don_t_support_recursive_watching_natively,
28794         },
28795     ];
28796     ts.commonOptionsWithBuild = [
28797         {
28798             name: "help",
28799             shortName: "h",
28800             type: "boolean",
28801             showInSimplifiedHelpView: true,
28802             category: ts.Diagnostics.Command_line_Options,
28803             description: ts.Diagnostics.Print_this_message,
28804         },
28805         {
28806             name: "help",
28807             shortName: "?",
28808             type: "boolean"
28809         },
28810         {
28811             name: "watch",
28812             shortName: "w",
28813             type: "boolean",
28814             showInSimplifiedHelpView: true,
28815             category: ts.Diagnostics.Command_line_Options,
28816             description: ts.Diagnostics.Watch_input_files,
28817         },
28818         {
28819             name: "preserveWatchOutput",
28820             type: "boolean",
28821             showInSimplifiedHelpView: false,
28822             category: ts.Diagnostics.Command_line_Options,
28823             description: ts.Diagnostics.Whether_to_keep_outdated_console_output_in_watch_mode_instead_of_clearing_the_screen,
28824         },
28825         {
28826             name: "listFiles",
28827             type: "boolean",
28828             category: ts.Diagnostics.Advanced_Options,
28829             description: ts.Diagnostics.Print_names_of_files_part_of_the_compilation
28830         },
28831         {
28832             name: "listEmittedFiles",
28833             type: "boolean",
28834             category: ts.Diagnostics.Advanced_Options,
28835             description: ts.Diagnostics.Print_names_of_generated_files_part_of_the_compilation
28836         },
28837         {
28838             name: "pretty",
28839             type: "boolean",
28840             showInSimplifiedHelpView: true,
28841             category: ts.Diagnostics.Command_line_Options,
28842             description: ts.Diagnostics.Stylize_errors_and_messages_using_color_and_context_experimental
28843         },
28844         {
28845             name: "traceResolution",
28846             type: "boolean",
28847             category: ts.Diagnostics.Advanced_Options,
28848             description: ts.Diagnostics.Enable_tracing_of_the_name_resolution_process
28849         },
28850         {
28851             name: "diagnostics",
28852             type: "boolean",
28853             category: ts.Diagnostics.Advanced_Options,
28854             description: ts.Diagnostics.Show_diagnostic_information
28855         },
28856         {
28857             name: "extendedDiagnostics",
28858             type: "boolean",
28859             category: ts.Diagnostics.Advanced_Options,
28860             description: ts.Diagnostics.Show_verbose_diagnostic_information
28861         },
28862         {
28863             name: "generateCpuProfile",
28864             type: "string",
28865             isFilePath: true,
28866             paramType: ts.Diagnostics.FILE_OR_DIRECTORY,
28867             category: ts.Diagnostics.Advanced_Options,
28868             description: ts.Diagnostics.Generates_a_CPU_profile
28869         },
28870         {
28871             name: "generateTrace",
28872             type: "string",
28873             isFilePath: true,
28874             isCommandLineOnly: true,
28875             paramType: ts.Diagnostics.DIRECTORY,
28876             category: ts.Diagnostics.Advanced_Options,
28877             description: ts.Diagnostics.Generates_an_event_trace_and_a_list_of_types
28878         },
28879         {
28880             name: "incremental",
28881             shortName: "i",
28882             type: "boolean",
28883             category: ts.Diagnostics.Basic_Options,
28884             description: ts.Diagnostics.Enable_incremental_compilation,
28885             transpileOptionValue: undefined
28886         },
28887         {
28888             name: "assumeChangesOnlyAffectDirectDependencies",
28889             type: "boolean",
28890             affectsSemanticDiagnostics: true,
28891             affectsEmit: true,
28892             category: ts.Diagnostics.Advanced_Options,
28893             description: ts.Diagnostics.Have_recompiles_in_incremental_and_watch_assume_that_changes_within_a_file_will_only_affect_files_directly_depending_on_it
28894         },
28895         {
28896             name: "locale",
28897             type: "string",
28898             category: ts.Diagnostics.Advanced_Options,
28899             description: ts.Diagnostics.The_locale_used_when_displaying_messages_to_the_user_e_g_en_us
28900         },
28901     ];
28902     ts.optionDeclarations = __spreadArrays(ts.commonOptionsWithBuild, [
28903         {
28904             name: "all",
28905             type: "boolean",
28906             showInSimplifiedHelpView: true,
28907             category: ts.Diagnostics.Command_line_Options,
28908             description: ts.Diagnostics.Show_all_compiler_options,
28909         },
28910         {
28911             name: "version",
28912             shortName: "v",
28913             type: "boolean",
28914             showInSimplifiedHelpView: true,
28915             category: ts.Diagnostics.Command_line_Options,
28916             description: ts.Diagnostics.Print_the_compiler_s_version,
28917         },
28918         {
28919             name: "init",
28920             type: "boolean",
28921             showInSimplifiedHelpView: true,
28922             category: ts.Diagnostics.Command_line_Options,
28923             description: ts.Diagnostics.Initializes_a_TypeScript_project_and_creates_a_tsconfig_json_file,
28924         },
28925         {
28926             name: "project",
28927             shortName: "p",
28928             type: "string",
28929             isFilePath: true,
28930             showInSimplifiedHelpView: true,
28931             category: ts.Diagnostics.Command_line_Options,
28932             paramType: ts.Diagnostics.FILE_OR_DIRECTORY,
28933             description: ts.Diagnostics.Compile_the_project_given_the_path_to_its_configuration_file_or_to_a_folder_with_a_tsconfig_json,
28934         },
28935         {
28936             name: "build",
28937             type: "boolean",
28938             shortName: "b",
28939             showInSimplifiedHelpView: true,
28940             category: ts.Diagnostics.Command_line_Options,
28941             description: ts.Diagnostics.Build_one_or_more_projects_and_their_dependencies_if_out_of_date
28942         },
28943         {
28944             name: "showConfig",
28945             type: "boolean",
28946             category: ts.Diagnostics.Command_line_Options,
28947             isCommandLineOnly: true,
28948             description: ts.Diagnostics.Print_the_final_configuration_instead_of_building
28949         },
28950         {
28951             name: "listFilesOnly",
28952             type: "boolean",
28953             category: ts.Diagnostics.Command_line_Options,
28954             affectsSemanticDiagnostics: true,
28955             affectsEmit: true,
28956             isCommandLineOnly: true,
28957             description: ts.Diagnostics.Print_names_of_files_that_are_part_of_the_compilation_and_then_stop_processing
28958         },
28959         {
28960             name: "target",
28961             shortName: "t",
28962             type: new ts.Map(ts.getEntries({
28963                 es3: 0,
28964                 es5: 1,
28965                 es6: 2,
28966                 es2015: 2,
28967                 es2016: 3,
28968                 es2017: 4,
28969                 es2018: 5,
28970                 es2019: 6,
28971                 es2020: 7,
28972                 esnext: 99,
28973             })),
28974             affectsSourceFile: true,
28975             affectsModuleResolution: true,
28976             affectsEmit: true,
28977             paramType: ts.Diagnostics.VERSION,
28978             showInSimplifiedHelpView: true,
28979             category: ts.Diagnostics.Basic_Options,
28980             description: ts.Diagnostics.Specify_ECMAScript_target_version_Colon_ES3_default_ES5_ES2015_ES2016_ES2017_ES2018_ES2019_ES2020_or_ESNEXT,
28981         },
28982         {
28983             name: "module",
28984             shortName: "m",
28985             type: new ts.Map(ts.getEntries({
28986                 none: ts.ModuleKind.None,
28987                 commonjs: ts.ModuleKind.CommonJS,
28988                 amd: ts.ModuleKind.AMD,
28989                 system: ts.ModuleKind.System,
28990                 umd: ts.ModuleKind.UMD,
28991                 es6: ts.ModuleKind.ES2015,
28992                 es2015: ts.ModuleKind.ES2015,
28993                 es2020: ts.ModuleKind.ES2020,
28994                 esnext: ts.ModuleKind.ESNext
28995             })),
28996             affectsModuleResolution: true,
28997             affectsEmit: true,
28998             paramType: ts.Diagnostics.KIND,
28999             showInSimplifiedHelpView: true,
29000             category: ts.Diagnostics.Basic_Options,
29001             description: ts.Diagnostics.Specify_module_code_generation_Colon_none_commonjs_amd_system_umd_es2015_es2020_or_ESNext,
29002         },
29003         {
29004             name: "lib",
29005             type: "list",
29006             element: {
29007                 name: "lib",
29008                 type: ts.libMap
29009             },
29010             affectsModuleResolution: true,
29011             showInSimplifiedHelpView: true,
29012             category: ts.Diagnostics.Basic_Options,
29013             description: ts.Diagnostics.Specify_library_files_to_be_included_in_the_compilation,
29014             transpileOptionValue: undefined
29015         },
29016         {
29017             name: "allowJs",
29018             type: "boolean",
29019             affectsModuleResolution: true,
29020             showInSimplifiedHelpView: true,
29021             category: ts.Diagnostics.Basic_Options,
29022             description: ts.Diagnostics.Allow_javascript_files_to_be_compiled
29023         },
29024         {
29025             name: "checkJs",
29026             type: "boolean",
29027             category: ts.Diagnostics.Basic_Options,
29028             description: ts.Diagnostics.Report_errors_in_js_files
29029         },
29030         {
29031             name: "jsx",
29032             type: jsxOptionMap,
29033             affectsSourceFile: true,
29034             affectsEmit: true,
29035             affectsModuleResolution: true,
29036             paramType: ts.Diagnostics.KIND,
29037             showInSimplifiedHelpView: true,
29038             category: ts.Diagnostics.Basic_Options,
29039             description: ts.Diagnostics.Specify_JSX_code_generation_Colon_preserve_react_native_or_react,
29040         },
29041         {
29042             name: "declaration",
29043             shortName: "d",
29044             type: "boolean",
29045             affectsEmit: true,
29046             showInSimplifiedHelpView: true,
29047             category: ts.Diagnostics.Basic_Options,
29048             description: ts.Diagnostics.Generates_corresponding_d_ts_file,
29049             transpileOptionValue: undefined
29050         },
29051         {
29052             name: "declarationMap",
29053             type: "boolean",
29054             affectsEmit: true,
29055             showInSimplifiedHelpView: true,
29056             category: ts.Diagnostics.Basic_Options,
29057             description: ts.Diagnostics.Generates_a_sourcemap_for_each_corresponding_d_ts_file,
29058             transpileOptionValue: undefined
29059         },
29060         {
29061             name: "emitDeclarationOnly",
29062             type: "boolean",
29063             affectsEmit: true,
29064             category: ts.Diagnostics.Advanced_Options,
29065             description: ts.Diagnostics.Only_emit_d_ts_declaration_files,
29066             transpileOptionValue: undefined
29067         },
29068         {
29069             name: "sourceMap",
29070             type: "boolean",
29071             affectsEmit: true,
29072             showInSimplifiedHelpView: true,
29073             category: ts.Diagnostics.Basic_Options,
29074             description: ts.Diagnostics.Generates_corresponding_map_file,
29075         },
29076         {
29077             name: "outFile",
29078             type: "string",
29079             affectsEmit: true,
29080             isFilePath: true,
29081             paramType: ts.Diagnostics.FILE,
29082             showInSimplifiedHelpView: true,
29083             category: ts.Diagnostics.Basic_Options,
29084             description: ts.Diagnostics.Concatenate_and_emit_output_to_single_file,
29085             transpileOptionValue: undefined
29086         },
29087         {
29088             name: "outDir",
29089             type: "string",
29090             affectsEmit: true,
29091             isFilePath: true,
29092             paramType: ts.Diagnostics.DIRECTORY,
29093             showInSimplifiedHelpView: true,
29094             category: ts.Diagnostics.Basic_Options,
29095             description: ts.Diagnostics.Redirect_output_structure_to_the_directory,
29096         },
29097         {
29098             name: "rootDir",
29099             type: "string",
29100             affectsEmit: true,
29101             isFilePath: true,
29102             paramType: ts.Diagnostics.LOCATION,
29103             category: ts.Diagnostics.Basic_Options,
29104             description: ts.Diagnostics.Specify_the_root_directory_of_input_files_Use_to_control_the_output_directory_structure_with_outDir,
29105         },
29106         {
29107             name: "composite",
29108             type: "boolean",
29109             affectsEmit: true,
29110             isTSConfigOnly: true,
29111             category: ts.Diagnostics.Basic_Options,
29112             description: ts.Diagnostics.Enable_project_compilation,
29113             transpileOptionValue: undefined
29114         },
29115         {
29116             name: "tsBuildInfoFile",
29117             type: "string",
29118             affectsEmit: true,
29119             isFilePath: true,
29120             paramType: ts.Diagnostics.FILE,
29121             category: ts.Diagnostics.Basic_Options,
29122             description: ts.Diagnostics.Specify_file_to_store_incremental_compilation_information,
29123             transpileOptionValue: undefined
29124         },
29125         {
29126             name: "removeComments",
29127             type: "boolean",
29128             affectsEmit: true,
29129             showInSimplifiedHelpView: true,
29130             category: ts.Diagnostics.Basic_Options,
29131             description: ts.Diagnostics.Do_not_emit_comments_to_output,
29132         },
29133         {
29134             name: "noEmit",
29135             type: "boolean",
29136             showInSimplifiedHelpView: true,
29137             category: ts.Diagnostics.Basic_Options,
29138             description: ts.Diagnostics.Do_not_emit_outputs,
29139             transpileOptionValue: undefined
29140         },
29141         {
29142             name: "importHelpers",
29143             type: "boolean",
29144             affectsEmit: true,
29145             category: ts.Diagnostics.Basic_Options,
29146             description: ts.Diagnostics.Import_emit_helpers_from_tslib
29147         },
29148         {
29149             name: "importsNotUsedAsValues",
29150             type: new ts.Map(ts.getEntries({
29151                 remove: 0,
29152                 preserve: 1,
29153                 error: 2
29154             })),
29155             affectsEmit: true,
29156             affectsSemanticDiagnostics: true,
29157             category: ts.Diagnostics.Advanced_Options,
29158             description: ts.Diagnostics.Specify_emit_Slashchecking_behavior_for_imports_that_are_only_used_for_types
29159         },
29160         {
29161             name: "downlevelIteration",
29162             type: "boolean",
29163             affectsEmit: true,
29164             category: ts.Diagnostics.Basic_Options,
29165             description: ts.Diagnostics.Provide_full_support_for_iterables_in_for_of_spread_and_destructuring_when_targeting_ES5_or_ES3
29166         },
29167         {
29168             name: "isolatedModules",
29169             type: "boolean",
29170             category: ts.Diagnostics.Basic_Options,
29171             description: ts.Diagnostics.Transpile_each_file_as_a_separate_module_similar_to_ts_transpileModule,
29172             transpileOptionValue: true
29173         },
29174         {
29175             name: "strict",
29176             type: "boolean",
29177             showInSimplifiedHelpView: true,
29178             category: ts.Diagnostics.Strict_Type_Checking_Options,
29179             description: ts.Diagnostics.Enable_all_strict_type_checking_options
29180         },
29181         {
29182             name: "noImplicitAny",
29183             type: "boolean",
29184             affectsSemanticDiagnostics: true,
29185             strictFlag: true,
29186             showInSimplifiedHelpView: true,
29187             category: ts.Diagnostics.Strict_Type_Checking_Options,
29188             description: ts.Diagnostics.Raise_error_on_expressions_and_declarations_with_an_implied_any_type
29189         },
29190         {
29191             name: "strictNullChecks",
29192             type: "boolean",
29193             affectsSemanticDiagnostics: true,
29194             strictFlag: true,
29195             showInSimplifiedHelpView: true,
29196             category: ts.Diagnostics.Strict_Type_Checking_Options,
29197             description: ts.Diagnostics.Enable_strict_null_checks
29198         },
29199         {
29200             name: "strictFunctionTypes",
29201             type: "boolean",
29202             affectsSemanticDiagnostics: true,
29203             strictFlag: true,
29204             showInSimplifiedHelpView: true,
29205             category: ts.Diagnostics.Strict_Type_Checking_Options,
29206             description: ts.Diagnostics.Enable_strict_checking_of_function_types
29207         },
29208         {
29209             name: "strictBindCallApply",
29210             type: "boolean",
29211             strictFlag: true,
29212             showInSimplifiedHelpView: true,
29213             category: ts.Diagnostics.Strict_Type_Checking_Options,
29214             description: ts.Diagnostics.Enable_strict_bind_call_and_apply_methods_on_functions
29215         },
29216         {
29217             name: "strictPropertyInitialization",
29218             type: "boolean",
29219             affectsSemanticDiagnostics: true,
29220             strictFlag: true,
29221             showInSimplifiedHelpView: true,
29222             category: ts.Diagnostics.Strict_Type_Checking_Options,
29223             description: ts.Diagnostics.Enable_strict_checking_of_property_initialization_in_classes
29224         },
29225         {
29226             name: "noImplicitThis",
29227             type: "boolean",
29228             affectsSemanticDiagnostics: true,
29229             strictFlag: true,
29230             showInSimplifiedHelpView: true,
29231             category: ts.Diagnostics.Strict_Type_Checking_Options,
29232             description: ts.Diagnostics.Raise_error_on_this_expressions_with_an_implied_any_type,
29233         },
29234         {
29235             name: "alwaysStrict",
29236             type: "boolean",
29237             affectsSourceFile: true,
29238             strictFlag: true,
29239             showInSimplifiedHelpView: true,
29240             category: ts.Diagnostics.Strict_Type_Checking_Options,
29241             description: ts.Diagnostics.Parse_in_strict_mode_and_emit_use_strict_for_each_source_file
29242         },
29243         {
29244             name: "noUnusedLocals",
29245             type: "boolean",
29246             affectsSemanticDiagnostics: true,
29247             showInSimplifiedHelpView: true,
29248             category: ts.Diagnostics.Additional_Checks,
29249             description: ts.Diagnostics.Report_errors_on_unused_locals,
29250         },
29251         {
29252             name: "noUnusedParameters",
29253             type: "boolean",
29254             affectsSemanticDiagnostics: true,
29255             showInSimplifiedHelpView: true,
29256             category: ts.Diagnostics.Additional_Checks,
29257             description: ts.Diagnostics.Report_errors_on_unused_parameters,
29258         },
29259         {
29260             name: "noImplicitReturns",
29261             type: "boolean",
29262             affectsSemanticDiagnostics: true,
29263             showInSimplifiedHelpView: true,
29264             category: ts.Diagnostics.Additional_Checks,
29265             description: ts.Diagnostics.Report_error_when_not_all_code_paths_in_function_return_a_value
29266         },
29267         {
29268             name: "noFallthroughCasesInSwitch",
29269             type: "boolean",
29270             affectsBindDiagnostics: true,
29271             affectsSemanticDiagnostics: true,
29272             showInSimplifiedHelpView: true,
29273             category: ts.Diagnostics.Additional_Checks,
29274             description: ts.Diagnostics.Report_errors_for_fallthrough_cases_in_switch_statement
29275         },
29276         {
29277             name: "noUncheckedIndexedAccess",
29278             type: "boolean",
29279             affectsSemanticDiagnostics: true,
29280             showInSimplifiedHelpView: false,
29281             category: ts.Diagnostics.Additional_Checks,
29282             description: ts.Diagnostics.Include_undefined_in_index_signature_results
29283         },
29284         {
29285             name: "moduleResolution",
29286             type: new ts.Map(ts.getEntries({
29287                 node: ts.ModuleResolutionKind.NodeJs,
29288                 classic: ts.ModuleResolutionKind.Classic,
29289             })),
29290             affectsModuleResolution: true,
29291             paramType: ts.Diagnostics.STRATEGY,
29292             category: ts.Diagnostics.Module_Resolution_Options,
29293             description: ts.Diagnostics.Specify_module_resolution_strategy_Colon_node_Node_js_or_classic_TypeScript_pre_1_6,
29294         },
29295         {
29296             name: "baseUrl",
29297             type: "string",
29298             affectsModuleResolution: true,
29299             isFilePath: true,
29300             category: ts.Diagnostics.Module_Resolution_Options,
29301             description: ts.Diagnostics.Base_directory_to_resolve_non_absolute_module_names
29302         },
29303         {
29304             name: "paths",
29305             type: "object",
29306             affectsModuleResolution: true,
29307             isTSConfigOnly: true,
29308             category: ts.Diagnostics.Module_Resolution_Options,
29309             description: ts.Diagnostics.A_series_of_entries_which_re_map_imports_to_lookup_locations_relative_to_the_baseUrl,
29310             transpileOptionValue: undefined
29311         },
29312         {
29313             name: "rootDirs",
29314             type: "list",
29315             isTSConfigOnly: true,
29316             element: {
29317                 name: "rootDirs",
29318                 type: "string",
29319                 isFilePath: true
29320             },
29321             affectsModuleResolution: true,
29322             category: ts.Diagnostics.Module_Resolution_Options,
29323             description: ts.Diagnostics.List_of_root_folders_whose_combined_content_represents_the_structure_of_the_project_at_runtime,
29324             transpileOptionValue: undefined
29325         },
29326         {
29327             name: "typeRoots",
29328             type: "list",
29329             element: {
29330                 name: "typeRoots",
29331                 type: "string",
29332                 isFilePath: true
29333             },
29334             affectsModuleResolution: true,
29335             category: ts.Diagnostics.Module_Resolution_Options,
29336             description: ts.Diagnostics.List_of_folders_to_include_type_definitions_from
29337         },
29338         {
29339             name: "types",
29340             type: "list",
29341             element: {
29342                 name: "types",
29343                 type: "string"
29344             },
29345             affectsModuleResolution: true,
29346             showInSimplifiedHelpView: true,
29347             category: ts.Diagnostics.Module_Resolution_Options,
29348             description: ts.Diagnostics.Type_declaration_files_to_be_included_in_compilation,
29349             transpileOptionValue: undefined
29350         },
29351         {
29352             name: "allowSyntheticDefaultImports",
29353             type: "boolean",
29354             affectsSemanticDiagnostics: true,
29355             category: ts.Diagnostics.Module_Resolution_Options,
29356             description: ts.Diagnostics.Allow_default_imports_from_modules_with_no_default_export_This_does_not_affect_code_emit_just_typechecking
29357         },
29358         {
29359             name: "esModuleInterop",
29360             type: "boolean",
29361             affectsSemanticDiagnostics: true,
29362             affectsEmit: true,
29363             showInSimplifiedHelpView: true,
29364             category: ts.Diagnostics.Module_Resolution_Options,
29365             description: ts.Diagnostics.Enables_emit_interoperability_between_CommonJS_and_ES_Modules_via_creation_of_namespace_objects_for_all_imports_Implies_allowSyntheticDefaultImports
29366         },
29367         {
29368             name: "preserveSymlinks",
29369             type: "boolean",
29370             category: ts.Diagnostics.Module_Resolution_Options,
29371             description: ts.Diagnostics.Do_not_resolve_the_real_path_of_symlinks,
29372         },
29373         {
29374             name: "allowUmdGlobalAccess",
29375             type: "boolean",
29376             affectsSemanticDiagnostics: true,
29377             category: ts.Diagnostics.Module_Resolution_Options,
29378             description: ts.Diagnostics.Allow_accessing_UMD_globals_from_modules,
29379         },
29380         {
29381             name: "sourceRoot",
29382             type: "string",
29383             affectsEmit: true,
29384             paramType: ts.Diagnostics.LOCATION,
29385             category: ts.Diagnostics.Source_Map_Options,
29386             description: ts.Diagnostics.Specify_the_location_where_debugger_should_locate_TypeScript_files_instead_of_source_locations,
29387         },
29388         {
29389             name: "mapRoot",
29390             type: "string",
29391             affectsEmit: true,
29392             paramType: ts.Diagnostics.LOCATION,
29393             category: ts.Diagnostics.Source_Map_Options,
29394             description: ts.Diagnostics.Specify_the_location_where_debugger_should_locate_map_files_instead_of_generated_locations,
29395         },
29396         {
29397             name: "inlineSourceMap",
29398             type: "boolean",
29399             affectsEmit: true,
29400             category: ts.Diagnostics.Source_Map_Options,
29401             description: ts.Diagnostics.Emit_a_single_file_with_source_maps_instead_of_having_a_separate_file
29402         },
29403         {
29404             name: "inlineSources",
29405             type: "boolean",
29406             affectsEmit: true,
29407             category: ts.Diagnostics.Source_Map_Options,
29408             description: ts.Diagnostics.Emit_the_source_alongside_the_sourcemaps_within_a_single_file_requires_inlineSourceMap_or_sourceMap_to_be_set
29409         },
29410         {
29411             name: "experimentalDecorators",
29412             type: "boolean",
29413             affectsSemanticDiagnostics: true,
29414             category: ts.Diagnostics.Experimental_Options,
29415             description: ts.Diagnostics.Enables_experimental_support_for_ES7_decorators
29416         },
29417         {
29418             name: "emitDecoratorMetadata",
29419             type: "boolean",
29420             affectsSemanticDiagnostics: true,
29421             affectsEmit: true,
29422             category: ts.Diagnostics.Experimental_Options,
29423             description: ts.Diagnostics.Enables_experimental_support_for_emitting_type_metadata_for_decorators
29424         },
29425         {
29426             name: "jsxFactory",
29427             type: "string",
29428             category: ts.Diagnostics.Advanced_Options,
29429             description: ts.Diagnostics.Specify_the_JSX_factory_function_to_use_when_targeting_react_JSX_emit_e_g_React_createElement_or_h
29430         },
29431         {
29432             name: "jsxFragmentFactory",
29433             type: "string",
29434             category: ts.Diagnostics.Advanced_Options,
29435             description: ts.Diagnostics.Specify_the_JSX_fragment_factory_function_to_use_when_targeting_react_JSX_emit_with_jsxFactory_compiler_option_is_specified_e_g_Fragment
29436         },
29437         {
29438             name: "jsxImportSource",
29439             type: "string",
29440             affectsSemanticDiagnostics: true,
29441             affectsEmit: true,
29442             affectsModuleResolution: true,
29443             category: ts.Diagnostics.Advanced_Options,
29444             description: ts.Diagnostics.Specify_the_module_specifier_to_be_used_to_import_the_jsx_and_jsxs_factory_functions_from_eg_react
29445         },
29446         {
29447             name: "resolveJsonModule",
29448             type: "boolean",
29449             affectsModuleResolution: true,
29450             category: ts.Diagnostics.Advanced_Options,
29451             description: ts.Diagnostics.Include_modules_imported_with_json_extension
29452         },
29453         {
29454             name: "out",
29455             type: "string",
29456             affectsEmit: true,
29457             isFilePath: false,
29458             category: ts.Diagnostics.Advanced_Options,
29459             paramType: ts.Diagnostics.FILE,
29460             description: ts.Diagnostics.Deprecated_Use_outFile_instead_Concatenate_and_emit_output_to_single_file,
29461             transpileOptionValue: undefined
29462         },
29463         {
29464             name: "reactNamespace",
29465             type: "string",
29466             affectsEmit: true,
29467             category: ts.Diagnostics.Advanced_Options,
29468             description: ts.Diagnostics.Deprecated_Use_jsxFactory_instead_Specify_the_object_invoked_for_createElement_when_targeting_react_JSX_emit
29469         },
29470         {
29471             name: "skipDefaultLibCheck",
29472             type: "boolean",
29473             category: ts.Diagnostics.Advanced_Options,
29474             description: ts.Diagnostics.Deprecated_Use_skipLibCheck_instead_Skip_type_checking_of_default_library_declaration_files
29475         },
29476         {
29477             name: "charset",
29478             type: "string",
29479             category: ts.Diagnostics.Advanced_Options,
29480             description: ts.Diagnostics.The_character_set_of_the_input_files
29481         },
29482         {
29483             name: "emitBOM",
29484             type: "boolean",
29485             affectsEmit: true,
29486             category: ts.Diagnostics.Advanced_Options,
29487             description: ts.Diagnostics.Emit_a_UTF_8_Byte_Order_Mark_BOM_in_the_beginning_of_output_files
29488         },
29489         {
29490             name: "newLine",
29491             type: new ts.Map(ts.getEntries({
29492                 crlf: 0,
29493                 lf: 1
29494             })),
29495             affectsEmit: true,
29496             paramType: ts.Diagnostics.NEWLINE,
29497             category: ts.Diagnostics.Advanced_Options,
29498             description: ts.Diagnostics.Specify_the_end_of_line_sequence_to_be_used_when_emitting_files_Colon_CRLF_dos_or_LF_unix,
29499         },
29500         {
29501             name: "noErrorTruncation",
29502             type: "boolean",
29503             affectsSemanticDiagnostics: true,
29504             category: ts.Diagnostics.Advanced_Options,
29505             description: ts.Diagnostics.Do_not_truncate_error_messages
29506         },
29507         {
29508             name: "noLib",
29509             type: "boolean",
29510             affectsModuleResolution: true,
29511             category: ts.Diagnostics.Advanced_Options,
29512             description: ts.Diagnostics.Do_not_include_the_default_library_file_lib_d_ts,
29513             transpileOptionValue: true
29514         },
29515         {
29516             name: "noResolve",
29517             type: "boolean",
29518             affectsModuleResolution: true,
29519             category: ts.Diagnostics.Advanced_Options,
29520             description: ts.Diagnostics.Do_not_add_triple_slash_references_or_imported_modules_to_the_list_of_compiled_files,
29521             transpileOptionValue: true
29522         },
29523         {
29524             name: "stripInternal",
29525             type: "boolean",
29526             affectsEmit: true,
29527             category: ts.Diagnostics.Advanced_Options,
29528             description: ts.Diagnostics.Do_not_emit_declarations_for_code_that_has_an_internal_annotation,
29529         },
29530         {
29531             name: "disableSizeLimit",
29532             type: "boolean",
29533             affectsSourceFile: true,
29534             category: ts.Diagnostics.Advanced_Options,
29535             description: ts.Diagnostics.Disable_size_limitations_on_JavaScript_projects
29536         },
29537         {
29538             name: "disableSourceOfProjectReferenceRedirect",
29539             type: "boolean",
29540             isTSConfigOnly: true,
29541             category: ts.Diagnostics.Advanced_Options,
29542             description: ts.Diagnostics.Disable_use_of_source_files_instead_of_declaration_files_from_referenced_projects
29543         },
29544         {
29545             name: "disableSolutionSearching",
29546             type: "boolean",
29547             isTSConfigOnly: true,
29548             category: ts.Diagnostics.Advanced_Options,
29549             description: ts.Diagnostics.Disable_solution_searching_for_this_project
29550         },
29551         {
29552             name: "disableReferencedProjectLoad",
29553             type: "boolean",
29554             isTSConfigOnly: true,
29555             category: ts.Diagnostics.Advanced_Options,
29556             description: ts.Diagnostics.Disable_loading_referenced_projects
29557         },
29558         {
29559             name: "noImplicitUseStrict",
29560             type: "boolean",
29561             affectsSemanticDiagnostics: true,
29562             category: ts.Diagnostics.Advanced_Options,
29563             description: ts.Diagnostics.Do_not_emit_use_strict_directives_in_module_output
29564         },
29565         {
29566             name: "noEmitHelpers",
29567             type: "boolean",
29568             affectsEmit: true,
29569             category: ts.Diagnostics.Advanced_Options,
29570             description: ts.Diagnostics.Do_not_generate_custom_helper_functions_like_extends_in_compiled_output
29571         },
29572         {
29573             name: "noEmitOnError",
29574             type: "boolean",
29575             affectsEmit: true,
29576             category: ts.Diagnostics.Advanced_Options,
29577             description: ts.Diagnostics.Do_not_emit_outputs_if_any_errors_were_reported,
29578             transpileOptionValue: undefined
29579         },
29580         {
29581             name: "preserveConstEnums",
29582             type: "boolean",
29583             affectsEmit: true,
29584             category: ts.Diagnostics.Advanced_Options,
29585             description: ts.Diagnostics.Do_not_erase_const_enum_declarations_in_generated_code
29586         },
29587         {
29588             name: "declarationDir",
29589             type: "string",
29590             affectsEmit: true,
29591             isFilePath: true,
29592             paramType: ts.Diagnostics.DIRECTORY,
29593             category: ts.Diagnostics.Advanced_Options,
29594             description: ts.Diagnostics.Output_directory_for_generated_declaration_files,
29595             transpileOptionValue: undefined
29596         },
29597         {
29598             name: "skipLibCheck",
29599             type: "boolean",
29600             category: ts.Diagnostics.Advanced_Options,
29601             description: ts.Diagnostics.Skip_type_checking_of_declaration_files,
29602         },
29603         {
29604             name: "allowUnusedLabels",
29605             type: "boolean",
29606             affectsBindDiagnostics: true,
29607             affectsSemanticDiagnostics: true,
29608             category: ts.Diagnostics.Advanced_Options,
29609             description: ts.Diagnostics.Do_not_report_errors_on_unused_labels
29610         },
29611         {
29612             name: "allowUnreachableCode",
29613             type: "boolean",
29614             affectsBindDiagnostics: true,
29615             affectsSemanticDiagnostics: true,
29616             category: ts.Diagnostics.Advanced_Options,
29617             description: ts.Diagnostics.Do_not_report_errors_on_unreachable_code
29618         },
29619         {
29620             name: "suppressExcessPropertyErrors",
29621             type: "boolean",
29622             affectsSemanticDiagnostics: true,
29623             category: ts.Diagnostics.Advanced_Options,
29624             description: ts.Diagnostics.Suppress_excess_property_checks_for_object_literals,
29625         },
29626         {
29627             name: "suppressImplicitAnyIndexErrors",
29628             type: "boolean",
29629             affectsSemanticDiagnostics: true,
29630             category: ts.Diagnostics.Advanced_Options,
29631             description: ts.Diagnostics.Suppress_noImplicitAny_errors_for_indexing_objects_lacking_index_signatures,
29632         },
29633         {
29634             name: "forceConsistentCasingInFileNames",
29635             type: "boolean",
29636             affectsModuleResolution: true,
29637             category: ts.Diagnostics.Advanced_Options,
29638             description: ts.Diagnostics.Disallow_inconsistently_cased_references_to_the_same_file
29639         },
29640         {
29641             name: "maxNodeModuleJsDepth",
29642             type: "number",
29643             affectsModuleResolution: true,
29644             category: ts.Diagnostics.Advanced_Options,
29645             description: ts.Diagnostics.The_maximum_dependency_depth_to_search_under_node_modules_and_load_JavaScript_files
29646         },
29647         {
29648             name: "noStrictGenericChecks",
29649             type: "boolean",
29650             affectsSemanticDiagnostics: true,
29651             category: ts.Diagnostics.Advanced_Options,
29652             description: ts.Diagnostics.Disable_strict_checking_of_generic_signatures_in_function_types,
29653         },
29654         {
29655             name: "useDefineForClassFields",
29656             type: "boolean",
29657             affectsSemanticDiagnostics: true,
29658             affectsEmit: true,
29659             category: ts.Diagnostics.Advanced_Options,
29660             description: ts.Diagnostics.Emit_class_fields_with_Define_instead_of_Set,
29661         },
29662         {
29663             name: "keyofStringsOnly",
29664             type: "boolean",
29665             category: ts.Diagnostics.Advanced_Options,
29666             description: ts.Diagnostics.Resolve_keyof_to_string_valued_property_names_only_no_numbers_or_symbols,
29667         },
29668         {
29669             name: "plugins",
29670             type: "list",
29671             isTSConfigOnly: true,
29672             element: {
29673                 name: "plugin",
29674                 type: "object"
29675             },
29676             description: ts.Diagnostics.List_of_language_service_plugins
29677         },
29678     ]);
29679     ts.semanticDiagnosticsOptionDeclarations = ts.optionDeclarations.filter(function (option) { return !!option.affectsSemanticDiagnostics; });
29680     ts.affectsEmitOptionDeclarations = ts.optionDeclarations.filter(function (option) { return !!option.affectsEmit; });
29681     ts.moduleResolutionOptionDeclarations = ts.optionDeclarations.filter(function (option) { return !!option.affectsModuleResolution; });
29682     ts.sourceFileAffectingCompilerOptions = ts.optionDeclarations.filter(function (option) {
29683         return !!option.affectsSourceFile || !!option.affectsModuleResolution || !!option.affectsBindDiagnostics;
29684     });
29685     ts.transpileOptionValueCompilerOptions = ts.optionDeclarations.filter(function (option) {
29686         return ts.hasProperty(option, "transpileOptionValue");
29687     });
29688     ts.buildOpts = __spreadArrays(ts.commonOptionsWithBuild, [
29689         {
29690             name: "verbose",
29691             shortName: "v",
29692             category: ts.Diagnostics.Command_line_Options,
29693             description: ts.Diagnostics.Enable_verbose_logging,
29694             type: "boolean"
29695         },
29696         {
29697             name: "dry",
29698             shortName: "d",
29699             category: ts.Diagnostics.Command_line_Options,
29700             description: ts.Diagnostics.Show_what_would_be_built_or_deleted_if_specified_with_clean,
29701             type: "boolean"
29702         },
29703         {
29704             name: "force",
29705             shortName: "f",
29706             category: ts.Diagnostics.Command_line_Options,
29707             description: ts.Diagnostics.Build_all_projects_including_those_that_appear_to_be_up_to_date,
29708             type: "boolean"
29709         },
29710         {
29711             name: "clean",
29712             category: ts.Diagnostics.Command_line_Options,
29713             description: ts.Diagnostics.Delete_the_outputs_of_all_projects,
29714             type: "boolean"
29715         }
29716     ]);
29717     ts.typeAcquisitionDeclarations = [
29718         {
29719             name: "enableAutoDiscovery",
29720             type: "boolean",
29721         },
29722         {
29723             name: "enable",
29724             type: "boolean",
29725         },
29726         {
29727             name: "include",
29728             type: "list",
29729             element: {
29730                 name: "include",
29731                 type: "string"
29732             }
29733         },
29734         {
29735             name: "exclude",
29736             type: "list",
29737             element: {
29738                 name: "exclude",
29739                 type: "string"
29740             }
29741         },
29742         {
29743             name: "disableFilenameBasedTypeAcquisition",
29744             type: "boolean",
29745         },
29746     ];
29747     function createOptionNameMap(optionDeclarations) {
29748         var optionsNameMap = new ts.Map();
29749         var shortOptionNames = new ts.Map();
29750         ts.forEach(optionDeclarations, function (option) {
29751             optionsNameMap.set(option.name.toLowerCase(), option);
29752             if (option.shortName) {
29753                 shortOptionNames.set(option.shortName, option.name);
29754             }
29755         });
29756         return { optionsNameMap: optionsNameMap, shortOptionNames: shortOptionNames };
29757     }
29758     ts.createOptionNameMap = createOptionNameMap;
29759     var optionsNameMapCache;
29760     function getOptionsNameMap() {
29761         return optionsNameMapCache || (optionsNameMapCache = createOptionNameMap(ts.optionDeclarations));
29762     }
29763     ts.getOptionsNameMap = getOptionsNameMap;
29764     ts.defaultInitCompilerOptions = {
29765         module: ts.ModuleKind.CommonJS,
29766         target: 1,
29767         strict: true,
29768         esModuleInterop: true,
29769         forceConsistentCasingInFileNames: true,
29770         skipLibCheck: true
29771     };
29772     function convertEnableAutoDiscoveryToEnable(typeAcquisition) {
29773         if (typeAcquisition && typeAcquisition.enableAutoDiscovery !== undefined && typeAcquisition.enable === undefined) {
29774             return {
29775                 enable: typeAcquisition.enableAutoDiscovery,
29776                 include: typeAcquisition.include || [],
29777                 exclude: typeAcquisition.exclude || []
29778             };
29779         }
29780         return typeAcquisition;
29781     }
29782     ts.convertEnableAutoDiscoveryToEnable = convertEnableAutoDiscoveryToEnable;
29783     function createCompilerDiagnosticForInvalidCustomType(opt) {
29784         return createDiagnosticForInvalidCustomType(opt, ts.createCompilerDiagnostic);
29785     }
29786     ts.createCompilerDiagnosticForInvalidCustomType = createCompilerDiagnosticForInvalidCustomType;
29787     function createDiagnosticForInvalidCustomType(opt, createDiagnostic) {
29788         var namesOfType = ts.arrayFrom(opt.type.keys()).map(function (key) { return "'" + key + "'"; }).join(", ");
29789         return createDiagnostic(ts.Diagnostics.Argument_for_0_option_must_be_Colon_1, "--" + opt.name, namesOfType);
29790     }
29791     function parseCustomTypeOption(opt, value, errors) {
29792         return convertJsonOptionOfCustomType(opt, trimString(value || ""), errors);
29793     }
29794     ts.parseCustomTypeOption = parseCustomTypeOption;
29795     function parseListTypeOption(opt, value, errors) {
29796         if (value === void 0) { value = ""; }
29797         value = trimString(value);
29798         if (ts.startsWith(value, "-")) {
29799             return undefined;
29800         }
29801         if (value === "") {
29802             return [];
29803         }
29804         var values = value.split(",");
29805         switch (opt.element.type) {
29806             case "number":
29807                 return ts.map(values, parseInt);
29808             case "string":
29809                 return ts.map(values, function (v) { return v || ""; });
29810             default:
29811                 return ts.mapDefined(values, function (v) { return parseCustomTypeOption(opt.element, v, errors); });
29812         }
29813     }
29814     ts.parseListTypeOption = parseListTypeOption;
29815     function getOptionName(option) {
29816         return option.name;
29817     }
29818     function createUnknownOptionError(unknownOption, diagnostics, createDiagnostics, unknownOptionErrorText) {
29819         var possibleOption = ts.getSpellingSuggestion(unknownOption, diagnostics.optionDeclarations, getOptionName);
29820         return possibleOption ?
29821             createDiagnostics(diagnostics.unknownDidYouMeanDiagnostic, unknownOptionErrorText || unknownOption, possibleOption.name) :
29822             createDiagnostics(diagnostics.unknownOptionDiagnostic, unknownOptionErrorText || unknownOption);
29823     }
29824     function parseCommandLineWorker(diagnostics, commandLine, readFile) {
29825         var options = {};
29826         var watchOptions;
29827         var fileNames = [];
29828         var errors = [];
29829         parseStrings(commandLine);
29830         return {
29831             options: options,
29832             watchOptions: watchOptions,
29833             fileNames: fileNames,
29834             errors: errors
29835         };
29836         function parseStrings(args) {
29837             var i = 0;
29838             while (i < args.length) {
29839                 var s = args[i];
29840                 i++;
29841                 if (s.charCodeAt(0) === 64) {
29842                     parseResponseFile(s.slice(1));
29843                 }
29844                 else if (s.charCodeAt(0) === 45) {
29845                     var inputOptionName = s.slice(s.charCodeAt(1) === 45 ? 2 : 1);
29846                     var opt = getOptionDeclarationFromName(diagnostics.getOptionsNameMap, inputOptionName, true);
29847                     if (opt) {
29848                         i = parseOptionValue(args, i, diagnostics, opt, options, errors);
29849                     }
29850                     else {
29851                         var watchOpt = getOptionDeclarationFromName(watchOptionsDidYouMeanDiagnostics.getOptionsNameMap, inputOptionName, true);
29852                         if (watchOpt) {
29853                             i = parseOptionValue(args, i, watchOptionsDidYouMeanDiagnostics, watchOpt, watchOptions || (watchOptions = {}), errors);
29854                         }
29855                         else {
29856                             errors.push(createUnknownOptionError(inputOptionName, diagnostics, ts.createCompilerDiagnostic, s));
29857                         }
29858                     }
29859                 }
29860                 else {
29861                     fileNames.push(s);
29862                 }
29863             }
29864         }
29865         function parseResponseFile(fileName) {
29866             var text = tryReadFile(fileName, readFile || (function (fileName) { return ts.sys.readFile(fileName); }));
29867             if (!ts.isString(text)) {
29868                 errors.push(text);
29869                 return;
29870             }
29871             var args = [];
29872             var pos = 0;
29873             while (true) {
29874                 while (pos < text.length && text.charCodeAt(pos) <= 32)
29875                     pos++;
29876                 if (pos >= text.length)
29877                     break;
29878                 var start = pos;
29879                 if (text.charCodeAt(start) === 34) {
29880                     pos++;
29881                     while (pos < text.length && text.charCodeAt(pos) !== 34)
29882                         pos++;
29883                     if (pos < text.length) {
29884                         args.push(text.substring(start + 1, pos));
29885                         pos++;
29886                     }
29887                     else {
29888                         errors.push(ts.createCompilerDiagnostic(ts.Diagnostics.Unterminated_quoted_string_in_response_file_0, fileName));
29889                     }
29890                 }
29891                 else {
29892                     while (text.charCodeAt(pos) > 32)
29893                         pos++;
29894                     args.push(text.substring(start, pos));
29895                 }
29896             }
29897             parseStrings(args);
29898         }
29899     }
29900     ts.parseCommandLineWorker = parseCommandLineWorker;
29901     function parseOptionValue(args, i, diagnostics, opt, options, errors) {
29902         if (opt.isTSConfigOnly) {
29903             var optValue = args[i];
29904             if (optValue === "null") {
29905                 options[opt.name] = undefined;
29906                 i++;
29907             }
29908             else if (opt.type === "boolean") {
29909                 if (optValue === "false") {
29910                     options[opt.name] = false;
29911                     i++;
29912                 }
29913                 else {
29914                     if (optValue === "true")
29915                         i++;
29916                     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));
29917                 }
29918             }
29919             else {
29920                 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));
29921                 if (optValue && !ts.startsWith(optValue, "-"))
29922                     i++;
29923             }
29924         }
29925         else {
29926             if (!args[i] && opt.type !== "boolean") {
29927                 errors.push(ts.createCompilerDiagnostic(diagnostics.optionTypeMismatchDiagnostic, opt.name, getCompilerOptionValueTypeString(opt)));
29928             }
29929             if (args[i] !== "null") {
29930                 switch (opt.type) {
29931                     case "number":
29932                         options[opt.name] = parseInt(args[i]);
29933                         i++;
29934                         break;
29935                     case "boolean":
29936                         var optValue = args[i];
29937                         options[opt.name] = optValue !== "false";
29938                         if (optValue === "false" || optValue === "true") {
29939                             i++;
29940                         }
29941                         break;
29942                     case "string":
29943                         options[opt.name] = args[i] || "";
29944                         i++;
29945                         break;
29946                     case "list":
29947                         var result = parseListTypeOption(opt, args[i], errors);
29948                         options[opt.name] = result || [];
29949                         if (result) {
29950                             i++;
29951                         }
29952                         break;
29953                     default:
29954                         options[opt.name] = parseCustomTypeOption(opt, args[i], errors);
29955                         i++;
29956                         break;
29957                 }
29958             }
29959             else {
29960                 options[opt.name] = undefined;
29961                 i++;
29962             }
29963         }
29964         return i;
29965     }
29966     ts.compilerOptionsDidYouMeanDiagnostics = {
29967         getOptionsNameMap: getOptionsNameMap,
29968         optionDeclarations: ts.optionDeclarations,
29969         unknownOptionDiagnostic: ts.Diagnostics.Unknown_compiler_option_0,
29970         unknownDidYouMeanDiagnostic: ts.Diagnostics.Unknown_compiler_option_0_Did_you_mean_1,
29971         optionTypeMismatchDiagnostic: ts.Diagnostics.Compiler_option_0_expects_an_argument
29972     };
29973     function parseCommandLine(commandLine, readFile) {
29974         return parseCommandLineWorker(ts.compilerOptionsDidYouMeanDiagnostics, commandLine, readFile);
29975     }
29976     ts.parseCommandLine = parseCommandLine;
29977     function getOptionFromName(optionName, allowShort) {
29978         return getOptionDeclarationFromName(getOptionsNameMap, optionName, allowShort);
29979     }
29980     ts.getOptionFromName = getOptionFromName;
29981     function getOptionDeclarationFromName(getOptionNameMap, optionName, allowShort) {
29982         if (allowShort === void 0) { allowShort = false; }
29983         optionName = optionName.toLowerCase();
29984         var _a = getOptionNameMap(), optionsNameMap = _a.optionsNameMap, shortOptionNames = _a.shortOptionNames;
29985         if (allowShort) {
29986             var short = shortOptionNames.get(optionName);
29987             if (short !== undefined) {
29988                 optionName = short;
29989             }
29990         }
29991         return optionsNameMap.get(optionName);
29992     }
29993     var buildOptionsNameMapCache;
29994     function getBuildOptionsNameMap() {
29995         return buildOptionsNameMapCache || (buildOptionsNameMapCache = createOptionNameMap(ts.buildOpts));
29996     }
29997     var buildOptionsDidYouMeanDiagnostics = {
29998         getOptionsNameMap: getBuildOptionsNameMap,
29999         optionDeclarations: ts.buildOpts,
30000         unknownOptionDiagnostic: ts.Diagnostics.Unknown_build_option_0,
30001         unknownDidYouMeanDiagnostic: ts.Diagnostics.Unknown_build_option_0_Did_you_mean_1,
30002         optionTypeMismatchDiagnostic: ts.Diagnostics.Build_option_0_requires_a_value_of_type_1
30003     };
30004     function parseBuildCommand(args) {
30005         var _a = parseCommandLineWorker(buildOptionsDidYouMeanDiagnostics, args), options = _a.options, watchOptions = _a.watchOptions, projects = _a.fileNames, errors = _a.errors;
30006         var buildOptions = options;
30007         if (projects.length === 0) {
30008             projects.push(".");
30009         }
30010         if (buildOptions.clean && buildOptions.force) {
30011             errors.push(ts.createCompilerDiagnostic(ts.Diagnostics.Options_0_and_1_cannot_be_combined, "clean", "force"));
30012         }
30013         if (buildOptions.clean && buildOptions.verbose) {
30014             errors.push(ts.createCompilerDiagnostic(ts.Diagnostics.Options_0_and_1_cannot_be_combined, "clean", "verbose"));
30015         }
30016         if (buildOptions.clean && buildOptions.watch) {
30017             errors.push(ts.createCompilerDiagnostic(ts.Diagnostics.Options_0_and_1_cannot_be_combined, "clean", "watch"));
30018         }
30019         if (buildOptions.watch && buildOptions.dry) {
30020             errors.push(ts.createCompilerDiagnostic(ts.Diagnostics.Options_0_and_1_cannot_be_combined, "watch", "dry"));
30021         }
30022         return { buildOptions: buildOptions, watchOptions: watchOptions, projects: projects, errors: errors };
30023     }
30024     ts.parseBuildCommand = parseBuildCommand;
30025     function getDiagnosticText(_message) {
30026         var _args = [];
30027         for (var _i = 1; _i < arguments.length; _i++) {
30028             _args[_i - 1] = arguments[_i];
30029         }
30030         var diagnostic = ts.createCompilerDiagnostic.apply(undefined, arguments);
30031         return diagnostic.messageText;
30032     }
30033     ts.getDiagnosticText = getDiagnosticText;
30034     function getParsedCommandLineOfConfigFile(configFileName, optionsToExtend, host, extendedConfigCache, watchOptionsToExtend, extraFileExtensions) {
30035         var configFileText = tryReadFile(configFileName, function (fileName) { return host.readFile(fileName); });
30036         if (!ts.isString(configFileText)) {
30037             host.onUnRecoverableConfigFileDiagnostic(configFileText);
30038             return undefined;
30039         }
30040         var result = ts.parseJsonText(configFileName, configFileText);
30041         var cwd = host.getCurrentDirectory();
30042         result.path = ts.toPath(configFileName, cwd, ts.createGetCanonicalFileName(host.useCaseSensitiveFileNames));
30043         result.resolvedPath = result.path;
30044         result.originalFileName = result.fileName;
30045         return parseJsonSourceFileConfigFileContent(result, host, ts.getNormalizedAbsolutePath(ts.getDirectoryPath(configFileName), cwd), optionsToExtend, ts.getNormalizedAbsolutePath(configFileName, cwd), undefined, extraFileExtensions, extendedConfigCache, watchOptionsToExtend);
30046     }
30047     ts.getParsedCommandLineOfConfigFile = getParsedCommandLineOfConfigFile;
30048     function readConfigFile(fileName, readFile) {
30049         var textOrDiagnostic = tryReadFile(fileName, readFile);
30050         return ts.isString(textOrDiagnostic) ? parseConfigFileTextToJson(fileName, textOrDiagnostic) : { config: {}, error: textOrDiagnostic };
30051     }
30052     ts.readConfigFile = readConfigFile;
30053     function parseConfigFileTextToJson(fileName, jsonText) {
30054         var jsonSourceFile = ts.parseJsonText(fileName, jsonText);
30055         return {
30056             config: convertToObject(jsonSourceFile, jsonSourceFile.parseDiagnostics),
30057             error: jsonSourceFile.parseDiagnostics.length ? jsonSourceFile.parseDiagnostics[0] : undefined
30058         };
30059     }
30060     ts.parseConfigFileTextToJson = parseConfigFileTextToJson;
30061     function readJsonConfigFile(fileName, readFile) {
30062         var textOrDiagnostic = tryReadFile(fileName, readFile);
30063         return ts.isString(textOrDiagnostic) ? ts.parseJsonText(fileName, textOrDiagnostic) : { fileName: fileName, parseDiagnostics: [textOrDiagnostic] };
30064     }
30065     ts.readJsonConfigFile = readJsonConfigFile;
30066     function tryReadFile(fileName, readFile) {
30067         var text;
30068         try {
30069             text = readFile(fileName);
30070         }
30071         catch (e) {
30072             return ts.createCompilerDiagnostic(ts.Diagnostics.Cannot_read_file_0_Colon_1, fileName, e.message);
30073         }
30074         return text === undefined ? ts.createCompilerDiagnostic(ts.Diagnostics.Cannot_read_file_0, fileName) : text;
30075     }
30076     ts.tryReadFile = tryReadFile;
30077     function commandLineOptionsToMap(options) {
30078         return ts.arrayToMap(options, getOptionName);
30079     }
30080     var typeAcquisitionDidYouMeanDiagnostics = {
30081         optionDeclarations: ts.typeAcquisitionDeclarations,
30082         unknownOptionDiagnostic: ts.Diagnostics.Unknown_type_acquisition_option_0,
30083         unknownDidYouMeanDiagnostic: ts.Diagnostics.Unknown_type_acquisition_option_0_Did_you_mean_1,
30084     };
30085     var watchOptionsNameMapCache;
30086     function getWatchOptionsNameMap() {
30087         return watchOptionsNameMapCache || (watchOptionsNameMapCache = createOptionNameMap(ts.optionsForWatch));
30088     }
30089     var watchOptionsDidYouMeanDiagnostics = {
30090         getOptionsNameMap: getWatchOptionsNameMap,
30091         optionDeclarations: ts.optionsForWatch,
30092         unknownOptionDiagnostic: ts.Diagnostics.Unknown_watch_option_0,
30093         unknownDidYouMeanDiagnostic: ts.Diagnostics.Unknown_watch_option_0_Did_you_mean_1,
30094         optionTypeMismatchDiagnostic: ts.Diagnostics.Watch_option_0_requires_a_value_of_type_1
30095     };
30096     var commandLineCompilerOptionsMapCache;
30097     function getCommandLineCompilerOptionsMap() {
30098         return commandLineCompilerOptionsMapCache || (commandLineCompilerOptionsMapCache = commandLineOptionsToMap(ts.optionDeclarations));
30099     }
30100     var commandLineWatchOptionsMapCache;
30101     function getCommandLineWatchOptionsMap() {
30102         return commandLineWatchOptionsMapCache || (commandLineWatchOptionsMapCache = commandLineOptionsToMap(ts.optionsForWatch));
30103     }
30104     var commandLineTypeAcquisitionMapCache;
30105     function getCommandLineTypeAcquisitionMap() {
30106         return commandLineTypeAcquisitionMapCache || (commandLineTypeAcquisitionMapCache = commandLineOptionsToMap(ts.typeAcquisitionDeclarations));
30107     }
30108     var _tsconfigRootOptions;
30109     function getTsconfigRootOptionsMap() {
30110         if (_tsconfigRootOptions === undefined) {
30111             _tsconfigRootOptions = {
30112                 name: undefined,
30113                 type: "object",
30114                 elementOptions: commandLineOptionsToMap([
30115                     {
30116                         name: "compilerOptions",
30117                         type: "object",
30118                         elementOptions: getCommandLineCompilerOptionsMap(),
30119                         extraKeyDiagnostics: ts.compilerOptionsDidYouMeanDiagnostics,
30120                     },
30121                     {
30122                         name: "watchOptions",
30123                         type: "object",
30124                         elementOptions: getCommandLineWatchOptionsMap(),
30125                         extraKeyDiagnostics: watchOptionsDidYouMeanDiagnostics,
30126                     },
30127                     {
30128                         name: "typingOptions",
30129                         type: "object",
30130                         elementOptions: getCommandLineTypeAcquisitionMap(),
30131                         extraKeyDiagnostics: typeAcquisitionDidYouMeanDiagnostics,
30132                     },
30133                     {
30134                         name: "typeAcquisition",
30135                         type: "object",
30136                         elementOptions: getCommandLineTypeAcquisitionMap(),
30137                         extraKeyDiagnostics: typeAcquisitionDidYouMeanDiagnostics
30138                     },
30139                     {
30140                         name: "extends",
30141                         type: "string"
30142                     },
30143                     {
30144                         name: "references",
30145                         type: "list",
30146                         element: {
30147                             name: "references",
30148                             type: "object"
30149                         }
30150                     },
30151                     {
30152                         name: "files",
30153                         type: "list",
30154                         element: {
30155                             name: "files",
30156                             type: "string"
30157                         }
30158                     },
30159                     {
30160                         name: "include",
30161                         type: "list",
30162                         element: {
30163                             name: "include",
30164                             type: "string"
30165                         }
30166                     },
30167                     {
30168                         name: "exclude",
30169                         type: "list",
30170                         element: {
30171                             name: "exclude",
30172                             type: "string"
30173                         }
30174                     },
30175                     ts.compileOnSaveCommandLineOption
30176                 ])
30177             };
30178         }
30179         return _tsconfigRootOptions;
30180     }
30181     function convertToObject(sourceFile, errors) {
30182         return convertToObjectWorker(sourceFile, errors, true, undefined, undefined);
30183     }
30184     ts.convertToObject = convertToObject;
30185     function convertToObjectWorker(sourceFile, errors, returnValue, knownRootOptions, jsonConversionNotifier) {
30186         if (!sourceFile.statements.length) {
30187             return returnValue ? {} : undefined;
30188         }
30189         return convertPropertyValueToJson(sourceFile.statements[0].expression, knownRootOptions);
30190         function isRootOptionMap(knownOptions) {
30191             return knownRootOptions && knownRootOptions.elementOptions === knownOptions;
30192         }
30193         function convertObjectLiteralExpressionToJson(node, knownOptions, extraKeyDiagnostics, parentOption) {
30194             var result = returnValue ? {} : undefined;
30195             var _loop_4 = function (element) {
30196                 if (element.kind !== 288) {
30197                     errors.push(ts.createDiagnosticForNodeInSourceFile(sourceFile, element, ts.Diagnostics.Property_assignment_expected));
30198                     return "continue";
30199                 }
30200                 if (element.questionToken) {
30201                     errors.push(ts.createDiagnosticForNodeInSourceFile(sourceFile, element.questionToken, ts.Diagnostics.The_0_modifier_can_only_be_used_in_TypeScript_files, "?"));
30202                 }
30203                 if (!isDoubleQuotedString(element.name)) {
30204                     errors.push(ts.createDiagnosticForNodeInSourceFile(sourceFile, element.name, ts.Diagnostics.String_literal_with_double_quotes_expected));
30205                 }
30206                 var textOfKey = ts.isComputedNonLiteralName(element.name) ? undefined : ts.getTextOfPropertyName(element.name);
30207                 var keyText = textOfKey && ts.unescapeLeadingUnderscores(textOfKey);
30208                 var option = keyText && knownOptions ? knownOptions.get(keyText) : undefined;
30209                 if (keyText && extraKeyDiagnostics && !option) {
30210                     if (knownOptions) {
30211                         errors.push(createUnknownOptionError(keyText, extraKeyDiagnostics, function (message, arg0, arg1) { return ts.createDiagnosticForNodeInSourceFile(sourceFile, element.name, message, arg0, arg1); }));
30212                     }
30213                     else {
30214                         errors.push(ts.createDiagnosticForNodeInSourceFile(sourceFile, element.name, extraKeyDiagnostics.unknownOptionDiagnostic, keyText));
30215                     }
30216                 }
30217                 var value = convertPropertyValueToJson(element.initializer, option);
30218                 if (typeof keyText !== "undefined") {
30219                     if (returnValue) {
30220                         result[keyText] = value;
30221                     }
30222                     if (jsonConversionNotifier &&
30223                         (parentOption || isRootOptionMap(knownOptions))) {
30224                         var isValidOptionValue = isCompilerOptionsValue(option, value);
30225                         if (parentOption) {
30226                             if (isValidOptionValue) {
30227                                 jsonConversionNotifier.onSetValidOptionKeyValueInParent(parentOption, option, value);
30228                             }
30229                         }
30230                         else if (isRootOptionMap(knownOptions)) {
30231                             if (isValidOptionValue) {
30232                                 jsonConversionNotifier.onSetValidOptionKeyValueInRoot(keyText, element.name, value, element.initializer);
30233                             }
30234                             else if (!option) {
30235                                 jsonConversionNotifier.onSetUnknownOptionKeyValueInRoot(keyText, element.name, value, element.initializer);
30236                             }
30237                         }
30238                     }
30239                 }
30240             };
30241             for (var _i = 0, _a = node.properties; _i < _a.length; _i++) {
30242                 var element = _a[_i];
30243                 _loop_4(element);
30244             }
30245             return result;
30246         }
30247         function convertArrayLiteralExpressionToJson(elements, elementOption) {
30248             if (!returnValue) {
30249                 return elements.forEach(function (element) { return convertPropertyValueToJson(element, elementOption); });
30250             }
30251             return ts.filter(elements.map(function (element) { return convertPropertyValueToJson(element, elementOption); }), function (v) { return v !== undefined; });
30252         }
30253         function convertPropertyValueToJson(valueExpression, option) {
30254             switch (valueExpression.kind) {
30255                 case 109:
30256                     reportInvalidOptionValue(option && option.type !== "boolean");
30257                     return true;
30258                 case 94:
30259                     reportInvalidOptionValue(option && option.type !== "boolean");
30260                     return false;
30261                 case 103:
30262                     reportInvalidOptionValue(option && option.name === "extends");
30263                     return null;
30264                 case 10:
30265                     if (!isDoubleQuotedString(valueExpression)) {
30266                         errors.push(ts.createDiagnosticForNodeInSourceFile(sourceFile, valueExpression, ts.Diagnostics.String_literal_with_double_quotes_expected));
30267                     }
30268                     reportInvalidOptionValue(option && (ts.isString(option.type) && option.type !== "string"));
30269                     var text = valueExpression.text;
30270                     if (option && !ts.isString(option.type)) {
30271                         var customOption = option;
30272                         if (!customOption.type.has(text.toLowerCase())) {
30273                             errors.push(createDiagnosticForInvalidCustomType(customOption, function (message, arg0, arg1) { return ts.createDiagnosticForNodeInSourceFile(sourceFile, valueExpression, message, arg0, arg1); }));
30274                         }
30275                     }
30276                     return text;
30277                 case 8:
30278                     reportInvalidOptionValue(option && option.type !== "number");
30279                     return Number(valueExpression.text);
30280                 case 214:
30281                     if (valueExpression.operator !== 40 || valueExpression.operand.kind !== 8) {
30282                         break;
30283                     }
30284                     reportInvalidOptionValue(option && option.type !== "number");
30285                     return -Number(valueExpression.operand.text);
30286                 case 200:
30287                     reportInvalidOptionValue(option && option.type !== "object");
30288                     var objectLiteralExpression = valueExpression;
30289                     if (option) {
30290                         var _a = option, elementOptions = _a.elementOptions, extraKeyDiagnostics = _a.extraKeyDiagnostics, optionName = _a.name;
30291                         return convertObjectLiteralExpressionToJson(objectLiteralExpression, elementOptions, extraKeyDiagnostics, optionName);
30292                     }
30293                     else {
30294                         return convertObjectLiteralExpressionToJson(objectLiteralExpression, undefined, undefined, undefined);
30295                     }
30296                 case 199:
30297                     reportInvalidOptionValue(option && option.type !== "list");
30298                     return convertArrayLiteralExpressionToJson(valueExpression.elements, option && option.element);
30299             }
30300             if (option) {
30301                 reportInvalidOptionValue(true);
30302             }
30303             else {
30304                 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));
30305             }
30306             return undefined;
30307             function reportInvalidOptionValue(isError) {
30308                 if (isError) {
30309                     errors.push(ts.createDiagnosticForNodeInSourceFile(sourceFile, valueExpression, ts.Diagnostics.Compiler_option_0_requires_a_value_of_type_1, option.name, getCompilerOptionValueTypeString(option)));
30310                 }
30311             }
30312         }
30313         function isDoubleQuotedString(node) {
30314             return ts.isStringLiteral(node) && ts.isStringDoubleQuoted(node, sourceFile);
30315         }
30316     }
30317     ts.convertToObjectWorker = convertToObjectWorker;
30318     function getCompilerOptionValueTypeString(option) {
30319         return option.type === "list" ?
30320             "Array" :
30321             ts.isString(option.type) ? option.type : "string";
30322     }
30323     function isCompilerOptionsValue(option, value) {
30324         if (option) {
30325             if (isNullOrUndefined(value))
30326                 return true;
30327             if (option.type === "list") {
30328                 return ts.isArray(value);
30329             }
30330             var expectedType = ts.isString(option.type) ? option.type : "string";
30331             return typeof value === expectedType;
30332         }
30333         return false;
30334     }
30335     function convertToTSConfig(configParseResult, configFileName, host) {
30336         var getCanonicalFileName = ts.createGetCanonicalFileName(host.useCaseSensitiveFileNames);
30337         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); });
30338         var optionMap = serializeCompilerOptions(configParseResult.options, { configFilePath: ts.getNormalizedAbsolutePath(configFileName, host.getCurrentDirectory()), useCaseSensitiveFileNames: host.useCaseSensitiveFileNames });
30339         var watchOptionMap = configParseResult.watchOptions && serializeWatchOptions(configParseResult.watchOptions);
30340         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 ? {
30341             include: filterSameAsDefaultInclude(configParseResult.configFileSpecs.validatedIncludeSpecs),
30342             exclude: configParseResult.configFileSpecs.validatedExcludeSpecs
30343         } : {})), { compileOnSave: !!configParseResult.compileOnSave ? true : undefined });
30344         return config;
30345     }
30346     ts.convertToTSConfig = convertToTSConfig;
30347     function optionMapToObject(optionMap) {
30348         return __assign({}, ts.arrayFrom(optionMap.entries()).reduce(function (prev, cur) {
30349             var _a;
30350             return (__assign(__assign({}, prev), (_a = {}, _a[cur[0]] = cur[1], _a)));
30351         }, {}));
30352     }
30353     function filterSameAsDefaultInclude(specs) {
30354         if (!ts.length(specs))
30355             return undefined;
30356         if (ts.length(specs) !== 1)
30357             return specs;
30358         if (specs[0] === "**/*")
30359             return undefined;
30360         return specs;
30361     }
30362     function matchesSpecs(path, includeSpecs, excludeSpecs, host) {
30363         if (!includeSpecs)
30364             return function (_) { return true; };
30365         var patterns = ts.getFileMatcherPatterns(path, excludeSpecs, includeSpecs, host.useCaseSensitiveFileNames, host.getCurrentDirectory());
30366         var excludeRe = patterns.excludePattern && ts.getRegexFromPattern(patterns.excludePattern, host.useCaseSensitiveFileNames);
30367         var includeRe = patterns.includeFilePattern && ts.getRegexFromPattern(patterns.includeFilePattern, host.useCaseSensitiveFileNames);
30368         if (includeRe) {
30369             if (excludeRe) {
30370                 return function (path) { return !(includeRe.test(path) && !excludeRe.test(path)); };
30371             }
30372             return function (path) { return !includeRe.test(path); };
30373         }
30374         if (excludeRe) {
30375             return function (path) { return excludeRe.test(path); };
30376         }
30377         return function (_) { return true; };
30378     }
30379     function getCustomTypeMapOfCommandLineOption(optionDefinition) {
30380         if (optionDefinition.type === "string" || optionDefinition.type === "number" || optionDefinition.type === "boolean" || optionDefinition.type === "object") {
30381             return undefined;
30382         }
30383         else if (optionDefinition.type === "list") {
30384             return getCustomTypeMapOfCommandLineOption(optionDefinition.element);
30385         }
30386         else {
30387             return optionDefinition.type;
30388         }
30389     }
30390     function getNameOfCompilerOptionValue(value, customTypeMap) {
30391         return ts.forEachEntry(customTypeMap, function (mapValue, key) {
30392             if (mapValue === value) {
30393                 return key;
30394             }
30395         });
30396     }
30397     function serializeCompilerOptions(options, pathOptions) {
30398         return serializeOptionBaseObject(options, getOptionsNameMap(), pathOptions);
30399     }
30400     function serializeWatchOptions(options) {
30401         return serializeOptionBaseObject(options, getWatchOptionsNameMap());
30402     }
30403     function serializeOptionBaseObject(options, _a, pathOptions) {
30404         var optionsNameMap = _a.optionsNameMap;
30405         var result = new ts.Map();
30406         var getCanonicalFileName = pathOptions && ts.createGetCanonicalFileName(pathOptions.useCaseSensitiveFileNames);
30407         var _loop_5 = function (name) {
30408             if (ts.hasProperty(options, name)) {
30409                 if (optionsNameMap.has(name) && optionsNameMap.get(name).category === ts.Diagnostics.Command_line_Options) {
30410                     return "continue";
30411                 }
30412                 var value = options[name];
30413                 var optionDefinition = optionsNameMap.get(name.toLowerCase());
30414                 if (optionDefinition) {
30415                     var customTypeMap_1 = getCustomTypeMapOfCommandLineOption(optionDefinition);
30416                     if (!customTypeMap_1) {
30417                         if (pathOptions && optionDefinition.isFilePath) {
30418                             result.set(name, ts.getRelativePathFromFile(pathOptions.configFilePath, ts.getNormalizedAbsolutePath(value, ts.getDirectoryPath(pathOptions.configFilePath)), getCanonicalFileName));
30419                         }
30420                         else {
30421                             result.set(name, value);
30422                         }
30423                     }
30424                     else {
30425                         if (optionDefinition.type === "list") {
30426                             result.set(name, value.map(function (element) { return getNameOfCompilerOptionValue(element, customTypeMap_1); }));
30427                         }
30428                         else {
30429                             result.set(name, getNameOfCompilerOptionValue(value, customTypeMap_1));
30430                         }
30431                     }
30432                 }
30433             }
30434         };
30435         for (var name in options) {
30436             _loop_5(name);
30437         }
30438         return result;
30439     }
30440     function generateTSConfig(options, fileNames, newLine) {
30441         var compilerOptions = ts.extend(options, ts.defaultInitCompilerOptions);
30442         var compilerOptionsMap = serializeCompilerOptions(compilerOptions);
30443         return writeConfigurations();
30444         function getDefaultValueForOption(option) {
30445             switch (option.type) {
30446                 case "number":
30447                     return 1;
30448                 case "boolean":
30449                     return true;
30450                 case "string":
30451                     return option.isFilePath ? "./" : "";
30452                 case "list":
30453                     return [];
30454                 case "object":
30455                     return {};
30456                 default:
30457                     var iterResult = option.type.keys().next();
30458                     if (!iterResult.done)
30459                         return iterResult.value;
30460                     return ts.Debug.fail("Expected 'option.type' to have entries.");
30461             }
30462         }
30463         function makePadding(paddingLength) {
30464             return Array(paddingLength + 1).join(" ");
30465         }
30466         function isAllowedOption(_a) {
30467             var category = _a.category, name = _a.name;
30468             return category !== undefined
30469                 && category !== ts.Diagnostics.Command_line_Options
30470                 && (category !== ts.Diagnostics.Advanced_Options || compilerOptionsMap.has(name));
30471         }
30472         function writeConfigurations() {
30473             var categorizedOptions = ts.createMultiMap();
30474             for (var _i = 0, optionDeclarations_1 = ts.optionDeclarations; _i < optionDeclarations_1.length; _i++) {
30475                 var option = optionDeclarations_1[_i];
30476                 var category = option.category;
30477                 if (isAllowedOption(option)) {
30478                     categorizedOptions.add(ts.getLocaleSpecificMessage(category), option);
30479                 }
30480             }
30481             var marginLength = 0;
30482             var seenKnownKeys = 0;
30483             var entries = [];
30484             categorizedOptions.forEach(function (options, category) {
30485                 if (entries.length !== 0) {
30486                     entries.push({ value: "" });
30487                 }
30488                 entries.push({ value: "/* " + category + " */" });
30489                 for (var _i = 0, options_1 = options; _i < options_1.length; _i++) {
30490                     var option = options_1[_i];
30491                     var optionName = void 0;
30492                     if (compilerOptionsMap.has(option.name)) {
30493                         optionName = "\"" + option.name + "\": " + JSON.stringify(compilerOptionsMap.get(option.name)) + ((seenKnownKeys += 1) === compilerOptionsMap.size ? "" : ",");
30494                     }
30495                     else {
30496                         optionName = "// \"" + option.name + "\": " + JSON.stringify(getDefaultValueForOption(option)) + ",";
30497                     }
30498                     entries.push({
30499                         value: optionName,
30500                         description: "/* " + (option.description && ts.getLocaleSpecificMessage(option.description) || option.name) + " */"
30501                     });
30502                     marginLength = Math.max(optionName.length, marginLength);
30503                 }
30504             });
30505             var tab = makePadding(2);
30506             var result = [];
30507             result.push("{");
30508             result.push(tab + "\"compilerOptions\": {");
30509             result.push("" + tab + tab + "/* " + ts.getLocaleSpecificMessage(ts.Diagnostics.Visit_https_Colon_Slash_Slashaka_ms_Slashtsconfig_json_to_read_more_about_this_file) + " */");
30510             result.push("");
30511             for (var _a = 0, entries_2 = entries; _a < entries_2.length; _a++) {
30512                 var entry = entries_2[_a];
30513                 var value = entry.value, _b = entry.description, description = _b === void 0 ? "" : _b;
30514                 result.push(value && "" + tab + tab + value + (description && (makePadding(marginLength - value.length + 2) + description)));
30515             }
30516             if (fileNames.length) {
30517                 result.push(tab + "},");
30518                 result.push(tab + "\"files\": [");
30519                 for (var i = 0; i < fileNames.length; i++) {
30520                     result.push("" + tab + tab + JSON.stringify(fileNames[i]) + (i === fileNames.length - 1 ? "" : ","));
30521                 }
30522                 result.push(tab + "]");
30523             }
30524             else {
30525                 result.push(tab + "}");
30526             }
30527             result.push("}");
30528             return result.join(newLine) + newLine;
30529         }
30530     }
30531     ts.generateTSConfig = generateTSConfig;
30532     function convertToOptionsWithAbsolutePaths(options, toAbsolutePath) {
30533         var result = {};
30534         var optionsNameMap = getOptionsNameMap().optionsNameMap;
30535         for (var name in options) {
30536             if (ts.hasProperty(options, name)) {
30537                 result[name] = convertToOptionValueWithAbsolutePaths(optionsNameMap.get(name.toLowerCase()), options[name], toAbsolutePath);
30538             }
30539         }
30540         if (result.configFilePath) {
30541             result.configFilePath = toAbsolutePath(result.configFilePath);
30542         }
30543         return result;
30544     }
30545     ts.convertToOptionsWithAbsolutePaths = convertToOptionsWithAbsolutePaths;
30546     function convertToOptionValueWithAbsolutePaths(option, value, toAbsolutePath) {
30547         if (option && !isNullOrUndefined(value)) {
30548             if (option.type === "list") {
30549                 var values = value;
30550                 if (option.element.isFilePath && values.length) {
30551                     return values.map(toAbsolutePath);
30552                 }
30553             }
30554             else if (option.isFilePath) {
30555                 return toAbsolutePath(value);
30556             }
30557         }
30558         return value;
30559     }
30560     function parseJsonConfigFileContent(json, host, basePath, existingOptions, configFileName, resolutionStack, extraFileExtensions, extendedConfigCache, existingWatchOptions) {
30561         return parseJsonConfigFileContentWorker(json, undefined, host, basePath, existingOptions, existingWatchOptions, configFileName, resolutionStack, extraFileExtensions, extendedConfigCache);
30562     }
30563     ts.parseJsonConfigFileContent = parseJsonConfigFileContent;
30564     function parseJsonSourceFileConfigFileContent(sourceFile, host, basePath, existingOptions, configFileName, resolutionStack, extraFileExtensions, extendedConfigCache, existingWatchOptions) {
30565         return parseJsonConfigFileContentWorker(undefined, sourceFile, host, basePath, existingOptions, existingWatchOptions, configFileName, resolutionStack, extraFileExtensions, extendedConfigCache);
30566     }
30567     ts.parseJsonSourceFileConfigFileContent = parseJsonSourceFileConfigFileContent;
30568     function setConfigFileInOptions(options, configFile) {
30569         if (configFile) {
30570             Object.defineProperty(options, "configFile", { enumerable: false, writable: false, value: configFile });
30571         }
30572     }
30573     ts.setConfigFileInOptions = setConfigFileInOptions;
30574     function isNullOrUndefined(x) {
30575         return x === undefined || x === null;
30576     }
30577     function directoryOfCombinedPath(fileName, basePath) {
30578         return ts.getDirectoryPath(ts.getNormalizedAbsolutePath(fileName, basePath));
30579     }
30580     function parseJsonConfigFileContentWorker(json, sourceFile, host, basePath, existingOptions, existingWatchOptions, configFileName, resolutionStack, extraFileExtensions, extendedConfigCache) {
30581         if (existingOptions === void 0) { existingOptions = {}; }
30582         if (resolutionStack === void 0) { resolutionStack = []; }
30583         if (extraFileExtensions === void 0) { extraFileExtensions = []; }
30584         ts.Debug.assert((json === undefined && sourceFile !== undefined) || (json !== undefined && sourceFile === undefined));
30585         var errors = [];
30586         var parsedConfig = parseConfig(json, sourceFile, host, basePath, configFileName, resolutionStack, errors, extendedConfigCache);
30587         var raw = parsedConfig.raw;
30588         var options = ts.extend(existingOptions, parsedConfig.options || {});
30589         var watchOptions = existingWatchOptions && parsedConfig.watchOptions ?
30590             ts.extend(existingWatchOptions, parsedConfig.watchOptions) :
30591             parsedConfig.watchOptions || existingWatchOptions;
30592         options.configFilePath = configFileName && ts.normalizeSlashes(configFileName);
30593         setConfigFileInOptions(options, sourceFile);
30594         var projectReferences;
30595         var _a = getFileNames(), fileNames = _a.fileNames, wildcardDirectories = _a.wildcardDirectories, spec = _a.spec;
30596         return {
30597             options: options,
30598             watchOptions: watchOptions,
30599             fileNames: fileNames,
30600             projectReferences: projectReferences,
30601             typeAcquisition: parsedConfig.typeAcquisition || getDefaultTypeAcquisition(),
30602             raw: raw,
30603             errors: errors,
30604             wildcardDirectories: wildcardDirectories,
30605             compileOnSave: !!raw.compileOnSave,
30606             configFileSpecs: spec
30607         };
30608         function getFileNames() {
30609             var referencesOfRaw = getPropFromRaw("references", function (element) { return typeof element === "object"; }, "object");
30610             if (ts.isArray(referencesOfRaw)) {
30611                 for (var _i = 0, referencesOfRaw_1 = referencesOfRaw; _i < referencesOfRaw_1.length; _i++) {
30612                     var ref = referencesOfRaw_1[_i];
30613                     if (typeof ref.path !== "string") {
30614                         createCompilerDiagnosticOnlyIfJson(ts.Diagnostics.Compiler_option_0_requires_a_value_of_type_1, "reference.path", "string");
30615                     }
30616                     else {
30617                         (projectReferences || (projectReferences = [])).push({
30618                             path: ts.getNormalizedAbsolutePath(ref.path, basePath),
30619                             originalPath: ref.path,
30620                             prepend: ref.prepend,
30621                             circular: ref.circular
30622                         });
30623                     }
30624                 }
30625             }
30626             var filesSpecs = toPropValue(getSpecsFromRaw("files"));
30627             if (filesSpecs) {
30628                 var hasZeroOrNoReferences = referencesOfRaw === "no-prop" || ts.isArray(referencesOfRaw) && referencesOfRaw.length === 0;
30629                 var hasExtends = ts.hasProperty(raw, "extends");
30630                 if (filesSpecs.length === 0 && hasZeroOrNoReferences && !hasExtends) {
30631                     if (sourceFile) {
30632                         var fileName = configFileName || "tsconfig.json";
30633                         var diagnosticMessage = ts.Diagnostics.The_files_list_in_config_file_0_is_empty;
30634                         var nodeValue = ts.firstDefined(ts.getTsConfigPropArray(sourceFile, "files"), function (property) { return property.initializer; });
30635                         var error = nodeValue
30636                             ? ts.createDiagnosticForNodeInSourceFile(sourceFile, nodeValue, diagnosticMessage, fileName)
30637                             : ts.createCompilerDiagnostic(diagnosticMessage, fileName);
30638                         errors.push(error);
30639                     }
30640                     else {
30641                         createCompilerDiagnosticOnlyIfJson(ts.Diagnostics.The_files_list_in_config_file_0_is_empty, configFileName || "tsconfig.json");
30642                     }
30643                 }
30644             }
30645             var includeSpecs = toPropValue(getSpecsFromRaw("include"));
30646             var excludeOfRaw = getSpecsFromRaw("exclude");
30647             var excludeSpecs = toPropValue(excludeOfRaw);
30648             if (excludeOfRaw === "no-prop" && raw.compilerOptions) {
30649                 var outDir = raw.compilerOptions.outDir;
30650                 var declarationDir = raw.compilerOptions.declarationDir;
30651                 if (outDir || declarationDir) {
30652                     excludeSpecs = [outDir, declarationDir].filter(function (d) { return !!d; });
30653                 }
30654             }
30655             if (filesSpecs === undefined && includeSpecs === undefined) {
30656                 includeSpecs = ["**/*"];
30657             }
30658             var result = matchFileNames(filesSpecs, includeSpecs, excludeSpecs, configFileName ? directoryOfCombinedPath(configFileName, basePath) : basePath, options, host, errors, extraFileExtensions, sourceFile);
30659             if (shouldReportNoInputFiles(result, canJsonReportNoInputFiles(raw), resolutionStack)) {
30660                 errors.push(getErrorForNoInputFiles(result.spec, configFileName));
30661             }
30662             return result;
30663         }
30664         function toPropValue(specResult) {
30665             return ts.isArray(specResult) ? specResult : undefined;
30666         }
30667         function getSpecsFromRaw(prop) {
30668             return getPropFromRaw(prop, ts.isString, "string");
30669         }
30670         function getPropFromRaw(prop, validateElement, elementTypeName) {
30671             if (ts.hasProperty(raw, prop) && !isNullOrUndefined(raw[prop])) {
30672                 if (ts.isArray(raw[prop])) {
30673                     var result = raw[prop];
30674                     if (!sourceFile && !ts.every(result, validateElement)) {
30675                         errors.push(ts.createCompilerDiagnostic(ts.Diagnostics.Compiler_option_0_requires_a_value_of_type_1, prop, elementTypeName));
30676                     }
30677                     return result;
30678                 }
30679                 else {
30680                     createCompilerDiagnosticOnlyIfJson(ts.Diagnostics.Compiler_option_0_requires_a_value_of_type_1, prop, "Array");
30681                     return "not-array";
30682                 }
30683             }
30684             return "no-prop";
30685         }
30686         function createCompilerDiagnosticOnlyIfJson(message, arg0, arg1) {
30687             if (!sourceFile) {
30688                 errors.push(ts.createCompilerDiagnostic(message, arg0, arg1));
30689             }
30690         }
30691     }
30692     function isErrorNoInputFiles(error) {
30693         return error.code === ts.Diagnostics.No_inputs_were_found_in_config_file_0_Specified_include_paths_were_1_and_exclude_paths_were_2.code;
30694     }
30695     function getErrorForNoInputFiles(_a, configFileName) {
30696         var includeSpecs = _a.includeSpecs, excludeSpecs = _a.excludeSpecs;
30697         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 || []));
30698     }
30699     function shouldReportNoInputFiles(result, canJsonReportNoInutFiles, resolutionStack) {
30700         return result.fileNames.length === 0 && canJsonReportNoInutFiles && (!resolutionStack || resolutionStack.length === 0);
30701     }
30702     function canJsonReportNoInputFiles(raw) {
30703         return !ts.hasProperty(raw, "files") && !ts.hasProperty(raw, "references");
30704     }
30705     ts.canJsonReportNoInputFiles = canJsonReportNoInputFiles;
30706     function updateErrorForNoInputFiles(result, configFileName, configFileSpecs, configParseDiagnostics, canJsonReportNoInutFiles) {
30707         var existingErrors = configParseDiagnostics.length;
30708         if (shouldReportNoInputFiles(result, canJsonReportNoInutFiles)) {
30709             configParseDiagnostics.push(getErrorForNoInputFiles(configFileSpecs, configFileName));
30710         }
30711         else {
30712             ts.filterMutate(configParseDiagnostics, function (error) { return !isErrorNoInputFiles(error); });
30713         }
30714         return existingErrors !== configParseDiagnostics.length;
30715     }
30716     ts.updateErrorForNoInputFiles = updateErrorForNoInputFiles;
30717     function isSuccessfulParsedTsconfig(value) {
30718         return !!value.options;
30719     }
30720     function parseConfig(json, sourceFile, host, basePath, configFileName, resolutionStack, errors, extendedConfigCache) {
30721         var _a;
30722         basePath = ts.normalizeSlashes(basePath);
30723         var resolvedPath = ts.getNormalizedAbsolutePath(configFileName || "", basePath);
30724         if (resolutionStack.indexOf(resolvedPath) >= 0) {
30725             errors.push(ts.createCompilerDiagnostic(ts.Diagnostics.Circularity_detected_while_resolving_configuration_Colon_0, __spreadArrays(resolutionStack, [resolvedPath]).join(" -> ")));
30726             return { raw: json || convertToObject(sourceFile, errors) };
30727         }
30728         var ownConfig = json ?
30729             parseOwnConfigOfJson(json, host, basePath, configFileName, errors) :
30730             parseOwnConfigOfJsonSourceFile(sourceFile, host, basePath, configFileName, errors);
30731         if ((_a = ownConfig.options) === null || _a === void 0 ? void 0 : _a.paths) {
30732             ownConfig.options.pathsBasePath = basePath;
30733         }
30734         if (ownConfig.extendedConfigPath) {
30735             resolutionStack = resolutionStack.concat([resolvedPath]);
30736             var extendedConfig = getExtendedConfig(sourceFile, ownConfig.extendedConfigPath, host, basePath, resolutionStack, errors, extendedConfigCache);
30737             if (extendedConfig && isSuccessfulParsedTsconfig(extendedConfig)) {
30738                 var baseRaw_1 = extendedConfig.raw;
30739                 var raw_1 = ownConfig.raw;
30740                 var setPropertyInRawIfNotUndefined = function (propertyName) {
30741                     var value = raw_1[propertyName] || baseRaw_1[propertyName];
30742                     if (value) {
30743                         raw_1[propertyName] = value;
30744                     }
30745                 };
30746                 setPropertyInRawIfNotUndefined("include");
30747                 setPropertyInRawIfNotUndefined("exclude");
30748                 setPropertyInRawIfNotUndefined("files");
30749                 if (raw_1.compileOnSave === undefined) {
30750                     raw_1.compileOnSave = baseRaw_1.compileOnSave;
30751                 }
30752                 ownConfig.options = ts.assign({}, extendedConfig.options, ownConfig.options);
30753                 ownConfig.watchOptions = ownConfig.watchOptions && extendedConfig.watchOptions ?
30754                     ts.assign({}, extendedConfig.watchOptions, ownConfig.watchOptions) :
30755                     ownConfig.watchOptions || extendedConfig.watchOptions;
30756             }
30757         }
30758         return ownConfig;
30759     }
30760     function parseOwnConfigOfJson(json, host, basePath, configFileName, errors) {
30761         if (ts.hasProperty(json, "excludes")) {
30762             errors.push(ts.createCompilerDiagnostic(ts.Diagnostics.Unknown_option_excludes_Did_you_mean_exclude));
30763         }
30764         var options = convertCompilerOptionsFromJsonWorker(json.compilerOptions, basePath, errors, configFileName);
30765         var typeAcquisition = convertTypeAcquisitionFromJsonWorker(json.typeAcquisition || json.typingOptions, basePath, errors, configFileName);
30766         var watchOptions = convertWatchOptionsFromJsonWorker(json.watchOptions, basePath, errors);
30767         json.compileOnSave = convertCompileOnSaveOptionFromJson(json, basePath, errors);
30768         var extendedConfigPath;
30769         if (json.extends) {
30770             if (!ts.isString(json.extends)) {
30771                 errors.push(ts.createCompilerDiagnostic(ts.Diagnostics.Compiler_option_0_requires_a_value_of_type_1, "extends", "string"));
30772             }
30773             else {
30774                 var newBase = configFileName ? directoryOfCombinedPath(configFileName, basePath) : basePath;
30775                 extendedConfigPath = getExtendsConfigPath(json.extends, host, newBase, errors, ts.createCompilerDiagnostic);
30776             }
30777         }
30778         return { raw: json, options: options, watchOptions: watchOptions, typeAcquisition: typeAcquisition, extendedConfigPath: extendedConfigPath };
30779     }
30780     function parseOwnConfigOfJsonSourceFile(sourceFile, host, basePath, configFileName, errors) {
30781         var options = getDefaultCompilerOptions(configFileName);
30782         var typeAcquisition, typingOptionstypeAcquisition;
30783         var watchOptions;
30784         var extendedConfigPath;
30785         var optionsIterator = {
30786             onSetValidOptionKeyValueInParent: function (parentOption, option, value) {
30787                 var currentOption;
30788                 switch (parentOption) {
30789                     case "compilerOptions":
30790                         currentOption = options;
30791                         break;
30792                     case "watchOptions":
30793                         currentOption = (watchOptions || (watchOptions = {}));
30794                         break;
30795                     case "typeAcquisition":
30796                         currentOption = (typeAcquisition || (typeAcquisition = getDefaultTypeAcquisition(configFileName)));
30797                         break;
30798                     case "typingOptions":
30799                         currentOption = (typingOptionstypeAcquisition || (typingOptionstypeAcquisition = getDefaultTypeAcquisition(configFileName)));
30800                         break;
30801                     default:
30802                         ts.Debug.fail("Unknown option");
30803                 }
30804                 currentOption[option.name] = normalizeOptionValue(option, basePath, value);
30805             },
30806             onSetValidOptionKeyValueInRoot: function (key, _keyNode, value, valueNode) {
30807                 switch (key) {
30808                     case "extends":
30809                         var newBase = configFileName ? directoryOfCombinedPath(configFileName, basePath) : basePath;
30810                         extendedConfigPath = getExtendsConfigPath(value, host, newBase, errors, function (message, arg0) {
30811                             return ts.createDiagnosticForNodeInSourceFile(sourceFile, valueNode, message, arg0);
30812                         });
30813                         return;
30814                 }
30815             },
30816             onSetUnknownOptionKeyValueInRoot: function (key, keyNode, _value, _valueNode) {
30817                 if (key === "excludes") {
30818                     errors.push(ts.createDiagnosticForNodeInSourceFile(sourceFile, keyNode, ts.Diagnostics.Unknown_option_excludes_Did_you_mean_exclude));
30819                 }
30820             }
30821         };
30822         var json = convertToObjectWorker(sourceFile, errors, true, getTsconfigRootOptionsMap(), optionsIterator);
30823         if (!typeAcquisition) {
30824             if (typingOptionstypeAcquisition) {
30825                 typeAcquisition = (typingOptionstypeAcquisition.enableAutoDiscovery !== undefined) ?
30826                     {
30827                         enable: typingOptionstypeAcquisition.enableAutoDiscovery,
30828                         include: typingOptionstypeAcquisition.include,
30829                         exclude: typingOptionstypeAcquisition.exclude
30830                     } :
30831                     typingOptionstypeAcquisition;
30832             }
30833             else {
30834                 typeAcquisition = getDefaultTypeAcquisition(configFileName);
30835             }
30836         }
30837         return { raw: json, options: options, watchOptions: watchOptions, typeAcquisition: typeAcquisition, extendedConfigPath: extendedConfigPath };
30838     }
30839     function getExtendsConfigPath(extendedConfig, host, basePath, errors, createDiagnostic) {
30840         extendedConfig = ts.normalizeSlashes(extendedConfig);
30841         if (ts.isRootedDiskPath(extendedConfig) || ts.startsWith(extendedConfig, "./") || ts.startsWith(extendedConfig, "../")) {
30842             var extendedConfigPath = ts.getNormalizedAbsolutePath(extendedConfig, basePath);
30843             if (!host.fileExists(extendedConfigPath) && !ts.endsWith(extendedConfigPath, ".json")) {
30844                 extendedConfigPath = extendedConfigPath + ".json";
30845                 if (!host.fileExists(extendedConfigPath)) {
30846                     errors.push(createDiagnostic(ts.Diagnostics.File_0_not_found, extendedConfig));
30847                     return undefined;
30848                 }
30849             }
30850             return extendedConfigPath;
30851         }
30852         var resolved = ts.nodeModuleNameResolver(extendedConfig, ts.combinePaths(basePath, "tsconfig.json"), { moduleResolution: ts.ModuleResolutionKind.NodeJs }, host, undefined, undefined, true);
30853         if (resolved.resolvedModule) {
30854             return resolved.resolvedModule.resolvedFileName;
30855         }
30856         errors.push(createDiagnostic(ts.Diagnostics.File_0_not_found, extendedConfig));
30857         return undefined;
30858     }
30859     function getExtendedConfig(sourceFile, extendedConfigPath, host, basePath, resolutionStack, errors, extendedConfigCache) {
30860         var _a;
30861         var path = host.useCaseSensitiveFileNames ? extendedConfigPath : ts.toFileNameLowerCase(extendedConfigPath);
30862         var value;
30863         var extendedResult;
30864         var extendedConfig;
30865         if (extendedConfigCache && (value = extendedConfigCache.get(path))) {
30866             (extendedResult = value.extendedResult, extendedConfig = value.extendedConfig);
30867         }
30868         else {
30869             extendedResult = readJsonConfigFile(extendedConfigPath, function (path) { return host.readFile(path); });
30870             if (!extendedResult.parseDiagnostics.length) {
30871                 var extendedDirname = ts.getDirectoryPath(extendedConfigPath);
30872                 extendedConfig = parseConfig(undefined, extendedResult, host, extendedDirname, ts.getBaseFileName(extendedConfigPath), resolutionStack, errors, extendedConfigCache);
30873                 if (isSuccessfulParsedTsconfig(extendedConfig)) {
30874                     var relativeDifference_1 = ts.convertToRelativePath(extendedDirname, basePath, ts.identity);
30875                     var updatePath_1 = function (path) { return ts.isRootedDiskPath(path) ? path : ts.combinePaths(relativeDifference_1, path); };
30876                     var mapPropertiesInRawIfNotUndefined = function (propertyName) {
30877                         if (raw_2[propertyName]) {
30878                             raw_2[propertyName] = ts.map(raw_2[propertyName], updatePath_1);
30879                         }
30880                     };
30881                     var raw_2 = extendedConfig.raw;
30882                     mapPropertiesInRawIfNotUndefined("include");
30883                     mapPropertiesInRawIfNotUndefined("exclude");
30884                     mapPropertiesInRawIfNotUndefined("files");
30885                 }
30886             }
30887             if (extendedConfigCache) {
30888                 extendedConfigCache.set(path, { extendedResult: extendedResult, extendedConfig: extendedConfig });
30889             }
30890         }
30891         if (sourceFile) {
30892             sourceFile.extendedSourceFiles = [extendedResult.fileName];
30893             if (extendedResult.extendedSourceFiles) {
30894                 (_a = sourceFile.extendedSourceFiles).push.apply(_a, extendedResult.extendedSourceFiles);
30895             }
30896         }
30897         if (extendedResult.parseDiagnostics.length) {
30898             errors.push.apply(errors, extendedResult.parseDiagnostics);
30899             return undefined;
30900         }
30901         return extendedConfig;
30902     }
30903     function convertCompileOnSaveOptionFromJson(jsonOption, basePath, errors) {
30904         if (!ts.hasProperty(jsonOption, ts.compileOnSaveCommandLineOption.name)) {
30905             return false;
30906         }
30907         var result = convertJsonOption(ts.compileOnSaveCommandLineOption, jsonOption.compileOnSave, basePath, errors);
30908         return typeof result === "boolean" && result;
30909     }
30910     function convertCompilerOptionsFromJson(jsonOptions, basePath, configFileName) {
30911         var errors = [];
30912         var options = convertCompilerOptionsFromJsonWorker(jsonOptions, basePath, errors, configFileName);
30913         return { options: options, errors: errors };
30914     }
30915     ts.convertCompilerOptionsFromJson = convertCompilerOptionsFromJson;
30916     function convertTypeAcquisitionFromJson(jsonOptions, basePath, configFileName) {
30917         var errors = [];
30918         var options = convertTypeAcquisitionFromJsonWorker(jsonOptions, basePath, errors, configFileName);
30919         return { options: options, errors: errors };
30920     }
30921     ts.convertTypeAcquisitionFromJson = convertTypeAcquisitionFromJson;
30922     function getDefaultCompilerOptions(configFileName) {
30923         var options = configFileName && ts.getBaseFileName(configFileName) === "jsconfig.json"
30924             ? { allowJs: true, maxNodeModuleJsDepth: 2, allowSyntheticDefaultImports: true, skipLibCheck: true, noEmit: true }
30925             : {};
30926         return options;
30927     }
30928     function convertCompilerOptionsFromJsonWorker(jsonOptions, basePath, errors, configFileName) {
30929         var options = getDefaultCompilerOptions(configFileName);
30930         convertOptionsFromJson(getCommandLineCompilerOptionsMap(), jsonOptions, basePath, options, ts.compilerOptionsDidYouMeanDiagnostics, errors);
30931         if (configFileName) {
30932             options.configFilePath = ts.normalizeSlashes(configFileName);
30933         }
30934         return options;
30935     }
30936     function getDefaultTypeAcquisition(configFileName) {
30937         return { enable: !!configFileName && ts.getBaseFileName(configFileName) === "jsconfig.json", include: [], exclude: [] };
30938     }
30939     function convertTypeAcquisitionFromJsonWorker(jsonOptions, basePath, errors, configFileName) {
30940         var options = getDefaultTypeAcquisition(configFileName);
30941         var typeAcquisition = convertEnableAutoDiscoveryToEnable(jsonOptions);
30942         convertOptionsFromJson(getCommandLineTypeAcquisitionMap(), typeAcquisition, basePath, options, typeAcquisitionDidYouMeanDiagnostics, errors);
30943         return options;
30944     }
30945     function convertWatchOptionsFromJsonWorker(jsonOptions, basePath, errors) {
30946         return convertOptionsFromJson(getCommandLineWatchOptionsMap(), jsonOptions, basePath, undefined, watchOptionsDidYouMeanDiagnostics, errors);
30947     }
30948     function convertOptionsFromJson(optionsNameMap, jsonOptions, basePath, defaultOptions, diagnostics, errors) {
30949         if (!jsonOptions) {
30950             return;
30951         }
30952         for (var id in jsonOptions) {
30953             var opt = optionsNameMap.get(id);
30954             if (opt) {
30955                 (defaultOptions || (defaultOptions = {}))[opt.name] = convertJsonOption(opt, jsonOptions[id], basePath, errors);
30956             }
30957             else {
30958                 errors.push(createUnknownOptionError(id, diagnostics, ts.createCompilerDiagnostic));
30959             }
30960         }
30961         return defaultOptions;
30962     }
30963     function convertJsonOption(opt, value, basePath, errors) {
30964         if (isCompilerOptionsValue(opt, value)) {
30965             var optType = opt.type;
30966             if (optType === "list" && ts.isArray(value)) {
30967                 return convertJsonOptionOfListType(opt, value, basePath, errors);
30968             }
30969             else if (!ts.isString(optType)) {
30970                 return convertJsonOptionOfCustomType(opt, value, errors);
30971             }
30972             return normalizeNonListOptionValue(opt, basePath, value);
30973         }
30974         else {
30975             errors.push(ts.createCompilerDiagnostic(ts.Diagnostics.Compiler_option_0_requires_a_value_of_type_1, opt.name, getCompilerOptionValueTypeString(opt)));
30976         }
30977     }
30978     function normalizeOptionValue(option, basePath, value) {
30979         if (isNullOrUndefined(value))
30980             return undefined;
30981         if (option.type === "list") {
30982             var listOption_1 = option;
30983             if (listOption_1.element.isFilePath || !ts.isString(listOption_1.element.type)) {
30984                 return ts.filter(ts.map(value, function (v) { return normalizeOptionValue(listOption_1.element, basePath, v); }), function (v) { return !!v; });
30985             }
30986             return value;
30987         }
30988         else if (!ts.isString(option.type)) {
30989             return option.type.get(ts.isString(value) ? value.toLowerCase() : value);
30990         }
30991         return normalizeNonListOptionValue(option, basePath, value);
30992     }
30993     function normalizeNonListOptionValue(option, basePath, value) {
30994         if (option.isFilePath) {
30995             value = ts.getNormalizedAbsolutePath(value, basePath);
30996             if (value === "") {
30997                 value = ".";
30998             }
30999         }
31000         return value;
31001     }
31002     function convertJsonOptionOfCustomType(opt, value, errors) {
31003         if (isNullOrUndefined(value))
31004             return undefined;
31005         var key = value.toLowerCase();
31006         var val = opt.type.get(key);
31007         if (val !== undefined) {
31008             return val;
31009         }
31010         else {
31011             errors.push(createCompilerDiagnosticForInvalidCustomType(opt));
31012         }
31013     }
31014     function convertJsonOptionOfListType(option, values, basePath, errors) {
31015         return ts.filter(ts.map(values, function (v) { return convertJsonOption(option.element, v, basePath, errors); }), function (v) { return !!v; });
31016     }
31017     function trimString(s) {
31018         return typeof s.trim === "function" ? s.trim() : s.replace(/^[\s]+|[\s]+$/g, "");
31019     }
31020     var invalidTrailingRecursionPattern = /(^|\/)\*\*\/?$/;
31021     var invalidDotDotAfterRecursiveWildcardPattern = /(^|\/)\*\*\/(.*\/)?\.\.($|\/)/;
31022     var watchRecursivePattern = /\/[^/]*?[*?][^/]*\//;
31023     var wildcardDirectoryPattern = /^[^*?]*(?=\/[^/]*[*?])/;
31024     function matchFileNames(filesSpecs, includeSpecs, excludeSpecs, basePath, options, host, errors, extraFileExtensions, jsonSourceFile) {
31025         basePath = ts.normalizePath(basePath);
31026         var validatedIncludeSpecs, validatedExcludeSpecs;
31027         if (includeSpecs) {
31028             validatedIncludeSpecs = validateSpecs(includeSpecs, errors, false, jsonSourceFile, "include");
31029         }
31030         if (excludeSpecs) {
31031             validatedExcludeSpecs = validateSpecs(excludeSpecs, errors, true, jsonSourceFile, "exclude");
31032         }
31033         var wildcardDirectories = getWildcardDirectories(validatedIncludeSpecs, validatedExcludeSpecs, basePath, host.useCaseSensitiveFileNames);
31034         var spec = {
31035             filesSpecs: filesSpecs,
31036             includeSpecs: includeSpecs,
31037             excludeSpecs: excludeSpecs,
31038             validatedFilesSpec: ts.filter(filesSpecs, ts.isString),
31039             validatedIncludeSpecs: validatedIncludeSpecs,
31040             validatedExcludeSpecs: validatedExcludeSpecs,
31041             wildcardDirectories: wildcardDirectories
31042         };
31043         return getFileNamesFromConfigSpecs(spec, basePath, options, host, extraFileExtensions);
31044     }
31045     function getFileNamesFromConfigSpecs(spec, basePath, options, host, extraFileExtensions) {
31046         if (extraFileExtensions === void 0) { extraFileExtensions = ts.emptyArray; }
31047         basePath = ts.normalizePath(basePath);
31048         var keyMapper = ts.createGetCanonicalFileName(host.useCaseSensitiveFileNames);
31049         var literalFileMap = new ts.Map();
31050         var wildcardFileMap = new ts.Map();
31051         var wildCardJsonFileMap = new ts.Map();
31052         var validatedFilesSpec = spec.validatedFilesSpec, validatedIncludeSpecs = spec.validatedIncludeSpecs, validatedExcludeSpecs = spec.validatedExcludeSpecs, wildcardDirectories = spec.wildcardDirectories;
31053         var supportedExtensions = ts.getSupportedExtensions(options, extraFileExtensions);
31054         var supportedExtensionsWithJsonIfResolveJsonModule = ts.getSuppoertedExtensionsWithJsonIfResolveJsonModule(options, supportedExtensions);
31055         if (validatedFilesSpec) {
31056             for (var _i = 0, validatedFilesSpec_1 = validatedFilesSpec; _i < validatedFilesSpec_1.length; _i++) {
31057                 var fileName = validatedFilesSpec_1[_i];
31058                 var file = ts.getNormalizedAbsolutePath(fileName, basePath);
31059                 literalFileMap.set(keyMapper(file), file);
31060             }
31061         }
31062         var jsonOnlyIncludeRegexes;
31063         if (validatedIncludeSpecs && validatedIncludeSpecs.length > 0) {
31064             var _loop_6 = function (file) {
31065                 if (ts.fileExtensionIs(file, ".json")) {
31066                     if (!jsonOnlyIncludeRegexes) {
31067                         var includes = validatedIncludeSpecs.filter(function (s) { return ts.endsWith(s, ".json"); });
31068                         var includeFilePatterns = ts.map(ts.getRegularExpressionsForWildcards(includes, basePath, "files"), function (pattern) { return "^" + pattern + "$"; });
31069                         jsonOnlyIncludeRegexes = includeFilePatterns ? includeFilePatterns.map(function (pattern) { return ts.getRegexFromPattern(pattern, host.useCaseSensitiveFileNames); }) : ts.emptyArray;
31070                     }
31071                     var includeIndex = ts.findIndex(jsonOnlyIncludeRegexes, function (re) { return re.test(file); });
31072                     if (includeIndex !== -1) {
31073                         var key_1 = keyMapper(file);
31074                         if (!literalFileMap.has(key_1) && !wildCardJsonFileMap.has(key_1)) {
31075                             wildCardJsonFileMap.set(key_1, file);
31076                         }
31077                     }
31078                     return "continue";
31079                 }
31080                 if (hasFileWithHigherPriorityExtension(file, literalFileMap, wildcardFileMap, supportedExtensions, keyMapper)) {
31081                     return "continue";
31082                 }
31083                 removeWildcardFilesWithLowerPriorityExtension(file, wildcardFileMap, supportedExtensions, keyMapper);
31084                 var key = keyMapper(file);
31085                 if (!literalFileMap.has(key) && !wildcardFileMap.has(key)) {
31086                     wildcardFileMap.set(key, file);
31087                 }
31088             };
31089             for (var _a = 0, _b = host.readDirectory(basePath, supportedExtensionsWithJsonIfResolveJsonModule, validatedExcludeSpecs, validatedIncludeSpecs, undefined); _a < _b.length; _a++) {
31090                 var file = _b[_a];
31091                 _loop_6(file);
31092             }
31093         }
31094         var literalFiles = ts.arrayFrom(literalFileMap.values());
31095         var wildcardFiles = ts.arrayFrom(wildcardFileMap.values());
31096         return {
31097             fileNames: literalFiles.concat(wildcardFiles, ts.arrayFrom(wildCardJsonFileMap.values())),
31098             wildcardDirectories: wildcardDirectories,
31099             spec: spec
31100         };
31101     }
31102     ts.getFileNamesFromConfigSpecs = getFileNamesFromConfigSpecs;
31103     function isExcludedFile(pathToCheck, spec, basePath, useCaseSensitiveFileNames, currentDirectory) {
31104         var validatedFilesSpec = spec.validatedFilesSpec, validatedIncludeSpecs = spec.validatedIncludeSpecs, validatedExcludeSpecs = spec.validatedExcludeSpecs;
31105         if (!ts.length(validatedIncludeSpecs) || !ts.length(validatedExcludeSpecs))
31106             return false;
31107         basePath = ts.normalizePath(basePath);
31108         var keyMapper = ts.createGetCanonicalFileName(useCaseSensitiveFileNames);
31109         if (validatedFilesSpec) {
31110             for (var _i = 0, validatedFilesSpec_2 = validatedFilesSpec; _i < validatedFilesSpec_2.length; _i++) {
31111                 var fileName = validatedFilesSpec_2[_i];
31112                 if (keyMapper(ts.getNormalizedAbsolutePath(fileName, basePath)) === pathToCheck)
31113                     return false;
31114             }
31115         }
31116         var excludePattern = ts.getRegularExpressionForWildcard(validatedExcludeSpecs, ts.combinePaths(ts.normalizePath(currentDirectory), basePath), "exclude");
31117         var excludeRegex = excludePattern && ts.getRegexFromPattern(excludePattern, useCaseSensitiveFileNames);
31118         if (!excludeRegex)
31119             return false;
31120         if (excludeRegex.test(pathToCheck))
31121             return true;
31122         return !ts.hasExtension(pathToCheck) && excludeRegex.test(ts.ensureTrailingDirectorySeparator(pathToCheck));
31123     }
31124     ts.isExcludedFile = isExcludedFile;
31125     function validateSpecs(specs, errors, allowTrailingRecursion, jsonSourceFile, specKey) {
31126         return specs.filter(function (spec) {
31127             if (!ts.isString(spec))
31128                 return false;
31129             var diag = specToDiagnostic(spec, allowTrailingRecursion);
31130             if (diag !== undefined) {
31131                 errors.push(createDiagnostic(diag, spec));
31132             }
31133             return diag === undefined;
31134         });
31135         function createDiagnostic(message, spec) {
31136             var element = ts.getTsConfigPropArrayElementValue(jsonSourceFile, specKey, spec);
31137             return element ?
31138                 ts.createDiagnosticForNodeInSourceFile(jsonSourceFile, element, message, spec) :
31139                 ts.createCompilerDiagnostic(message, spec);
31140         }
31141     }
31142     function specToDiagnostic(spec, allowTrailingRecursion) {
31143         if (!allowTrailingRecursion && invalidTrailingRecursionPattern.test(spec)) {
31144             return ts.Diagnostics.File_specification_cannot_end_in_a_recursive_directory_wildcard_Asterisk_Asterisk_Colon_0;
31145         }
31146         else if (invalidDotDotAfterRecursiveWildcardPattern.test(spec)) {
31147             return ts.Diagnostics.File_specification_cannot_contain_a_parent_directory_that_appears_after_a_recursive_directory_wildcard_Asterisk_Asterisk_Colon_0;
31148         }
31149     }
31150     function getWildcardDirectories(include, exclude, path, useCaseSensitiveFileNames) {
31151         var rawExcludeRegex = ts.getRegularExpressionForWildcard(exclude, path, "exclude");
31152         var excludeRegex = rawExcludeRegex && new RegExp(rawExcludeRegex, useCaseSensitiveFileNames ? "" : "i");
31153         var wildcardDirectories = {};
31154         if (include !== undefined) {
31155             var recursiveKeys = [];
31156             for (var _i = 0, include_1 = include; _i < include_1.length; _i++) {
31157                 var file = include_1[_i];
31158                 var spec = ts.normalizePath(ts.combinePaths(path, file));
31159                 if (excludeRegex && excludeRegex.test(spec)) {
31160                     continue;
31161                 }
31162                 var match = getWildcardDirectoryFromSpec(spec, useCaseSensitiveFileNames);
31163                 if (match) {
31164                     var key = match.key, flags = match.flags;
31165                     var existingFlags = wildcardDirectories[key];
31166                     if (existingFlags === undefined || existingFlags < flags) {
31167                         wildcardDirectories[key] = flags;
31168                         if (flags === 1) {
31169                             recursiveKeys.push(key);
31170                         }
31171                     }
31172                 }
31173             }
31174             for (var key in wildcardDirectories) {
31175                 if (ts.hasProperty(wildcardDirectories, key)) {
31176                     for (var _a = 0, recursiveKeys_1 = recursiveKeys; _a < recursiveKeys_1.length; _a++) {
31177                         var recursiveKey = recursiveKeys_1[_a];
31178                         if (key !== recursiveKey && ts.containsPath(recursiveKey, key, path, !useCaseSensitiveFileNames)) {
31179                             delete wildcardDirectories[key];
31180                         }
31181                     }
31182                 }
31183             }
31184         }
31185         return wildcardDirectories;
31186     }
31187     function getWildcardDirectoryFromSpec(spec, useCaseSensitiveFileNames) {
31188         var match = wildcardDirectoryPattern.exec(spec);
31189         if (match) {
31190             return {
31191                 key: useCaseSensitiveFileNames ? match[0] : ts.toFileNameLowerCase(match[0]),
31192                 flags: watchRecursivePattern.test(spec) ? 1 : 0
31193             };
31194         }
31195         if (ts.isImplicitGlob(spec)) {
31196             return {
31197                 key: useCaseSensitiveFileNames ? spec : ts.toFileNameLowerCase(spec),
31198                 flags: 1
31199             };
31200         }
31201         return undefined;
31202     }
31203     function hasFileWithHigherPriorityExtension(file, literalFiles, wildcardFiles, extensions, keyMapper) {
31204         var extensionPriority = ts.getExtensionPriority(file, extensions);
31205         var adjustedExtensionPriority = ts.adjustExtensionPriority(extensionPriority, extensions);
31206         for (var i = 0; i < adjustedExtensionPriority; i++) {
31207             var higherPriorityExtension = extensions[i];
31208             var higherPriorityPath = keyMapper(ts.changeExtension(file, higherPriorityExtension));
31209             if (literalFiles.has(higherPriorityPath) || wildcardFiles.has(higherPriorityPath)) {
31210                 return true;
31211             }
31212         }
31213         return false;
31214     }
31215     function removeWildcardFilesWithLowerPriorityExtension(file, wildcardFiles, extensions, keyMapper) {
31216         var extensionPriority = ts.getExtensionPriority(file, extensions);
31217         var nextExtensionPriority = ts.getNextLowestExtensionPriority(extensionPriority, extensions);
31218         for (var i = nextExtensionPriority; i < extensions.length; i++) {
31219             var lowerPriorityExtension = extensions[i];
31220             var lowerPriorityPath = keyMapper(ts.changeExtension(file, lowerPriorityExtension));
31221             wildcardFiles.delete(lowerPriorityPath);
31222         }
31223     }
31224     function convertCompilerOptionsForTelemetry(opts) {
31225         var out = {};
31226         for (var key in opts) {
31227             if (opts.hasOwnProperty(key)) {
31228                 var type = getOptionFromName(key);
31229                 if (type !== undefined) {
31230                     out[key] = getOptionValueWithEmptyStrings(opts[key], type);
31231                 }
31232             }
31233         }
31234         return out;
31235     }
31236     ts.convertCompilerOptionsForTelemetry = convertCompilerOptionsForTelemetry;
31237     function getOptionValueWithEmptyStrings(value, option) {
31238         switch (option.type) {
31239             case "object":
31240                 return "";
31241             case "string":
31242                 return "";
31243             case "number":
31244                 return typeof value === "number" ? value : "";
31245             case "boolean":
31246                 return typeof value === "boolean" ? value : "";
31247             case "list":
31248                 var elementType_1 = option.element;
31249                 return ts.isArray(value) ? value.map(function (v) { return getOptionValueWithEmptyStrings(v, elementType_1); }) : "";
31250             default:
31251                 return ts.forEachEntry(option.type, function (optionEnumValue, optionStringValue) {
31252                     if (optionEnumValue === value) {
31253                         return optionStringValue;
31254                     }
31255                 });
31256         }
31257     }
31258 })(ts || (ts = {}));
31259 var ts;
31260 (function (ts) {
31261     function trace(host) {
31262         host.trace(ts.formatMessage.apply(undefined, arguments));
31263     }
31264     ts.trace = trace;
31265     function isTraceEnabled(compilerOptions, host) {
31266         return !!compilerOptions.traceResolution && host.trace !== undefined;
31267     }
31268     ts.isTraceEnabled = isTraceEnabled;
31269     function withPackageId(packageInfo, r) {
31270         var packageId;
31271         if (r && packageInfo) {
31272             var packageJsonContent = packageInfo.packageJsonContent;
31273             if (typeof packageJsonContent.name === "string" && typeof packageJsonContent.version === "string") {
31274                 packageId = {
31275                     name: packageJsonContent.name,
31276                     subModuleName: r.path.slice(packageInfo.packageDirectory.length + ts.directorySeparator.length),
31277                     version: packageJsonContent.version
31278                 };
31279             }
31280         }
31281         return r && { path: r.path, extension: r.ext, packageId: packageId };
31282     }
31283     function noPackageId(r) {
31284         return withPackageId(undefined, r);
31285     }
31286     function removeIgnoredPackageId(r) {
31287         if (r) {
31288             ts.Debug.assert(r.packageId === undefined);
31289             return { path: r.path, ext: r.extension };
31290         }
31291     }
31292     var Extensions;
31293     (function (Extensions) {
31294         Extensions[Extensions["TypeScript"] = 0] = "TypeScript";
31295         Extensions[Extensions["JavaScript"] = 1] = "JavaScript";
31296         Extensions[Extensions["Json"] = 2] = "Json";
31297         Extensions[Extensions["TSConfig"] = 3] = "TSConfig";
31298         Extensions[Extensions["DtsOnly"] = 4] = "DtsOnly";
31299     })(Extensions || (Extensions = {}));
31300     function resolvedTypeScriptOnly(resolved) {
31301         if (!resolved) {
31302             return undefined;
31303         }
31304         ts.Debug.assert(ts.extensionIsTS(resolved.extension));
31305         return { fileName: resolved.path, packageId: resolved.packageId };
31306     }
31307     function createResolvedModuleWithFailedLookupLocations(resolved, isExternalLibraryImport, failedLookupLocations, resultFromCache) {
31308         var _a;
31309         if (resultFromCache) {
31310             (_a = resultFromCache.failedLookupLocations).push.apply(_a, failedLookupLocations);
31311             return resultFromCache;
31312         }
31313         return {
31314             resolvedModule: resolved && { resolvedFileName: resolved.path, originalPath: resolved.originalPath === true ? undefined : resolved.originalPath, extension: resolved.extension, isExternalLibraryImport: isExternalLibraryImport, packageId: resolved.packageId },
31315             failedLookupLocations: failedLookupLocations
31316         };
31317     }
31318     function readPackageJsonField(jsonContent, fieldName, typeOfTag, state) {
31319         if (!ts.hasProperty(jsonContent, fieldName)) {
31320             if (state.traceEnabled) {
31321                 trace(state.host, ts.Diagnostics.package_json_does_not_have_a_0_field, fieldName);
31322             }
31323             return;
31324         }
31325         var value = jsonContent[fieldName];
31326         if (typeof value !== typeOfTag || value === null) {
31327             if (state.traceEnabled) {
31328                 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);
31329             }
31330             return;
31331         }
31332         return value;
31333     }
31334     function readPackageJsonPathField(jsonContent, fieldName, baseDirectory, state) {
31335         var fileName = readPackageJsonField(jsonContent, fieldName, "string", state);
31336         if (fileName === undefined) {
31337             return;
31338         }
31339         if (!fileName) {
31340             if (state.traceEnabled) {
31341                 trace(state.host, ts.Diagnostics.package_json_had_a_falsy_0_field, fieldName);
31342             }
31343             return;
31344         }
31345         var path = ts.normalizePath(ts.combinePaths(baseDirectory, fileName));
31346         if (state.traceEnabled) {
31347             trace(state.host, ts.Diagnostics.package_json_has_0_field_1_that_references_2, fieldName, fileName, path);
31348         }
31349         return path;
31350     }
31351     function readPackageJsonTypesFields(jsonContent, baseDirectory, state) {
31352         return readPackageJsonPathField(jsonContent, "typings", baseDirectory, state)
31353             || readPackageJsonPathField(jsonContent, "types", baseDirectory, state);
31354     }
31355     function readPackageJsonTSConfigField(jsonContent, baseDirectory, state) {
31356         return readPackageJsonPathField(jsonContent, "tsconfig", baseDirectory, state);
31357     }
31358     function readPackageJsonMainField(jsonContent, baseDirectory, state) {
31359         return readPackageJsonPathField(jsonContent, "main", baseDirectory, state);
31360     }
31361     function readPackageJsonTypesVersionsField(jsonContent, state) {
31362         var typesVersions = readPackageJsonField(jsonContent, "typesVersions", "object", state);
31363         if (typesVersions === undefined)
31364             return;
31365         if (state.traceEnabled) {
31366             trace(state.host, ts.Diagnostics.package_json_has_a_typesVersions_field_with_version_specific_path_mappings);
31367         }
31368         return typesVersions;
31369     }
31370     function readPackageJsonTypesVersionPaths(jsonContent, state) {
31371         var typesVersions = readPackageJsonTypesVersionsField(jsonContent, state);
31372         if (typesVersions === undefined)
31373             return;
31374         if (state.traceEnabled) {
31375             for (var key in typesVersions) {
31376                 if (ts.hasProperty(typesVersions, key) && !ts.VersionRange.tryParse(key)) {
31377                     trace(state.host, ts.Diagnostics.package_json_has_a_typesVersions_entry_0_that_is_not_a_valid_semver_range, key);
31378                 }
31379             }
31380         }
31381         var result = getPackageJsonTypesVersionsPaths(typesVersions);
31382         if (!result) {
31383             if (state.traceEnabled) {
31384                 trace(state.host, ts.Diagnostics.package_json_does_not_have_a_typesVersions_entry_that_matches_version_0, ts.versionMajorMinor);
31385             }
31386             return;
31387         }
31388         var bestVersionKey = result.version, bestVersionPaths = result.paths;
31389         if (typeof bestVersionPaths !== "object") {
31390             if (state.traceEnabled) {
31391                 trace(state.host, ts.Diagnostics.Expected_type_of_0_field_in_package_json_to_be_1_got_2, "typesVersions['" + bestVersionKey + "']", "object", typeof bestVersionPaths);
31392             }
31393             return;
31394         }
31395         return result;
31396     }
31397     var typeScriptVersion;
31398     function getPackageJsonTypesVersionsPaths(typesVersions) {
31399         if (!typeScriptVersion)
31400             typeScriptVersion = new ts.Version(ts.version);
31401         for (var key in typesVersions) {
31402             if (!ts.hasProperty(typesVersions, key))
31403                 continue;
31404             var keyRange = ts.VersionRange.tryParse(key);
31405             if (keyRange === undefined) {
31406                 continue;
31407             }
31408             if (keyRange.test(typeScriptVersion)) {
31409                 return { version: key, paths: typesVersions[key] };
31410             }
31411         }
31412     }
31413     ts.getPackageJsonTypesVersionsPaths = getPackageJsonTypesVersionsPaths;
31414     function getEffectiveTypeRoots(options, host) {
31415         if (options.typeRoots) {
31416             return options.typeRoots;
31417         }
31418         var currentDirectory;
31419         if (options.configFilePath) {
31420             currentDirectory = ts.getDirectoryPath(options.configFilePath);
31421         }
31422         else if (host.getCurrentDirectory) {
31423             currentDirectory = host.getCurrentDirectory();
31424         }
31425         if (currentDirectory !== undefined) {
31426             return getDefaultTypeRoots(currentDirectory, host);
31427         }
31428     }
31429     ts.getEffectiveTypeRoots = getEffectiveTypeRoots;
31430     function getDefaultTypeRoots(currentDirectory, host) {
31431         if (!host.directoryExists) {
31432             return [ts.combinePaths(currentDirectory, nodeModulesAtTypes)];
31433         }
31434         var typeRoots;
31435         ts.forEachAncestorDirectory(ts.normalizePath(currentDirectory), function (directory) {
31436             var atTypes = ts.combinePaths(directory, nodeModulesAtTypes);
31437             if (host.directoryExists(atTypes)) {
31438                 (typeRoots || (typeRoots = [])).push(atTypes);
31439             }
31440             return undefined;
31441         });
31442         return typeRoots;
31443     }
31444     var nodeModulesAtTypes = ts.combinePaths("node_modules", "@types");
31445     function resolveTypeReferenceDirective(typeReferenceDirectiveName, containingFile, options, host, redirectedReference) {
31446         var traceEnabled = isTraceEnabled(options, host);
31447         if (redirectedReference) {
31448             options = redirectedReference.commandLine.options;
31449         }
31450         var failedLookupLocations = [];
31451         var moduleResolutionState = { compilerOptions: options, host: host, traceEnabled: traceEnabled, failedLookupLocations: failedLookupLocations };
31452         var typeRoots = getEffectiveTypeRoots(options, host);
31453         if (traceEnabled) {
31454             if (containingFile === undefined) {
31455                 if (typeRoots === undefined) {
31456                     trace(host, ts.Diagnostics.Resolving_type_reference_directive_0_containing_file_not_set_root_directory_not_set, typeReferenceDirectiveName);
31457                 }
31458                 else {
31459                     trace(host, ts.Diagnostics.Resolving_type_reference_directive_0_containing_file_not_set_root_directory_1, typeReferenceDirectiveName, typeRoots);
31460                 }
31461             }
31462             else {
31463                 if (typeRoots === undefined) {
31464                     trace(host, ts.Diagnostics.Resolving_type_reference_directive_0_containing_file_1_root_directory_not_set, typeReferenceDirectiveName, containingFile);
31465                 }
31466                 else {
31467                     trace(host, ts.Diagnostics.Resolving_type_reference_directive_0_containing_file_1_root_directory_2, typeReferenceDirectiveName, containingFile, typeRoots);
31468                 }
31469             }
31470             if (redirectedReference) {
31471                 trace(host, ts.Diagnostics.Using_compiler_options_of_project_reference_redirect_0, redirectedReference.sourceFile.fileName);
31472             }
31473         }
31474         var resolved = primaryLookup();
31475         var primary = true;
31476         if (!resolved) {
31477             resolved = secondaryLookup();
31478             primary = false;
31479         }
31480         var resolvedTypeReferenceDirective;
31481         if (resolved) {
31482             var fileName = resolved.fileName, packageId = resolved.packageId;
31483             var resolvedFileName = options.preserveSymlinks ? fileName : realPath(fileName, host, traceEnabled);
31484             if (traceEnabled) {
31485                 if (packageId) {
31486                     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);
31487                 }
31488                 else {
31489                     trace(host, ts.Diagnostics.Type_reference_directive_0_was_successfully_resolved_to_1_primary_Colon_2, typeReferenceDirectiveName, resolvedFileName, primary);
31490                 }
31491             }
31492             resolvedTypeReferenceDirective = { primary: primary, resolvedFileName: resolvedFileName, packageId: packageId, isExternalLibraryImport: pathContainsNodeModules(fileName) };
31493         }
31494         return { resolvedTypeReferenceDirective: resolvedTypeReferenceDirective, failedLookupLocations: failedLookupLocations };
31495         function primaryLookup() {
31496             if (typeRoots && typeRoots.length) {
31497                 if (traceEnabled) {
31498                     trace(host, ts.Diagnostics.Resolving_with_primary_search_path_0, typeRoots.join(", "));
31499                 }
31500                 return ts.firstDefined(typeRoots, function (typeRoot) {
31501                     var candidate = ts.combinePaths(typeRoot, typeReferenceDirectiveName);
31502                     var candidateDirectory = ts.getDirectoryPath(candidate);
31503                     var directoryExists = ts.directoryProbablyExists(candidateDirectory, host);
31504                     if (!directoryExists && traceEnabled) {
31505                         trace(host, ts.Diagnostics.Directory_0_does_not_exist_skipping_all_lookups_in_it, candidateDirectory);
31506                     }
31507                     return resolvedTypeScriptOnly(loadNodeModuleFromDirectory(Extensions.DtsOnly, candidate, !directoryExists, moduleResolutionState));
31508                 });
31509             }
31510             else {
31511                 if (traceEnabled) {
31512                     trace(host, ts.Diagnostics.Root_directory_cannot_be_determined_skipping_primary_search_paths);
31513                 }
31514             }
31515         }
31516         function secondaryLookup() {
31517             var initialLocationForSecondaryLookup = containingFile && ts.getDirectoryPath(containingFile);
31518             if (initialLocationForSecondaryLookup !== undefined) {
31519                 if (traceEnabled) {
31520                     trace(host, ts.Diagnostics.Looking_up_in_node_modules_folder_initial_location_0, initialLocationForSecondaryLookup);
31521                 }
31522                 var result = void 0;
31523                 if (!ts.isExternalModuleNameRelative(typeReferenceDirectiveName)) {
31524                     var searchResult = loadModuleFromNearestNodeModulesDirectory(Extensions.DtsOnly, typeReferenceDirectiveName, initialLocationForSecondaryLookup, moduleResolutionState, undefined, undefined);
31525                     result = searchResult && searchResult.value;
31526                 }
31527                 else {
31528                     var candidate = ts.normalizePathAndParts(ts.combinePaths(initialLocationForSecondaryLookup, typeReferenceDirectiveName)).path;
31529                     result = nodeLoadModuleByRelativeName(Extensions.DtsOnly, candidate, false, moduleResolutionState, true);
31530                 }
31531                 var resolvedFile = resolvedTypeScriptOnly(result);
31532                 if (!resolvedFile && traceEnabled) {
31533                     trace(host, ts.Diagnostics.Type_reference_directive_0_was_not_resolved, typeReferenceDirectiveName);
31534                 }
31535                 return resolvedFile;
31536             }
31537             else {
31538                 if (traceEnabled) {
31539                     trace(host, ts.Diagnostics.Containing_file_is_not_specified_and_root_directory_cannot_be_determined_skipping_lookup_in_node_modules_folder);
31540                 }
31541             }
31542         }
31543     }
31544     ts.resolveTypeReferenceDirective = resolveTypeReferenceDirective;
31545     function getAutomaticTypeDirectiveNames(options, host) {
31546         if (options.types) {
31547             return options.types;
31548         }
31549         var result = [];
31550         if (host.directoryExists && host.getDirectories) {
31551             var typeRoots = getEffectiveTypeRoots(options, host);
31552             if (typeRoots) {
31553                 for (var _i = 0, typeRoots_1 = typeRoots; _i < typeRoots_1.length; _i++) {
31554                     var root = typeRoots_1[_i];
31555                     if (host.directoryExists(root)) {
31556                         for (var _a = 0, _b = host.getDirectories(root); _a < _b.length; _a++) {
31557                             var typeDirectivePath = _b[_a];
31558                             var normalized = ts.normalizePath(typeDirectivePath);
31559                             var packageJsonPath = ts.combinePaths(root, normalized, "package.json");
31560                             var isNotNeededPackage = host.fileExists(packageJsonPath) && ts.readJson(packageJsonPath, host).typings === null;
31561                             if (!isNotNeededPackage) {
31562                                 var baseFileName = ts.getBaseFileName(normalized);
31563                                 if (baseFileName.charCodeAt(0) !== 46) {
31564                                     result.push(baseFileName);
31565                                 }
31566                             }
31567                         }
31568                     }
31569                 }
31570             }
31571         }
31572         return result;
31573     }
31574     ts.getAutomaticTypeDirectiveNames = getAutomaticTypeDirectiveNames;
31575     function createModuleResolutionCache(currentDirectory, getCanonicalFileName, options) {
31576         return createModuleResolutionCacheWithMaps(createCacheWithRedirects(options), createCacheWithRedirects(options), currentDirectory, getCanonicalFileName);
31577     }
31578     ts.createModuleResolutionCache = createModuleResolutionCache;
31579     function createCacheWithRedirects(options) {
31580         var ownMap = new ts.Map();
31581         var redirectsMap = new ts.Map();
31582         return {
31583             ownMap: ownMap,
31584             redirectsMap: redirectsMap,
31585             getOrCreateMapOfCacheRedirects: getOrCreateMapOfCacheRedirects,
31586             clear: clear,
31587             setOwnOptions: setOwnOptions,
31588             setOwnMap: setOwnMap
31589         };
31590         function setOwnOptions(newOptions) {
31591             options = newOptions;
31592         }
31593         function setOwnMap(newOwnMap) {
31594             ownMap = newOwnMap;
31595         }
31596         function getOrCreateMapOfCacheRedirects(redirectedReference) {
31597             if (!redirectedReference) {
31598                 return ownMap;
31599             }
31600             var path = redirectedReference.sourceFile.path;
31601             var redirects = redirectsMap.get(path);
31602             if (!redirects) {
31603                 redirects = !options || ts.optionsHaveModuleResolutionChanges(options, redirectedReference.commandLine.options) ? new ts.Map() : ownMap;
31604                 redirectsMap.set(path, redirects);
31605             }
31606             return redirects;
31607         }
31608         function clear() {
31609             ownMap.clear();
31610             redirectsMap.clear();
31611         }
31612     }
31613     ts.createCacheWithRedirects = createCacheWithRedirects;
31614     function createModuleResolutionCacheWithMaps(directoryToModuleNameMap, moduleNameToDirectoryMap, currentDirectory, getCanonicalFileName) {
31615         return { getOrCreateCacheForDirectory: getOrCreateCacheForDirectory, getOrCreateCacheForModuleName: getOrCreateCacheForModuleName, directoryToModuleNameMap: directoryToModuleNameMap, moduleNameToDirectoryMap: moduleNameToDirectoryMap };
31616         function getOrCreateCacheForDirectory(directoryName, redirectedReference) {
31617             var path = ts.toPath(directoryName, currentDirectory, getCanonicalFileName);
31618             return getOrCreateCache(directoryToModuleNameMap, redirectedReference, path, function () { return new ts.Map(); });
31619         }
31620         function getOrCreateCacheForModuleName(nonRelativeModuleName, redirectedReference) {
31621             ts.Debug.assert(!ts.isExternalModuleNameRelative(nonRelativeModuleName));
31622             return getOrCreateCache(moduleNameToDirectoryMap, redirectedReference, nonRelativeModuleName, createPerModuleNameCache);
31623         }
31624         function getOrCreateCache(cacheWithRedirects, redirectedReference, key, create) {
31625             var cache = cacheWithRedirects.getOrCreateMapOfCacheRedirects(redirectedReference);
31626             var result = cache.get(key);
31627             if (!result) {
31628                 result = create();
31629                 cache.set(key, result);
31630             }
31631             return result;
31632         }
31633         function createPerModuleNameCache() {
31634             var directoryPathMap = new ts.Map();
31635             return { get: get, set: set };
31636             function get(directory) {
31637                 return directoryPathMap.get(ts.toPath(directory, currentDirectory, getCanonicalFileName));
31638             }
31639             function set(directory, result) {
31640                 var path = ts.toPath(directory, currentDirectory, getCanonicalFileName);
31641                 if (directoryPathMap.has(path)) {
31642                     return;
31643                 }
31644                 directoryPathMap.set(path, result);
31645                 var resolvedFileName = result.resolvedModule &&
31646                     (result.resolvedModule.originalPath || result.resolvedModule.resolvedFileName);
31647                 var commonPrefix = resolvedFileName && getCommonPrefix(path, resolvedFileName);
31648                 var current = path;
31649                 while (current !== commonPrefix) {
31650                     var parent = ts.getDirectoryPath(current);
31651                     if (parent === current || directoryPathMap.has(parent)) {
31652                         break;
31653                     }
31654                     directoryPathMap.set(parent, result);
31655                     current = parent;
31656                 }
31657             }
31658             function getCommonPrefix(directory, resolution) {
31659                 var resolutionDirectory = ts.toPath(ts.getDirectoryPath(resolution), currentDirectory, getCanonicalFileName);
31660                 var i = 0;
31661                 var limit = Math.min(directory.length, resolutionDirectory.length);
31662                 while (i < limit && directory.charCodeAt(i) === resolutionDirectory.charCodeAt(i)) {
31663                     i++;
31664                 }
31665                 if (i === directory.length && (resolutionDirectory.length === i || resolutionDirectory[i] === ts.directorySeparator)) {
31666                     return directory;
31667                 }
31668                 var rootLength = ts.getRootLength(directory);
31669                 if (i < rootLength) {
31670                     return undefined;
31671                 }
31672                 var sep = directory.lastIndexOf(ts.directorySeparator, i - 1);
31673                 if (sep === -1) {
31674                     return undefined;
31675                 }
31676                 return directory.substr(0, Math.max(sep, rootLength));
31677             }
31678         }
31679     }
31680     ts.createModuleResolutionCacheWithMaps = createModuleResolutionCacheWithMaps;
31681     function resolveModuleNameFromCache(moduleName, containingFile, cache) {
31682         var containingDirectory = ts.getDirectoryPath(containingFile);
31683         var perFolderCache = cache && cache.getOrCreateCacheForDirectory(containingDirectory);
31684         return perFolderCache && perFolderCache.get(moduleName);
31685     }
31686     ts.resolveModuleNameFromCache = resolveModuleNameFromCache;
31687     function resolveModuleName(moduleName, containingFile, compilerOptions, host, cache, redirectedReference) {
31688         var traceEnabled = isTraceEnabled(compilerOptions, host);
31689         if (redirectedReference) {
31690             compilerOptions = redirectedReference.commandLine.options;
31691         }
31692         if (traceEnabled) {
31693             trace(host, ts.Diagnostics.Resolving_module_0_from_1, moduleName, containingFile);
31694             if (redirectedReference) {
31695                 trace(host, ts.Diagnostics.Using_compiler_options_of_project_reference_redirect_0, redirectedReference.sourceFile.fileName);
31696             }
31697         }
31698         var containingDirectory = ts.getDirectoryPath(containingFile);
31699         var perFolderCache = cache && cache.getOrCreateCacheForDirectory(containingDirectory, redirectedReference);
31700         var result = perFolderCache && perFolderCache.get(moduleName);
31701         if (result) {
31702             if (traceEnabled) {
31703                 trace(host, ts.Diagnostics.Resolution_for_module_0_was_found_in_cache_from_location_1, moduleName, containingDirectory);
31704             }
31705         }
31706         else {
31707             var moduleResolution = compilerOptions.moduleResolution;
31708             if (moduleResolution === undefined) {
31709                 moduleResolution = ts.getEmitModuleKind(compilerOptions) === ts.ModuleKind.CommonJS ? ts.ModuleResolutionKind.NodeJs : ts.ModuleResolutionKind.Classic;
31710                 if (traceEnabled) {
31711                     trace(host, ts.Diagnostics.Module_resolution_kind_is_not_specified_using_0, ts.ModuleResolutionKind[moduleResolution]);
31712                 }
31713             }
31714             else {
31715                 if (traceEnabled) {
31716                     trace(host, ts.Diagnostics.Explicitly_specified_module_resolution_kind_Colon_0, ts.ModuleResolutionKind[moduleResolution]);
31717                 }
31718             }
31719             ts.perfLogger.logStartResolveModule(moduleName);
31720             switch (moduleResolution) {
31721                 case ts.ModuleResolutionKind.NodeJs:
31722                     result = nodeModuleNameResolver(moduleName, containingFile, compilerOptions, host, cache, redirectedReference);
31723                     break;
31724                 case ts.ModuleResolutionKind.Classic:
31725                     result = classicNameResolver(moduleName, containingFile, compilerOptions, host, cache, redirectedReference);
31726                     break;
31727                 default:
31728                     return ts.Debug.fail("Unexpected moduleResolution: " + moduleResolution);
31729             }
31730             if (result && result.resolvedModule)
31731                 ts.perfLogger.logInfoEvent("Module \"" + moduleName + "\" resolved to \"" + result.resolvedModule.resolvedFileName + "\"");
31732             ts.perfLogger.logStopResolveModule((result && result.resolvedModule) ? "" + result.resolvedModule.resolvedFileName : "null");
31733             if (perFolderCache) {
31734                 perFolderCache.set(moduleName, result);
31735                 if (!ts.isExternalModuleNameRelative(moduleName)) {
31736                     cache.getOrCreateCacheForModuleName(moduleName, redirectedReference).set(containingDirectory, result);
31737                 }
31738             }
31739         }
31740         if (traceEnabled) {
31741             if (result.resolvedModule) {
31742                 if (result.resolvedModule.packageId) {
31743                     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));
31744                 }
31745                 else {
31746                     trace(host, ts.Diagnostics.Module_name_0_was_successfully_resolved_to_1, moduleName, result.resolvedModule.resolvedFileName);
31747                 }
31748             }
31749             else {
31750                 trace(host, ts.Diagnostics.Module_name_0_was_not_resolved, moduleName);
31751             }
31752         }
31753         return result;
31754     }
31755     ts.resolveModuleName = resolveModuleName;
31756     function tryLoadModuleUsingOptionalResolutionSettings(extensions, moduleName, containingDirectory, loader, state) {
31757         var resolved = tryLoadModuleUsingPathsIfEligible(extensions, moduleName, loader, state);
31758         if (resolved)
31759             return resolved.value;
31760         if (!ts.isExternalModuleNameRelative(moduleName)) {
31761             return tryLoadModuleUsingBaseUrl(extensions, moduleName, loader, state);
31762         }
31763         else {
31764             return tryLoadModuleUsingRootDirs(extensions, moduleName, containingDirectory, loader, state);
31765         }
31766     }
31767     function tryLoadModuleUsingPathsIfEligible(extensions, moduleName, loader, state) {
31768         var _a = state.compilerOptions, baseUrl = _a.baseUrl, paths = _a.paths;
31769         if (paths && !ts.pathIsRelative(moduleName)) {
31770             if (state.traceEnabled) {
31771                 if (baseUrl) {
31772                     trace(state.host, ts.Diagnostics.baseUrl_option_is_set_to_0_using_this_value_to_resolve_non_relative_module_name_1, baseUrl, moduleName);
31773                 }
31774                 trace(state.host, ts.Diagnostics.paths_option_is_specified_looking_for_a_pattern_to_match_module_name_0, moduleName);
31775             }
31776             var baseDirectory = ts.getPathsBasePath(state.compilerOptions, state.host);
31777             return tryLoadModuleUsingPaths(extensions, moduleName, baseDirectory, paths, loader, false, state);
31778         }
31779     }
31780     function tryLoadModuleUsingRootDirs(extensions, moduleName, containingDirectory, loader, state) {
31781         if (!state.compilerOptions.rootDirs) {
31782             return undefined;
31783         }
31784         if (state.traceEnabled) {
31785             trace(state.host, ts.Diagnostics.rootDirs_option_is_set_using_it_to_resolve_relative_module_name_0, moduleName);
31786         }
31787         var candidate = ts.normalizePath(ts.combinePaths(containingDirectory, moduleName));
31788         var matchedRootDir;
31789         var matchedNormalizedPrefix;
31790         for (var _i = 0, _a = state.compilerOptions.rootDirs; _i < _a.length; _i++) {
31791             var rootDir = _a[_i];
31792             var normalizedRoot = ts.normalizePath(rootDir);
31793             if (!ts.endsWith(normalizedRoot, ts.directorySeparator)) {
31794                 normalizedRoot += ts.directorySeparator;
31795             }
31796             var isLongestMatchingPrefix = ts.startsWith(candidate, normalizedRoot) &&
31797                 (matchedNormalizedPrefix === undefined || matchedNormalizedPrefix.length < normalizedRoot.length);
31798             if (state.traceEnabled) {
31799                 trace(state.host, ts.Diagnostics.Checking_if_0_is_the_longest_matching_prefix_for_1_2, normalizedRoot, candidate, isLongestMatchingPrefix);
31800             }
31801             if (isLongestMatchingPrefix) {
31802                 matchedNormalizedPrefix = normalizedRoot;
31803                 matchedRootDir = rootDir;
31804             }
31805         }
31806         if (matchedNormalizedPrefix) {
31807             if (state.traceEnabled) {
31808                 trace(state.host, ts.Diagnostics.Longest_matching_prefix_for_0_is_1, candidate, matchedNormalizedPrefix);
31809             }
31810             var suffix = candidate.substr(matchedNormalizedPrefix.length);
31811             if (state.traceEnabled) {
31812                 trace(state.host, ts.Diagnostics.Loading_0_from_the_root_dir_1_candidate_location_2, suffix, matchedNormalizedPrefix, candidate);
31813             }
31814             var resolvedFileName = loader(extensions, candidate, !ts.directoryProbablyExists(containingDirectory, state.host), state);
31815             if (resolvedFileName) {
31816                 return resolvedFileName;
31817             }
31818             if (state.traceEnabled) {
31819                 trace(state.host, ts.Diagnostics.Trying_other_entries_in_rootDirs);
31820             }
31821             for (var _b = 0, _c = state.compilerOptions.rootDirs; _b < _c.length; _b++) {
31822                 var rootDir = _c[_b];
31823                 if (rootDir === matchedRootDir) {
31824                     continue;
31825                 }
31826                 var candidate_1 = ts.combinePaths(ts.normalizePath(rootDir), suffix);
31827                 if (state.traceEnabled) {
31828                     trace(state.host, ts.Diagnostics.Loading_0_from_the_root_dir_1_candidate_location_2, suffix, rootDir, candidate_1);
31829                 }
31830                 var baseDirectory = ts.getDirectoryPath(candidate_1);
31831                 var resolvedFileName_1 = loader(extensions, candidate_1, !ts.directoryProbablyExists(baseDirectory, state.host), state);
31832                 if (resolvedFileName_1) {
31833                     return resolvedFileName_1;
31834                 }
31835             }
31836             if (state.traceEnabled) {
31837                 trace(state.host, ts.Diagnostics.Module_resolution_using_rootDirs_has_failed);
31838             }
31839         }
31840         return undefined;
31841     }
31842     function tryLoadModuleUsingBaseUrl(extensions, moduleName, loader, state) {
31843         var baseUrl = state.compilerOptions.baseUrl;
31844         if (!baseUrl) {
31845             return undefined;
31846         }
31847         if (state.traceEnabled) {
31848             trace(state.host, ts.Diagnostics.baseUrl_option_is_set_to_0_using_this_value_to_resolve_non_relative_module_name_1, baseUrl, moduleName);
31849         }
31850         var candidate = ts.normalizePath(ts.combinePaths(baseUrl, moduleName));
31851         if (state.traceEnabled) {
31852             trace(state.host, ts.Diagnostics.Resolving_module_name_0_relative_to_base_url_1_2, moduleName, baseUrl, candidate);
31853         }
31854         return loader(extensions, candidate, !ts.directoryProbablyExists(ts.getDirectoryPath(candidate), state.host), state);
31855     }
31856     function resolveJSModule(moduleName, initialDir, host) {
31857         var _a = tryResolveJSModuleWorker(moduleName, initialDir, host), resolvedModule = _a.resolvedModule, failedLookupLocations = _a.failedLookupLocations;
31858         if (!resolvedModule) {
31859             throw new Error("Could not resolve JS module '" + moduleName + "' starting at '" + initialDir + "'. Looked in: " + failedLookupLocations.join(", "));
31860         }
31861         return resolvedModule.resolvedFileName;
31862     }
31863     ts.resolveJSModule = resolveJSModule;
31864     function tryResolveJSModule(moduleName, initialDir, host) {
31865         var resolvedModule = tryResolveJSModuleWorker(moduleName, initialDir, host).resolvedModule;
31866         return resolvedModule && resolvedModule.resolvedFileName;
31867     }
31868     ts.tryResolveJSModule = tryResolveJSModule;
31869     var jsOnlyExtensions = [Extensions.JavaScript];
31870     var tsExtensions = [Extensions.TypeScript, Extensions.JavaScript];
31871     var tsPlusJsonExtensions = __spreadArrays(tsExtensions, [Extensions.Json]);
31872     var tsconfigExtensions = [Extensions.TSConfig];
31873     function tryResolveJSModuleWorker(moduleName, initialDir, host) {
31874         return nodeModuleNameResolverWorker(moduleName, initialDir, { moduleResolution: ts.ModuleResolutionKind.NodeJs, allowJs: true }, host, undefined, jsOnlyExtensions, undefined);
31875     }
31876     function nodeModuleNameResolver(moduleName, containingFile, compilerOptions, host, cache, redirectedReference, lookupConfig) {
31877         return nodeModuleNameResolverWorker(moduleName, ts.getDirectoryPath(containingFile), compilerOptions, host, cache, lookupConfig ? tsconfigExtensions : (compilerOptions.resolveJsonModule ? tsPlusJsonExtensions : tsExtensions), redirectedReference);
31878     }
31879     ts.nodeModuleNameResolver = nodeModuleNameResolver;
31880     function nodeModuleNameResolverWorker(moduleName, containingDirectory, compilerOptions, host, cache, extensions, redirectedReference) {
31881         var _a, _b;
31882         var traceEnabled = isTraceEnabled(compilerOptions, host);
31883         var failedLookupLocations = [];
31884         var state = { compilerOptions: compilerOptions, host: host, traceEnabled: traceEnabled, failedLookupLocations: failedLookupLocations };
31885         var result = ts.forEach(extensions, function (ext) { return tryResolve(ext); });
31886         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);
31887         function tryResolve(extensions) {
31888             var loader = function (extensions, candidate, onlyRecordFailures, state) { return nodeLoadModuleByRelativeName(extensions, candidate, onlyRecordFailures, state, true); };
31889             var resolved = tryLoadModuleUsingOptionalResolutionSettings(extensions, moduleName, containingDirectory, loader, state);
31890             if (resolved) {
31891                 return toSearchResult({ resolved: resolved, isExternalLibraryImport: pathContainsNodeModules(resolved.path) });
31892             }
31893             if (!ts.isExternalModuleNameRelative(moduleName)) {
31894                 if (traceEnabled) {
31895                     trace(host, ts.Diagnostics.Loading_module_0_from_node_modules_folder_target_file_type_1, moduleName, Extensions[extensions]);
31896                 }
31897                 var resolved_1 = loadModuleFromNearestNodeModulesDirectory(extensions, moduleName, containingDirectory, state, cache, redirectedReference);
31898                 if (!resolved_1)
31899                     return undefined;
31900                 var resolvedValue = resolved_1.value;
31901                 if (!compilerOptions.preserveSymlinks && resolvedValue && !resolvedValue.originalPath) {
31902                     var path = realPath(resolvedValue.path, host, traceEnabled);
31903                     var originalPath = path === resolvedValue.path ? undefined : resolvedValue.path;
31904                     resolvedValue = __assign(__assign({}, resolvedValue), { path: path, originalPath: originalPath });
31905                 }
31906                 return { value: resolvedValue && { resolved: resolvedValue, isExternalLibraryImport: true } };
31907             }
31908             else {
31909                 var _a = ts.normalizePathAndParts(ts.combinePaths(containingDirectory, moduleName)), candidate = _a.path, parts = _a.parts;
31910                 var resolved_2 = nodeLoadModuleByRelativeName(extensions, candidate, false, state, true);
31911                 return resolved_2 && toSearchResult({ resolved: resolved_2, isExternalLibraryImport: ts.contains(parts, "node_modules") });
31912             }
31913         }
31914     }
31915     function realPath(path, host, traceEnabled) {
31916         if (!host.realpath) {
31917             return path;
31918         }
31919         var real = ts.normalizePath(host.realpath(path));
31920         if (traceEnabled) {
31921             trace(host, ts.Diagnostics.Resolving_real_path_for_0_result_1, path, real);
31922         }
31923         ts.Debug.assert(host.fileExists(real), path + " linked to nonexistent file " + real);
31924         return real;
31925     }
31926     function nodeLoadModuleByRelativeName(extensions, candidate, onlyRecordFailures, state, considerPackageJson) {
31927         if (state.traceEnabled) {
31928             trace(state.host, ts.Diagnostics.Loading_module_as_file_Slash_folder_candidate_module_location_0_target_file_type_1, candidate, Extensions[extensions]);
31929         }
31930         if (!ts.hasTrailingDirectorySeparator(candidate)) {
31931             if (!onlyRecordFailures) {
31932                 var parentOfCandidate = ts.getDirectoryPath(candidate);
31933                 if (!ts.directoryProbablyExists(parentOfCandidate, state.host)) {
31934                     if (state.traceEnabled) {
31935                         trace(state.host, ts.Diagnostics.Directory_0_does_not_exist_skipping_all_lookups_in_it, parentOfCandidate);
31936                     }
31937                     onlyRecordFailures = true;
31938                 }
31939             }
31940             var resolvedFromFile = loadModuleFromFile(extensions, candidate, onlyRecordFailures, state);
31941             if (resolvedFromFile) {
31942                 var packageDirectory = considerPackageJson ? parseNodeModuleFromPath(resolvedFromFile) : undefined;
31943                 var packageInfo = packageDirectory ? getPackageJsonInfo(packageDirectory, false, state) : undefined;
31944                 return withPackageId(packageInfo, resolvedFromFile);
31945             }
31946         }
31947         if (!onlyRecordFailures) {
31948             var candidateExists = ts.directoryProbablyExists(candidate, state.host);
31949             if (!candidateExists) {
31950                 if (state.traceEnabled) {
31951                     trace(state.host, ts.Diagnostics.Directory_0_does_not_exist_skipping_all_lookups_in_it, candidate);
31952                 }
31953                 onlyRecordFailures = true;
31954             }
31955         }
31956         return loadNodeModuleFromDirectory(extensions, candidate, onlyRecordFailures, state, considerPackageJson);
31957     }
31958     ts.nodeModulesPathPart = "/node_modules/";
31959     function pathContainsNodeModules(path) {
31960         return ts.stringContains(path, ts.nodeModulesPathPart);
31961     }
31962     ts.pathContainsNodeModules = pathContainsNodeModules;
31963     function parseNodeModuleFromPath(resolved) {
31964         var path = ts.normalizePath(resolved.path);
31965         var idx = path.lastIndexOf(ts.nodeModulesPathPart);
31966         if (idx === -1) {
31967             return undefined;
31968         }
31969         var indexAfterNodeModules = idx + ts.nodeModulesPathPart.length;
31970         var indexAfterPackageName = moveToNextDirectorySeparatorIfAvailable(path, indexAfterNodeModules);
31971         if (path.charCodeAt(indexAfterNodeModules) === 64) {
31972             indexAfterPackageName = moveToNextDirectorySeparatorIfAvailable(path, indexAfterPackageName);
31973         }
31974         return path.slice(0, indexAfterPackageName);
31975     }
31976     function moveToNextDirectorySeparatorIfAvailable(path, prevSeparatorIndex) {
31977         var nextSeparatorIndex = path.indexOf(ts.directorySeparator, prevSeparatorIndex + 1);
31978         return nextSeparatorIndex === -1 ? prevSeparatorIndex : nextSeparatorIndex;
31979     }
31980     function loadModuleFromFileNoPackageId(extensions, candidate, onlyRecordFailures, state) {
31981         return noPackageId(loadModuleFromFile(extensions, candidate, onlyRecordFailures, state));
31982     }
31983     function loadModuleFromFile(extensions, candidate, onlyRecordFailures, state) {
31984         if (extensions === Extensions.Json || extensions === Extensions.TSConfig) {
31985             var extensionLess = ts.tryRemoveExtension(candidate, ".json");
31986             return (extensionLess === undefined && extensions === Extensions.Json) ? undefined : tryAddingExtensions(extensionLess || candidate, extensions, onlyRecordFailures, state);
31987         }
31988         var resolvedByAddingExtension = tryAddingExtensions(candidate, extensions, onlyRecordFailures, state);
31989         if (resolvedByAddingExtension) {
31990             return resolvedByAddingExtension;
31991         }
31992         if (ts.hasJSFileExtension(candidate)) {
31993             var extensionless = ts.removeFileExtension(candidate);
31994             if (state.traceEnabled) {
31995                 var extension = candidate.substring(extensionless.length);
31996                 trace(state.host, ts.Diagnostics.File_name_0_has_a_1_extension_stripping_it, candidate, extension);
31997             }
31998             return tryAddingExtensions(extensionless, extensions, onlyRecordFailures, state);
31999         }
32000     }
32001     function tryAddingExtensions(candidate, extensions, onlyRecordFailures, state) {
32002         if (!onlyRecordFailures) {
32003             var directory = ts.getDirectoryPath(candidate);
32004             if (directory) {
32005                 onlyRecordFailures = !ts.directoryProbablyExists(directory, state.host);
32006             }
32007         }
32008         switch (extensions) {
32009             case Extensions.DtsOnly:
32010                 return tryExtension(".d.ts");
32011             case Extensions.TypeScript:
32012                 return tryExtension(".ts") || tryExtension(".tsx") || tryExtension(".d.ts");
32013             case Extensions.JavaScript:
32014                 return tryExtension(".js") || tryExtension(".jsx");
32015             case Extensions.TSConfig:
32016             case Extensions.Json:
32017                 return tryExtension(".json");
32018         }
32019         function tryExtension(ext) {
32020             var path = tryFile(candidate + ext, onlyRecordFailures, state);
32021             return path === undefined ? undefined : { path: path, ext: ext };
32022         }
32023     }
32024     function tryFile(fileName, onlyRecordFailures, state) {
32025         if (!onlyRecordFailures) {
32026             if (state.host.fileExists(fileName)) {
32027                 if (state.traceEnabled) {
32028                     trace(state.host, ts.Diagnostics.File_0_exist_use_it_as_a_name_resolution_result, fileName);
32029                 }
32030                 return fileName;
32031             }
32032             else {
32033                 if (state.traceEnabled) {
32034                     trace(state.host, ts.Diagnostics.File_0_does_not_exist, fileName);
32035                 }
32036             }
32037         }
32038         state.failedLookupLocations.push(fileName);
32039         return undefined;
32040     }
32041     function loadNodeModuleFromDirectory(extensions, candidate, onlyRecordFailures, state, considerPackageJson) {
32042         if (considerPackageJson === void 0) { considerPackageJson = true; }
32043         var packageInfo = considerPackageJson ? getPackageJsonInfo(candidate, onlyRecordFailures, state) : undefined;
32044         var packageJsonContent = packageInfo && packageInfo.packageJsonContent;
32045         var versionPaths = packageInfo && packageInfo.versionPaths;
32046         return withPackageId(packageInfo, loadNodeModuleFromDirectoryWorker(extensions, candidate, onlyRecordFailures, state, packageJsonContent, versionPaths));
32047     }
32048     function getPackageJsonInfo(packageDirectory, onlyRecordFailures, state) {
32049         var host = state.host, traceEnabled = state.traceEnabled;
32050         var directoryExists = !onlyRecordFailures && ts.directoryProbablyExists(packageDirectory, host);
32051         var packageJsonPath = ts.combinePaths(packageDirectory, "package.json");
32052         if (directoryExists && host.fileExists(packageJsonPath)) {
32053             var packageJsonContent = ts.readJson(packageJsonPath, host);
32054             if (traceEnabled) {
32055                 trace(host, ts.Diagnostics.Found_package_json_at_0, packageJsonPath);
32056             }
32057             var versionPaths = readPackageJsonTypesVersionPaths(packageJsonContent, state);
32058             return { packageDirectory: packageDirectory, packageJsonContent: packageJsonContent, versionPaths: versionPaths };
32059         }
32060         else {
32061             if (directoryExists && traceEnabled) {
32062                 trace(host, ts.Diagnostics.File_0_does_not_exist, packageJsonPath);
32063             }
32064             state.failedLookupLocations.push(packageJsonPath);
32065         }
32066     }
32067     function loadNodeModuleFromDirectoryWorker(extensions, candidate, onlyRecordFailures, state, jsonContent, versionPaths) {
32068         var packageFile;
32069         if (jsonContent) {
32070             switch (extensions) {
32071                 case Extensions.JavaScript:
32072                 case Extensions.Json:
32073                     packageFile = readPackageJsonMainField(jsonContent, candidate, state);
32074                     break;
32075                 case Extensions.TypeScript:
32076                     packageFile = readPackageJsonTypesFields(jsonContent, candidate, state) || readPackageJsonMainField(jsonContent, candidate, state);
32077                     break;
32078                 case Extensions.DtsOnly:
32079                     packageFile = readPackageJsonTypesFields(jsonContent, candidate, state);
32080                     break;
32081                 case Extensions.TSConfig:
32082                     packageFile = readPackageJsonTSConfigField(jsonContent, candidate, state);
32083                     break;
32084                 default:
32085                     return ts.Debug.assertNever(extensions);
32086             }
32087         }
32088         var loader = function (extensions, candidate, onlyRecordFailures, state) {
32089             var fromFile = tryFile(candidate, onlyRecordFailures, state);
32090             if (fromFile) {
32091                 var resolved = resolvedIfExtensionMatches(extensions, fromFile);
32092                 if (resolved) {
32093                     return noPackageId(resolved);
32094                 }
32095                 if (state.traceEnabled) {
32096                     trace(state.host, ts.Diagnostics.File_0_has_an_unsupported_extension_so_skipping_it, fromFile);
32097                 }
32098             }
32099             var nextExtensions = extensions === Extensions.DtsOnly ? Extensions.TypeScript : extensions;
32100             return nodeLoadModuleByRelativeName(nextExtensions, candidate, onlyRecordFailures, state, false);
32101         };
32102         var onlyRecordFailuresForPackageFile = packageFile ? !ts.directoryProbablyExists(ts.getDirectoryPath(packageFile), state.host) : undefined;
32103         var onlyRecordFailuresForIndex = onlyRecordFailures || !ts.directoryProbablyExists(candidate, state.host);
32104         var indexPath = ts.combinePaths(candidate, extensions === Extensions.TSConfig ? "tsconfig" : "index");
32105         if (versionPaths && (!packageFile || ts.containsPath(candidate, packageFile))) {
32106             var moduleName = ts.getRelativePathFromDirectory(candidate, packageFile || indexPath, false);
32107             if (state.traceEnabled) {
32108                 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);
32109             }
32110             var result = tryLoadModuleUsingPaths(extensions, moduleName, candidate, versionPaths.paths, loader, onlyRecordFailuresForPackageFile || onlyRecordFailuresForIndex, state);
32111             if (result) {
32112                 return removeIgnoredPackageId(result.value);
32113             }
32114         }
32115         var packageFileResult = packageFile && removeIgnoredPackageId(loader(extensions, packageFile, onlyRecordFailuresForPackageFile, state));
32116         if (packageFileResult)
32117             return packageFileResult;
32118         return loadModuleFromFile(extensions, indexPath, onlyRecordFailuresForIndex, state);
32119     }
32120     function resolvedIfExtensionMatches(extensions, path) {
32121         var ext = ts.tryGetExtensionFromPath(path);
32122         return ext !== undefined && extensionIsOk(extensions, ext) ? { path: path, ext: ext } : undefined;
32123     }
32124     function extensionIsOk(extensions, extension) {
32125         switch (extensions) {
32126             case Extensions.JavaScript:
32127                 return extension === ".js" || extension === ".jsx";
32128             case Extensions.TSConfig:
32129             case Extensions.Json:
32130                 return extension === ".json";
32131             case Extensions.TypeScript:
32132                 return extension === ".ts" || extension === ".tsx" || extension === ".d.ts";
32133             case Extensions.DtsOnly:
32134                 return extension === ".d.ts";
32135         }
32136     }
32137     function parsePackageName(moduleName) {
32138         var idx = moduleName.indexOf(ts.directorySeparator);
32139         if (moduleName[0] === "@") {
32140             idx = moduleName.indexOf(ts.directorySeparator, idx + 1);
32141         }
32142         return idx === -1 ? { packageName: moduleName, rest: "" } : { packageName: moduleName.slice(0, idx), rest: moduleName.slice(idx + 1) };
32143     }
32144     ts.parsePackageName = parsePackageName;
32145     function loadModuleFromNearestNodeModulesDirectory(extensions, moduleName, directory, state, cache, redirectedReference) {
32146         return loadModuleFromNearestNodeModulesDirectoryWorker(extensions, moduleName, directory, state, false, cache, redirectedReference);
32147     }
32148     function loadModuleFromNearestNodeModulesDirectoryTypesScope(moduleName, directory, state) {
32149         return loadModuleFromNearestNodeModulesDirectoryWorker(Extensions.DtsOnly, moduleName, directory, state, true, undefined, undefined);
32150     }
32151     function loadModuleFromNearestNodeModulesDirectoryWorker(extensions, moduleName, directory, state, typesScopeOnly, cache, redirectedReference) {
32152         var perModuleNameCache = cache && cache.getOrCreateCacheForModuleName(moduleName, redirectedReference);
32153         return ts.forEachAncestorDirectory(ts.normalizeSlashes(directory), function (ancestorDirectory) {
32154             if (ts.getBaseFileName(ancestorDirectory) !== "node_modules") {
32155                 var resolutionFromCache = tryFindNonRelativeModuleNameInCache(perModuleNameCache, moduleName, ancestorDirectory, state);
32156                 if (resolutionFromCache) {
32157                     return resolutionFromCache;
32158                 }
32159                 return toSearchResult(loadModuleFromImmediateNodeModulesDirectory(extensions, moduleName, ancestorDirectory, state, typesScopeOnly));
32160             }
32161         });
32162     }
32163     function loadModuleFromImmediateNodeModulesDirectory(extensions, moduleName, directory, state, typesScopeOnly) {
32164         var nodeModulesFolder = ts.combinePaths(directory, "node_modules");
32165         var nodeModulesFolderExists = ts.directoryProbablyExists(nodeModulesFolder, state.host);
32166         if (!nodeModulesFolderExists && state.traceEnabled) {
32167             trace(state.host, ts.Diagnostics.Directory_0_does_not_exist_skipping_all_lookups_in_it, nodeModulesFolder);
32168         }
32169         var packageResult = typesScopeOnly ? undefined : loadModuleFromSpecificNodeModulesDirectory(extensions, moduleName, nodeModulesFolder, nodeModulesFolderExists, state);
32170         if (packageResult) {
32171             return packageResult;
32172         }
32173         if (extensions === Extensions.TypeScript || extensions === Extensions.DtsOnly) {
32174             var nodeModulesAtTypes_1 = ts.combinePaths(nodeModulesFolder, "@types");
32175             var nodeModulesAtTypesExists = nodeModulesFolderExists;
32176             if (nodeModulesFolderExists && !ts.directoryProbablyExists(nodeModulesAtTypes_1, state.host)) {
32177                 if (state.traceEnabled) {
32178                     trace(state.host, ts.Diagnostics.Directory_0_does_not_exist_skipping_all_lookups_in_it, nodeModulesAtTypes_1);
32179                 }
32180                 nodeModulesAtTypesExists = false;
32181             }
32182             return loadModuleFromSpecificNodeModulesDirectory(Extensions.DtsOnly, mangleScopedPackageNameWithTrace(moduleName, state), nodeModulesAtTypes_1, nodeModulesAtTypesExists, state);
32183         }
32184     }
32185     function loadModuleFromSpecificNodeModulesDirectory(extensions, moduleName, nodeModulesDirectory, nodeModulesDirectoryExists, state) {
32186         var candidate = ts.normalizePath(ts.combinePaths(nodeModulesDirectory, moduleName));
32187         var packageInfo = getPackageJsonInfo(candidate, !nodeModulesDirectoryExists, state);
32188         if (packageInfo) {
32189             var fromFile = loadModuleFromFile(extensions, candidate, !nodeModulesDirectoryExists, state);
32190             if (fromFile) {
32191                 return noPackageId(fromFile);
32192             }
32193             var fromDirectory = loadNodeModuleFromDirectoryWorker(extensions, candidate, !nodeModulesDirectoryExists, state, packageInfo.packageJsonContent, packageInfo.versionPaths);
32194             return withPackageId(packageInfo, fromDirectory);
32195         }
32196         var loader = function (extensions, candidate, onlyRecordFailures, state) {
32197             var pathAndExtension = loadModuleFromFile(extensions, candidate, onlyRecordFailures, state) ||
32198                 loadNodeModuleFromDirectoryWorker(extensions, candidate, onlyRecordFailures, state, packageInfo && packageInfo.packageJsonContent, packageInfo && packageInfo.versionPaths);
32199             return withPackageId(packageInfo, pathAndExtension);
32200         };
32201         var _a = parsePackageName(moduleName), packageName = _a.packageName, rest = _a.rest;
32202         if (rest !== "") {
32203             var packageDirectory = ts.combinePaths(nodeModulesDirectory, packageName);
32204             packageInfo = getPackageJsonInfo(packageDirectory, !nodeModulesDirectoryExists, state);
32205             if (packageInfo && packageInfo.versionPaths) {
32206                 if (state.traceEnabled) {
32207                     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);
32208                 }
32209                 var packageDirectoryExists = nodeModulesDirectoryExists && ts.directoryProbablyExists(packageDirectory, state.host);
32210                 var fromPaths = tryLoadModuleUsingPaths(extensions, rest, packageDirectory, packageInfo.versionPaths.paths, loader, !packageDirectoryExists, state);
32211                 if (fromPaths) {
32212                     return fromPaths.value;
32213                 }
32214             }
32215         }
32216         return loader(extensions, candidate, !nodeModulesDirectoryExists, state);
32217     }
32218     function tryLoadModuleUsingPaths(extensions, moduleName, baseDirectory, paths, loader, onlyRecordFailures, state) {
32219         var matchedPattern = ts.matchPatternOrExact(ts.getOwnKeys(paths), moduleName);
32220         if (matchedPattern) {
32221             var matchedStar_1 = ts.isString(matchedPattern) ? undefined : ts.matchedText(matchedPattern, moduleName);
32222             var matchedPatternText = ts.isString(matchedPattern) ? matchedPattern : ts.patternText(matchedPattern);
32223             if (state.traceEnabled) {
32224                 trace(state.host, ts.Diagnostics.Module_name_0_matched_pattern_1, moduleName, matchedPatternText);
32225             }
32226             var resolved = ts.forEach(paths[matchedPatternText], function (subst) {
32227                 var path = matchedStar_1 ? subst.replace("*", matchedStar_1) : subst;
32228                 var candidate = ts.normalizePath(ts.combinePaths(baseDirectory, path));
32229                 if (state.traceEnabled) {
32230                     trace(state.host, ts.Diagnostics.Trying_substitution_0_candidate_module_location_Colon_1, subst, path);
32231                 }
32232                 var extension = ts.tryGetExtensionFromPath(candidate);
32233                 if (extension !== undefined) {
32234                     var path_1 = tryFile(candidate, onlyRecordFailures, state);
32235                     if (path_1 !== undefined) {
32236                         return noPackageId({ path: path_1, ext: extension });
32237                     }
32238                 }
32239                 return loader(extensions, candidate, onlyRecordFailures || !ts.directoryProbablyExists(ts.getDirectoryPath(candidate), state.host), state);
32240             });
32241             return { value: resolved };
32242         }
32243     }
32244     var mangledScopedPackageSeparator = "__";
32245     function mangleScopedPackageNameWithTrace(packageName, state) {
32246         var mangled = mangleScopedPackageName(packageName);
32247         if (state.traceEnabled && mangled !== packageName) {
32248             trace(state.host, ts.Diagnostics.Scoped_package_detected_looking_in_0, mangled);
32249         }
32250         return mangled;
32251     }
32252     function getTypesPackageName(packageName) {
32253         return "@types/" + mangleScopedPackageName(packageName);
32254     }
32255     ts.getTypesPackageName = getTypesPackageName;
32256     function mangleScopedPackageName(packageName) {
32257         if (ts.startsWith(packageName, "@")) {
32258             var replaceSlash = packageName.replace(ts.directorySeparator, mangledScopedPackageSeparator);
32259             if (replaceSlash !== packageName) {
32260                 return replaceSlash.slice(1);
32261             }
32262         }
32263         return packageName;
32264     }
32265     ts.mangleScopedPackageName = mangleScopedPackageName;
32266     function getPackageNameFromTypesPackageName(mangledName) {
32267         var withoutAtTypePrefix = ts.removePrefix(mangledName, "@types/");
32268         if (withoutAtTypePrefix !== mangledName) {
32269             return unmangleScopedPackageName(withoutAtTypePrefix);
32270         }
32271         return mangledName;
32272     }
32273     ts.getPackageNameFromTypesPackageName = getPackageNameFromTypesPackageName;
32274     function unmangleScopedPackageName(typesPackageName) {
32275         return ts.stringContains(typesPackageName, mangledScopedPackageSeparator) ?
32276             "@" + typesPackageName.replace(mangledScopedPackageSeparator, ts.directorySeparator) :
32277             typesPackageName;
32278     }
32279     ts.unmangleScopedPackageName = unmangleScopedPackageName;
32280     function tryFindNonRelativeModuleNameInCache(cache, moduleName, containingDirectory, state) {
32281         var result = cache && cache.get(containingDirectory);
32282         if (result) {
32283             if (state.traceEnabled) {
32284                 trace(state.host, ts.Diagnostics.Resolution_for_module_0_was_found_in_cache_from_location_1, moduleName, containingDirectory);
32285             }
32286             state.resultFromCache = result;
32287             return { value: result.resolvedModule && { path: result.resolvedModule.resolvedFileName, originalPath: result.resolvedModule.originalPath || true, extension: result.resolvedModule.extension, packageId: result.resolvedModule.packageId } };
32288         }
32289     }
32290     function classicNameResolver(moduleName, containingFile, compilerOptions, host, cache, redirectedReference) {
32291         var traceEnabled = isTraceEnabled(compilerOptions, host);
32292         var failedLookupLocations = [];
32293         var state = { compilerOptions: compilerOptions, host: host, traceEnabled: traceEnabled, failedLookupLocations: failedLookupLocations };
32294         var containingDirectory = ts.getDirectoryPath(containingFile);
32295         var resolved = tryResolve(Extensions.TypeScript) || tryResolve(Extensions.JavaScript);
32296         return createResolvedModuleWithFailedLookupLocations(resolved && resolved.value, false, failedLookupLocations, state.resultFromCache);
32297         function tryResolve(extensions) {
32298             var resolvedUsingSettings = tryLoadModuleUsingOptionalResolutionSettings(extensions, moduleName, containingDirectory, loadModuleFromFileNoPackageId, state);
32299             if (resolvedUsingSettings) {
32300                 return { value: resolvedUsingSettings };
32301             }
32302             if (!ts.isExternalModuleNameRelative(moduleName)) {
32303                 var perModuleNameCache_1 = cache && cache.getOrCreateCacheForModuleName(moduleName, redirectedReference);
32304                 var resolved_3 = ts.forEachAncestorDirectory(containingDirectory, function (directory) {
32305                     var resolutionFromCache = tryFindNonRelativeModuleNameInCache(perModuleNameCache_1, moduleName, directory, state);
32306                     if (resolutionFromCache) {
32307                         return resolutionFromCache;
32308                     }
32309                     var searchName = ts.normalizePath(ts.combinePaths(directory, moduleName));
32310                     return toSearchResult(loadModuleFromFileNoPackageId(extensions, searchName, false, state));
32311                 });
32312                 if (resolved_3) {
32313                     return resolved_3;
32314                 }
32315                 if (extensions === Extensions.TypeScript) {
32316                     return loadModuleFromNearestNodeModulesDirectoryTypesScope(moduleName, containingDirectory, state);
32317                 }
32318             }
32319             else {
32320                 var candidate = ts.normalizePath(ts.combinePaths(containingDirectory, moduleName));
32321                 return toSearchResult(loadModuleFromFileNoPackageId(extensions, candidate, false, state));
32322             }
32323         }
32324     }
32325     ts.classicNameResolver = classicNameResolver;
32326     function loadModuleFromGlobalCache(moduleName, projectName, compilerOptions, host, globalCache) {
32327         var traceEnabled = isTraceEnabled(compilerOptions, host);
32328         if (traceEnabled) {
32329             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);
32330         }
32331         var failedLookupLocations = [];
32332         var state = { compilerOptions: compilerOptions, host: host, traceEnabled: traceEnabled, failedLookupLocations: failedLookupLocations };
32333         var resolved = loadModuleFromImmediateNodeModulesDirectory(Extensions.DtsOnly, moduleName, globalCache, state, false);
32334         return createResolvedModuleWithFailedLookupLocations(resolved, true, failedLookupLocations, state.resultFromCache);
32335     }
32336     ts.loadModuleFromGlobalCache = loadModuleFromGlobalCache;
32337     function toSearchResult(value) {
32338         return value !== undefined ? { value: value } : undefined;
32339     }
32340 })(ts || (ts = {}));
32341 var ts;
32342 (function (ts) {
32343     function getModuleInstanceState(node, visited) {
32344         if (node.body && !node.body.parent) {
32345             ts.setParent(node.body, node);
32346             ts.setParentRecursive(node.body, false);
32347         }
32348         return node.body ? getModuleInstanceStateCached(node.body, visited) : 1;
32349     }
32350     ts.getModuleInstanceState = getModuleInstanceState;
32351     function getModuleInstanceStateCached(node, visited) {
32352         if (visited === void 0) { visited = new ts.Map(); }
32353         var nodeId = ts.getNodeId(node);
32354         if (visited.has(nodeId)) {
32355             return visited.get(nodeId) || 0;
32356         }
32357         visited.set(nodeId, undefined);
32358         var result = getModuleInstanceStateWorker(node, visited);
32359         visited.set(nodeId, result);
32360         return result;
32361     }
32362     function getModuleInstanceStateWorker(node, visited) {
32363         switch (node.kind) {
32364             case 253:
32365             case 254:
32366                 return 0;
32367             case 255:
32368                 if (ts.isEnumConst(node)) {
32369                     return 2;
32370                 }
32371                 break;
32372             case 261:
32373             case 260:
32374                 if (!(ts.hasSyntacticModifier(node, 1))) {
32375                     return 0;
32376                 }
32377                 break;
32378             case 267:
32379                 var exportDeclaration = node;
32380                 if (!exportDeclaration.moduleSpecifier && exportDeclaration.exportClause && exportDeclaration.exportClause.kind === 268) {
32381                     var state = 0;
32382                     for (var _i = 0, _a = exportDeclaration.exportClause.elements; _i < _a.length; _i++) {
32383                         var specifier = _a[_i];
32384                         var specifierState = getModuleInstanceStateForAliasTarget(specifier, visited);
32385                         if (specifierState > state) {
32386                             state = specifierState;
32387                         }
32388                         if (state === 1) {
32389                             return state;
32390                         }
32391                     }
32392                     return state;
32393                 }
32394                 break;
32395             case 257: {
32396                 var state_1 = 0;
32397                 ts.forEachChild(node, function (n) {
32398                     var childState = getModuleInstanceStateCached(n, visited);
32399                     switch (childState) {
32400                         case 0:
32401                             return;
32402                         case 2:
32403                             state_1 = 2;
32404                             return;
32405                         case 1:
32406                             state_1 = 1;
32407                             return true;
32408                         default:
32409                             ts.Debug.assertNever(childState);
32410                     }
32411                 });
32412                 return state_1;
32413             }
32414             case 256:
32415                 return getModuleInstanceState(node, visited);
32416             case 78:
32417                 if (node.isInJSDocNamespace) {
32418                     return 0;
32419                 }
32420         }
32421         return 1;
32422     }
32423     function getModuleInstanceStateForAliasTarget(specifier, visited) {
32424         var name = specifier.propertyName || specifier.name;
32425         var p = specifier.parent;
32426         while (p) {
32427             if (ts.isBlock(p) || ts.isModuleBlock(p) || ts.isSourceFile(p)) {
32428                 var statements = p.statements;
32429                 var found = void 0;
32430                 for (var _i = 0, statements_2 = statements; _i < statements_2.length; _i++) {
32431                     var statement = statements_2[_i];
32432                     if (ts.nodeHasName(statement, name)) {
32433                         if (!statement.parent) {
32434                             ts.setParent(statement, p);
32435                             ts.setParentRecursive(statement, false);
32436                         }
32437                         var state = getModuleInstanceStateCached(statement, visited);
32438                         if (found === undefined || state > found) {
32439                             found = state;
32440                         }
32441                         if (found === 1) {
32442                             return found;
32443                         }
32444                     }
32445                 }
32446                 if (found !== undefined) {
32447                     return found;
32448                 }
32449             }
32450             p = p.parent;
32451         }
32452         return 1;
32453     }
32454     function initFlowNode(node) {
32455         ts.Debug.attachFlowNodeDebugInfo(node);
32456         return node;
32457     }
32458     var binder = createBinder();
32459     function bindSourceFile(file, options) {
32460         var tracingData = ["bind", "bindSourceFile", { path: file.path }];
32461         ts.tracing.begin.apply(ts.tracing, tracingData);
32462         ts.performance.mark("beforeBind");
32463         ts.perfLogger.logStartBindFile("" + file.fileName);
32464         binder(file, options);
32465         ts.perfLogger.logStopBindFile();
32466         ts.performance.mark("afterBind");
32467         ts.performance.measure("Bind", "beforeBind", "afterBind");
32468         ts.tracing.end.apply(ts.tracing, tracingData);
32469     }
32470     ts.bindSourceFile = bindSourceFile;
32471     function createBinder() {
32472         var file;
32473         var options;
32474         var languageVersion;
32475         var parent;
32476         var container;
32477         var thisParentContainer;
32478         var blockScopeContainer;
32479         var lastContainer;
32480         var delayedTypeAliases;
32481         var seenThisKeyword;
32482         var currentFlow;
32483         var currentBreakTarget;
32484         var currentContinueTarget;
32485         var currentReturnTarget;
32486         var currentTrueTarget;
32487         var currentFalseTarget;
32488         var currentExceptionTarget;
32489         var preSwitchCaseFlow;
32490         var activeLabelList;
32491         var hasExplicitReturn;
32492         var emitFlags;
32493         var inStrictMode;
32494         var inAssignmentPattern = false;
32495         var symbolCount = 0;
32496         var Symbol;
32497         var classifiableNames;
32498         var unreachableFlow = { flags: 1 };
32499         var reportedUnreachableFlow = { flags: 1 };
32500         function createDiagnosticForNode(node, message, arg0, arg1, arg2) {
32501             return ts.createDiagnosticForNodeInSourceFile(ts.getSourceFileOfNode(node) || file, node, message, arg0, arg1, arg2);
32502         }
32503         function bindSourceFile(f, opts) {
32504             file = f;
32505             options = opts;
32506             languageVersion = ts.getEmitScriptTarget(options);
32507             inStrictMode = bindInStrictMode(file, opts);
32508             classifiableNames = new ts.Set();
32509             symbolCount = 0;
32510             Symbol = ts.objectAllocator.getSymbolConstructor();
32511             ts.Debug.attachFlowNodeDebugInfo(unreachableFlow);
32512             ts.Debug.attachFlowNodeDebugInfo(reportedUnreachableFlow);
32513             if (!file.locals) {
32514                 bind(file);
32515                 file.symbolCount = symbolCount;
32516                 file.classifiableNames = classifiableNames;
32517                 delayedBindJSDocTypedefTag();
32518             }
32519             file = undefined;
32520             options = undefined;
32521             languageVersion = undefined;
32522             parent = undefined;
32523             container = undefined;
32524             thisParentContainer = undefined;
32525             blockScopeContainer = undefined;
32526             lastContainer = undefined;
32527             delayedTypeAliases = undefined;
32528             seenThisKeyword = false;
32529             currentFlow = undefined;
32530             currentBreakTarget = undefined;
32531             currentContinueTarget = undefined;
32532             currentReturnTarget = undefined;
32533             currentTrueTarget = undefined;
32534             currentFalseTarget = undefined;
32535             currentExceptionTarget = undefined;
32536             activeLabelList = undefined;
32537             hasExplicitReturn = false;
32538             inAssignmentPattern = false;
32539             emitFlags = 0;
32540         }
32541         return bindSourceFile;
32542         function bindInStrictMode(file, opts) {
32543             if (ts.getStrictOptionValue(opts, "alwaysStrict") && !file.isDeclarationFile) {
32544                 return true;
32545             }
32546             else {
32547                 return !!file.externalModuleIndicator;
32548             }
32549         }
32550         function createSymbol(flags, name) {
32551             symbolCount++;
32552             return new Symbol(flags, name);
32553         }
32554         function addDeclarationToSymbol(symbol, node, symbolFlags) {
32555             symbol.flags |= symbolFlags;
32556             node.symbol = symbol;
32557             symbol.declarations = ts.appendIfUnique(symbol.declarations, node);
32558             if (symbolFlags & (32 | 384 | 1536 | 3) && !symbol.exports) {
32559                 symbol.exports = ts.createSymbolTable();
32560             }
32561             if (symbolFlags & (32 | 64 | 2048 | 4096) && !symbol.members) {
32562                 symbol.members = ts.createSymbolTable();
32563             }
32564             if (symbol.constEnumOnlyModule && (symbol.flags & (16 | 32 | 256))) {
32565                 symbol.constEnumOnlyModule = false;
32566             }
32567             if (symbolFlags & 111551) {
32568                 ts.setValueDeclaration(symbol, node);
32569             }
32570         }
32571         function getDeclarationName(node) {
32572             if (node.kind === 266) {
32573                 return node.isExportEquals ? "export=" : "default";
32574             }
32575             var name = ts.getNameOfDeclaration(node);
32576             if (name) {
32577                 if (ts.isAmbientModule(node)) {
32578                     var moduleName = ts.getTextOfIdentifierOrLiteral(name);
32579                     return (ts.isGlobalScopeAugmentation(node) ? "__global" : "\"" + moduleName + "\"");
32580                 }
32581                 if (name.kind === 158) {
32582                     var nameExpression = name.expression;
32583                     if (ts.isStringOrNumericLiteralLike(nameExpression)) {
32584                         return ts.escapeLeadingUnderscores(nameExpression.text);
32585                     }
32586                     if (ts.isSignedNumericLiteral(nameExpression)) {
32587                         return ts.tokenToString(nameExpression.operator) + nameExpression.operand.text;
32588                     }
32589                     ts.Debug.assert(ts.isWellKnownSymbolSyntactically(nameExpression));
32590                     return ts.getPropertyNameForKnownSymbolName(ts.idText(nameExpression.name));
32591                 }
32592                 if (ts.isWellKnownSymbolSyntactically(name)) {
32593                     return ts.getPropertyNameForKnownSymbolName(ts.idText(name.name));
32594                 }
32595                 if (ts.isPrivateIdentifier(name)) {
32596                     var containingClass = ts.getContainingClass(node);
32597                     if (!containingClass) {
32598                         return undefined;
32599                     }
32600                     var containingClassSymbol = containingClass.symbol;
32601                     return ts.getSymbolNameForPrivateIdentifier(containingClassSymbol, name.escapedText);
32602                 }
32603                 return ts.isPropertyNameLiteral(name) ? ts.getEscapedTextOfIdentifierOrLiteral(name) : undefined;
32604             }
32605             switch (node.kind) {
32606                 case 166:
32607                     return "__constructor";
32608                 case 174:
32609                 case 169:
32610                 case 313:
32611                     return "__call";
32612                 case 175:
32613                 case 170:
32614                     return "__new";
32615                 case 171:
32616                     return "__index";
32617                 case 267:
32618                     return "__export";
32619                 case 297:
32620                     return "export=";
32621                 case 216:
32622                     if (ts.getAssignmentDeclarationKind(node) === 2) {
32623                         return "export=";
32624                     }
32625                     ts.Debug.fail("Unknown binary declaration kind");
32626                     break;
32627                 case 308:
32628                     return (ts.isJSDocConstructSignature(node) ? "__new" : "__call");
32629                 case 160:
32630                     ts.Debug.assert(node.parent.kind === 308, "Impossible parameter parent kind", function () { return "parent is: " + (ts.SyntaxKind ? ts.SyntaxKind[node.parent.kind] : node.parent.kind) + ", expected JSDocFunctionType"; });
32631                     var functionType = node.parent;
32632                     var index = functionType.parameters.indexOf(node);
32633                     return "arg" + index;
32634             }
32635         }
32636         function getDisplayName(node) {
32637             return ts.isNamedDeclaration(node) ? ts.declarationNameToString(node.name) : ts.unescapeLeadingUnderscores(ts.Debug.checkDefined(getDeclarationName(node)));
32638         }
32639         function declareSymbol(symbolTable, parent, node, includes, excludes, isReplaceableByMethod) {
32640             ts.Debug.assert(!ts.hasDynamicName(node));
32641             var isDefaultExport = ts.hasSyntacticModifier(node, 512) || ts.isExportSpecifier(node) && node.name.escapedText === "default";
32642             var name = isDefaultExport && parent ? "default" : getDeclarationName(node);
32643             var symbol;
32644             if (name === undefined) {
32645                 symbol = createSymbol(0, "__missing");
32646             }
32647             else {
32648                 symbol = symbolTable.get(name);
32649                 if (includes & 2885600) {
32650                     classifiableNames.add(name);
32651                 }
32652                 if (!symbol) {
32653                     symbolTable.set(name, symbol = createSymbol(0, name));
32654                     if (isReplaceableByMethod)
32655                         symbol.isReplaceableByMethod = true;
32656                 }
32657                 else if (isReplaceableByMethod && !symbol.isReplaceableByMethod) {
32658                     return symbol;
32659                 }
32660                 else if (symbol.flags & excludes) {
32661                     if (symbol.isReplaceableByMethod) {
32662                         symbolTable.set(name, symbol = createSymbol(0, name));
32663                     }
32664                     else if (!(includes & 3 && symbol.flags & 67108864)) {
32665                         if (ts.isNamedDeclaration(node)) {
32666                             ts.setParent(node.name, node);
32667                         }
32668                         var message_1 = symbol.flags & 2
32669                             ? ts.Diagnostics.Cannot_redeclare_block_scoped_variable_0
32670                             : ts.Diagnostics.Duplicate_identifier_0;
32671                         var messageNeedsName_1 = true;
32672                         if (symbol.flags & 384 || includes & 384) {
32673                             message_1 = ts.Diagnostics.Enum_declarations_can_only_merge_with_namespace_or_other_enum_declarations;
32674                             messageNeedsName_1 = false;
32675                         }
32676                         var multipleDefaultExports_1 = false;
32677                         if (ts.length(symbol.declarations)) {
32678                             if (isDefaultExport) {
32679                                 message_1 = ts.Diagnostics.A_module_cannot_have_multiple_default_exports;
32680                                 messageNeedsName_1 = false;
32681                                 multipleDefaultExports_1 = true;
32682                             }
32683                             else {
32684                                 if (symbol.declarations && symbol.declarations.length &&
32685                                     (node.kind === 266 && !node.isExportEquals)) {
32686                                     message_1 = ts.Diagnostics.A_module_cannot_have_multiple_default_exports;
32687                                     messageNeedsName_1 = false;
32688                                     multipleDefaultExports_1 = true;
32689                                 }
32690                             }
32691                         }
32692                         var relatedInformation_1 = [];
32693                         if (ts.isTypeAliasDeclaration(node) && ts.nodeIsMissing(node.type) && ts.hasSyntacticModifier(node, 1) && symbol.flags & (2097152 | 788968 | 1920)) {
32694                             relatedInformation_1.push(createDiagnosticForNode(node, ts.Diagnostics.Did_you_mean_0, "export type { " + ts.unescapeLeadingUnderscores(node.name.escapedText) + " }"));
32695                         }
32696                         var declarationName_1 = ts.getNameOfDeclaration(node) || node;
32697                         ts.forEach(symbol.declarations, function (declaration, index) {
32698                             var decl = ts.getNameOfDeclaration(declaration) || declaration;
32699                             var diag = createDiagnosticForNode(decl, message_1, messageNeedsName_1 ? getDisplayName(declaration) : undefined);
32700                             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);
32701                             if (multipleDefaultExports_1) {
32702                                 relatedInformation_1.push(createDiagnosticForNode(decl, ts.Diagnostics.The_first_export_default_is_here));
32703                             }
32704                         });
32705                         var diag = createDiagnosticForNode(declarationName_1, message_1, messageNeedsName_1 ? getDisplayName(node) : undefined);
32706                         file.bindDiagnostics.push(ts.addRelatedInfo.apply(void 0, __spreadArrays([diag], relatedInformation_1)));
32707                         symbol = createSymbol(0, name);
32708                     }
32709                 }
32710             }
32711             addDeclarationToSymbol(symbol, node, includes);
32712             if (symbol.parent) {
32713                 ts.Debug.assert(symbol.parent === parent, "Existing symbol parent should match new one");
32714             }
32715             else {
32716                 symbol.parent = parent;
32717             }
32718             return symbol;
32719         }
32720         function declareModuleMember(node, symbolFlags, symbolExcludes) {
32721             var hasExportModifier = !!(ts.getCombinedModifierFlags(node) & 1) || jsdocTreatAsExported(node);
32722             if (symbolFlags & 2097152) {
32723                 if (node.kind === 270 || (node.kind === 260 && hasExportModifier)) {
32724                     return declareSymbol(container.symbol.exports, container.symbol, node, symbolFlags, symbolExcludes);
32725                 }
32726                 else {
32727                     return declareSymbol(container.locals, undefined, node, symbolFlags, symbolExcludes);
32728                 }
32729             }
32730             else {
32731                 if (ts.isJSDocTypeAlias(node))
32732                     ts.Debug.assert(ts.isInJSFile(node));
32733                 if (!ts.isAmbientModule(node) && (hasExportModifier || container.flags & 64)) {
32734                     if (!container.locals || (ts.hasSyntacticModifier(node, 512) && !getDeclarationName(node))) {
32735                         return declareSymbol(container.symbol.exports, container.symbol, node, symbolFlags, symbolExcludes);
32736                     }
32737                     var exportKind = symbolFlags & 111551 ? 1048576 : 0;
32738                     var local = declareSymbol(container.locals, undefined, node, exportKind, symbolExcludes);
32739                     local.exportSymbol = declareSymbol(container.symbol.exports, container.symbol, node, symbolFlags, symbolExcludes);
32740                     node.localSymbol = local;
32741                     return local;
32742                 }
32743                 else {
32744                     return declareSymbol(container.locals, undefined, node, symbolFlags, symbolExcludes);
32745                 }
32746             }
32747         }
32748         function jsdocTreatAsExported(node) {
32749             if (node.parent && ts.isModuleDeclaration(node)) {
32750                 node = node.parent;
32751             }
32752             if (!ts.isJSDocTypeAlias(node))
32753                 return false;
32754             if (!ts.isJSDocEnumTag(node) && !!node.fullName)
32755                 return true;
32756             var declName = ts.getNameOfDeclaration(node);
32757             if (!declName)
32758                 return false;
32759             if (ts.isPropertyAccessEntityNameExpression(declName.parent) && isTopLevelNamespaceAssignment(declName.parent))
32760                 return true;
32761             if (ts.isDeclaration(declName.parent) && ts.getCombinedModifierFlags(declName.parent) & 1)
32762                 return true;
32763             return false;
32764         }
32765         function bindContainer(node, containerFlags) {
32766             var saveContainer = container;
32767             var saveThisParentContainer = thisParentContainer;
32768             var savedBlockScopeContainer = blockScopeContainer;
32769             if (containerFlags & 1) {
32770                 if (node.kind !== 209) {
32771                     thisParentContainer = container;
32772                 }
32773                 container = blockScopeContainer = node;
32774                 if (containerFlags & 32) {
32775                     container.locals = ts.createSymbolTable();
32776                 }
32777                 addToContainerChain(container);
32778             }
32779             else if (containerFlags & 2) {
32780                 blockScopeContainer = node;
32781                 blockScopeContainer.locals = undefined;
32782             }
32783             if (containerFlags & 4) {
32784                 var saveCurrentFlow = currentFlow;
32785                 var saveBreakTarget = currentBreakTarget;
32786                 var saveContinueTarget = currentContinueTarget;
32787                 var saveReturnTarget = currentReturnTarget;
32788                 var saveExceptionTarget = currentExceptionTarget;
32789                 var saveActiveLabelList = activeLabelList;
32790                 var saveHasExplicitReturn = hasExplicitReturn;
32791                 var isIIFE = containerFlags & 16 && !ts.hasSyntacticModifier(node, 256) &&
32792                     !node.asteriskToken && !!ts.getImmediatelyInvokedFunctionExpression(node);
32793                 if (!isIIFE) {
32794                     currentFlow = initFlowNode({ flags: 2 });
32795                     if (containerFlags & (16 | 128)) {
32796                         currentFlow.node = node;
32797                     }
32798                 }
32799                 currentReturnTarget = isIIFE || node.kind === 166 || (ts.isInJSFile && (node.kind === 251 || node.kind === 208)) ? createBranchLabel() : undefined;
32800                 currentExceptionTarget = undefined;
32801                 currentBreakTarget = undefined;
32802                 currentContinueTarget = undefined;
32803                 activeLabelList = undefined;
32804                 hasExplicitReturn = false;
32805                 bindChildren(node);
32806                 node.flags &= ~2816;
32807                 if (!(currentFlow.flags & 1) && containerFlags & 8 && ts.nodeIsPresent(node.body)) {
32808                     node.flags |= 256;
32809                     if (hasExplicitReturn)
32810                         node.flags |= 512;
32811                     node.endFlowNode = currentFlow;
32812                 }
32813                 if (node.kind === 297) {
32814                     node.flags |= emitFlags;
32815                 }
32816                 if (currentReturnTarget) {
32817                     addAntecedent(currentReturnTarget, currentFlow);
32818                     currentFlow = finishFlowLabel(currentReturnTarget);
32819                     if (node.kind === 166 || (ts.isInJSFile && (node.kind === 251 || node.kind === 208))) {
32820                         node.returnFlowNode = currentFlow;
32821                     }
32822                 }
32823                 if (!isIIFE) {
32824                     currentFlow = saveCurrentFlow;
32825                 }
32826                 currentBreakTarget = saveBreakTarget;
32827                 currentContinueTarget = saveContinueTarget;
32828                 currentReturnTarget = saveReturnTarget;
32829                 currentExceptionTarget = saveExceptionTarget;
32830                 activeLabelList = saveActiveLabelList;
32831                 hasExplicitReturn = saveHasExplicitReturn;
32832             }
32833             else if (containerFlags & 64) {
32834                 seenThisKeyword = false;
32835                 bindChildren(node);
32836                 node.flags = seenThisKeyword ? node.flags | 128 : node.flags & ~128;
32837             }
32838             else {
32839                 bindChildren(node);
32840             }
32841             container = saveContainer;
32842             thisParentContainer = saveThisParentContainer;
32843             blockScopeContainer = savedBlockScopeContainer;
32844         }
32845         function bindEachFunctionsFirst(nodes) {
32846             bindEach(nodes, function (n) { return n.kind === 251 ? bind(n) : undefined; });
32847             bindEach(nodes, function (n) { return n.kind !== 251 ? bind(n) : undefined; });
32848         }
32849         function bindEach(nodes, bindFunction) {
32850             if (bindFunction === void 0) { bindFunction = bind; }
32851             if (nodes === undefined) {
32852                 return;
32853             }
32854             ts.forEach(nodes, bindFunction);
32855         }
32856         function bindEachChild(node) {
32857             ts.forEachChild(node, bind, bindEach);
32858         }
32859         function bindChildren(node) {
32860             var saveInAssignmentPattern = inAssignmentPattern;
32861             inAssignmentPattern = false;
32862             if (checkUnreachable(node)) {
32863                 bindEachChild(node);
32864                 bindJSDoc(node);
32865                 inAssignmentPattern = saveInAssignmentPattern;
32866                 return;
32867             }
32868             if (node.kind >= 232 && node.kind <= 248 && !options.allowUnreachableCode) {
32869                 node.flowNode = currentFlow;
32870             }
32871             switch (node.kind) {
32872                 case 236:
32873                     bindWhileStatement(node);
32874                     break;
32875                 case 235:
32876                     bindDoStatement(node);
32877                     break;
32878                 case 237:
32879                     bindForStatement(node);
32880                     break;
32881                 case 238:
32882                 case 239:
32883                     bindForInOrForOfStatement(node);
32884                     break;
32885                 case 234:
32886                     bindIfStatement(node);
32887                     break;
32888                 case 242:
32889                 case 246:
32890                     bindReturnOrThrow(node);
32891                     break;
32892                 case 241:
32893                 case 240:
32894                     bindBreakOrContinueStatement(node);
32895                     break;
32896                 case 247:
32897                     bindTryStatement(node);
32898                     break;
32899                 case 244:
32900                     bindSwitchStatement(node);
32901                     break;
32902                 case 258:
32903                     bindCaseBlock(node);
32904                     break;
32905                 case 284:
32906                     bindCaseClause(node);
32907                     break;
32908                 case 233:
32909                     bindExpressionStatement(node);
32910                     break;
32911                 case 245:
32912                     bindLabeledStatement(node);
32913                     break;
32914                 case 214:
32915                     bindPrefixUnaryExpressionFlow(node);
32916                     break;
32917                 case 215:
32918                     bindPostfixUnaryExpressionFlow(node);
32919                     break;
32920                 case 216:
32921                     if (ts.isDestructuringAssignment(node)) {
32922                         inAssignmentPattern = saveInAssignmentPattern;
32923                         bindDestructuringAssignmentFlow(node);
32924                         return;
32925                     }
32926                     bindBinaryExpressionFlow(node);
32927                     break;
32928                 case 210:
32929                     bindDeleteExpressionFlow(node);
32930                     break;
32931                 case 217:
32932                     bindConditionalExpressionFlow(node);
32933                     break;
32934                 case 249:
32935                     bindVariableDeclarationFlow(node);
32936                     break;
32937                 case 201:
32938                 case 202:
32939                     bindAccessExpressionFlow(node);
32940                     break;
32941                 case 203:
32942                     bindCallExpressionFlow(node);
32943                     break;
32944                 case 225:
32945                     bindNonNullExpressionFlow(node);
32946                     break;
32947                 case 331:
32948                 case 324:
32949                 case 325:
32950                     bindJSDocTypeAlias(node);
32951                     break;
32952                 case 297: {
32953                     bindEachFunctionsFirst(node.statements);
32954                     bind(node.endOfFileToken);
32955                     break;
32956                 }
32957                 case 230:
32958                 case 257:
32959                     bindEachFunctionsFirst(node.statements);
32960                     break;
32961                 case 198:
32962                     bindBindingElementFlow(node);
32963                     break;
32964                 case 200:
32965                 case 199:
32966                 case 288:
32967                 case 220:
32968                     inAssignmentPattern = saveInAssignmentPattern;
32969                 default:
32970                     bindEachChild(node);
32971                     break;
32972             }
32973             bindJSDoc(node);
32974             inAssignmentPattern = saveInAssignmentPattern;
32975         }
32976         function isNarrowingExpression(expr) {
32977             switch (expr.kind) {
32978                 case 78:
32979                 case 79:
32980                 case 107:
32981                 case 201:
32982                 case 202:
32983                     return containsNarrowableReference(expr);
32984                 case 203:
32985                     return hasNarrowableArgument(expr);
32986                 case 207:
32987                 case 225:
32988                     return isNarrowingExpression(expr.expression);
32989                 case 216:
32990                     return isNarrowingBinaryExpression(expr);
32991                 case 214:
32992                     return expr.operator === 53 && isNarrowingExpression(expr.operand);
32993                 case 211:
32994                     return isNarrowingExpression(expr.expression);
32995             }
32996             return false;
32997         }
32998         function isNarrowableReference(expr) {
32999             return expr.kind === 78 || expr.kind === 79 || expr.kind === 107 || expr.kind === 105 ||
33000                 (ts.isPropertyAccessExpression(expr) || ts.isNonNullExpression(expr) || ts.isParenthesizedExpression(expr)) && isNarrowableReference(expr.expression) ||
33001                 ts.isBinaryExpression(expr) && expr.operatorToken.kind === 27 && isNarrowableReference(expr.right) ||
33002                 ts.isElementAccessExpression(expr) && ts.isStringOrNumericLiteralLike(expr.argumentExpression) && isNarrowableReference(expr.expression) ||
33003                 ts.isAssignmentExpression(expr) && isNarrowableReference(expr.left);
33004         }
33005         function containsNarrowableReference(expr) {
33006             return isNarrowableReference(expr) || ts.isOptionalChain(expr) && containsNarrowableReference(expr.expression);
33007         }
33008         function hasNarrowableArgument(expr) {
33009             if (expr.arguments) {
33010                 for (var _i = 0, _a = expr.arguments; _i < _a.length; _i++) {
33011                     var argument = _a[_i];
33012                     if (containsNarrowableReference(argument)) {
33013                         return true;
33014                     }
33015                 }
33016             }
33017             if (expr.expression.kind === 201 &&
33018                 containsNarrowableReference(expr.expression.expression)) {
33019                 return true;
33020             }
33021             return false;
33022         }
33023         function isNarrowingTypeofOperands(expr1, expr2) {
33024             return ts.isTypeOfExpression(expr1) && isNarrowableOperand(expr1.expression) && ts.isStringLiteralLike(expr2);
33025         }
33026         function isNarrowableInOperands(left, right) {
33027             return ts.isStringLiteralLike(left) && isNarrowingExpression(right);
33028         }
33029         function isNarrowingBinaryExpression(expr) {
33030             switch (expr.operatorToken.kind) {
33031                 case 62:
33032                 case 74:
33033                 case 75:
33034                 case 76:
33035                     return containsNarrowableReference(expr.left);
33036                 case 34:
33037                 case 35:
33038                 case 36:
33039                 case 37:
33040                     return isNarrowableOperand(expr.left) || isNarrowableOperand(expr.right) ||
33041                         isNarrowingTypeofOperands(expr.right, expr.left) || isNarrowingTypeofOperands(expr.left, expr.right);
33042                 case 101:
33043                     return isNarrowableOperand(expr.left);
33044                 case 100:
33045                     return isNarrowableInOperands(expr.left, expr.right);
33046                 case 27:
33047                     return isNarrowingExpression(expr.right);
33048             }
33049             return false;
33050         }
33051         function isNarrowableOperand(expr) {
33052             switch (expr.kind) {
33053                 case 207:
33054                     return isNarrowableOperand(expr.expression);
33055                 case 216:
33056                     switch (expr.operatorToken.kind) {
33057                         case 62:
33058                             return isNarrowableOperand(expr.left);
33059                         case 27:
33060                             return isNarrowableOperand(expr.right);
33061                     }
33062             }
33063             return containsNarrowableReference(expr);
33064         }
33065         function createBranchLabel() {
33066             return initFlowNode({ flags: 4, antecedents: undefined });
33067         }
33068         function createLoopLabel() {
33069             return initFlowNode({ flags: 8, antecedents: undefined });
33070         }
33071         function createReduceLabel(target, antecedents, antecedent) {
33072             return initFlowNode({ flags: 1024, target: target, antecedents: antecedents, antecedent: antecedent });
33073         }
33074         function setFlowNodeReferenced(flow) {
33075             flow.flags |= flow.flags & 2048 ? 4096 : 2048;
33076         }
33077         function addAntecedent(label, antecedent) {
33078             if (!(antecedent.flags & 1) && !ts.contains(label.antecedents, antecedent)) {
33079                 (label.antecedents || (label.antecedents = [])).push(antecedent);
33080                 setFlowNodeReferenced(antecedent);
33081             }
33082         }
33083         function createFlowCondition(flags, antecedent, expression) {
33084             if (antecedent.flags & 1) {
33085                 return antecedent;
33086             }
33087             if (!expression) {
33088                 return flags & 32 ? antecedent : unreachableFlow;
33089             }
33090             if ((expression.kind === 109 && flags & 64 ||
33091                 expression.kind === 94 && flags & 32) &&
33092                 !ts.isExpressionOfOptionalChainRoot(expression) && !ts.isNullishCoalesce(expression.parent)) {
33093                 return unreachableFlow;
33094             }
33095             if (!isNarrowingExpression(expression)) {
33096                 return antecedent;
33097             }
33098             setFlowNodeReferenced(antecedent);
33099             return initFlowNode({ flags: flags, antecedent: antecedent, node: expression });
33100         }
33101         function createFlowSwitchClause(antecedent, switchStatement, clauseStart, clauseEnd) {
33102             setFlowNodeReferenced(antecedent);
33103             return initFlowNode({ flags: 128, antecedent: antecedent, switchStatement: switchStatement, clauseStart: clauseStart, clauseEnd: clauseEnd });
33104         }
33105         function createFlowMutation(flags, antecedent, node) {
33106             setFlowNodeReferenced(antecedent);
33107             var result = initFlowNode({ flags: flags, antecedent: antecedent, node: node });
33108             if (currentExceptionTarget) {
33109                 addAntecedent(currentExceptionTarget, result);
33110             }
33111             return result;
33112         }
33113         function createFlowCall(antecedent, node) {
33114             setFlowNodeReferenced(antecedent);
33115             return initFlowNode({ flags: 512, antecedent: antecedent, node: node });
33116         }
33117         function finishFlowLabel(flow) {
33118             var antecedents = flow.antecedents;
33119             if (!antecedents) {
33120                 return unreachableFlow;
33121             }
33122             if (antecedents.length === 1) {
33123                 return antecedents[0];
33124             }
33125             return flow;
33126         }
33127         function isStatementCondition(node) {
33128             var parent = node.parent;
33129             switch (parent.kind) {
33130                 case 234:
33131                 case 236:
33132                 case 235:
33133                     return parent.expression === node;
33134                 case 237:
33135                 case 217:
33136                     return parent.condition === node;
33137             }
33138             return false;
33139         }
33140         function isLogicalExpression(node) {
33141             while (true) {
33142                 if (node.kind === 207) {
33143                     node = node.expression;
33144                 }
33145                 else if (node.kind === 214 && node.operator === 53) {
33146                     node = node.operand;
33147                 }
33148                 else {
33149                     return node.kind === 216 && (node.operatorToken.kind === 55 ||
33150                         node.operatorToken.kind === 56 ||
33151                         node.operatorToken.kind === 60);
33152                 }
33153             }
33154         }
33155         function isLogicalAssignmentExpression(node) {
33156             node = ts.skipParentheses(node);
33157             return ts.isBinaryExpression(node) && ts.isLogicalOrCoalescingAssignmentOperator(node.operatorToken.kind);
33158         }
33159         function isTopLevelLogicalExpression(node) {
33160             while (ts.isParenthesizedExpression(node.parent) ||
33161                 ts.isPrefixUnaryExpression(node.parent) && node.parent.operator === 53) {
33162                 node = node.parent;
33163             }
33164             return !isStatementCondition(node) &&
33165                 !isLogicalAssignmentExpression(node.parent) &&
33166                 !isLogicalExpression(node.parent) &&
33167                 !(ts.isOptionalChain(node.parent) && node.parent.expression === node);
33168         }
33169         function doWithConditionalBranches(action, value, trueTarget, falseTarget) {
33170             var savedTrueTarget = currentTrueTarget;
33171             var savedFalseTarget = currentFalseTarget;
33172             currentTrueTarget = trueTarget;
33173             currentFalseTarget = falseTarget;
33174             action(value);
33175             currentTrueTarget = savedTrueTarget;
33176             currentFalseTarget = savedFalseTarget;
33177         }
33178         function bindCondition(node, trueTarget, falseTarget) {
33179             doWithConditionalBranches(bind, node, trueTarget, falseTarget);
33180             if (!node || !isLogicalAssignmentExpression(node) && !isLogicalExpression(node) && !(ts.isOptionalChain(node) && ts.isOutermostOptionalChain(node))) {
33181                 addAntecedent(trueTarget, createFlowCondition(32, currentFlow, node));
33182                 addAntecedent(falseTarget, createFlowCondition(64, currentFlow, node));
33183             }
33184         }
33185         function bindIterativeStatement(node, breakTarget, continueTarget) {
33186             var saveBreakTarget = currentBreakTarget;
33187             var saveContinueTarget = currentContinueTarget;
33188             currentBreakTarget = breakTarget;
33189             currentContinueTarget = continueTarget;
33190             bind(node);
33191             currentBreakTarget = saveBreakTarget;
33192             currentContinueTarget = saveContinueTarget;
33193         }
33194         function setContinueTarget(node, target) {
33195             var label = activeLabelList;
33196             while (label && node.parent.kind === 245) {
33197                 label.continueTarget = target;
33198                 label = label.next;
33199                 node = node.parent;
33200             }
33201             return target;
33202         }
33203         function bindWhileStatement(node) {
33204             var preWhileLabel = setContinueTarget(node, createLoopLabel());
33205             var preBodyLabel = createBranchLabel();
33206             var postWhileLabel = createBranchLabel();
33207             addAntecedent(preWhileLabel, currentFlow);
33208             currentFlow = preWhileLabel;
33209             bindCondition(node.expression, preBodyLabel, postWhileLabel);
33210             currentFlow = finishFlowLabel(preBodyLabel);
33211             bindIterativeStatement(node.statement, postWhileLabel, preWhileLabel);
33212             addAntecedent(preWhileLabel, currentFlow);
33213             currentFlow = finishFlowLabel(postWhileLabel);
33214         }
33215         function bindDoStatement(node) {
33216             var preDoLabel = createLoopLabel();
33217             var preConditionLabel = setContinueTarget(node, createBranchLabel());
33218             var postDoLabel = createBranchLabel();
33219             addAntecedent(preDoLabel, currentFlow);
33220             currentFlow = preDoLabel;
33221             bindIterativeStatement(node.statement, postDoLabel, preConditionLabel);
33222             addAntecedent(preConditionLabel, currentFlow);
33223             currentFlow = finishFlowLabel(preConditionLabel);
33224             bindCondition(node.expression, preDoLabel, postDoLabel);
33225             currentFlow = finishFlowLabel(postDoLabel);
33226         }
33227         function bindForStatement(node) {
33228             var preLoopLabel = setContinueTarget(node, createLoopLabel());
33229             var preBodyLabel = createBranchLabel();
33230             var postLoopLabel = createBranchLabel();
33231             bind(node.initializer);
33232             addAntecedent(preLoopLabel, currentFlow);
33233             currentFlow = preLoopLabel;
33234             bindCondition(node.condition, preBodyLabel, postLoopLabel);
33235             currentFlow = finishFlowLabel(preBodyLabel);
33236             bindIterativeStatement(node.statement, postLoopLabel, preLoopLabel);
33237             bind(node.incrementor);
33238             addAntecedent(preLoopLabel, currentFlow);
33239             currentFlow = finishFlowLabel(postLoopLabel);
33240         }
33241         function bindForInOrForOfStatement(node) {
33242             var preLoopLabel = setContinueTarget(node, createLoopLabel());
33243             var postLoopLabel = createBranchLabel();
33244             bind(node.expression);
33245             addAntecedent(preLoopLabel, currentFlow);
33246             currentFlow = preLoopLabel;
33247             if (node.kind === 239) {
33248                 bind(node.awaitModifier);
33249             }
33250             addAntecedent(postLoopLabel, currentFlow);
33251             bind(node.initializer);
33252             if (node.initializer.kind !== 250) {
33253                 bindAssignmentTargetFlow(node.initializer);
33254             }
33255             bindIterativeStatement(node.statement, postLoopLabel, preLoopLabel);
33256             addAntecedent(preLoopLabel, currentFlow);
33257             currentFlow = finishFlowLabel(postLoopLabel);
33258         }
33259         function bindIfStatement(node) {
33260             var thenLabel = createBranchLabel();
33261             var elseLabel = createBranchLabel();
33262             var postIfLabel = createBranchLabel();
33263             bindCondition(node.expression, thenLabel, elseLabel);
33264             currentFlow = finishFlowLabel(thenLabel);
33265             bind(node.thenStatement);
33266             addAntecedent(postIfLabel, currentFlow);
33267             currentFlow = finishFlowLabel(elseLabel);
33268             bind(node.elseStatement);
33269             addAntecedent(postIfLabel, currentFlow);
33270             currentFlow = finishFlowLabel(postIfLabel);
33271         }
33272         function bindReturnOrThrow(node) {
33273             bind(node.expression);
33274             if (node.kind === 242) {
33275                 hasExplicitReturn = true;
33276                 if (currentReturnTarget) {
33277                     addAntecedent(currentReturnTarget, currentFlow);
33278                 }
33279             }
33280             currentFlow = unreachableFlow;
33281         }
33282         function findActiveLabel(name) {
33283             for (var label = activeLabelList; label; label = label.next) {
33284                 if (label.name === name) {
33285                     return label;
33286                 }
33287             }
33288             return undefined;
33289         }
33290         function bindBreakOrContinueFlow(node, breakTarget, continueTarget) {
33291             var flowLabel = node.kind === 241 ? breakTarget : continueTarget;
33292             if (flowLabel) {
33293                 addAntecedent(flowLabel, currentFlow);
33294                 currentFlow = unreachableFlow;
33295             }
33296         }
33297         function bindBreakOrContinueStatement(node) {
33298             bind(node.label);
33299             if (node.label) {
33300                 var activeLabel = findActiveLabel(node.label.escapedText);
33301                 if (activeLabel) {
33302                     activeLabel.referenced = true;
33303                     bindBreakOrContinueFlow(node, activeLabel.breakTarget, activeLabel.continueTarget);
33304                 }
33305             }
33306             else {
33307                 bindBreakOrContinueFlow(node, currentBreakTarget, currentContinueTarget);
33308             }
33309         }
33310         function bindTryStatement(node) {
33311             var saveReturnTarget = currentReturnTarget;
33312             var saveExceptionTarget = currentExceptionTarget;
33313             var normalExitLabel = createBranchLabel();
33314             var returnLabel = createBranchLabel();
33315             var exceptionLabel = createBranchLabel();
33316             if (node.finallyBlock) {
33317                 currentReturnTarget = returnLabel;
33318             }
33319             addAntecedent(exceptionLabel, currentFlow);
33320             currentExceptionTarget = exceptionLabel;
33321             bind(node.tryBlock);
33322             addAntecedent(normalExitLabel, currentFlow);
33323             if (node.catchClause) {
33324                 currentFlow = finishFlowLabel(exceptionLabel);
33325                 exceptionLabel = createBranchLabel();
33326                 addAntecedent(exceptionLabel, currentFlow);
33327                 currentExceptionTarget = exceptionLabel;
33328                 bind(node.catchClause);
33329                 addAntecedent(normalExitLabel, currentFlow);
33330             }
33331             currentReturnTarget = saveReturnTarget;
33332             currentExceptionTarget = saveExceptionTarget;
33333             if (node.finallyBlock) {
33334                 var finallyLabel = createBranchLabel();
33335                 finallyLabel.antecedents = ts.concatenate(ts.concatenate(normalExitLabel.antecedents, exceptionLabel.antecedents), returnLabel.antecedents);
33336                 currentFlow = finallyLabel;
33337                 bind(node.finallyBlock);
33338                 if (currentFlow.flags & 1) {
33339                     currentFlow = unreachableFlow;
33340                 }
33341                 else {
33342                     if (currentReturnTarget && returnLabel.antecedents) {
33343                         addAntecedent(currentReturnTarget, createReduceLabel(finallyLabel, returnLabel.antecedents, currentFlow));
33344                     }
33345                     if (currentExceptionTarget && exceptionLabel.antecedents) {
33346                         addAntecedent(currentExceptionTarget, createReduceLabel(finallyLabel, exceptionLabel.antecedents, currentFlow));
33347                     }
33348                     currentFlow = normalExitLabel.antecedents ? createReduceLabel(finallyLabel, normalExitLabel.antecedents, currentFlow) : unreachableFlow;
33349                 }
33350             }
33351             else {
33352                 currentFlow = finishFlowLabel(normalExitLabel);
33353             }
33354         }
33355         function bindSwitchStatement(node) {
33356             var postSwitchLabel = createBranchLabel();
33357             bind(node.expression);
33358             var saveBreakTarget = currentBreakTarget;
33359             var savePreSwitchCaseFlow = preSwitchCaseFlow;
33360             currentBreakTarget = postSwitchLabel;
33361             preSwitchCaseFlow = currentFlow;
33362             bind(node.caseBlock);
33363             addAntecedent(postSwitchLabel, currentFlow);
33364             var hasDefault = ts.forEach(node.caseBlock.clauses, function (c) { return c.kind === 285; });
33365             node.possiblyExhaustive = !hasDefault && !postSwitchLabel.antecedents;
33366             if (!hasDefault) {
33367                 addAntecedent(postSwitchLabel, createFlowSwitchClause(preSwitchCaseFlow, node, 0, 0));
33368             }
33369             currentBreakTarget = saveBreakTarget;
33370             preSwitchCaseFlow = savePreSwitchCaseFlow;
33371             currentFlow = finishFlowLabel(postSwitchLabel);
33372         }
33373         function bindCaseBlock(node) {
33374             var clauses = node.clauses;
33375             var isNarrowingSwitch = isNarrowingExpression(node.parent.expression);
33376             var fallthroughFlow = unreachableFlow;
33377             for (var i = 0; i < clauses.length; i++) {
33378                 var clauseStart = i;
33379                 while (!clauses[i].statements.length && i + 1 < clauses.length) {
33380                     bind(clauses[i]);
33381                     i++;
33382                 }
33383                 var preCaseLabel = createBranchLabel();
33384                 addAntecedent(preCaseLabel, isNarrowingSwitch ? createFlowSwitchClause(preSwitchCaseFlow, node.parent, clauseStart, i + 1) : preSwitchCaseFlow);
33385                 addAntecedent(preCaseLabel, fallthroughFlow);
33386                 currentFlow = finishFlowLabel(preCaseLabel);
33387                 var clause = clauses[i];
33388                 bind(clause);
33389                 fallthroughFlow = currentFlow;
33390                 if (!(currentFlow.flags & 1) && i !== clauses.length - 1 && options.noFallthroughCasesInSwitch) {
33391                     clause.fallthroughFlowNode = currentFlow;
33392                 }
33393             }
33394         }
33395         function bindCaseClause(node) {
33396             var saveCurrentFlow = currentFlow;
33397             currentFlow = preSwitchCaseFlow;
33398             bind(node.expression);
33399             currentFlow = saveCurrentFlow;
33400             bindEach(node.statements);
33401         }
33402         function bindExpressionStatement(node) {
33403             bind(node.expression);
33404             maybeBindExpressionFlowIfCall(node.expression);
33405         }
33406         function maybeBindExpressionFlowIfCall(node) {
33407             if (node.kind === 203) {
33408                 var call = node;
33409                 if (ts.isDottedName(call.expression) && call.expression.kind !== 105) {
33410                     currentFlow = createFlowCall(currentFlow, call);
33411                 }
33412             }
33413         }
33414         function bindLabeledStatement(node) {
33415             var postStatementLabel = createBranchLabel();
33416             activeLabelList = {
33417                 next: activeLabelList,
33418                 name: node.label.escapedText,
33419                 breakTarget: postStatementLabel,
33420                 continueTarget: undefined,
33421                 referenced: false
33422             };
33423             bind(node.label);
33424             bind(node.statement);
33425             if (!activeLabelList.referenced && !options.allowUnusedLabels) {
33426                 errorOrSuggestionOnNode(ts.unusedLabelIsError(options), node.label, ts.Diagnostics.Unused_label);
33427             }
33428             activeLabelList = activeLabelList.next;
33429             addAntecedent(postStatementLabel, currentFlow);
33430             currentFlow = finishFlowLabel(postStatementLabel);
33431         }
33432         function bindDestructuringTargetFlow(node) {
33433             if (node.kind === 216 && node.operatorToken.kind === 62) {
33434                 bindAssignmentTargetFlow(node.left);
33435             }
33436             else {
33437                 bindAssignmentTargetFlow(node);
33438             }
33439         }
33440         function bindAssignmentTargetFlow(node) {
33441             if (isNarrowableReference(node)) {
33442                 currentFlow = createFlowMutation(16, currentFlow, node);
33443             }
33444             else if (node.kind === 199) {
33445                 for (var _i = 0, _a = node.elements; _i < _a.length; _i++) {
33446                     var e = _a[_i];
33447                     if (e.kind === 220) {
33448                         bindAssignmentTargetFlow(e.expression);
33449                     }
33450                     else {
33451                         bindDestructuringTargetFlow(e);
33452                     }
33453                 }
33454             }
33455             else if (node.kind === 200) {
33456                 for (var _b = 0, _c = node.properties; _b < _c.length; _b++) {
33457                     var p = _c[_b];
33458                     if (p.kind === 288) {
33459                         bindDestructuringTargetFlow(p.initializer);
33460                     }
33461                     else if (p.kind === 289) {
33462                         bindAssignmentTargetFlow(p.name);
33463                     }
33464                     else if (p.kind === 290) {
33465                         bindAssignmentTargetFlow(p.expression);
33466                     }
33467                 }
33468             }
33469         }
33470         function bindLogicalLikeExpression(node, trueTarget, falseTarget) {
33471             var preRightLabel = createBranchLabel();
33472             if (node.operatorToken.kind === 55 || node.operatorToken.kind === 75) {
33473                 bindCondition(node.left, preRightLabel, falseTarget);
33474             }
33475             else {
33476                 bindCondition(node.left, trueTarget, preRightLabel);
33477             }
33478             currentFlow = finishFlowLabel(preRightLabel);
33479             bind(node.operatorToken);
33480             if (ts.isLogicalOrCoalescingAssignmentOperator(node.operatorToken.kind)) {
33481                 doWithConditionalBranches(bind, node.right, trueTarget, falseTarget);
33482                 bindAssignmentTargetFlow(node.left);
33483                 addAntecedent(trueTarget, createFlowCondition(32, currentFlow, node));
33484                 addAntecedent(falseTarget, createFlowCondition(64, currentFlow, node));
33485             }
33486             else {
33487                 bindCondition(node.right, trueTarget, falseTarget);
33488             }
33489         }
33490         function bindPrefixUnaryExpressionFlow(node) {
33491             if (node.operator === 53) {
33492                 var saveTrueTarget = currentTrueTarget;
33493                 currentTrueTarget = currentFalseTarget;
33494                 currentFalseTarget = saveTrueTarget;
33495                 bindEachChild(node);
33496                 currentFalseTarget = currentTrueTarget;
33497                 currentTrueTarget = saveTrueTarget;
33498             }
33499             else {
33500                 bindEachChild(node);
33501                 if (node.operator === 45 || node.operator === 46) {
33502                     bindAssignmentTargetFlow(node.operand);
33503                 }
33504             }
33505         }
33506         function bindPostfixUnaryExpressionFlow(node) {
33507             bindEachChild(node);
33508             if (node.operator === 45 || node.operator === 46) {
33509                 bindAssignmentTargetFlow(node.operand);
33510             }
33511         }
33512         function bindDestructuringAssignmentFlow(node) {
33513             if (inAssignmentPattern) {
33514                 inAssignmentPattern = false;
33515                 bind(node.operatorToken);
33516                 bind(node.right);
33517                 inAssignmentPattern = true;
33518                 bind(node.left);
33519             }
33520             else {
33521                 inAssignmentPattern = true;
33522                 bind(node.left);
33523                 inAssignmentPattern = false;
33524                 bind(node.operatorToken);
33525                 bind(node.right);
33526             }
33527             bindAssignmentTargetFlow(node.left);
33528         }
33529         function bindBinaryExpressionFlow(node) {
33530             var workStacks = {
33531                 expr: [node],
33532                 state: [1],
33533                 inStrictMode: [undefined],
33534                 parent: [undefined],
33535             };
33536             var stackIndex = 0;
33537             while (stackIndex >= 0) {
33538                 node = workStacks.expr[stackIndex];
33539                 switch (workStacks.state[stackIndex]) {
33540                     case 0: {
33541                         ts.setParent(node, parent);
33542                         var saveInStrictMode = inStrictMode;
33543                         bindWorker(node);
33544                         var saveParent = parent;
33545                         parent = node;
33546                         advanceState(1, saveInStrictMode, saveParent);
33547                         break;
33548                     }
33549                     case 1: {
33550                         var operator = node.operatorToken.kind;
33551                         if (operator === 55 || operator === 56 || operator === 60 ||
33552                             ts.isLogicalOrCoalescingAssignmentOperator(operator)) {
33553                             if (isTopLevelLogicalExpression(node)) {
33554                                 var postExpressionLabel = createBranchLabel();
33555                                 bindLogicalLikeExpression(node, postExpressionLabel, postExpressionLabel);
33556                                 currentFlow = finishFlowLabel(postExpressionLabel);
33557                             }
33558                             else {
33559                                 bindLogicalLikeExpression(node, currentTrueTarget, currentFalseTarget);
33560                             }
33561                             completeNode();
33562                         }
33563                         else {
33564                             advanceState(2);
33565                             maybeBind(node.left);
33566                         }
33567                         break;
33568                     }
33569                     case 2: {
33570                         if (node.operatorToken.kind === 27) {
33571                             maybeBindExpressionFlowIfCall(node.left);
33572                         }
33573                         advanceState(3);
33574                         maybeBind(node.operatorToken);
33575                         break;
33576                     }
33577                     case 3: {
33578                         advanceState(4);
33579                         maybeBind(node.right);
33580                         break;
33581                     }
33582                     case 4: {
33583                         var operator = node.operatorToken.kind;
33584                         if (ts.isAssignmentOperator(operator) && !ts.isAssignmentTarget(node)) {
33585                             bindAssignmentTargetFlow(node.left);
33586                             if (operator === 62 && node.left.kind === 202) {
33587                                 var elementAccess = node.left;
33588                                 if (isNarrowableOperand(elementAccess.expression)) {
33589                                     currentFlow = createFlowMutation(256, currentFlow, node);
33590                                 }
33591                             }
33592                         }
33593                         completeNode();
33594                         break;
33595                     }
33596                     default: return ts.Debug.fail("Invalid state " + workStacks.state[stackIndex] + " for bindBinaryExpressionFlow");
33597                 }
33598             }
33599             function advanceState(state, isInStrictMode, parent) {
33600                 workStacks.state[stackIndex] = state;
33601                 if (isInStrictMode !== undefined) {
33602                     workStacks.inStrictMode[stackIndex] = isInStrictMode;
33603                 }
33604                 if (parent !== undefined) {
33605                     workStacks.parent[stackIndex] = parent;
33606                 }
33607             }
33608             function completeNode() {
33609                 if (workStacks.inStrictMode[stackIndex] !== undefined) {
33610                     inStrictMode = workStacks.inStrictMode[stackIndex];
33611                     parent = workStacks.parent[stackIndex];
33612                 }
33613                 stackIndex--;
33614             }
33615             function maybeBind(node) {
33616                 if (node && ts.isBinaryExpression(node) && !ts.isDestructuringAssignment(node)) {
33617                     stackIndex++;
33618                     workStacks.expr[stackIndex] = node;
33619                     workStacks.state[stackIndex] = 0;
33620                     workStacks.inStrictMode[stackIndex] = undefined;
33621                     workStacks.parent[stackIndex] = undefined;
33622                 }
33623                 else {
33624                     bind(node);
33625                 }
33626             }
33627         }
33628         function bindDeleteExpressionFlow(node) {
33629             bindEachChild(node);
33630             if (node.expression.kind === 201) {
33631                 bindAssignmentTargetFlow(node.expression);
33632             }
33633         }
33634         function bindConditionalExpressionFlow(node) {
33635             var trueLabel = createBranchLabel();
33636             var falseLabel = createBranchLabel();
33637             var postExpressionLabel = createBranchLabel();
33638             bindCondition(node.condition, trueLabel, falseLabel);
33639             currentFlow = finishFlowLabel(trueLabel);
33640             bind(node.questionToken);
33641             bind(node.whenTrue);
33642             addAntecedent(postExpressionLabel, currentFlow);
33643             currentFlow = finishFlowLabel(falseLabel);
33644             bind(node.colonToken);
33645             bind(node.whenFalse);
33646             addAntecedent(postExpressionLabel, currentFlow);
33647             currentFlow = finishFlowLabel(postExpressionLabel);
33648         }
33649         function bindInitializedVariableFlow(node) {
33650             var name = !ts.isOmittedExpression(node) ? node.name : undefined;
33651             if (ts.isBindingPattern(name)) {
33652                 for (var _i = 0, _a = name.elements; _i < _a.length; _i++) {
33653                     var child = _a[_i];
33654                     bindInitializedVariableFlow(child);
33655                 }
33656             }
33657             else {
33658                 currentFlow = createFlowMutation(16, currentFlow, node);
33659             }
33660         }
33661         function bindVariableDeclarationFlow(node) {
33662             bindEachChild(node);
33663             if (node.initializer || ts.isForInOrOfStatement(node.parent.parent)) {
33664                 bindInitializedVariableFlow(node);
33665             }
33666         }
33667         function bindBindingElementFlow(node) {
33668             if (ts.isBindingPattern(node.name)) {
33669                 bindEach(node.decorators);
33670                 bindEach(node.modifiers);
33671                 bind(node.dotDotDotToken);
33672                 bind(node.propertyName);
33673                 bind(node.initializer);
33674                 bind(node.name);
33675             }
33676             else {
33677                 bindEachChild(node);
33678             }
33679         }
33680         function bindJSDocTypeAlias(node) {
33681             ts.setParent(node.tagName, node);
33682             if (node.kind !== 325 && node.fullName) {
33683                 ts.setParent(node.fullName, node);
33684                 ts.setParentRecursive(node.fullName, false);
33685             }
33686         }
33687         function bindJSDocClassTag(node) {
33688             bindEachChild(node);
33689             var host = ts.getHostSignatureFromJSDoc(node);
33690             if (host && host.kind !== 165) {
33691                 addDeclarationToSymbol(host.symbol, host, 32);
33692             }
33693         }
33694         function bindOptionalExpression(node, trueTarget, falseTarget) {
33695             doWithConditionalBranches(bind, node, trueTarget, falseTarget);
33696             if (!ts.isOptionalChain(node) || ts.isOutermostOptionalChain(node)) {
33697                 addAntecedent(trueTarget, createFlowCondition(32, currentFlow, node));
33698                 addAntecedent(falseTarget, createFlowCondition(64, currentFlow, node));
33699             }
33700         }
33701         function bindOptionalChainRest(node) {
33702             switch (node.kind) {
33703                 case 201:
33704                     bind(node.questionDotToken);
33705                     bind(node.name);
33706                     break;
33707                 case 202:
33708                     bind(node.questionDotToken);
33709                     bind(node.argumentExpression);
33710                     break;
33711                 case 203:
33712                     bind(node.questionDotToken);
33713                     bindEach(node.typeArguments);
33714                     bindEach(node.arguments);
33715                     break;
33716             }
33717         }
33718         function bindOptionalChain(node, trueTarget, falseTarget) {
33719             var preChainLabel = ts.isOptionalChainRoot(node) ? createBranchLabel() : undefined;
33720             bindOptionalExpression(node.expression, preChainLabel || trueTarget, falseTarget);
33721             if (preChainLabel) {
33722                 currentFlow = finishFlowLabel(preChainLabel);
33723             }
33724             doWithConditionalBranches(bindOptionalChainRest, node, trueTarget, falseTarget);
33725             if (ts.isOutermostOptionalChain(node)) {
33726                 addAntecedent(trueTarget, createFlowCondition(32, currentFlow, node));
33727                 addAntecedent(falseTarget, createFlowCondition(64, currentFlow, node));
33728             }
33729         }
33730         function bindOptionalChainFlow(node) {
33731             if (isTopLevelLogicalExpression(node)) {
33732                 var postExpressionLabel = createBranchLabel();
33733                 bindOptionalChain(node, postExpressionLabel, postExpressionLabel);
33734                 currentFlow = finishFlowLabel(postExpressionLabel);
33735             }
33736             else {
33737                 bindOptionalChain(node, currentTrueTarget, currentFalseTarget);
33738             }
33739         }
33740         function bindNonNullExpressionFlow(node) {
33741             if (ts.isOptionalChain(node)) {
33742                 bindOptionalChainFlow(node);
33743             }
33744             else {
33745                 bindEachChild(node);
33746             }
33747         }
33748         function bindAccessExpressionFlow(node) {
33749             if (ts.isOptionalChain(node)) {
33750                 bindOptionalChainFlow(node);
33751             }
33752             else {
33753                 bindEachChild(node);
33754             }
33755         }
33756         function bindCallExpressionFlow(node) {
33757             if (ts.isOptionalChain(node)) {
33758                 bindOptionalChainFlow(node);
33759             }
33760             else {
33761                 var expr = ts.skipParentheses(node.expression);
33762                 if (expr.kind === 208 || expr.kind === 209) {
33763                     bindEach(node.typeArguments);
33764                     bindEach(node.arguments);
33765                     bind(node.expression);
33766                 }
33767                 else {
33768                     bindEachChild(node);
33769                     if (node.expression.kind === 105) {
33770                         currentFlow = createFlowCall(currentFlow, node);
33771                     }
33772                 }
33773             }
33774             if (node.expression.kind === 201) {
33775                 var propertyAccess = node.expression;
33776                 if (ts.isIdentifier(propertyAccess.name) && isNarrowableOperand(propertyAccess.expression) && ts.isPushOrUnshiftIdentifier(propertyAccess.name)) {
33777                     currentFlow = createFlowMutation(256, currentFlow, node);
33778                 }
33779             }
33780         }
33781         function getContainerFlags(node) {
33782             switch (node.kind) {
33783                 case 221:
33784                 case 252:
33785                 case 255:
33786                 case 200:
33787                 case 177:
33788                 case 312:
33789                 case 281:
33790                     return 1;
33791                 case 253:
33792                     return 1 | 64;
33793                 case 256:
33794                 case 254:
33795                 case 190:
33796                     return 1 | 32;
33797                 case 297:
33798                     return 1 | 4 | 32;
33799                 case 165:
33800                     if (ts.isObjectLiteralOrClassExpressionMethod(node)) {
33801                         return 1 | 4 | 32 | 8 | 128;
33802                     }
33803                 case 166:
33804                 case 251:
33805                 case 164:
33806                 case 167:
33807                 case 168:
33808                 case 169:
33809                 case 313:
33810                 case 308:
33811                 case 174:
33812                 case 170:
33813                 case 171:
33814                 case 175:
33815                     return 1 | 4 | 32 | 8;
33816                 case 208:
33817                 case 209:
33818                     return 1 | 4 | 32 | 8 | 16;
33819                 case 257:
33820                     return 4;
33821                 case 163:
33822                     return node.initializer ? 4 : 0;
33823                 case 287:
33824                 case 237:
33825                 case 238:
33826                 case 239:
33827                 case 258:
33828                     return 2;
33829                 case 230:
33830                     return ts.isFunctionLike(node.parent) ? 0 : 2;
33831             }
33832             return 0;
33833         }
33834         function addToContainerChain(next) {
33835             if (lastContainer) {
33836                 lastContainer.nextContainer = next;
33837             }
33838             lastContainer = next;
33839         }
33840         function declareSymbolAndAddToSymbolTable(node, symbolFlags, symbolExcludes) {
33841             switch (container.kind) {
33842                 case 256:
33843                     return declareModuleMember(node, symbolFlags, symbolExcludes);
33844                 case 297:
33845                     return declareSourceFileMember(node, symbolFlags, symbolExcludes);
33846                 case 221:
33847                 case 252:
33848                     return declareClassMember(node, symbolFlags, symbolExcludes);
33849                 case 255:
33850                     return declareSymbol(container.symbol.exports, container.symbol, node, symbolFlags, symbolExcludes);
33851                 case 177:
33852                 case 312:
33853                 case 200:
33854                 case 253:
33855                 case 281:
33856                     return declareSymbol(container.symbol.members, container.symbol, node, symbolFlags, symbolExcludes);
33857                 case 174:
33858                 case 175:
33859                 case 169:
33860                 case 170:
33861                 case 313:
33862                 case 171:
33863                 case 165:
33864                 case 164:
33865                 case 166:
33866                 case 167:
33867                 case 168:
33868                 case 251:
33869                 case 208:
33870                 case 209:
33871                 case 308:
33872                 case 331:
33873                 case 324:
33874                 case 254:
33875                 case 190:
33876                     return declareSymbol(container.locals, undefined, node, symbolFlags, symbolExcludes);
33877             }
33878         }
33879         function declareClassMember(node, symbolFlags, symbolExcludes) {
33880             return ts.hasSyntacticModifier(node, 32)
33881                 ? declareSymbol(container.symbol.exports, container.symbol, node, symbolFlags, symbolExcludes)
33882                 : declareSymbol(container.symbol.members, container.symbol, node, symbolFlags, symbolExcludes);
33883         }
33884         function declareSourceFileMember(node, symbolFlags, symbolExcludes) {
33885             return ts.isExternalModule(file)
33886                 ? declareModuleMember(node, symbolFlags, symbolExcludes)
33887                 : declareSymbol(file.locals, undefined, node, symbolFlags, symbolExcludes);
33888         }
33889         function hasExportDeclarations(node) {
33890             var body = ts.isSourceFile(node) ? node : ts.tryCast(node.body, ts.isModuleBlock);
33891             return !!body && body.statements.some(function (s) { return ts.isExportDeclaration(s) || ts.isExportAssignment(s); });
33892         }
33893         function setExportContextFlag(node) {
33894             if (node.flags & 8388608 && !hasExportDeclarations(node)) {
33895                 node.flags |= 64;
33896             }
33897             else {
33898                 node.flags &= ~64;
33899             }
33900         }
33901         function bindModuleDeclaration(node) {
33902             setExportContextFlag(node);
33903             if (ts.isAmbientModule(node)) {
33904                 if (ts.hasSyntacticModifier(node, 1)) {
33905                     errorOnFirstToken(node, ts.Diagnostics.export_modifier_cannot_be_applied_to_ambient_modules_and_module_augmentations_since_they_are_always_visible);
33906                 }
33907                 if (ts.isModuleAugmentationExternal(node)) {
33908                     declareModuleSymbol(node);
33909                 }
33910                 else {
33911                     var pattern = void 0;
33912                     if (node.name.kind === 10) {
33913                         var text = node.name.text;
33914                         if (ts.hasZeroOrOneAsteriskCharacter(text)) {
33915                             pattern = ts.tryParsePattern(text);
33916                         }
33917                         else {
33918                             errorOnFirstToken(node.name, ts.Diagnostics.Pattern_0_can_have_at_most_one_Asterisk_character, text);
33919                         }
33920                     }
33921                     var symbol = declareSymbolAndAddToSymbolTable(node, 512, 110735);
33922                     file.patternAmbientModules = ts.append(file.patternAmbientModules, pattern && { pattern: pattern, symbol: symbol });
33923                 }
33924             }
33925             else {
33926                 var state = declareModuleSymbol(node);
33927                 if (state !== 0) {
33928                     var symbol = node.symbol;
33929                     symbol.constEnumOnlyModule = (!(symbol.flags & (16 | 32 | 256)))
33930                         && state === 2
33931                         && symbol.constEnumOnlyModule !== false;
33932                 }
33933             }
33934         }
33935         function declareModuleSymbol(node) {
33936             var state = getModuleInstanceState(node);
33937             var instantiated = state !== 0;
33938             declareSymbolAndAddToSymbolTable(node, instantiated ? 512 : 1024, instantiated ? 110735 : 0);
33939             return state;
33940         }
33941         function bindFunctionOrConstructorType(node) {
33942             var symbol = createSymbol(131072, getDeclarationName(node));
33943             addDeclarationToSymbol(symbol, node, 131072);
33944             var typeLiteralSymbol = createSymbol(2048, "__type");
33945             addDeclarationToSymbol(typeLiteralSymbol, node, 2048);
33946             typeLiteralSymbol.members = ts.createSymbolTable();
33947             typeLiteralSymbol.members.set(symbol.escapedName, symbol);
33948         }
33949         function bindObjectLiteralExpression(node) {
33950             if (inStrictMode && !ts.isAssignmentTarget(node)) {
33951                 var seen = new ts.Map();
33952                 for (var _i = 0, _a = node.properties; _i < _a.length; _i++) {
33953                     var prop = _a[_i];
33954                     if (prop.kind === 290 || prop.name.kind !== 78) {
33955                         continue;
33956                     }
33957                     var identifier = prop.name;
33958                     var currentKind = prop.kind === 288 || prop.kind === 289 || prop.kind === 165
33959                         ? 1
33960                         : 2;
33961                     var existingKind = seen.get(identifier.escapedText);
33962                     if (!existingKind) {
33963                         seen.set(identifier.escapedText, currentKind);
33964                         continue;
33965                     }
33966                     if (currentKind === 1 && existingKind === 1) {
33967                         var span = ts.getErrorSpanForNode(file, identifier);
33968                         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));
33969                     }
33970                 }
33971             }
33972             return bindAnonymousDeclaration(node, 4096, "__object");
33973         }
33974         function bindJsxAttributes(node) {
33975             return bindAnonymousDeclaration(node, 4096, "__jsxAttributes");
33976         }
33977         function bindJsxAttribute(node, symbolFlags, symbolExcludes) {
33978             return declareSymbolAndAddToSymbolTable(node, symbolFlags, symbolExcludes);
33979         }
33980         function bindAnonymousDeclaration(node, symbolFlags, name) {
33981             var symbol = createSymbol(symbolFlags, name);
33982             if (symbolFlags & (8 | 106500)) {
33983                 symbol.parent = container.symbol;
33984             }
33985             addDeclarationToSymbol(symbol, node, symbolFlags);
33986             return symbol;
33987         }
33988         function bindBlockScopedDeclaration(node, symbolFlags, symbolExcludes) {
33989             switch (blockScopeContainer.kind) {
33990                 case 256:
33991                     declareModuleMember(node, symbolFlags, symbolExcludes);
33992                     break;
33993                 case 297:
33994                     if (ts.isExternalOrCommonJsModule(container)) {
33995                         declareModuleMember(node, symbolFlags, symbolExcludes);
33996                         break;
33997                     }
33998                 default:
33999                     if (!blockScopeContainer.locals) {
34000                         blockScopeContainer.locals = ts.createSymbolTable();
34001                         addToContainerChain(blockScopeContainer);
34002                     }
34003                     declareSymbol(blockScopeContainer.locals, undefined, node, symbolFlags, symbolExcludes);
34004             }
34005         }
34006         function delayedBindJSDocTypedefTag() {
34007             if (!delayedTypeAliases) {
34008                 return;
34009             }
34010             var saveContainer = container;
34011             var saveLastContainer = lastContainer;
34012             var saveBlockScopeContainer = blockScopeContainer;
34013             var saveParent = parent;
34014             var saveCurrentFlow = currentFlow;
34015             for (var _i = 0, delayedTypeAliases_1 = delayedTypeAliases; _i < delayedTypeAliases_1.length; _i++) {
34016                 var typeAlias = delayedTypeAliases_1[_i];
34017                 var host = ts.getJSDocHost(typeAlias);
34018                 container = ts.findAncestor(host.parent, function (n) { return !!(getContainerFlags(n) & 1); }) || file;
34019                 blockScopeContainer = ts.getEnclosingBlockScopeContainer(host) || file;
34020                 currentFlow = initFlowNode({ flags: 2 });
34021                 parent = typeAlias;
34022                 bind(typeAlias.typeExpression);
34023                 var declName = ts.getNameOfDeclaration(typeAlias);
34024                 if ((ts.isJSDocEnumTag(typeAlias) || !typeAlias.fullName) && declName && ts.isPropertyAccessEntityNameExpression(declName.parent)) {
34025                     var isTopLevel = isTopLevelNamespaceAssignment(declName.parent);
34026                     if (isTopLevel) {
34027                         bindPotentiallyMissingNamespaces(file.symbol, declName.parent, isTopLevel, !!ts.findAncestor(declName, function (d) { return ts.isPropertyAccessExpression(d) && d.name.escapedText === "prototype"; }), false);
34028                         var oldContainer = container;
34029                         switch (ts.getAssignmentDeclarationPropertyAccessKind(declName.parent)) {
34030                             case 1:
34031                             case 2:
34032                                 if (!ts.isExternalOrCommonJsModule(file)) {
34033                                     container = undefined;
34034                                 }
34035                                 else {
34036                                     container = file;
34037                                 }
34038                                 break;
34039                             case 4:
34040                                 container = declName.parent.expression;
34041                                 break;
34042                             case 3:
34043                                 container = declName.parent.expression.name;
34044                                 break;
34045                             case 5:
34046                                 container = isExportsOrModuleExportsOrAlias(file, declName.parent.expression) ? file
34047                                     : ts.isPropertyAccessExpression(declName.parent.expression) ? declName.parent.expression.name
34048                                         : declName.parent.expression;
34049                                 break;
34050                             case 0:
34051                                 return ts.Debug.fail("Shouldn't have detected typedef or enum on non-assignment declaration");
34052                         }
34053                         if (container) {
34054                             declareModuleMember(typeAlias, 524288, 788968);
34055                         }
34056                         container = oldContainer;
34057                     }
34058                 }
34059                 else if (ts.isJSDocEnumTag(typeAlias) || !typeAlias.fullName || typeAlias.fullName.kind === 78) {
34060                     parent = typeAlias.parent;
34061                     bindBlockScopedDeclaration(typeAlias, 524288, 788968);
34062                 }
34063                 else {
34064                     bind(typeAlias.fullName);
34065                 }
34066             }
34067             container = saveContainer;
34068             lastContainer = saveLastContainer;
34069             blockScopeContainer = saveBlockScopeContainer;
34070             parent = saveParent;
34071             currentFlow = saveCurrentFlow;
34072         }
34073         function checkContextualIdentifier(node) {
34074             if (!file.parseDiagnostics.length &&
34075                 !(node.flags & 8388608) &&
34076                 !(node.flags & 4194304) &&
34077                 !ts.isIdentifierName(node)) {
34078                 if (inStrictMode &&
34079                     node.originalKeywordKind >= 116 &&
34080                     node.originalKeywordKind <= 124) {
34081                     file.bindDiagnostics.push(createDiagnosticForNode(node, getStrictModeIdentifierMessage(node), ts.declarationNameToString(node)));
34082                 }
34083                 else if (node.originalKeywordKind === 130) {
34084                     if (ts.isExternalModule(file) && ts.isInTopLevelContext(node)) {
34085                         file.bindDiagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.Identifier_expected_0_is_a_reserved_word_at_the_top_level_of_a_module, ts.declarationNameToString(node)));
34086                     }
34087                     else if (node.flags & 32768) {
34088                         file.bindDiagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.Identifier_expected_0_is_a_reserved_word_that_cannot_be_used_here, ts.declarationNameToString(node)));
34089                     }
34090                 }
34091                 else if (node.originalKeywordKind === 124 && node.flags & 8192) {
34092                     file.bindDiagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.Identifier_expected_0_is_a_reserved_word_that_cannot_be_used_here, ts.declarationNameToString(node)));
34093                 }
34094             }
34095         }
34096         function getStrictModeIdentifierMessage(node) {
34097             if (ts.getContainingClass(node)) {
34098                 return ts.Diagnostics.Identifier_expected_0_is_a_reserved_word_in_strict_mode_Class_definitions_are_automatically_in_strict_mode;
34099             }
34100             if (file.externalModuleIndicator) {
34101                 return ts.Diagnostics.Identifier_expected_0_is_a_reserved_word_in_strict_mode_Modules_are_automatically_in_strict_mode;
34102             }
34103             return ts.Diagnostics.Identifier_expected_0_is_a_reserved_word_in_strict_mode;
34104         }
34105         function checkPrivateIdentifier(node) {
34106             if (node.escapedText === "#constructor") {
34107                 if (!file.parseDiagnostics.length) {
34108                     file.bindDiagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.constructor_is_a_reserved_word, ts.declarationNameToString(node)));
34109                 }
34110             }
34111         }
34112         function checkStrictModeBinaryExpression(node) {
34113             if (inStrictMode && ts.isLeftHandSideExpression(node.left) && ts.isAssignmentOperator(node.operatorToken.kind)) {
34114                 checkStrictModeEvalOrArguments(node, node.left);
34115             }
34116         }
34117         function checkStrictModeCatchClause(node) {
34118             if (inStrictMode && node.variableDeclaration) {
34119                 checkStrictModeEvalOrArguments(node, node.variableDeclaration.name);
34120             }
34121         }
34122         function checkStrictModeDeleteExpression(node) {
34123             if (inStrictMode && node.expression.kind === 78) {
34124                 var span = ts.getErrorSpanForNode(file, node.expression);
34125                 file.bindDiagnostics.push(ts.createFileDiagnostic(file, span.start, span.length, ts.Diagnostics.delete_cannot_be_called_on_an_identifier_in_strict_mode));
34126             }
34127         }
34128         function isEvalOrArgumentsIdentifier(node) {
34129             return ts.isIdentifier(node) && (node.escapedText === "eval" || node.escapedText === "arguments");
34130         }
34131         function checkStrictModeEvalOrArguments(contextNode, name) {
34132             if (name && name.kind === 78) {
34133                 var identifier = name;
34134                 if (isEvalOrArgumentsIdentifier(identifier)) {
34135                     var span = ts.getErrorSpanForNode(file, name);
34136                     file.bindDiagnostics.push(ts.createFileDiagnostic(file, span.start, span.length, getStrictModeEvalOrArgumentsMessage(contextNode), ts.idText(identifier)));
34137                 }
34138             }
34139         }
34140         function getStrictModeEvalOrArgumentsMessage(node) {
34141             if (ts.getContainingClass(node)) {
34142                 return ts.Diagnostics.Invalid_use_of_0_Class_definitions_are_automatically_in_strict_mode;
34143             }
34144             if (file.externalModuleIndicator) {
34145                 return ts.Diagnostics.Invalid_use_of_0_Modules_are_automatically_in_strict_mode;
34146             }
34147             return ts.Diagnostics.Invalid_use_of_0_in_strict_mode;
34148         }
34149         function checkStrictModeFunctionName(node) {
34150             if (inStrictMode) {
34151                 checkStrictModeEvalOrArguments(node, node.name);
34152             }
34153         }
34154         function getStrictModeBlockScopeFunctionDeclarationMessage(node) {
34155             if (ts.getContainingClass(node)) {
34156                 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;
34157             }
34158             if (file.externalModuleIndicator) {
34159                 return ts.Diagnostics.Function_declarations_are_not_allowed_inside_blocks_in_strict_mode_when_targeting_ES3_or_ES5_Modules_are_automatically_in_strict_mode;
34160             }
34161             return ts.Diagnostics.Function_declarations_are_not_allowed_inside_blocks_in_strict_mode_when_targeting_ES3_or_ES5;
34162         }
34163         function checkStrictModeFunctionDeclaration(node) {
34164             if (languageVersion < 2) {
34165                 if (blockScopeContainer.kind !== 297 &&
34166                     blockScopeContainer.kind !== 256 &&
34167                     !ts.isFunctionLike(blockScopeContainer)) {
34168                     var errorSpan = ts.getErrorSpanForNode(file, node);
34169                     file.bindDiagnostics.push(ts.createFileDiagnostic(file, errorSpan.start, errorSpan.length, getStrictModeBlockScopeFunctionDeclarationMessage(node)));
34170                 }
34171             }
34172         }
34173         function checkStrictModeNumericLiteral(node) {
34174             if (inStrictMode && node.numericLiteralFlags & 32) {
34175                 file.bindDiagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.Octal_literals_are_not_allowed_in_strict_mode));
34176             }
34177         }
34178         function checkStrictModePostfixUnaryExpression(node) {
34179             if (inStrictMode) {
34180                 checkStrictModeEvalOrArguments(node, node.operand);
34181             }
34182         }
34183         function checkStrictModePrefixUnaryExpression(node) {
34184             if (inStrictMode) {
34185                 if (node.operator === 45 || node.operator === 46) {
34186                     checkStrictModeEvalOrArguments(node, node.operand);
34187                 }
34188             }
34189         }
34190         function checkStrictModeWithStatement(node) {
34191             if (inStrictMode) {
34192                 errorOnFirstToken(node, ts.Diagnostics.with_statements_are_not_allowed_in_strict_mode);
34193             }
34194         }
34195         function checkStrictModeLabeledStatement(node) {
34196             if (inStrictMode && options.target >= 2) {
34197                 if (ts.isDeclarationStatement(node.statement) || ts.isVariableStatement(node.statement)) {
34198                     errorOnFirstToken(node.label, ts.Diagnostics.A_label_is_not_allowed_here);
34199                 }
34200             }
34201         }
34202         function errorOnFirstToken(node, message, arg0, arg1, arg2) {
34203             var span = ts.getSpanOfTokenAtPosition(file, node.pos);
34204             file.bindDiagnostics.push(ts.createFileDiagnostic(file, span.start, span.length, message, arg0, arg1, arg2));
34205         }
34206         function errorOrSuggestionOnNode(isError, node, message) {
34207             errorOrSuggestionOnRange(isError, node, node, message);
34208         }
34209         function errorOrSuggestionOnRange(isError, startNode, endNode, message) {
34210             addErrorOrSuggestionDiagnostic(isError, { pos: ts.getTokenPosOfNode(startNode, file), end: endNode.end }, message);
34211         }
34212         function addErrorOrSuggestionDiagnostic(isError, range, message) {
34213             var diag = ts.createFileDiagnostic(file, range.pos, range.end - range.pos, message);
34214             if (isError) {
34215                 file.bindDiagnostics.push(diag);
34216             }
34217             else {
34218                 file.bindSuggestionDiagnostics = ts.append(file.bindSuggestionDiagnostics, __assign(__assign({}, diag), { category: ts.DiagnosticCategory.Suggestion }));
34219             }
34220         }
34221         function bind(node) {
34222             if (!node) {
34223                 return;
34224             }
34225             ts.setParent(node, parent);
34226             var saveInStrictMode = inStrictMode;
34227             bindWorker(node);
34228             if (node.kind > 156) {
34229                 var saveParent = parent;
34230                 parent = node;
34231                 var containerFlags = getContainerFlags(node);
34232                 if (containerFlags === 0) {
34233                     bindChildren(node);
34234                 }
34235                 else {
34236                     bindContainer(node, containerFlags);
34237                 }
34238                 parent = saveParent;
34239             }
34240             else {
34241                 var saveParent = parent;
34242                 if (node.kind === 1)
34243                     parent = node;
34244                 bindJSDoc(node);
34245                 parent = saveParent;
34246             }
34247             inStrictMode = saveInStrictMode;
34248         }
34249         function bindJSDoc(node) {
34250             if (ts.hasJSDocNodes(node)) {
34251                 if (ts.isInJSFile(node)) {
34252                     for (var _i = 0, _a = node.jsDoc; _i < _a.length; _i++) {
34253                         var j = _a[_i];
34254                         bind(j);
34255                     }
34256                 }
34257                 else {
34258                     for (var _b = 0, _c = node.jsDoc; _b < _c.length; _b++) {
34259                         var j = _c[_b];
34260                         ts.setParent(j, node);
34261                         ts.setParentRecursive(j, false);
34262                     }
34263                 }
34264             }
34265         }
34266         function updateStrictModeStatementList(statements) {
34267             if (!inStrictMode) {
34268                 for (var _i = 0, statements_3 = statements; _i < statements_3.length; _i++) {
34269                     var statement = statements_3[_i];
34270                     if (!ts.isPrologueDirective(statement)) {
34271                         return;
34272                     }
34273                     if (isUseStrictPrologueDirective(statement)) {
34274                         inStrictMode = true;
34275                         return;
34276                     }
34277                 }
34278             }
34279         }
34280         function isUseStrictPrologueDirective(node) {
34281             var nodeText = ts.getSourceTextOfNodeFromSourceFile(file, node.expression);
34282             return nodeText === '"use strict"' || nodeText === "'use strict'";
34283         }
34284         function bindWorker(node) {
34285             switch (node.kind) {
34286                 case 78:
34287                     if (node.isInJSDocNamespace) {
34288                         var parentNode = node.parent;
34289                         while (parentNode && !ts.isJSDocTypeAlias(parentNode)) {
34290                             parentNode = parentNode.parent;
34291                         }
34292                         bindBlockScopedDeclaration(parentNode, 524288, 788968);
34293                         break;
34294                     }
34295                 case 107:
34296                     if (currentFlow && (ts.isExpression(node) || parent.kind === 289)) {
34297                         node.flowNode = currentFlow;
34298                     }
34299                     return checkContextualIdentifier(node);
34300                 case 105:
34301                     node.flowNode = currentFlow;
34302                     break;
34303                 case 79:
34304                     return checkPrivateIdentifier(node);
34305                 case 201:
34306                 case 202:
34307                     var expr = node;
34308                     if (currentFlow && isNarrowableReference(expr)) {
34309                         expr.flowNode = currentFlow;
34310                     }
34311                     if (ts.isSpecialPropertyDeclaration(expr)) {
34312                         bindSpecialPropertyDeclaration(expr);
34313                     }
34314                     if (ts.isInJSFile(expr) &&
34315                         file.commonJsModuleIndicator &&
34316                         ts.isModuleExportsAccessExpression(expr) &&
34317                         !lookupSymbolForName(blockScopeContainer, "module")) {
34318                         declareSymbol(file.locals, undefined, expr.expression, 1 | 134217728, 111550);
34319                     }
34320                     break;
34321                 case 216:
34322                     var specialKind = ts.getAssignmentDeclarationKind(node);
34323                     switch (specialKind) {
34324                         case 1:
34325                             bindExportsPropertyAssignment(node);
34326                             break;
34327                         case 2:
34328                             bindModuleExportsAssignment(node);
34329                             break;
34330                         case 3:
34331                             bindPrototypePropertyAssignment(node.left, node);
34332                             break;
34333                         case 6:
34334                             bindPrototypeAssignment(node);
34335                             break;
34336                         case 4:
34337                             bindThisPropertyAssignment(node);
34338                             break;
34339                         case 5:
34340                             var expression = node.left.expression;
34341                             if (ts.isInJSFile(node) && ts.isIdentifier(expression)) {
34342                                 var symbol = lookupSymbolForName(blockScopeContainer, expression.escapedText);
34343                                 if (ts.isThisInitializedDeclaration(symbol === null || symbol === void 0 ? void 0 : symbol.valueDeclaration)) {
34344                                     bindThisPropertyAssignment(node);
34345                                     break;
34346                                 }
34347                             }
34348                             bindSpecialPropertyAssignment(node);
34349                             break;
34350                         case 0:
34351                             break;
34352                         default:
34353                             ts.Debug.fail("Unknown binary expression special property assignment kind");
34354                     }
34355                     return checkStrictModeBinaryExpression(node);
34356                 case 287:
34357                     return checkStrictModeCatchClause(node);
34358                 case 210:
34359                     return checkStrictModeDeleteExpression(node);
34360                 case 8:
34361                     return checkStrictModeNumericLiteral(node);
34362                 case 215:
34363                     return checkStrictModePostfixUnaryExpression(node);
34364                 case 214:
34365                     return checkStrictModePrefixUnaryExpression(node);
34366                 case 243:
34367                     return checkStrictModeWithStatement(node);
34368                 case 245:
34369                     return checkStrictModeLabeledStatement(node);
34370                 case 187:
34371                     seenThisKeyword = true;
34372                     return;
34373                 case 172:
34374                     break;
34375                 case 159:
34376                     return bindTypeParameter(node);
34377                 case 160:
34378                     return bindParameter(node);
34379                 case 249:
34380                     return bindVariableDeclarationOrBindingElement(node);
34381                 case 198:
34382                     node.flowNode = currentFlow;
34383                     return bindVariableDeclarationOrBindingElement(node);
34384                 case 163:
34385                 case 162:
34386                     return bindPropertyWorker(node);
34387                 case 288:
34388                 case 289:
34389                     return bindPropertyOrMethodOrAccessor(node, 4, 0);
34390                 case 291:
34391                     return bindPropertyOrMethodOrAccessor(node, 8, 900095);
34392                 case 169:
34393                 case 170:
34394                 case 171:
34395                     return declareSymbolAndAddToSymbolTable(node, 131072, 0);
34396                 case 165:
34397                 case 164:
34398                     return bindPropertyOrMethodOrAccessor(node, 8192 | (node.questionToken ? 16777216 : 0), ts.isObjectLiteralMethod(node) ? 0 : 103359);
34399                 case 251:
34400                     return bindFunctionDeclaration(node);
34401                 case 166:
34402                     return declareSymbolAndAddToSymbolTable(node, 16384, 0);
34403                 case 167:
34404                     return bindPropertyOrMethodOrAccessor(node, 32768, 46015);
34405                 case 168:
34406                     return bindPropertyOrMethodOrAccessor(node, 65536, 78783);
34407                 case 174:
34408                 case 308:
34409                 case 313:
34410                 case 175:
34411                     return bindFunctionOrConstructorType(node);
34412                 case 177:
34413                 case 312:
34414                 case 190:
34415                     return bindAnonymousTypeWorker(node);
34416                 case 319:
34417                     return bindJSDocClassTag(node);
34418                 case 200:
34419                     return bindObjectLiteralExpression(node);
34420                 case 208:
34421                 case 209:
34422                     return bindFunctionExpression(node);
34423                 case 203:
34424                     var assignmentKind = ts.getAssignmentDeclarationKind(node);
34425                     switch (assignmentKind) {
34426                         case 7:
34427                             return bindObjectDefinePropertyAssignment(node);
34428                         case 8:
34429                             return bindObjectDefinePropertyExport(node);
34430                         case 9:
34431                             return bindObjectDefinePrototypeProperty(node);
34432                         case 0:
34433                             break;
34434                         default:
34435                             return ts.Debug.fail("Unknown call expression assignment declaration kind");
34436                     }
34437                     if (ts.isInJSFile(node)) {
34438                         bindCallExpression(node);
34439                     }
34440                     break;
34441                 case 221:
34442                 case 252:
34443                     inStrictMode = true;
34444                     return bindClassLikeDeclaration(node);
34445                 case 253:
34446                     return bindBlockScopedDeclaration(node, 64, 788872);
34447                 case 254:
34448                     return bindBlockScopedDeclaration(node, 524288, 788968);
34449                 case 255:
34450                     return bindEnumDeclaration(node);
34451                 case 256:
34452                     return bindModuleDeclaration(node);
34453                 case 281:
34454                     return bindJsxAttributes(node);
34455                 case 280:
34456                     return bindJsxAttribute(node, 4, 0);
34457                 case 260:
34458                 case 263:
34459                 case 265:
34460                 case 270:
34461                     return declareSymbolAndAddToSymbolTable(node, 2097152, 2097152);
34462                 case 259:
34463                     return bindNamespaceExportDeclaration(node);
34464                 case 262:
34465                     return bindImportClause(node);
34466                 case 267:
34467                     return bindExportDeclaration(node);
34468                 case 266:
34469                     return bindExportAssignment(node);
34470                 case 297:
34471                     updateStrictModeStatementList(node.statements);
34472                     return bindSourceFileIfExternalModule();
34473                 case 230:
34474                     if (!ts.isFunctionLike(node.parent)) {
34475                         return;
34476                     }
34477                 case 257:
34478                     return updateStrictModeStatementList(node.statements);
34479                 case 326:
34480                     if (node.parent.kind === 313) {
34481                         return bindParameter(node);
34482                     }
34483                     if (node.parent.kind !== 312) {
34484                         break;
34485                     }
34486                 case 333:
34487                     var propTag = node;
34488                     var flags = propTag.isBracketed || propTag.typeExpression && propTag.typeExpression.type.kind === 307 ?
34489                         4 | 16777216 :
34490                         4;
34491                     return declareSymbolAndAddToSymbolTable(propTag, flags, 0);
34492                 case 331:
34493                 case 324:
34494                 case 325:
34495                     return (delayedTypeAliases || (delayedTypeAliases = [])).push(node);
34496             }
34497         }
34498         function bindPropertyWorker(node) {
34499             return bindPropertyOrMethodOrAccessor(node, 4 | (node.questionToken ? 16777216 : 0), 0);
34500         }
34501         function bindAnonymousTypeWorker(node) {
34502             return bindAnonymousDeclaration(node, 2048, "__type");
34503         }
34504         function bindSourceFileIfExternalModule() {
34505             setExportContextFlag(file);
34506             if (ts.isExternalModule(file)) {
34507                 bindSourceFileAsExternalModule();
34508             }
34509             else if (ts.isJsonSourceFile(file)) {
34510                 bindSourceFileAsExternalModule();
34511                 var originalSymbol = file.symbol;
34512                 declareSymbol(file.symbol.exports, file.symbol, file, 4, 67108863);
34513                 file.symbol = originalSymbol;
34514             }
34515         }
34516         function bindSourceFileAsExternalModule() {
34517             bindAnonymousDeclaration(file, 512, "\"" + ts.removeFileExtension(file.fileName) + "\"");
34518         }
34519         function bindExportAssignment(node) {
34520             if (!container.symbol || !container.symbol.exports) {
34521                 bindAnonymousDeclaration(node, 2097152, getDeclarationName(node));
34522             }
34523             else {
34524                 var flags = ts.exportAssignmentIsAlias(node)
34525                     ? 2097152
34526                     : 4;
34527                 var symbol = declareSymbol(container.symbol.exports, container.symbol, node, flags, 67108863);
34528                 if (node.isExportEquals) {
34529                     ts.setValueDeclaration(symbol, node);
34530                 }
34531             }
34532         }
34533         function bindNamespaceExportDeclaration(node) {
34534             if (node.modifiers && node.modifiers.length) {
34535                 file.bindDiagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.Modifiers_cannot_appear_here));
34536             }
34537             var diag = !ts.isSourceFile(node.parent) ? ts.Diagnostics.Global_module_exports_may_only_appear_at_top_level
34538                 : !ts.isExternalModule(node.parent) ? ts.Diagnostics.Global_module_exports_may_only_appear_in_module_files
34539                     : !node.parent.isDeclarationFile ? ts.Diagnostics.Global_module_exports_may_only_appear_in_declaration_files
34540                         : undefined;
34541             if (diag) {
34542                 file.bindDiagnostics.push(createDiagnosticForNode(node, diag));
34543             }
34544             else {
34545                 file.symbol.globalExports = file.symbol.globalExports || ts.createSymbolTable();
34546                 declareSymbol(file.symbol.globalExports, file.symbol, node, 2097152, 2097152);
34547             }
34548         }
34549         function bindExportDeclaration(node) {
34550             if (!container.symbol || !container.symbol.exports) {
34551                 bindAnonymousDeclaration(node, 8388608, getDeclarationName(node));
34552             }
34553             else if (!node.exportClause) {
34554                 declareSymbol(container.symbol.exports, container.symbol, node, 8388608, 0);
34555             }
34556             else if (ts.isNamespaceExport(node.exportClause)) {
34557                 ts.setParent(node.exportClause, node);
34558                 declareSymbol(container.symbol.exports, container.symbol, node.exportClause, 2097152, 2097152);
34559             }
34560         }
34561         function bindImportClause(node) {
34562             if (node.name) {
34563                 declareSymbolAndAddToSymbolTable(node, 2097152, 2097152);
34564             }
34565         }
34566         function setCommonJsModuleIndicator(node) {
34567             if (file.externalModuleIndicator) {
34568                 return false;
34569             }
34570             if (!file.commonJsModuleIndicator) {
34571                 file.commonJsModuleIndicator = node;
34572                 bindSourceFileAsExternalModule();
34573             }
34574             return true;
34575         }
34576         function bindObjectDefinePropertyExport(node) {
34577             if (!setCommonJsModuleIndicator(node)) {
34578                 return;
34579             }
34580             var symbol = forEachIdentifierInEntityName(node.arguments[0], undefined, function (id, symbol) {
34581                 if (symbol) {
34582                     addDeclarationToSymbol(symbol, id, 1536 | 67108864);
34583                 }
34584                 return symbol;
34585             });
34586             if (symbol) {
34587                 var flags = 4 | 1048576;
34588                 declareSymbol(symbol.exports, symbol, node, flags, 0);
34589             }
34590         }
34591         function bindExportsPropertyAssignment(node) {
34592             if (!setCommonJsModuleIndicator(node)) {
34593                 return;
34594             }
34595             var symbol = forEachIdentifierInEntityName(node.left.expression, undefined, function (id, symbol) {
34596                 if (symbol) {
34597                     addDeclarationToSymbol(symbol, id, 1536 | 67108864);
34598                 }
34599                 return symbol;
34600             });
34601             if (symbol) {
34602                 var isAlias = ts.isAliasableExpression(node.right) && (ts.isExportsIdentifier(node.left.expression) || ts.isModuleExportsAccessExpression(node.left.expression));
34603                 var flags = isAlias ? 2097152 : 4 | 1048576;
34604                 ts.setParent(node.left, node);
34605                 declareSymbol(symbol.exports, symbol, node.left, flags, 0);
34606             }
34607         }
34608         function bindModuleExportsAssignment(node) {
34609             if (!setCommonJsModuleIndicator(node)) {
34610                 return;
34611             }
34612             var assignedExpression = ts.getRightMostAssignedExpression(node.right);
34613             if (ts.isEmptyObjectLiteral(assignedExpression) || container === file && isExportsOrModuleExportsOrAlias(file, assignedExpression)) {
34614                 return;
34615             }
34616             if (ts.isObjectLiteralExpression(assignedExpression) && ts.every(assignedExpression.properties, ts.isShorthandPropertyAssignment)) {
34617                 ts.forEach(assignedExpression.properties, bindExportAssignedObjectMemberAlias);
34618                 return;
34619             }
34620             var flags = ts.exportAssignmentIsAlias(node)
34621                 ? 2097152
34622                 : 4 | 1048576 | 512;
34623             var symbol = declareSymbol(file.symbol.exports, file.symbol, node, flags | 67108864, 0);
34624             ts.setValueDeclaration(symbol, node);
34625         }
34626         function bindExportAssignedObjectMemberAlias(node) {
34627             declareSymbol(file.symbol.exports, file.symbol, node, 2097152 | 67108864, 0);
34628         }
34629         function bindThisPropertyAssignment(node) {
34630             ts.Debug.assert(ts.isInJSFile(node));
34631             var hasPrivateIdentifier = (ts.isBinaryExpression(node) && ts.isPropertyAccessExpression(node.left) && ts.isPrivateIdentifier(node.left.name))
34632                 || (ts.isPropertyAccessExpression(node) && ts.isPrivateIdentifier(node.name));
34633             if (hasPrivateIdentifier) {
34634                 return;
34635             }
34636             var thisContainer = ts.getThisContainer(node, false);
34637             switch (thisContainer.kind) {
34638                 case 251:
34639                 case 208:
34640                     var constructorSymbol = thisContainer.symbol;
34641                     if (ts.isBinaryExpression(thisContainer.parent) && thisContainer.parent.operatorToken.kind === 62) {
34642                         var l = thisContainer.parent.left;
34643                         if (ts.isBindableStaticAccessExpression(l) && ts.isPrototypeAccess(l.expression)) {
34644                             constructorSymbol = lookupSymbolForPropertyAccess(l.expression.expression, thisParentContainer);
34645                         }
34646                     }
34647                     if (constructorSymbol && constructorSymbol.valueDeclaration) {
34648                         constructorSymbol.members = constructorSymbol.members || ts.createSymbolTable();
34649                         if (ts.hasDynamicName(node)) {
34650                             bindDynamicallyNamedThisPropertyAssignment(node, constructorSymbol);
34651                         }
34652                         else {
34653                             declareSymbol(constructorSymbol.members, constructorSymbol, node, 4 | 67108864, 0 & ~4);
34654                         }
34655                         addDeclarationToSymbol(constructorSymbol, constructorSymbol.valueDeclaration, 32);
34656                     }
34657                     break;
34658                 case 166:
34659                 case 163:
34660                 case 165:
34661                 case 167:
34662                 case 168:
34663                     var containingClass = thisContainer.parent;
34664                     var symbolTable = ts.hasSyntacticModifier(thisContainer, 32) ? containingClass.symbol.exports : containingClass.symbol.members;
34665                     if (ts.hasDynamicName(node)) {
34666                         bindDynamicallyNamedThisPropertyAssignment(node, containingClass.symbol);
34667                     }
34668                     else {
34669                         declareSymbol(symbolTable, containingClass.symbol, node, 4 | 67108864, 0, true);
34670                     }
34671                     break;
34672                 case 297:
34673                     if (ts.hasDynamicName(node)) {
34674                         break;
34675                     }
34676                     else if (thisContainer.commonJsModuleIndicator) {
34677                         declareSymbol(thisContainer.symbol.exports, thisContainer.symbol, node, 4 | 1048576, 0);
34678                     }
34679                     else {
34680                         declareSymbolAndAddToSymbolTable(node, 1, 111550);
34681                     }
34682                     break;
34683                 default:
34684                     ts.Debug.failBadSyntaxKind(thisContainer);
34685             }
34686         }
34687         function bindDynamicallyNamedThisPropertyAssignment(node, symbol) {
34688             bindAnonymousDeclaration(node, 4, "__computed");
34689             addLateBoundAssignmentDeclarationToSymbol(node, symbol);
34690         }
34691         function addLateBoundAssignmentDeclarationToSymbol(node, symbol) {
34692             if (symbol) {
34693                 (symbol.assignmentDeclarationMembers || (symbol.assignmentDeclarationMembers = new ts.Map())).set(ts.getNodeId(node), node);
34694             }
34695         }
34696         function bindSpecialPropertyDeclaration(node) {
34697             if (node.expression.kind === 107) {
34698                 bindThisPropertyAssignment(node);
34699             }
34700             else if (ts.isBindableStaticAccessExpression(node) && node.parent.parent.kind === 297) {
34701                 if (ts.isPrototypeAccess(node.expression)) {
34702                     bindPrototypePropertyAssignment(node, node.parent);
34703                 }
34704                 else {
34705                     bindStaticPropertyAssignment(node);
34706                 }
34707             }
34708         }
34709         function bindPrototypeAssignment(node) {
34710             ts.setParent(node.left, node);
34711             ts.setParent(node.right, node);
34712             bindPropertyAssignment(node.left.expression, node.left, false, true);
34713         }
34714         function bindObjectDefinePrototypeProperty(node) {
34715             var namespaceSymbol = lookupSymbolForPropertyAccess(node.arguments[0].expression);
34716             if (namespaceSymbol && namespaceSymbol.valueDeclaration) {
34717                 addDeclarationToSymbol(namespaceSymbol, namespaceSymbol.valueDeclaration, 32);
34718             }
34719             bindPotentiallyNewExpandoMemberToNamespace(node, namespaceSymbol, true);
34720         }
34721         function bindPrototypePropertyAssignment(lhs, parent) {
34722             var classPrototype = lhs.expression;
34723             var constructorFunction = classPrototype.expression;
34724             ts.setParent(constructorFunction, classPrototype);
34725             ts.setParent(classPrototype, lhs);
34726             ts.setParent(lhs, parent);
34727             bindPropertyAssignment(constructorFunction, lhs, true, true);
34728         }
34729         function bindObjectDefinePropertyAssignment(node) {
34730             var namespaceSymbol = lookupSymbolForPropertyAccess(node.arguments[0]);
34731             var isToplevel = node.parent.parent.kind === 297;
34732             namespaceSymbol = bindPotentiallyMissingNamespaces(namespaceSymbol, node.arguments[0], isToplevel, false, false);
34733             bindPotentiallyNewExpandoMemberToNamespace(node, namespaceSymbol, false);
34734         }
34735         function bindSpecialPropertyAssignment(node) {
34736             var _a;
34737             var parentSymbol = lookupSymbolForPropertyAccess(node.left.expression, container) || lookupSymbolForPropertyAccess(node.left.expression, blockScopeContainer);
34738             if (!ts.isInJSFile(node) && !ts.isFunctionSymbol(parentSymbol)) {
34739                 return;
34740             }
34741             var rootExpr = ts.getLeftmostAccessExpression(node.left);
34742             if (ts.isIdentifier(rootExpr) && ((_a = lookupSymbolForName(container, rootExpr.escapedText)) === null || _a === void 0 ? void 0 : _a.flags) & 2097152) {
34743                 return;
34744             }
34745             ts.setParent(node.left, node);
34746             ts.setParent(node.right, node);
34747             if (ts.isIdentifier(node.left.expression) && container === file && isExportsOrModuleExportsOrAlias(file, node.left.expression)) {
34748                 bindExportsPropertyAssignment(node);
34749             }
34750             else if (ts.hasDynamicName(node)) {
34751                 bindAnonymousDeclaration(node, 4 | 67108864, "__computed");
34752                 var sym = bindPotentiallyMissingNamespaces(parentSymbol, node.left.expression, isTopLevelNamespaceAssignment(node.left), false, false);
34753                 addLateBoundAssignmentDeclarationToSymbol(node, sym);
34754             }
34755             else {
34756                 bindStaticPropertyAssignment(ts.cast(node.left, ts.isBindableStaticNameExpression));
34757             }
34758         }
34759         function bindStaticPropertyAssignment(node) {
34760             ts.Debug.assert(!ts.isIdentifier(node));
34761             ts.setParent(node.expression, node);
34762             bindPropertyAssignment(node.expression, node, false, false);
34763         }
34764         function bindPotentiallyMissingNamespaces(namespaceSymbol, entityName, isToplevel, isPrototypeProperty, containerIsClass) {
34765             if ((namespaceSymbol === null || namespaceSymbol === void 0 ? void 0 : namespaceSymbol.flags) & 2097152) {
34766                 return namespaceSymbol;
34767             }
34768             if (isToplevel && !isPrototypeProperty) {
34769                 var flags_2 = 1536 | 67108864;
34770                 var excludeFlags_1 = 110735 & ~67108864;
34771                 namespaceSymbol = forEachIdentifierInEntityName(entityName, namespaceSymbol, function (id, symbol, parent) {
34772                     if (symbol) {
34773                         addDeclarationToSymbol(symbol, id, flags_2);
34774                         return symbol;
34775                     }
34776                     else {
34777                         var table = parent ? parent.exports :
34778                             file.jsGlobalAugmentations || (file.jsGlobalAugmentations = ts.createSymbolTable());
34779                         return declareSymbol(table, parent, id, flags_2, excludeFlags_1);
34780                     }
34781                 });
34782             }
34783             if (containerIsClass && namespaceSymbol && namespaceSymbol.valueDeclaration) {
34784                 addDeclarationToSymbol(namespaceSymbol, namespaceSymbol.valueDeclaration, 32);
34785             }
34786             return namespaceSymbol;
34787         }
34788         function bindPotentiallyNewExpandoMemberToNamespace(declaration, namespaceSymbol, isPrototypeProperty) {
34789             if (!namespaceSymbol || !isExpandoSymbol(namespaceSymbol)) {
34790                 return;
34791             }
34792             var symbolTable = isPrototypeProperty ?
34793                 (namespaceSymbol.members || (namespaceSymbol.members = ts.createSymbolTable())) :
34794                 (namespaceSymbol.exports || (namespaceSymbol.exports = ts.createSymbolTable()));
34795             var includes = 0;
34796             var excludes = 0;
34797             if (ts.isFunctionLikeDeclaration(ts.getAssignedExpandoInitializer(declaration))) {
34798                 includes = 8192;
34799                 excludes = 103359;
34800             }
34801             else if (ts.isCallExpression(declaration) && ts.isBindableObjectDefinePropertyCall(declaration)) {
34802                 if (ts.some(declaration.arguments[2].properties, function (p) {
34803                     var id = ts.getNameOfDeclaration(p);
34804                     return !!id && ts.isIdentifier(id) && ts.idText(id) === "set";
34805                 })) {
34806                     includes |= 65536 | 4;
34807                     excludes |= 78783;
34808                 }
34809                 if (ts.some(declaration.arguments[2].properties, function (p) {
34810                     var id = ts.getNameOfDeclaration(p);
34811                     return !!id && ts.isIdentifier(id) && ts.idText(id) === "get";
34812                 })) {
34813                     includes |= 32768 | 4;
34814                     excludes |= 46015;
34815                 }
34816             }
34817             if (includes === 0) {
34818                 includes = 4;
34819                 excludes = 0;
34820             }
34821             declareSymbol(symbolTable, namespaceSymbol, declaration, includes | 67108864, excludes & ~67108864);
34822         }
34823         function isTopLevelNamespaceAssignment(propertyAccess) {
34824             return ts.isBinaryExpression(propertyAccess.parent)
34825                 ? getParentOfBinaryExpression(propertyAccess.parent).parent.kind === 297
34826                 : propertyAccess.parent.parent.kind === 297;
34827         }
34828         function bindPropertyAssignment(name, propertyAccess, isPrototypeProperty, containerIsClass) {
34829             var namespaceSymbol = lookupSymbolForPropertyAccess(name, container) || lookupSymbolForPropertyAccess(name, blockScopeContainer);
34830             var isToplevel = isTopLevelNamespaceAssignment(propertyAccess);
34831             namespaceSymbol = bindPotentiallyMissingNamespaces(namespaceSymbol, propertyAccess.expression, isToplevel, isPrototypeProperty, containerIsClass);
34832             bindPotentiallyNewExpandoMemberToNamespace(propertyAccess, namespaceSymbol, isPrototypeProperty);
34833         }
34834         function isExpandoSymbol(symbol) {
34835             if (symbol.flags & (16 | 32 | 1024)) {
34836                 return true;
34837             }
34838             var node = symbol.valueDeclaration;
34839             if (node && ts.isCallExpression(node)) {
34840                 return !!ts.getAssignedExpandoInitializer(node);
34841             }
34842             var init = !node ? undefined :
34843                 ts.isVariableDeclaration(node) ? node.initializer :
34844                     ts.isBinaryExpression(node) ? node.right :
34845                         ts.isPropertyAccessExpression(node) && ts.isBinaryExpression(node.parent) ? node.parent.right :
34846                             undefined;
34847             init = init && ts.getRightMostAssignedExpression(init);
34848             if (init) {
34849                 var isPrototypeAssignment = ts.isPrototypeAccess(ts.isVariableDeclaration(node) ? node.name : ts.isBinaryExpression(node) ? node.left : node);
34850                 return !!ts.getExpandoInitializer(ts.isBinaryExpression(init) && (init.operatorToken.kind === 56 || init.operatorToken.kind === 60) ? init.right : init, isPrototypeAssignment);
34851             }
34852             return false;
34853         }
34854         function getParentOfBinaryExpression(expr) {
34855             while (ts.isBinaryExpression(expr.parent)) {
34856                 expr = expr.parent;
34857             }
34858             return expr.parent;
34859         }
34860         function lookupSymbolForPropertyAccess(node, lookupContainer) {
34861             if (lookupContainer === void 0) { lookupContainer = container; }
34862             if (ts.isIdentifier(node)) {
34863                 return lookupSymbolForName(lookupContainer, node.escapedText);
34864             }
34865             else {
34866                 var symbol = lookupSymbolForPropertyAccess(node.expression);
34867                 return symbol && symbol.exports && symbol.exports.get(ts.getElementOrPropertyAccessName(node));
34868             }
34869         }
34870         function forEachIdentifierInEntityName(e, parent, action) {
34871             if (isExportsOrModuleExportsOrAlias(file, e)) {
34872                 return file.symbol;
34873             }
34874             else if (ts.isIdentifier(e)) {
34875                 return action(e, lookupSymbolForPropertyAccess(e), parent);
34876             }
34877             else {
34878                 var s = forEachIdentifierInEntityName(e.expression, parent, action);
34879                 var name = ts.getNameOrArgument(e);
34880                 if (ts.isPrivateIdentifier(name)) {
34881                     ts.Debug.fail("unexpected PrivateIdentifier");
34882                 }
34883                 return action(name, s && s.exports && s.exports.get(ts.getElementOrPropertyAccessName(e)), s);
34884             }
34885         }
34886         function bindCallExpression(node) {
34887             if (!file.commonJsModuleIndicator && ts.isRequireCall(node, false)) {
34888                 setCommonJsModuleIndicator(node);
34889             }
34890         }
34891         function bindClassLikeDeclaration(node) {
34892             if (node.kind === 252) {
34893                 bindBlockScopedDeclaration(node, 32, 899503);
34894             }
34895             else {
34896                 var bindingName = node.name ? node.name.escapedText : "__class";
34897                 bindAnonymousDeclaration(node, 32, bindingName);
34898                 if (node.name) {
34899                     classifiableNames.add(node.name.escapedText);
34900                 }
34901             }
34902             var symbol = node.symbol;
34903             var prototypeSymbol = createSymbol(4 | 4194304, "prototype");
34904             var symbolExport = symbol.exports.get(prototypeSymbol.escapedName);
34905             if (symbolExport) {
34906                 if (node.name) {
34907                     ts.setParent(node.name, node);
34908                 }
34909                 file.bindDiagnostics.push(createDiagnosticForNode(symbolExport.declarations[0], ts.Diagnostics.Duplicate_identifier_0, ts.symbolName(prototypeSymbol)));
34910             }
34911             symbol.exports.set(prototypeSymbol.escapedName, prototypeSymbol);
34912             prototypeSymbol.parent = symbol;
34913         }
34914         function bindEnumDeclaration(node) {
34915             return ts.isEnumConst(node)
34916                 ? bindBlockScopedDeclaration(node, 128, 899967)
34917                 : bindBlockScopedDeclaration(node, 256, 899327);
34918         }
34919         function bindVariableDeclarationOrBindingElement(node) {
34920             if (inStrictMode) {
34921                 checkStrictModeEvalOrArguments(node, node.name);
34922             }
34923             if (!ts.isBindingPattern(node.name)) {
34924                 if (ts.isInJSFile(node) && ts.isRequireVariableDeclaration(node, true) && !ts.getJSDocTypeTag(node)) {
34925                     declareSymbolAndAddToSymbolTable(node, 2097152, 2097152);
34926                 }
34927                 else if (ts.isBlockOrCatchScoped(node)) {
34928                     bindBlockScopedDeclaration(node, 2, 111551);
34929                 }
34930                 else if (ts.isParameterDeclaration(node)) {
34931                     declareSymbolAndAddToSymbolTable(node, 1, 111551);
34932                 }
34933                 else {
34934                     declareSymbolAndAddToSymbolTable(node, 1, 111550);
34935                 }
34936             }
34937         }
34938         function bindParameter(node) {
34939             if (node.kind === 326 && container.kind !== 313) {
34940                 return;
34941             }
34942             if (inStrictMode && !(node.flags & 8388608)) {
34943                 checkStrictModeEvalOrArguments(node, node.name);
34944             }
34945             if (ts.isBindingPattern(node.name)) {
34946                 bindAnonymousDeclaration(node, 1, "__" + node.parent.parameters.indexOf(node));
34947             }
34948             else {
34949                 declareSymbolAndAddToSymbolTable(node, 1, 111551);
34950             }
34951             if (ts.isParameterPropertyDeclaration(node, node.parent)) {
34952                 var classDeclaration = node.parent.parent;
34953                 declareSymbol(classDeclaration.symbol.members, classDeclaration.symbol, node, 4 | (node.questionToken ? 16777216 : 0), 0);
34954             }
34955         }
34956         function bindFunctionDeclaration(node) {
34957             if (!file.isDeclarationFile && !(node.flags & 8388608)) {
34958                 if (ts.isAsyncFunction(node)) {
34959                     emitFlags |= 2048;
34960                 }
34961             }
34962             checkStrictModeFunctionName(node);
34963             if (inStrictMode) {
34964                 checkStrictModeFunctionDeclaration(node);
34965                 bindBlockScopedDeclaration(node, 16, 110991);
34966             }
34967             else {
34968                 declareSymbolAndAddToSymbolTable(node, 16, 110991);
34969             }
34970         }
34971         function bindFunctionExpression(node) {
34972             if (!file.isDeclarationFile && !(node.flags & 8388608)) {
34973                 if (ts.isAsyncFunction(node)) {
34974                     emitFlags |= 2048;
34975                 }
34976             }
34977             if (currentFlow) {
34978                 node.flowNode = currentFlow;
34979             }
34980             checkStrictModeFunctionName(node);
34981             var bindingName = node.name ? node.name.escapedText : "__function";
34982             return bindAnonymousDeclaration(node, 16, bindingName);
34983         }
34984         function bindPropertyOrMethodOrAccessor(node, symbolFlags, symbolExcludes) {
34985             if (!file.isDeclarationFile && !(node.flags & 8388608) && ts.isAsyncFunction(node)) {
34986                 emitFlags |= 2048;
34987             }
34988             if (currentFlow && ts.isObjectLiteralOrClassExpressionMethod(node)) {
34989                 node.flowNode = currentFlow;
34990             }
34991             return ts.hasDynamicName(node)
34992                 ? bindAnonymousDeclaration(node, symbolFlags, "__computed")
34993                 : declareSymbolAndAddToSymbolTable(node, symbolFlags, symbolExcludes);
34994         }
34995         function getInferTypeContainer(node) {
34996             var extendsType = ts.findAncestor(node, function (n) { return n.parent && ts.isConditionalTypeNode(n.parent) && n.parent.extendsType === n; });
34997             return extendsType && extendsType.parent;
34998         }
34999         function bindTypeParameter(node) {
35000             if (ts.isJSDocTemplateTag(node.parent)) {
35001                 var container_1 = ts.find(node.parent.parent.tags, ts.isJSDocTypeAlias) || ts.getHostSignatureFromJSDoc(node.parent);
35002                 if (container_1) {
35003                     if (!container_1.locals) {
35004                         container_1.locals = ts.createSymbolTable();
35005                     }
35006                     declareSymbol(container_1.locals, undefined, node, 262144, 526824);
35007                 }
35008                 else {
35009                     declareSymbolAndAddToSymbolTable(node, 262144, 526824);
35010                 }
35011             }
35012             else if (node.parent.kind === 185) {
35013                 var container_2 = getInferTypeContainer(node.parent);
35014                 if (container_2) {
35015                     if (!container_2.locals) {
35016                         container_2.locals = ts.createSymbolTable();
35017                     }
35018                     declareSymbol(container_2.locals, undefined, node, 262144, 526824);
35019                 }
35020                 else {
35021                     bindAnonymousDeclaration(node, 262144, getDeclarationName(node));
35022                 }
35023             }
35024             else {
35025                 declareSymbolAndAddToSymbolTable(node, 262144, 526824);
35026             }
35027         }
35028         function shouldReportErrorOnModuleDeclaration(node) {
35029             var instanceState = getModuleInstanceState(node);
35030             return instanceState === 1 || (instanceState === 2 && !!options.preserveConstEnums);
35031         }
35032         function checkUnreachable(node) {
35033             if (!(currentFlow.flags & 1)) {
35034                 return false;
35035             }
35036             if (currentFlow === unreachableFlow) {
35037                 var reportError = (ts.isStatementButNotDeclaration(node) && node.kind !== 231) ||
35038                     node.kind === 252 ||
35039                     (node.kind === 256 && shouldReportErrorOnModuleDeclaration(node));
35040                 if (reportError) {
35041                     currentFlow = reportedUnreachableFlow;
35042                     if (!options.allowUnreachableCode) {
35043                         var isError_1 = ts.unreachableCodeIsError(options) &&
35044                             !(node.flags & 8388608) &&
35045                             (!ts.isVariableStatement(node) ||
35046                                 !!(ts.getCombinedNodeFlags(node.declarationList) & 3) ||
35047                                 node.declarationList.declarations.some(function (d) { return !!d.initializer; }));
35048                         eachUnreachableRange(node, function (start, end) { return errorOrSuggestionOnRange(isError_1, start, end, ts.Diagnostics.Unreachable_code_detected); });
35049                     }
35050                 }
35051             }
35052             return true;
35053         }
35054     }
35055     function eachUnreachableRange(node, cb) {
35056         if (ts.isStatement(node) && isExecutableStatement(node) && ts.isBlock(node.parent)) {
35057             var statements = node.parent.statements;
35058             var slice_1 = ts.sliceAfter(statements, node);
35059             ts.getRangesWhere(slice_1, isExecutableStatement, function (start, afterEnd) { return cb(slice_1[start], slice_1[afterEnd - 1]); });
35060         }
35061         else {
35062             cb(node, node);
35063         }
35064     }
35065     function isExecutableStatement(s) {
35066         return !ts.isFunctionDeclaration(s) && !isPurelyTypeDeclaration(s) && !ts.isEnumDeclaration(s) &&
35067             !(ts.isVariableStatement(s) && !(ts.getCombinedNodeFlags(s) & (1 | 2)) && s.declarationList.declarations.some(function (d) { return !d.initializer; }));
35068     }
35069     function isPurelyTypeDeclaration(s) {
35070         switch (s.kind) {
35071             case 253:
35072             case 254:
35073                 return true;
35074             case 256:
35075                 return getModuleInstanceState(s) !== 1;
35076             case 255:
35077                 return ts.hasSyntacticModifier(s, 2048);
35078             default:
35079                 return false;
35080         }
35081     }
35082     function isExportsOrModuleExportsOrAlias(sourceFile, node) {
35083         var i = 0;
35084         var q = [node];
35085         while (q.length && i < 100) {
35086             i++;
35087             node = q.shift();
35088             if (ts.isExportsIdentifier(node) || ts.isModuleExportsAccessExpression(node)) {
35089                 return true;
35090             }
35091             else if (ts.isIdentifier(node)) {
35092                 var symbol = lookupSymbolForName(sourceFile, node.escapedText);
35093                 if (!!symbol && !!symbol.valueDeclaration && ts.isVariableDeclaration(symbol.valueDeclaration) && !!symbol.valueDeclaration.initializer) {
35094                     var init = symbol.valueDeclaration.initializer;
35095                     q.push(init);
35096                     if (ts.isAssignmentExpression(init, true)) {
35097                         q.push(init.left);
35098                         q.push(init.right);
35099                     }
35100                 }
35101             }
35102         }
35103         return false;
35104     }
35105     ts.isExportsOrModuleExportsOrAlias = isExportsOrModuleExportsOrAlias;
35106     function lookupSymbolForName(container, name) {
35107         var local = container.locals && container.locals.get(name);
35108         if (local) {
35109             return local.exportSymbol || local;
35110         }
35111         if (ts.isSourceFile(container) && container.jsGlobalAugmentations && container.jsGlobalAugmentations.has(name)) {
35112             return container.jsGlobalAugmentations.get(name);
35113         }
35114         return container.symbol && container.symbol.exports && container.symbol.exports.get(name);
35115     }
35116 })(ts || (ts = {}));
35117 var ts;
35118 (function (ts) {
35119     function createGetSymbolWalker(getRestTypeOfSignature, getTypePredicateOfSignature, getReturnTypeOfSignature, getBaseTypes, resolveStructuredTypeMembers, getTypeOfSymbol, getResolvedSymbol, getIndexTypeOfStructuredType, getConstraintOfTypeParameter, getFirstIdentifier, getTypeArguments) {
35120         return getSymbolWalker;
35121         function getSymbolWalker(accept) {
35122             if (accept === void 0) { accept = function () { return true; }; }
35123             var visitedTypes = [];
35124             var visitedSymbols = [];
35125             return {
35126                 walkType: function (type) {
35127                     try {
35128                         visitType(type);
35129                         return { visitedTypes: ts.getOwnValues(visitedTypes), visitedSymbols: ts.getOwnValues(visitedSymbols) };
35130                     }
35131                     finally {
35132                         ts.clear(visitedTypes);
35133                         ts.clear(visitedSymbols);
35134                     }
35135                 },
35136                 walkSymbol: function (symbol) {
35137                     try {
35138                         visitSymbol(symbol);
35139                         return { visitedTypes: ts.getOwnValues(visitedTypes), visitedSymbols: ts.getOwnValues(visitedSymbols) };
35140                     }
35141                     finally {
35142                         ts.clear(visitedTypes);
35143                         ts.clear(visitedSymbols);
35144                     }
35145                 },
35146             };
35147             function visitType(type) {
35148                 if (!type) {
35149                     return;
35150                 }
35151                 if (visitedTypes[type.id]) {
35152                     return;
35153                 }
35154                 visitedTypes[type.id] = type;
35155                 var shouldBail = visitSymbol(type.symbol);
35156                 if (shouldBail)
35157                     return;
35158                 if (type.flags & 524288) {
35159                     var objectType = type;
35160                     var objectFlags = objectType.objectFlags;
35161                     if (objectFlags & 4) {
35162                         visitTypeReference(type);
35163                     }
35164                     if (objectFlags & 32) {
35165                         visitMappedType(type);
35166                     }
35167                     if (objectFlags & (1 | 2)) {
35168                         visitInterfaceType(type);
35169                     }
35170                     if (objectFlags & (8 | 16)) {
35171                         visitObjectType(objectType);
35172                     }
35173                 }
35174                 if (type.flags & 262144) {
35175                     visitTypeParameter(type);
35176                 }
35177                 if (type.flags & 3145728) {
35178                     visitUnionOrIntersectionType(type);
35179                 }
35180                 if (type.flags & 4194304) {
35181                     visitIndexType(type);
35182                 }
35183                 if (type.flags & 8388608) {
35184                     visitIndexedAccessType(type);
35185                 }
35186             }
35187             function visitTypeReference(type) {
35188                 visitType(type.target);
35189                 ts.forEach(getTypeArguments(type), visitType);
35190             }
35191             function visitTypeParameter(type) {
35192                 visitType(getConstraintOfTypeParameter(type));
35193             }
35194             function visitUnionOrIntersectionType(type) {
35195                 ts.forEach(type.types, visitType);
35196             }
35197             function visitIndexType(type) {
35198                 visitType(type.type);
35199             }
35200             function visitIndexedAccessType(type) {
35201                 visitType(type.objectType);
35202                 visitType(type.indexType);
35203                 visitType(type.constraint);
35204             }
35205             function visitMappedType(type) {
35206                 visitType(type.typeParameter);
35207                 visitType(type.constraintType);
35208                 visitType(type.templateType);
35209                 visitType(type.modifiersType);
35210             }
35211             function visitSignature(signature) {
35212                 var typePredicate = getTypePredicateOfSignature(signature);
35213                 if (typePredicate) {
35214                     visitType(typePredicate.type);
35215                 }
35216                 ts.forEach(signature.typeParameters, visitType);
35217                 for (var _i = 0, _a = signature.parameters; _i < _a.length; _i++) {
35218                     var parameter = _a[_i];
35219                     visitSymbol(parameter);
35220                 }
35221                 visitType(getRestTypeOfSignature(signature));
35222                 visitType(getReturnTypeOfSignature(signature));
35223             }
35224             function visitInterfaceType(interfaceT) {
35225                 visitObjectType(interfaceT);
35226                 ts.forEach(interfaceT.typeParameters, visitType);
35227                 ts.forEach(getBaseTypes(interfaceT), visitType);
35228                 visitType(interfaceT.thisType);
35229             }
35230             function visitObjectType(type) {
35231                 var stringIndexType = getIndexTypeOfStructuredType(type, 0);
35232                 visitType(stringIndexType);
35233                 var numberIndexType = getIndexTypeOfStructuredType(type, 1);
35234                 visitType(numberIndexType);
35235                 var resolved = resolveStructuredTypeMembers(type);
35236                 for (var _i = 0, _a = resolved.callSignatures; _i < _a.length; _i++) {
35237                     var signature = _a[_i];
35238                     visitSignature(signature);
35239                 }
35240                 for (var _b = 0, _c = resolved.constructSignatures; _b < _c.length; _b++) {
35241                     var signature = _c[_b];
35242                     visitSignature(signature);
35243                 }
35244                 for (var _d = 0, _e = resolved.properties; _d < _e.length; _d++) {
35245                     var p = _e[_d];
35246                     visitSymbol(p);
35247                 }
35248             }
35249             function visitSymbol(symbol) {
35250                 if (!symbol) {
35251                     return false;
35252                 }
35253                 var symbolId = ts.getSymbolId(symbol);
35254                 if (visitedSymbols[symbolId]) {
35255                     return false;
35256                 }
35257                 visitedSymbols[symbolId] = symbol;
35258                 if (!accept(symbol)) {
35259                     return true;
35260                 }
35261                 var t = getTypeOfSymbol(symbol);
35262                 visitType(t);
35263                 if (symbol.exports) {
35264                     symbol.exports.forEach(visitSymbol);
35265                 }
35266                 ts.forEach(symbol.declarations, function (d) {
35267                     if (d.type && d.type.kind === 176) {
35268                         var query = d.type;
35269                         var entity = getResolvedSymbol(getFirstIdentifier(query.exprName));
35270                         visitSymbol(entity);
35271                     }
35272                 });
35273                 return false;
35274             }
35275         }
35276     }
35277     ts.createGetSymbolWalker = createGetSymbolWalker;
35278 })(ts || (ts = {}));
35279 var ts;
35280 (function (ts) {
35281     var ambientModuleSymbolRegex = /^".+"$/;
35282     var anon = "(anonymous)";
35283     var nextSymbolId = 1;
35284     var nextNodeId = 1;
35285     var nextMergeId = 1;
35286     var nextFlowId = 1;
35287     var typeofEQFacts = new ts.Map(ts.getEntries({
35288         string: 1,
35289         number: 2,
35290         bigint: 4,
35291         boolean: 8,
35292         symbol: 16,
35293         undefined: 65536,
35294         object: 32,
35295         function: 64
35296     }));
35297     var typeofNEFacts = new ts.Map(ts.getEntries({
35298         string: 256,
35299         number: 512,
35300         bigint: 1024,
35301         boolean: 2048,
35302         symbol: 4096,
35303         undefined: 524288,
35304         object: 8192,
35305         function: 16384
35306     }));
35307     var isNotOverloadAndNotAccessor = ts.and(isNotOverload, isNotAccessor);
35308     var intrinsicTypeKinds = new ts.Map(ts.getEntries({
35309         Uppercase: 0,
35310         Lowercase: 1,
35311         Capitalize: 2,
35312         Uncapitalize: 3
35313     }));
35314     function SymbolLinks() {
35315     }
35316     function NodeLinks() {
35317         this.flags = 0;
35318     }
35319     function getNodeId(node) {
35320         if (!node.id) {
35321             node.id = nextNodeId;
35322             nextNodeId++;
35323         }
35324         return node.id;
35325     }
35326     ts.getNodeId = getNodeId;
35327     function getSymbolId(symbol) {
35328         if (!symbol.id) {
35329             symbol.id = nextSymbolId;
35330             nextSymbolId++;
35331         }
35332         return symbol.id;
35333     }
35334     ts.getSymbolId = getSymbolId;
35335     function isInstantiatedModule(node, preserveConstEnums) {
35336         var moduleState = ts.getModuleInstanceState(node);
35337         return moduleState === 1 ||
35338             (preserveConstEnums && moduleState === 2);
35339     }
35340     ts.isInstantiatedModule = isInstantiatedModule;
35341     function createTypeChecker(host, produceDiagnostics) {
35342         var getPackagesSet = ts.memoize(function () {
35343             var set = new ts.Set();
35344             host.getSourceFiles().forEach(function (sf) {
35345                 if (!sf.resolvedModules)
35346                     return;
35347                 ts.forEachEntry(sf.resolvedModules, function (r) {
35348                     if (r && r.packageId)
35349                         set.add(r.packageId.name);
35350                 });
35351             });
35352             return set;
35353         });
35354         var cancellationToken;
35355         var requestedExternalEmitHelpers;
35356         var externalHelpersModule;
35357         var Symbol = ts.objectAllocator.getSymbolConstructor();
35358         var Type = ts.objectAllocator.getTypeConstructor();
35359         var Signature = ts.objectAllocator.getSignatureConstructor();
35360         var typeCount = 0;
35361         var symbolCount = 0;
35362         var enumCount = 0;
35363         var totalInstantiationCount = 0;
35364         var instantiationCount = 0;
35365         var instantiationDepth = 0;
35366         var constraintDepth = 0;
35367         var currentNode;
35368         var typeCatalog = [];
35369         var emptySymbols = ts.createSymbolTable();
35370         var arrayVariances = [1];
35371         var compilerOptions = host.getCompilerOptions();
35372         var languageVersion = ts.getEmitScriptTarget(compilerOptions);
35373         var moduleKind = ts.getEmitModuleKind(compilerOptions);
35374         var allowSyntheticDefaultImports = ts.getAllowSyntheticDefaultImports(compilerOptions);
35375         var strictNullChecks = ts.getStrictOptionValue(compilerOptions, "strictNullChecks");
35376         var strictFunctionTypes = ts.getStrictOptionValue(compilerOptions, "strictFunctionTypes");
35377         var strictBindCallApply = ts.getStrictOptionValue(compilerOptions, "strictBindCallApply");
35378         var strictPropertyInitialization = ts.getStrictOptionValue(compilerOptions, "strictPropertyInitialization");
35379         var noImplicitAny = ts.getStrictOptionValue(compilerOptions, "noImplicitAny");
35380         var noImplicitThis = ts.getStrictOptionValue(compilerOptions, "noImplicitThis");
35381         var keyofStringsOnly = !!compilerOptions.keyofStringsOnly;
35382         var freshObjectLiteralFlag = compilerOptions.suppressExcessPropertyErrors ? 0 : 32768;
35383         var emitResolver = createResolver();
35384         var nodeBuilder = createNodeBuilder();
35385         var globals = ts.createSymbolTable();
35386         var undefinedSymbol = createSymbol(4, "undefined");
35387         undefinedSymbol.declarations = [];
35388         var globalThisSymbol = createSymbol(1536, "globalThis", 8);
35389         globalThisSymbol.exports = globals;
35390         globalThisSymbol.declarations = [];
35391         globals.set(globalThisSymbol.escapedName, globalThisSymbol);
35392         var argumentsSymbol = createSymbol(4, "arguments");
35393         var requireSymbol = createSymbol(4, "require");
35394         var apparentArgumentCount;
35395         var checker = {
35396             getNodeCount: function () { return ts.sum(host.getSourceFiles(), "nodeCount"); },
35397             getIdentifierCount: function () { return ts.sum(host.getSourceFiles(), "identifierCount"); },
35398             getSymbolCount: function () { return ts.sum(host.getSourceFiles(), "symbolCount") + symbolCount; },
35399             getTypeCatalog: function () { return typeCatalog; },
35400             getTypeCount: function () { return typeCount; },
35401             getInstantiationCount: function () { return totalInstantiationCount; },
35402             getRelationCacheSizes: function () { return ({
35403                 assignable: assignableRelation.size,
35404                 identity: identityRelation.size,
35405                 subtype: subtypeRelation.size,
35406                 strictSubtype: strictSubtypeRelation.size,
35407             }); },
35408             isUndefinedSymbol: function (symbol) { return symbol === undefinedSymbol; },
35409             isArgumentsSymbol: function (symbol) { return symbol === argumentsSymbol; },
35410             isUnknownSymbol: function (symbol) { return symbol === unknownSymbol; },
35411             getMergedSymbol: getMergedSymbol,
35412             getDiagnostics: getDiagnostics,
35413             getGlobalDiagnostics: getGlobalDiagnostics,
35414             getRecursionIdentity: getRecursionIdentity,
35415             getTypeOfSymbolAtLocation: function (symbol, locationIn) {
35416                 var location = ts.getParseTreeNode(locationIn);
35417                 return location ? getTypeOfSymbolAtLocation(symbol, location) : errorType;
35418             },
35419             getSymbolsOfParameterPropertyDeclaration: function (parameterIn, parameterName) {
35420                 var parameter = ts.getParseTreeNode(parameterIn, ts.isParameter);
35421                 if (parameter === undefined)
35422                     return ts.Debug.fail("Cannot get symbols of a synthetic parameter that cannot be resolved to a parse-tree node.");
35423                 return getSymbolsOfParameterPropertyDeclaration(parameter, ts.escapeLeadingUnderscores(parameterName));
35424             },
35425             getDeclaredTypeOfSymbol: getDeclaredTypeOfSymbol,
35426             getPropertiesOfType: getPropertiesOfType,
35427             getPropertyOfType: function (type, name) { return getPropertyOfType(type, ts.escapeLeadingUnderscores(name)); },
35428             getPrivateIdentifierPropertyOfType: function (leftType, name, location) {
35429                 var node = ts.getParseTreeNode(location);
35430                 if (!node) {
35431                     return undefined;
35432                 }
35433                 var propName = ts.escapeLeadingUnderscores(name);
35434                 var lexicallyScopedIdentifier = lookupSymbolForPrivateIdentifierDeclaration(propName, node);
35435                 return lexicallyScopedIdentifier ? getPrivateIdentifierPropertyOfType(leftType, lexicallyScopedIdentifier) : undefined;
35436             },
35437             getTypeOfPropertyOfType: function (type, name) { return getTypeOfPropertyOfType(type, ts.escapeLeadingUnderscores(name)); },
35438             getIndexInfoOfType: getIndexInfoOfType,
35439             getSignaturesOfType: getSignaturesOfType,
35440             getIndexTypeOfType: getIndexTypeOfType,
35441             getBaseTypes: getBaseTypes,
35442             getBaseTypeOfLiteralType: getBaseTypeOfLiteralType,
35443             getWidenedType: getWidenedType,
35444             getTypeFromTypeNode: function (nodeIn) {
35445                 var node = ts.getParseTreeNode(nodeIn, ts.isTypeNode);
35446                 return node ? getTypeFromTypeNode(node) : errorType;
35447             },
35448             getParameterType: getTypeAtPosition,
35449             getPromisedTypeOfPromise: getPromisedTypeOfPromise,
35450             getAwaitedType: function (type) { return getAwaitedType(type); },
35451             getReturnTypeOfSignature: getReturnTypeOfSignature,
35452             isNullableType: isNullableType,
35453             getNullableType: getNullableType,
35454             getNonNullableType: getNonNullableType,
35455             getNonOptionalType: removeOptionalTypeMarker,
35456             getTypeArguments: getTypeArguments,
35457             typeToTypeNode: nodeBuilder.typeToTypeNode,
35458             indexInfoToIndexSignatureDeclaration: nodeBuilder.indexInfoToIndexSignatureDeclaration,
35459             signatureToSignatureDeclaration: nodeBuilder.signatureToSignatureDeclaration,
35460             symbolToEntityName: nodeBuilder.symbolToEntityName,
35461             symbolToExpression: nodeBuilder.symbolToExpression,
35462             symbolToTypeParameterDeclarations: nodeBuilder.symbolToTypeParameterDeclarations,
35463             symbolToParameterDeclaration: nodeBuilder.symbolToParameterDeclaration,
35464             typeParameterToDeclaration: nodeBuilder.typeParameterToDeclaration,
35465             getSymbolsInScope: function (locationIn, meaning) {
35466                 var location = ts.getParseTreeNode(locationIn);
35467                 return location ? getSymbolsInScope(location, meaning) : [];
35468             },
35469             getSymbolAtLocation: function (nodeIn) {
35470                 var node = ts.getParseTreeNode(nodeIn);
35471                 return node ? getSymbolAtLocation(node, true) : undefined;
35472             },
35473             getShorthandAssignmentValueSymbol: function (nodeIn) {
35474                 var node = ts.getParseTreeNode(nodeIn);
35475                 return node ? getShorthandAssignmentValueSymbol(node) : undefined;
35476             },
35477             getExportSpecifierLocalTargetSymbol: function (nodeIn) {
35478                 var node = ts.getParseTreeNode(nodeIn, ts.isExportSpecifier);
35479                 return node ? getExportSpecifierLocalTargetSymbol(node) : undefined;
35480             },
35481             getExportSymbolOfSymbol: function (symbol) {
35482                 return getMergedSymbol(symbol.exportSymbol || symbol);
35483             },
35484             getTypeAtLocation: function (nodeIn) {
35485                 var node = ts.getParseTreeNode(nodeIn);
35486                 return node ? getTypeOfNode(node) : errorType;
35487             },
35488             getTypeOfAssignmentPattern: function (nodeIn) {
35489                 var node = ts.getParseTreeNode(nodeIn, ts.isAssignmentPattern);
35490                 return node && getTypeOfAssignmentPattern(node) || errorType;
35491             },
35492             getPropertySymbolOfDestructuringAssignment: function (locationIn) {
35493                 var location = ts.getParseTreeNode(locationIn, ts.isIdentifier);
35494                 return location ? getPropertySymbolOfDestructuringAssignment(location) : undefined;
35495             },
35496             signatureToString: function (signature, enclosingDeclaration, flags, kind) {
35497                 return signatureToString(signature, ts.getParseTreeNode(enclosingDeclaration), flags, kind);
35498             },
35499             typeToString: function (type, enclosingDeclaration, flags) {
35500                 return typeToString(type, ts.getParseTreeNode(enclosingDeclaration), flags);
35501             },
35502             symbolToString: function (symbol, enclosingDeclaration, meaning, flags) {
35503                 return symbolToString(symbol, ts.getParseTreeNode(enclosingDeclaration), meaning, flags);
35504             },
35505             typePredicateToString: function (predicate, enclosingDeclaration, flags) {
35506                 return typePredicateToString(predicate, ts.getParseTreeNode(enclosingDeclaration), flags);
35507             },
35508             writeSignature: function (signature, enclosingDeclaration, flags, kind, writer) {
35509                 return signatureToString(signature, ts.getParseTreeNode(enclosingDeclaration), flags, kind, writer);
35510             },
35511             writeType: function (type, enclosingDeclaration, flags, writer) {
35512                 return typeToString(type, ts.getParseTreeNode(enclosingDeclaration), flags, writer);
35513             },
35514             writeSymbol: function (symbol, enclosingDeclaration, meaning, flags, writer) {
35515                 return symbolToString(symbol, ts.getParseTreeNode(enclosingDeclaration), meaning, flags, writer);
35516             },
35517             writeTypePredicate: function (predicate, enclosingDeclaration, flags, writer) {
35518                 return typePredicateToString(predicate, ts.getParseTreeNode(enclosingDeclaration), flags, writer);
35519             },
35520             getAugmentedPropertiesOfType: getAugmentedPropertiesOfType,
35521             getRootSymbols: getRootSymbols,
35522             getSymbolOfExpando: getSymbolOfExpando,
35523             getContextualType: function (nodeIn, contextFlags) {
35524                 var node = ts.getParseTreeNode(nodeIn, ts.isExpression);
35525                 if (!node) {
35526                     return undefined;
35527                 }
35528                 var containingCall = ts.findAncestor(node, ts.isCallLikeExpression);
35529                 var containingCallResolvedSignature = containingCall && getNodeLinks(containingCall).resolvedSignature;
35530                 if (contextFlags & 4 && containingCall) {
35531                     var toMarkSkip = node;
35532                     do {
35533                         getNodeLinks(toMarkSkip).skipDirectInference = true;
35534                         toMarkSkip = toMarkSkip.parent;
35535                     } while (toMarkSkip && toMarkSkip !== containingCall);
35536                     getNodeLinks(containingCall).resolvedSignature = undefined;
35537                 }
35538                 var result = getContextualType(node, contextFlags);
35539                 if (contextFlags & 4 && containingCall) {
35540                     var toMarkSkip = node;
35541                     do {
35542                         getNodeLinks(toMarkSkip).skipDirectInference = undefined;
35543                         toMarkSkip = toMarkSkip.parent;
35544                     } while (toMarkSkip && toMarkSkip !== containingCall);
35545                     getNodeLinks(containingCall).resolvedSignature = containingCallResolvedSignature;
35546                 }
35547                 return result;
35548             },
35549             getContextualTypeForObjectLiteralElement: function (nodeIn) {
35550                 var node = ts.getParseTreeNode(nodeIn, ts.isObjectLiteralElementLike);
35551                 return node ? getContextualTypeForObjectLiteralElement(node) : undefined;
35552             },
35553             getContextualTypeForArgumentAtIndex: function (nodeIn, argIndex) {
35554                 var node = ts.getParseTreeNode(nodeIn, ts.isCallLikeExpression);
35555                 return node && getContextualTypeForArgumentAtIndex(node, argIndex);
35556             },
35557             getContextualTypeForJsxAttribute: function (nodeIn) {
35558                 var node = ts.getParseTreeNode(nodeIn, ts.isJsxAttributeLike);
35559                 return node && getContextualTypeForJsxAttribute(node);
35560             },
35561             isContextSensitive: isContextSensitive,
35562             getFullyQualifiedName: getFullyQualifiedName,
35563             getResolvedSignature: function (node, candidatesOutArray, argumentCount) {
35564                 return getResolvedSignatureWorker(node, candidatesOutArray, argumentCount, 0);
35565             },
35566             getResolvedSignatureForSignatureHelp: function (node, candidatesOutArray, argumentCount) {
35567                 return getResolvedSignatureWorker(node, candidatesOutArray, argumentCount, 16);
35568             },
35569             getExpandedParameters: getExpandedParameters,
35570             hasEffectiveRestParameter: hasEffectiveRestParameter,
35571             getConstantValue: function (nodeIn) {
35572                 var node = ts.getParseTreeNode(nodeIn, canHaveConstantValue);
35573                 return node ? getConstantValue(node) : undefined;
35574             },
35575             isValidPropertyAccess: function (nodeIn, propertyName) {
35576                 var node = ts.getParseTreeNode(nodeIn, ts.isPropertyAccessOrQualifiedNameOrImportTypeNode);
35577                 return !!node && isValidPropertyAccess(node, ts.escapeLeadingUnderscores(propertyName));
35578             },
35579             isValidPropertyAccessForCompletions: function (nodeIn, type, property) {
35580                 var node = ts.getParseTreeNode(nodeIn, ts.isPropertyAccessExpression);
35581                 return !!node && isValidPropertyAccessForCompletions(node, type, property);
35582             },
35583             getSignatureFromDeclaration: function (declarationIn) {
35584                 var declaration = ts.getParseTreeNode(declarationIn, ts.isFunctionLike);
35585                 return declaration ? getSignatureFromDeclaration(declaration) : undefined;
35586             },
35587             isImplementationOfOverload: function (nodeIn) {
35588                 var node = ts.getParseTreeNode(nodeIn, ts.isFunctionLike);
35589                 return node ? isImplementationOfOverload(node) : undefined;
35590             },
35591             getImmediateAliasedSymbol: getImmediateAliasedSymbol,
35592             getAliasedSymbol: resolveAlias,
35593             getEmitResolver: getEmitResolver,
35594             getExportsOfModule: getExportsOfModuleAsArray,
35595             getExportsAndPropertiesOfModule: getExportsAndPropertiesOfModule,
35596             getSymbolWalker: ts.createGetSymbolWalker(getRestTypeOfSignature, getTypePredicateOfSignature, getReturnTypeOfSignature, getBaseTypes, resolveStructuredTypeMembers, getTypeOfSymbol, getResolvedSymbol, getIndexTypeOfStructuredType, getConstraintOfTypeParameter, ts.getFirstIdentifier, getTypeArguments),
35597             getAmbientModules: getAmbientModules,
35598             getJsxIntrinsicTagNamesAt: getJsxIntrinsicTagNamesAt,
35599             isOptionalParameter: function (nodeIn) {
35600                 var node = ts.getParseTreeNode(nodeIn, ts.isParameter);
35601                 return node ? isOptionalParameter(node) : false;
35602             },
35603             tryGetMemberInModuleExports: function (name, symbol) { return tryGetMemberInModuleExports(ts.escapeLeadingUnderscores(name), symbol); },
35604             tryGetMemberInModuleExportsAndProperties: function (name, symbol) { return tryGetMemberInModuleExportsAndProperties(ts.escapeLeadingUnderscores(name), symbol); },
35605             tryFindAmbientModuleWithoutAugmentations: function (moduleName) {
35606                 return tryFindAmbientModule(moduleName, false);
35607             },
35608             getApparentType: getApparentType,
35609             getUnionType: getUnionType,
35610             isTypeAssignableTo: isTypeAssignableTo,
35611             createAnonymousType: createAnonymousType,
35612             createSignature: createSignature,
35613             createSymbol: createSymbol,
35614             createIndexInfo: createIndexInfo,
35615             getAnyType: function () { return anyType; },
35616             getStringType: function () { return stringType; },
35617             getNumberType: function () { return numberType; },
35618             createPromiseType: createPromiseType,
35619             createArrayType: createArrayType,
35620             getElementTypeOfArrayType: getElementTypeOfArrayType,
35621             getBooleanType: function () { return booleanType; },
35622             getFalseType: function (fresh) { return fresh ? falseType : regularFalseType; },
35623             getTrueType: function (fresh) { return fresh ? trueType : regularTrueType; },
35624             getVoidType: function () { return voidType; },
35625             getUndefinedType: function () { return undefinedType; },
35626             getNullType: function () { return nullType; },
35627             getESSymbolType: function () { return esSymbolType; },
35628             getNeverType: function () { return neverType; },
35629             getOptionalType: function () { return optionalType; },
35630             isSymbolAccessible: isSymbolAccessible,
35631             isArrayType: isArrayType,
35632             isTupleType: isTupleType,
35633             isArrayLikeType: isArrayLikeType,
35634             isTypeInvalidDueToUnionDiscriminant: isTypeInvalidDueToUnionDiscriminant,
35635             getAllPossiblePropertiesOfTypes: getAllPossiblePropertiesOfTypes,
35636             getSuggestedSymbolForNonexistentProperty: getSuggestedSymbolForNonexistentProperty,
35637             getSuggestionForNonexistentProperty: getSuggestionForNonexistentProperty,
35638             getSuggestedSymbolForNonexistentJSXAttribute: getSuggestedSymbolForNonexistentJSXAttribute,
35639             getSuggestedSymbolForNonexistentSymbol: function (location, name, meaning) { return getSuggestedSymbolForNonexistentSymbol(location, ts.escapeLeadingUnderscores(name), meaning); },
35640             getSuggestionForNonexistentSymbol: function (location, name, meaning) { return getSuggestionForNonexistentSymbol(location, ts.escapeLeadingUnderscores(name), meaning); },
35641             getSuggestedSymbolForNonexistentModule: getSuggestedSymbolForNonexistentModule,
35642             getSuggestionForNonexistentExport: getSuggestionForNonexistentExport,
35643             getBaseConstraintOfType: getBaseConstraintOfType,
35644             getDefaultFromTypeParameter: function (type) { return type && type.flags & 262144 ? getDefaultFromTypeParameter(type) : undefined; },
35645             resolveName: function (name, location, meaning, excludeGlobals) {
35646                 return resolveName(location, ts.escapeLeadingUnderscores(name), meaning, undefined, undefined, false, excludeGlobals);
35647             },
35648             getJsxNamespace: function (n) { return ts.unescapeLeadingUnderscores(getJsxNamespace(n)); },
35649             getAccessibleSymbolChain: getAccessibleSymbolChain,
35650             getTypePredicateOfSignature: getTypePredicateOfSignature,
35651             resolveExternalModuleName: function (moduleSpecifierIn) {
35652                 var moduleSpecifier = ts.getParseTreeNode(moduleSpecifierIn, ts.isExpression);
35653                 return moduleSpecifier && resolveExternalModuleName(moduleSpecifier, moduleSpecifier, true);
35654             },
35655             resolveExternalModuleSymbol: resolveExternalModuleSymbol,
35656             tryGetThisTypeAt: function (nodeIn, includeGlobalThis) {
35657                 var node = ts.getParseTreeNode(nodeIn);
35658                 return node && tryGetThisTypeAt(node, includeGlobalThis);
35659             },
35660             getTypeArgumentConstraint: function (nodeIn) {
35661                 var node = ts.getParseTreeNode(nodeIn, ts.isTypeNode);
35662                 return node && getTypeArgumentConstraint(node);
35663             },
35664             getSuggestionDiagnostics: function (fileIn, ct) {
35665                 var file = ts.getParseTreeNode(fileIn, ts.isSourceFile) || ts.Debug.fail("Could not determine parsed source file.");
35666                 if (ts.skipTypeChecking(file, compilerOptions, host)) {
35667                     return ts.emptyArray;
35668                 }
35669                 var diagnostics;
35670                 try {
35671                     cancellationToken = ct;
35672                     checkSourceFile(file);
35673                     ts.Debug.assert(!!(getNodeLinks(file).flags & 1));
35674                     diagnostics = ts.addRange(diagnostics, suggestionDiagnostics.getDiagnostics(file.fileName));
35675                     checkUnusedIdentifiers(getPotentiallyUnusedIdentifiers(file), function (containingNode, kind, diag) {
35676                         if (!ts.containsParseError(containingNode) && !unusedIsError(kind, !!(containingNode.flags & 8388608))) {
35677                             (diagnostics || (diagnostics = [])).push(__assign(__assign({}, diag), { category: ts.DiagnosticCategory.Suggestion }));
35678                         }
35679                     });
35680                     return diagnostics || ts.emptyArray;
35681                 }
35682                 finally {
35683                     cancellationToken = undefined;
35684                 }
35685             },
35686             runWithCancellationToken: function (token, callback) {
35687                 try {
35688                     cancellationToken = token;
35689                     return callback(checker);
35690                 }
35691                 finally {
35692                     cancellationToken = undefined;
35693                 }
35694             },
35695             getLocalTypeParametersOfClassOrInterfaceOrTypeAlias: getLocalTypeParametersOfClassOrInterfaceOrTypeAlias,
35696             isDeclarationVisible: isDeclarationVisible,
35697         };
35698         function getResolvedSignatureWorker(nodeIn, candidatesOutArray, argumentCount, checkMode) {
35699             var node = ts.getParseTreeNode(nodeIn, ts.isCallLikeExpression);
35700             apparentArgumentCount = argumentCount;
35701             var res = node ? getResolvedSignature(node, candidatesOutArray, checkMode) : undefined;
35702             apparentArgumentCount = undefined;
35703             return res;
35704         }
35705         var tupleTypes = new ts.Map();
35706         var unionTypes = new ts.Map();
35707         var intersectionTypes = new ts.Map();
35708         var literalTypes = new ts.Map();
35709         var indexedAccessTypes = new ts.Map();
35710         var templateLiteralTypes = new ts.Map();
35711         var stringMappingTypes = new ts.Map();
35712         var substitutionTypes = new ts.Map();
35713         var evolvingArrayTypes = [];
35714         var undefinedProperties = new ts.Map();
35715         var unknownSymbol = createSymbol(4, "unknown");
35716         var resolvingSymbol = createSymbol(0, "__resolving__");
35717         var anyType = createIntrinsicType(1, "any");
35718         var autoType = createIntrinsicType(1, "any");
35719         var wildcardType = createIntrinsicType(1, "any");
35720         var errorType = createIntrinsicType(1, "error");
35721         var nonInferrableAnyType = createIntrinsicType(1, "any", 524288);
35722         var intrinsicMarkerType = createIntrinsicType(1, "intrinsic");
35723         var unknownType = createIntrinsicType(2, "unknown");
35724         var undefinedType = createIntrinsicType(32768, "undefined");
35725         var undefinedWideningType = strictNullChecks ? undefinedType : createIntrinsicType(32768, "undefined", 524288);
35726         var optionalType = createIntrinsicType(32768, "undefined");
35727         var nullType = createIntrinsicType(65536, "null");
35728         var nullWideningType = strictNullChecks ? nullType : createIntrinsicType(65536, "null", 524288);
35729         var stringType = createIntrinsicType(4, "string");
35730         var numberType = createIntrinsicType(8, "number");
35731         var bigintType = createIntrinsicType(64, "bigint");
35732         var falseType = createIntrinsicType(512, "false");
35733         var regularFalseType = createIntrinsicType(512, "false");
35734         var trueType = createIntrinsicType(512, "true");
35735         var regularTrueType = createIntrinsicType(512, "true");
35736         trueType.regularType = regularTrueType;
35737         trueType.freshType = trueType;
35738         regularTrueType.regularType = regularTrueType;
35739         regularTrueType.freshType = trueType;
35740         falseType.regularType = regularFalseType;
35741         falseType.freshType = falseType;
35742         regularFalseType.regularType = regularFalseType;
35743         regularFalseType.freshType = falseType;
35744         var booleanType = createBooleanType([regularFalseType, regularTrueType]);
35745         createBooleanType([regularFalseType, trueType]);
35746         createBooleanType([falseType, regularTrueType]);
35747         createBooleanType([falseType, trueType]);
35748         var esSymbolType = createIntrinsicType(4096, "symbol");
35749         var voidType = createIntrinsicType(16384, "void");
35750         var neverType = createIntrinsicType(131072, "never");
35751         var silentNeverType = createIntrinsicType(131072, "never");
35752         var nonInferrableType = createIntrinsicType(131072, "never", 2097152);
35753         var implicitNeverType = createIntrinsicType(131072, "never");
35754         var unreachableNeverType = createIntrinsicType(131072, "never");
35755         var nonPrimitiveType = createIntrinsicType(67108864, "object");
35756         var stringNumberSymbolType = getUnionType([stringType, numberType, esSymbolType]);
35757         var keyofConstraintType = keyofStringsOnly ? stringType : stringNumberSymbolType;
35758         var numberOrBigIntType = getUnionType([numberType, bigintType]);
35759         var templateConstraintType = getUnionType([stringType, numberType, booleanType, bigintType, nullType, undefinedType]);
35760         var restrictiveMapper = makeFunctionTypeMapper(function (t) { return t.flags & 262144 ? getRestrictiveTypeParameter(t) : t; });
35761         var permissiveMapper = makeFunctionTypeMapper(function (t) { return t.flags & 262144 ? wildcardType : t; });
35762         var emptyObjectType = createAnonymousType(undefined, emptySymbols, ts.emptyArray, ts.emptyArray, undefined, undefined);
35763         var emptyJsxObjectType = createAnonymousType(undefined, emptySymbols, ts.emptyArray, ts.emptyArray, undefined, undefined);
35764         emptyJsxObjectType.objectFlags |= 4096;
35765         var emptyTypeLiteralSymbol = createSymbol(2048, "__type");
35766         emptyTypeLiteralSymbol.members = ts.createSymbolTable();
35767         var emptyTypeLiteralType = createAnonymousType(emptyTypeLiteralSymbol, emptySymbols, ts.emptyArray, ts.emptyArray, undefined, undefined);
35768         var emptyGenericType = createAnonymousType(undefined, emptySymbols, ts.emptyArray, ts.emptyArray, undefined, undefined);
35769         emptyGenericType.instantiations = new ts.Map();
35770         var anyFunctionType = createAnonymousType(undefined, emptySymbols, ts.emptyArray, ts.emptyArray, undefined, undefined);
35771         anyFunctionType.objectFlags |= 2097152;
35772         var noConstraintType = createAnonymousType(undefined, emptySymbols, ts.emptyArray, ts.emptyArray, undefined, undefined);
35773         var circularConstraintType = createAnonymousType(undefined, emptySymbols, ts.emptyArray, ts.emptyArray, undefined, undefined);
35774         var resolvingDefaultType = createAnonymousType(undefined, emptySymbols, ts.emptyArray, ts.emptyArray, undefined, undefined);
35775         var markerSuperType = createTypeParameter();
35776         var markerSubType = createTypeParameter();
35777         markerSubType.constraint = markerSuperType;
35778         var markerOtherType = createTypeParameter();
35779         var noTypePredicate = createTypePredicate(1, "<<unresolved>>", 0, anyType);
35780         var anySignature = createSignature(undefined, undefined, undefined, ts.emptyArray, anyType, undefined, 0, 0);
35781         var unknownSignature = createSignature(undefined, undefined, undefined, ts.emptyArray, errorType, undefined, 0, 0);
35782         var resolvingSignature = createSignature(undefined, undefined, undefined, ts.emptyArray, anyType, undefined, 0, 0);
35783         var silentNeverSignature = createSignature(undefined, undefined, undefined, ts.emptyArray, silentNeverType, undefined, 0, 0);
35784         var enumNumberIndexInfo = createIndexInfo(stringType, true);
35785         var iterationTypesCache = new ts.Map();
35786         var noIterationTypes = {
35787             get yieldType() { return ts.Debug.fail("Not supported"); },
35788             get returnType() { return ts.Debug.fail("Not supported"); },
35789             get nextType() { return ts.Debug.fail("Not supported"); },
35790         };
35791         var anyIterationTypes = createIterationTypes(anyType, anyType, anyType);
35792         var anyIterationTypesExceptNext = createIterationTypes(anyType, anyType, unknownType);
35793         var defaultIterationTypes = createIterationTypes(neverType, anyType, undefinedType);
35794         var asyncIterationTypesResolver = {
35795             iterableCacheKey: "iterationTypesOfAsyncIterable",
35796             iteratorCacheKey: "iterationTypesOfAsyncIterator",
35797             iteratorSymbolName: "asyncIterator",
35798             getGlobalIteratorType: getGlobalAsyncIteratorType,
35799             getGlobalIterableType: getGlobalAsyncIterableType,
35800             getGlobalIterableIteratorType: getGlobalAsyncIterableIteratorType,
35801             getGlobalGeneratorType: getGlobalAsyncGeneratorType,
35802             resolveIterationType: getAwaitedType,
35803             mustHaveANextMethodDiagnostic: ts.Diagnostics.An_async_iterator_must_have_a_next_method,
35804             mustBeAMethodDiagnostic: ts.Diagnostics.The_0_property_of_an_async_iterator_must_be_a_method,
35805             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,
35806         };
35807         var syncIterationTypesResolver = {
35808             iterableCacheKey: "iterationTypesOfIterable",
35809             iteratorCacheKey: "iterationTypesOfIterator",
35810             iteratorSymbolName: "iterator",
35811             getGlobalIteratorType: getGlobalIteratorType,
35812             getGlobalIterableType: getGlobalIterableType,
35813             getGlobalIterableIteratorType: getGlobalIterableIteratorType,
35814             getGlobalGeneratorType: getGlobalGeneratorType,
35815             resolveIterationType: function (type, _errorNode) { return type; },
35816             mustHaveANextMethodDiagnostic: ts.Diagnostics.An_iterator_must_have_a_next_method,
35817             mustBeAMethodDiagnostic: ts.Diagnostics.The_0_property_of_an_iterator_must_be_a_method,
35818             mustHaveAValueDiagnostic: ts.Diagnostics.The_type_returned_by_the_0_method_of_an_iterator_must_have_a_value_property,
35819         };
35820         var amalgamatedDuplicates;
35821         var reverseMappedCache = new ts.Map();
35822         var inInferTypeForHomomorphicMappedType = false;
35823         var ambientModulesCache;
35824         var patternAmbientModules;
35825         var patternAmbientModuleAugmentations;
35826         var globalObjectType;
35827         var globalFunctionType;
35828         var globalCallableFunctionType;
35829         var globalNewableFunctionType;
35830         var globalArrayType;
35831         var globalReadonlyArrayType;
35832         var globalStringType;
35833         var globalNumberType;
35834         var globalBooleanType;
35835         var globalRegExpType;
35836         var globalThisType;
35837         var anyArrayType;
35838         var autoArrayType;
35839         var anyReadonlyArrayType;
35840         var deferredGlobalNonNullableTypeAlias;
35841         var deferredGlobalESSymbolConstructorSymbol;
35842         var deferredGlobalESSymbolType;
35843         var deferredGlobalTypedPropertyDescriptorType;
35844         var deferredGlobalPromiseType;
35845         var deferredGlobalPromiseLikeType;
35846         var deferredGlobalPromiseConstructorSymbol;
35847         var deferredGlobalPromiseConstructorLikeType;
35848         var deferredGlobalIterableType;
35849         var deferredGlobalIteratorType;
35850         var deferredGlobalIterableIteratorType;
35851         var deferredGlobalGeneratorType;
35852         var deferredGlobalIteratorYieldResultType;
35853         var deferredGlobalIteratorReturnResultType;
35854         var deferredGlobalAsyncIterableType;
35855         var deferredGlobalAsyncIteratorType;
35856         var deferredGlobalAsyncIterableIteratorType;
35857         var deferredGlobalAsyncGeneratorType;
35858         var deferredGlobalTemplateStringsArrayType;
35859         var deferredGlobalImportMetaType;
35860         var deferredGlobalExtractSymbol;
35861         var deferredGlobalOmitSymbol;
35862         var deferredGlobalBigIntType;
35863         var allPotentiallyUnusedIdentifiers = new ts.Map();
35864         var flowLoopStart = 0;
35865         var flowLoopCount = 0;
35866         var sharedFlowCount = 0;
35867         var flowAnalysisDisabled = false;
35868         var flowInvocationCount = 0;
35869         var lastFlowNode;
35870         var lastFlowNodeReachable;
35871         var flowTypeCache;
35872         var emptyStringType = getLiteralType("");
35873         var zeroType = getLiteralType(0);
35874         var zeroBigIntType = getLiteralType({ negative: false, base10Value: "0" });
35875         var resolutionTargets = [];
35876         var resolutionResults = [];
35877         var resolutionPropertyNames = [];
35878         var suggestionCount = 0;
35879         var maximumSuggestionCount = 10;
35880         var mergedSymbols = [];
35881         var symbolLinks = [];
35882         var nodeLinks = [];
35883         var flowLoopCaches = [];
35884         var flowLoopNodes = [];
35885         var flowLoopKeys = [];
35886         var flowLoopTypes = [];
35887         var sharedFlowNodes = [];
35888         var sharedFlowTypes = [];
35889         var flowNodeReachable = [];
35890         var flowNodePostSuper = [];
35891         var potentialThisCollisions = [];
35892         var potentialNewTargetCollisions = [];
35893         var potentialWeakMapCollisions = [];
35894         var awaitedTypeStack = [];
35895         var diagnostics = ts.createDiagnosticCollection();
35896         var suggestionDiagnostics = ts.createDiagnosticCollection();
35897         var typeofTypesByName = new ts.Map(ts.getEntries({
35898             string: stringType,
35899             number: numberType,
35900             bigint: bigintType,
35901             boolean: booleanType,
35902             symbol: esSymbolType,
35903             undefined: undefinedType
35904         }));
35905         var typeofType = createTypeofType();
35906         var _jsxNamespace;
35907         var _jsxFactoryEntity;
35908         var outofbandVarianceMarkerHandler;
35909         var subtypeRelation = new ts.Map();
35910         var strictSubtypeRelation = new ts.Map();
35911         var assignableRelation = new ts.Map();
35912         var comparableRelation = new ts.Map();
35913         var identityRelation = new ts.Map();
35914         var enumRelation = new ts.Map();
35915         var builtinGlobals = ts.createSymbolTable();
35916         builtinGlobals.set(undefinedSymbol.escapedName, undefinedSymbol);
35917         initializeTypeChecker();
35918         return checker;
35919         function getJsxNamespace(location) {
35920             if (location) {
35921                 var file = ts.getSourceFileOfNode(location);
35922                 if (file) {
35923                     if (ts.isJsxOpeningFragment(location)) {
35924                         if (file.localJsxFragmentNamespace) {
35925                             return file.localJsxFragmentNamespace;
35926                         }
35927                         var jsxFragmentPragma = file.pragmas.get("jsxfrag");
35928                         if (jsxFragmentPragma) {
35929                             var chosenPragma = ts.isArray(jsxFragmentPragma) ? jsxFragmentPragma[0] : jsxFragmentPragma;
35930                             file.localJsxFragmentFactory = ts.parseIsolatedEntityName(chosenPragma.arguments.factory, languageVersion);
35931                             ts.visitNode(file.localJsxFragmentFactory, markAsSynthetic);
35932                             if (file.localJsxFragmentFactory) {
35933                                 return file.localJsxFragmentNamespace = ts.getFirstIdentifier(file.localJsxFragmentFactory).escapedText;
35934                             }
35935                         }
35936                         var entity = getJsxFragmentFactoryEntity(location);
35937                         if (entity) {
35938                             file.localJsxFragmentFactory = entity;
35939                             return file.localJsxFragmentNamespace = ts.getFirstIdentifier(entity).escapedText;
35940                         }
35941                     }
35942                     else {
35943                         if (file.localJsxNamespace) {
35944                             return file.localJsxNamespace;
35945                         }
35946                         var jsxPragma = file.pragmas.get("jsx");
35947                         if (jsxPragma) {
35948                             var chosenPragma = ts.isArray(jsxPragma) ? jsxPragma[0] : jsxPragma;
35949                             file.localJsxFactory = ts.parseIsolatedEntityName(chosenPragma.arguments.factory, languageVersion);
35950                             ts.visitNode(file.localJsxFactory, markAsSynthetic);
35951                             if (file.localJsxFactory) {
35952                                 return file.localJsxNamespace = ts.getFirstIdentifier(file.localJsxFactory).escapedText;
35953                             }
35954                         }
35955                     }
35956                 }
35957             }
35958             if (!_jsxNamespace) {
35959                 _jsxNamespace = "React";
35960                 if (compilerOptions.jsxFactory) {
35961                     _jsxFactoryEntity = ts.parseIsolatedEntityName(compilerOptions.jsxFactory, languageVersion);
35962                     ts.visitNode(_jsxFactoryEntity, markAsSynthetic);
35963                     if (_jsxFactoryEntity) {
35964                         _jsxNamespace = ts.getFirstIdentifier(_jsxFactoryEntity).escapedText;
35965                     }
35966                 }
35967                 else if (compilerOptions.reactNamespace) {
35968                     _jsxNamespace = ts.escapeLeadingUnderscores(compilerOptions.reactNamespace);
35969                 }
35970             }
35971             if (!_jsxFactoryEntity) {
35972                 _jsxFactoryEntity = ts.factory.createQualifiedName(ts.factory.createIdentifier(ts.unescapeLeadingUnderscores(_jsxNamespace)), "createElement");
35973             }
35974             return _jsxNamespace;
35975             function markAsSynthetic(node) {
35976                 ts.setTextRangePosEnd(node, -1, -1);
35977                 return ts.visitEachChild(node, markAsSynthetic, ts.nullTransformationContext);
35978             }
35979         }
35980         function getEmitResolver(sourceFile, cancellationToken) {
35981             getDiagnostics(sourceFile, cancellationToken);
35982             return emitResolver;
35983         }
35984         function lookupOrIssueError(location, message, arg0, arg1, arg2, arg3) {
35985             var diagnostic = location
35986                 ? ts.createDiagnosticForNode(location, message, arg0, arg1, arg2, arg3)
35987                 : ts.createCompilerDiagnostic(message, arg0, arg1, arg2, arg3);
35988             var existing = diagnostics.lookup(diagnostic);
35989             if (existing) {
35990                 return existing;
35991             }
35992             else {
35993                 diagnostics.add(diagnostic);
35994                 return diagnostic;
35995             }
35996         }
35997         function errorSkippedOn(key, location, message, arg0, arg1, arg2, arg3) {
35998             var diagnostic = error(location, message, arg0, arg1, arg2, arg3);
35999             diagnostic.skippedOn = key;
36000             return diagnostic;
36001         }
36002         function error(location, message, arg0, arg1, arg2, arg3) {
36003             var diagnostic = location
36004                 ? ts.createDiagnosticForNode(location, message, arg0, arg1, arg2, arg3)
36005                 : ts.createCompilerDiagnostic(message, arg0, arg1, arg2, arg3);
36006             diagnostics.add(diagnostic);
36007             return diagnostic;
36008         }
36009         function addErrorOrSuggestion(isError, diagnostic) {
36010             if (isError) {
36011                 diagnostics.add(diagnostic);
36012             }
36013             else {
36014                 suggestionDiagnostics.add(__assign(__assign({}, diagnostic), { category: ts.DiagnosticCategory.Suggestion }));
36015             }
36016         }
36017         function errorOrSuggestion(isError, location, message, arg0, arg1, arg2, arg3) {
36018             if (location.pos < 0 || location.end < 0) {
36019                 if (!isError) {
36020                     return;
36021                 }
36022                 var file = ts.getSourceFileOfNode(location);
36023                 addErrorOrSuggestion(isError, "message" in message ? ts.createFileDiagnostic(file, 0, 0, message, arg0, arg1, arg2, arg3) : ts.createDiagnosticForFileFromMessageChain(file, message));
36024                 return;
36025             }
36026             addErrorOrSuggestion(isError, "message" in message ? ts.createDiagnosticForNode(location, message, arg0, arg1, arg2, arg3) : ts.createDiagnosticForNodeFromMessageChain(location, message));
36027         }
36028         function errorAndMaybeSuggestAwait(location, maybeMissingAwait, message, arg0, arg1, arg2, arg3) {
36029             var diagnostic = error(location, message, arg0, arg1, arg2, arg3);
36030             if (maybeMissingAwait) {
36031                 var related = ts.createDiagnosticForNode(location, ts.Diagnostics.Did_you_forget_to_use_await);
36032                 ts.addRelatedInfo(diagnostic, related);
36033             }
36034             return diagnostic;
36035         }
36036         function createSymbol(flags, name, checkFlags) {
36037             symbolCount++;
36038             var symbol = (new Symbol(flags | 33554432, name));
36039             symbol.checkFlags = checkFlags || 0;
36040             return symbol;
36041         }
36042         function getExcludedSymbolFlags(flags) {
36043             var result = 0;
36044             if (flags & 2)
36045                 result |= 111551;
36046             if (flags & 1)
36047                 result |= 111550;
36048             if (flags & 4)
36049                 result |= 0;
36050             if (flags & 8)
36051                 result |= 900095;
36052             if (flags & 16)
36053                 result |= 110991;
36054             if (flags & 32)
36055                 result |= 899503;
36056             if (flags & 64)
36057                 result |= 788872;
36058             if (flags & 256)
36059                 result |= 899327;
36060             if (flags & 128)
36061                 result |= 899967;
36062             if (flags & 512)
36063                 result |= 110735;
36064             if (flags & 8192)
36065                 result |= 103359;
36066             if (flags & 32768)
36067                 result |= 46015;
36068             if (flags & 65536)
36069                 result |= 78783;
36070             if (flags & 262144)
36071                 result |= 526824;
36072             if (flags & 524288)
36073                 result |= 788968;
36074             if (flags & 2097152)
36075                 result |= 2097152;
36076             return result;
36077         }
36078         function recordMergedSymbol(target, source) {
36079             if (!source.mergeId) {
36080                 source.mergeId = nextMergeId;
36081                 nextMergeId++;
36082             }
36083             mergedSymbols[source.mergeId] = target;
36084         }
36085         function cloneSymbol(symbol) {
36086             var result = createSymbol(symbol.flags, symbol.escapedName);
36087             result.declarations = symbol.declarations ? symbol.declarations.slice() : [];
36088             result.parent = symbol.parent;
36089             if (symbol.valueDeclaration)
36090                 result.valueDeclaration = symbol.valueDeclaration;
36091             if (symbol.constEnumOnlyModule)
36092                 result.constEnumOnlyModule = true;
36093             if (symbol.members)
36094                 result.members = new ts.Map(symbol.members);
36095             if (symbol.exports)
36096                 result.exports = new ts.Map(symbol.exports);
36097             recordMergedSymbol(result, symbol);
36098             return result;
36099         }
36100         function mergeSymbol(target, source, unidirectional) {
36101             if (unidirectional === void 0) { unidirectional = false; }
36102             if (!(target.flags & getExcludedSymbolFlags(source.flags)) ||
36103                 (source.flags | target.flags) & 67108864) {
36104                 if (source === target) {
36105                     return target;
36106                 }
36107                 if (!(target.flags & 33554432)) {
36108                     var resolvedTarget = resolveSymbol(target);
36109                     if (resolvedTarget === unknownSymbol) {
36110                         return source;
36111                     }
36112                     target = cloneSymbol(resolvedTarget);
36113                 }
36114                 if (source.flags & 512 && target.flags & 512 && target.constEnumOnlyModule && !source.constEnumOnlyModule) {
36115                     target.constEnumOnlyModule = false;
36116                 }
36117                 target.flags |= source.flags;
36118                 if (source.valueDeclaration) {
36119                     ts.setValueDeclaration(target, source.valueDeclaration);
36120                 }
36121                 ts.addRange(target.declarations, source.declarations);
36122                 if (source.members) {
36123                     if (!target.members)
36124                         target.members = ts.createSymbolTable();
36125                     mergeSymbolTable(target.members, source.members, unidirectional);
36126                 }
36127                 if (source.exports) {
36128                     if (!target.exports)
36129                         target.exports = ts.createSymbolTable();
36130                     mergeSymbolTable(target.exports, source.exports, unidirectional);
36131                 }
36132                 if (!unidirectional) {
36133                     recordMergedSymbol(target, source);
36134                 }
36135             }
36136             else if (target.flags & 1024) {
36137                 if (target !== globalThisSymbol) {
36138                     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));
36139                 }
36140             }
36141             else {
36142                 var isEitherEnum = !!(target.flags & 384 || source.flags & 384);
36143                 var isEitherBlockScoped_1 = !!(target.flags & 2 || source.flags & 2);
36144                 var message = isEitherEnum
36145                     ? ts.Diagnostics.Enum_declarations_can_only_merge_with_namespace_or_other_enum_declarations
36146                     : isEitherBlockScoped_1
36147                         ? ts.Diagnostics.Cannot_redeclare_block_scoped_variable_0
36148                         : ts.Diagnostics.Duplicate_identifier_0;
36149                 var sourceSymbolFile = source.declarations && ts.getSourceFileOfNode(source.declarations[0]);
36150                 var targetSymbolFile = target.declarations && ts.getSourceFileOfNode(target.declarations[0]);
36151                 var symbolName_1 = symbolToString(source);
36152                 if (sourceSymbolFile && targetSymbolFile && amalgamatedDuplicates && !isEitherEnum && sourceSymbolFile !== targetSymbolFile) {
36153                     var firstFile_1 = ts.comparePaths(sourceSymbolFile.path, targetSymbolFile.path) === -1 ? sourceSymbolFile : targetSymbolFile;
36154                     var secondFile_1 = firstFile_1 === sourceSymbolFile ? targetSymbolFile : sourceSymbolFile;
36155                     var filesDuplicates = ts.getOrUpdate(amalgamatedDuplicates, firstFile_1.path + "|" + secondFile_1.path, function () {
36156                         return ({ firstFile: firstFile_1, secondFile: secondFile_1, conflictingSymbols: new ts.Map() });
36157                     });
36158                     var conflictingSymbolInfo = ts.getOrUpdate(filesDuplicates.conflictingSymbols, symbolName_1, function () {
36159                         return ({ isBlockScoped: isEitherBlockScoped_1, firstFileLocations: [], secondFileLocations: [] });
36160                     });
36161                     addDuplicateLocations(conflictingSymbolInfo.firstFileLocations, source);
36162                     addDuplicateLocations(conflictingSymbolInfo.secondFileLocations, target);
36163                 }
36164                 else {
36165                     addDuplicateDeclarationErrorsForSymbols(source, message, symbolName_1, target);
36166                     addDuplicateDeclarationErrorsForSymbols(target, message, symbolName_1, source);
36167                 }
36168             }
36169             return target;
36170             function addDuplicateLocations(locs, symbol) {
36171                 for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) {
36172                     var decl = _a[_i];
36173                     ts.pushIfUnique(locs, decl);
36174                 }
36175             }
36176         }
36177         function addDuplicateDeclarationErrorsForSymbols(target, message, symbolName, source) {
36178             ts.forEach(target.declarations, function (node) {
36179                 addDuplicateDeclarationError(node, message, symbolName, source.declarations);
36180             });
36181         }
36182         function addDuplicateDeclarationError(node, message, symbolName, relatedNodes) {
36183             var errorNode = (ts.getExpandoInitializer(node, false) ? ts.getNameOfExpando(node) : ts.getNameOfDeclaration(node)) || node;
36184             var err = lookupOrIssueError(errorNode, message, symbolName);
36185             var _loop_7 = function (relatedNode) {
36186                 var adjustedNode = (ts.getExpandoInitializer(relatedNode, false) ? ts.getNameOfExpando(relatedNode) : ts.getNameOfDeclaration(relatedNode)) || relatedNode;
36187                 if (adjustedNode === errorNode)
36188                     return "continue";
36189                 err.relatedInformation = err.relatedInformation || [];
36190                 var leadingMessage = ts.createDiagnosticForNode(adjustedNode, ts.Diagnostics._0_was_also_declared_here, symbolName);
36191                 var followOnMessage = ts.createDiagnosticForNode(adjustedNode, ts.Diagnostics.and_here);
36192                 if (ts.length(err.relatedInformation) >= 5 || ts.some(err.relatedInformation, function (r) { return ts.compareDiagnostics(r, followOnMessage) === 0 || ts.compareDiagnostics(r, leadingMessage) === 0; }))
36193                     return "continue";
36194                 ts.addRelatedInfo(err, !ts.length(err.relatedInformation) ? leadingMessage : followOnMessage);
36195             };
36196             for (var _i = 0, _a = relatedNodes || ts.emptyArray; _i < _a.length; _i++) {
36197                 var relatedNode = _a[_i];
36198                 _loop_7(relatedNode);
36199             }
36200         }
36201         function combineSymbolTables(first, second) {
36202             if (!(first === null || first === void 0 ? void 0 : first.size))
36203                 return second;
36204             if (!(second === null || second === void 0 ? void 0 : second.size))
36205                 return first;
36206             var combined = ts.createSymbolTable();
36207             mergeSymbolTable(combined, first);
36208             mergeSymbolTable(combined, second);
36209             return combined;
36210         }
36211         function mergeSymbolTable(target, source, unidirectional) {
36212             if (unidirectional === void 0) { unidirectional = false; }
36213             source.forEach(function (sourceSymbol, id) {
36214                 var targetSymbol = target.get(id);
36215                 target.set(id, targetSymbol ? mergeSymbol(targetSymbol, sourceSymbol, unidirectional) : sourceSymbol);
36216             });
36217         }
36218         function mergeModuleAugmentation(moduleName) {
36219             var _a, _b;
36220             var moduleAugmentation = moduleName.parent;
36221             if (moduleAugmentation.symbol.declarations[0] !== moduleAugmentation) {
36222                 ts.Debug.assert(moduleAugmentation.symbol.declarations.length > 1);
36223                 return;
36224             }
36225             if (ts.isGlobalScopeAugmentation(moduleAugmentation)) {
36226                 mergeSymbolTable(globals, moduleAugmentation.symbol.exports);
36227             }
36228             else {
36229                 var moduleNotFoundError = !(moduleName.parent.parent.flags & 8388608)
36230                     ? ts.Diagnostics.Invalid_module_name_in_augmentation_module_0_cannot_be_found
36231                     : undefined;
36232                 var mainModule_1 = resolveExternalModuleNameWorker(moduleName, moduleName, moduleNotFoundError, true);
36233                 if (!mainModule_1) {
36234                     return;
36235                 }
36236                 mainModule_1 = resolveExternalModuleSymbol(mainModule_1);
36237                 if (mainModule_1.flags & 1920) {
36238                     if (ts.some(patternAmbientModules, function (module) { return mainModule_1 === module.symbol; })) {
36239                         var merged = mergeSymbol(moduleAugmentation.symbol, mainModule_1, true);
36240                         if (!patternAmbientModuleAugmentations) {
36241                             patternAmbientModuleAugmentations = new ts.Map();
36242                         }
36243                         patternAmbientModuleAugmentations.set(moduleName.text, merged);
36244                     }
36245                     else {
36246                         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)) {
36247                             var resolvedExports = getResolvedMembersOrExportsOfSymbol(mainModule_1, "resolvedExports");
36248                             for (var _i = 0, _c = ts.arrayFrom(moduleAugmentation.symbol.exports.entries()); _i < _c.length; _i++) {
36249                                 var _d = _c[_i], key = _d[0], value = _d[1];
36250                                 if (resolvedExports.has(key) && !mainModule_1.exports.has(key)) {
36251                                     mergeSymbol(resolvedExports.get(key), value);
36252                                 }
36253                             }
36254                         }
36255                         mergeSymbol(mainModule_1, moduleAugmentation.symbol);
36256                     }
36257                 }
36258                 else {
36259                     error(moduleName, ts.Diagnostics.Cannot_augment_module_0_because_it_resolves_to_a_non_module_entity, moduleName.text);
36260                 }
36261             }
36262         }
36263         function addToSymbolTable(target, source, message) {
36264             source.forEach(function (sourceSymbol, id) {
36265                 var targetSymbol = target.get(id);
36266                 if (targetSymbol) {
36267                     ts.forEach(targetSymbol.declarations, addDeclarationDiagnostic(ts.unescapeLeadingUnderscores(id), message));
36268                 }
36269                 else {
36270                     target.set(id, sourceSymbol);
36271                 }
36272             });
36273             function addDeclarationDiagnostic(id, message) {
36274                 return function (declaration) { return diagnostics.add(ts.createDiagnosticForNode(declaration, message, id)); };
36275             }
36276         }
36277         function getSymbolLinks(symbol) {
36278             if (symbol.flags & 33554432)
36279                 return symbol;
36280             var id = getSymbolId(symbol);
36281             return symbolLinks[id] || (symbolLinks[id] = new SymbolLinks());
36282         }
36283         function getNodeLinks(node) {
36284             var nodeId = getNodeId(node);
36285             return nodeLinks[nodeId] || (nodeLinks[nodeId] = new NodeLinks());
36286         }
36287         function isGlobalSourceFile(node) {
36288             return node.kind === 297 && !ts.isExternalOrCommonJsModule(node);
36289         }
36290         function getSymbol(symbols, name, meaning) {
36291             if (meaning) {
36292                 var symbol = getMergedSymbol(symbols.get(name));
36293                 if (symbol) {
36294                     ts.Debug.assert((ts.getCheckFlags(symbol) & 1) === 0, "Should never get an instantiated symbol here.");
36295                     if (symbol.flags & meaning) {
36296                         return symbol;
36297                     }
36298                     if (symbol.flags & 2097152) {
36299                         var target = resolveAlias(symbol);
36300                         if (target === unknownSymbol || target.flags & meaning) {
36301                             return symbol;
36302                         }
36303                     }
36304                 }
36305             }
36306         }
36307         function getSymbolsOfParameterPropertyDeclaration(parameter, parameterName) {
36308             var constructorDeclaration = parameter.parent;
36309             var classDeclaration = parameter.parent.parent;
36310             var parameterSymbol = getSymbol(constructorDeclaration.locals, parameterName, 111551);
36311             var propertySymbol = getSymbol(getMembersOfSymbol(classDeclaration.symbol), parameterName, 111551);
36312             if (parameterSymbol && propertySymbol) {
36313                 return [parameterSymbol, propertySymbol];
36314             }
36315             return ts.Debug.fail("There should exist two symbols, one as property declaration and one as parameter declaration");
36316         }
36317         function isBlockScopedNameDeclaredBeforeUse(declaration, usage) {
36318             var declarationFile = ts.getSourceFileOfNode(declaration);
36319             var useFile = ts.getSourceFileOfNode(usage);
36320             var declContainer = ts.getEnclosingBlockScopeContainer(declaration);
36321             if (declarationFile !== useFile) {
36322                 if ((moduleKind && (declarationFile.externalModuleIndicator || useFile.externalModuleIndicator)) ||
36323                     (!ts.outFile(compilerOptions)) ||
36324                     isInTypeQuery(usage) ||
36325                     declaration.flags & 8388608) {
36326                     return true;
36327                 }
36328                 if (isUsedInFunctionOrInstanceProperty(usage, declaration)) {
36329                     return true;
36330                 }
36331                 var sourceFiles = host.getSourceFiles();
36332                 return sourceFiles.indexOf(declarationFile) <= sourceFiles.indexOf(useFile);
36333             }
36334             if (declaration.pos <= usage.pos && !(ts.isPropertyDeclaration(declaration) && ts.isThisProperty(usage.parent) && !declaration.initializer && !declaration.exclamationToken)) {
36335                 if (declaration.kind === 198) {
36336                     var errorBindingElement = ts.getAncestor(usage, 198);
36337                     if (errorBindingElement) {
36338                         return ts.findAncestor(errorBindingElement, ts.isBindingElement) !== ts.findAncestor(declaration, ts.isBindingElement) ||
36339                             declaration.pos < errorBindingElement.pos;
36340                     }
36341                     return isBlockScopedNameDeclaredBeforeUse(ts.getAncestor(declaration, 249), usage);
36342                 }
36343                 else if (declaration.kind === 249) {
36344                     return !isImmediatelyUsedInInitializerOfBlockScopedVariable(declaration, usage);
36345                 }
36346                 else if (ts.isClassDeclaration(declaration)) {
36347                     return !ts.findAncestor(usage, function (n) { return ts.isComputedPropertyName(n) && n.parent.parent === declaration; });
36348                 }
36349                 else if (ts.isPropertyDeclaration(declaration)) {
36350                     return !isPropertyImmediatelyReferencedWithinDeclaration(declaration, usage, false);
36351                 }
36352                 else if (ts.isParameterPropertyDeclaration(declaration, declaration.parent)) {
36353                     return !(compilerOptions.target === 99 && !!compilerOptions.useDefineForClassFields
36354                         && ts.getContainingClass(declaration) === ts.getContainingClass(usage)
36355                         && isUsedInFunctionOrInstanceProperty(usage, declaration));
36356                 }
36357                 return true;
36358             }
36359             if (usage.parent.kind === 270 || (usage.parent.kind === 266 && usage.parent.isExportEquals)) {
36360                 return true;
36361             }
36362             if (usage.kind === 266 && usage.isExportEquals) {
36363                 return true;
36364             }
36365             if (!!(usage.flags & 4194304) || isInTypeQuery(usage) || usageInTypeDeclaration()) {
36366                 return true;
36367             }
36368             if (isUsedInFunctionOrInstanceProperty(usage, declaration)) {
36369                 if (compilerOptions.target === 99 && !!compilerOptions.useDefineForClassFields
36370                     && ts.getContainingClass(declaration)
36371                     && (ts.isPropertyDeclaration(declaration) || ts.isParameterPropertyDeclaration(declaration, declaration.parent))) {
36372                     return !isPropertyImmediatelyReferencedWithinDeclaration(declaration, usage, true);
36373                 }
36374                 else {
36375                     return true;
36376                 }
36377             }
36378             return false;
36379             function usageInTypeDeclaration() {
36380                 return !!ts.findAncestor(usage, function (node) { return ts.isInterfaceDeclaration(node) || ts.isTypeAliasDeclaration(node); });
36381             }
36382             function isImmediatelyUsedInInitializerOfBlockScopedVariable(declaration, usage) {
36383                 switch (declaration.parent.parent.kind) {
36384                     case 232:
36385                     case 237:
36386                     case 239:
36387                         if (isSameScopeDescendentOf(usage, declaration, declContainer)) {
36388                             return true;
36389                         }
36390                         break;
36391                 }
36392                 var grandparent = declaration.parent.parent;
36393                 return ts.isForInOrOfStatement(grandparent) && isSameScopeDescendentOf(usage, grandparent.expression, declContainer);
36394             }
36395             function isUsedInFunctionOrInstanceProperty(usage, declaration) {
36396                 return !!ts.findAncestor(usage, function (current) {
36397                     if (current === declContainer) {
36398                         return "quit";
36399                     }
36400                     if (ts.isFunctionLike(current)) {
36401                         return true;
36402                     }
36403                     var initializerOfProperty = current.parent &&
36404                         current.parent.kind === 163 &&
36405                         current.parent.initializer === current;
36406                     if (initializerOfProperty) {
36407                         if (ts.hasSyntacticModifier(current.parent, 32)) {
36408                             if (declaration.kind === 165) {
36409                                 return true;
36410                             }
36411                         }
36412                         else {
36413                             var isDeclarationInstanceProperty = declaration.kind === 163 && !ts.hasSyntacticModifier(declaration, 32);
36414                             if (!isDeclarationInstanceProperty || ts.getContainingClass(usage) !== ts.getContainingClass(declaration)) {
36415                                 return true;
36416                             }
36417                         }
36418                     }
36419                     return false;
36420                 });
36421             }
36422             function isPropertyImmediatelyReferencedWithinDeclaration(declaration, usage, stopAtAnyPropertyDeclaration) {
36423                 if (usage.end > declaration.end) {
36424                     return false;
36425                 }
36426                 var ancestorChangingReferenceScope = ts.findAncestor(usage, function (node) {
36427                     if (node === declaration) {
36428                         return "quit";
36429                     }
36430                     switch (node.kind) {
36431                         case 209:
36432                             return true;
36433                         case 163:
36434                             return stopAtAnyPropertyDeclaration &&
36435                                 (ts.isPropertyDeclaration(declaration) && node.parent === declaration.parent
36436                                     || ts.isParameterPropertyDeclaration(declaration, declaration.parent) && node.parent === declaration.parent.parent)
36437                                 ? "quit" : true;
36438                         case 230:
36439                             switch (node.parent.kind) {
36440                                 case 167:
36441                                 case 165:
36442                                 case 168:
36443                                     return true;
36444                                 default:
36445                                     return false;
36446                             }
36447                         default:
36448                             return false;
36449                     }
36450                 });
36451                 return ancestorChangingReferenceScope === undefined;
36452             }
36453         }
36454         function useOuterVariableScopeInParameter(result, location, lastLocation) {
36455             var target = ts.getEmitScriptTarget(compilerOptions);
36456             var functionLocation = location;
36457             if (ts.isParameter(lastLocation) && functionLocation.body && result.valueDeclaration.pos >= functionLocation.body.pos && result.valueDeclaration.end <= functionLocation.body.end) {
36458                 if (target >= 2) {
36459                     var links = getNodeLinks(functionLocation);
36460                     if (links.declarationRequiresScopeChange === undefined) {
36461                         links.declarationRequiresScopeChange = ts.forEach(functionLocation.parameters, requiresScopeChange) || false;
36462                     }
36463                     return !links.declarationRequiresScopeChange;
36464                 }
36465             }
36466             return false;
36467             function requiresScopeChange(node) {
36468                 return requiresScopeChangeWorker(node.name)
36469                     || !!node.initializer && requiresScopeChangeWorker(node.initializer);
36470             }
36471             function requiresScopeChangeWorker(node) {
36472                 switch (node.kind) {
36473                     case 209:
36474                     case 208:
36475                     case 251:
36476                     case 166:
36477                         return false;
36478                     case 165:
36479                     case 167:
36480                     case 168:
36481                     case 288:
36482                         return requiresScopeChangeWorker(node.name);
36483                     case 163:
36484                         if (ts.hasStaticModifier(node)) {
36485                             return target < 99 || !compilerOptions.useDefineForClassFields;
36486                         }
36487                         return requiresScopeChangeWorker(node.name);
36488                     default:
36489                         if (ts.isNullishCoalesce(node) || ts.isOptionalChain(node)) {
36490                             return target < 7;
36491                         }
36492                         if (ts.isBindingElement(node) && node.dotDotDotToken && ts.isObjectBindingPattern(node.parent)) {
36493                             return target < 4;
36494                         }
36495                         if (ts.isTypeNode(node))
36496                             return false;
36497                         return ts.forEachChild(node, requiresScopeChangeWorker) || false;
36498                 }
36499             }
36500         }
36501         function resolveName(location, name, meaning, nameNotFoundMessage, nameArg, isUse, excludeGlobals, suggestedNameNotFoundMessage) {
36502             if (excludeGlobals === void 0) { excludeGlobals = false; }
36503             return resolveNameHelper(location, name, meaning, nameNotFoundMessage, nameArg, isUse, excludeGlobals, getSymbol, suggestedNameNotFoundMessage);
36504         }
36505         function resolveNameHelper(location, name, meaning, nameNotFoundMessage, nameArg, isUse, excludeGlobals, lookup, suggestedNameNotFoundMessage) {
36506             var originalLocation = location;
36507             var result;
36508             var lastLocation;
36509             var lastSelfReferenceLocation;
36510             var propertyWithInvalidInitializer;
36511             var associatedDeclarationForContainingInitializerOrBindingName;
36512             var withinDeferredContext = false;
36513             var errorLocation = location;
36514             var grandparent;
36515             var isInExternalModule = false;
36516             loop: while (location) {
36517                 if (location.locals && !isGlobalSourceFile(location)) {
36518                     if (result = lookup(location.locals, name, meaning)) {
36519                         var useResult = true;
36520                         if (ts.isFunctionLike(location) && lastLocation && lastLocation !== location.body) {
36521                             if (meaning & result.flags & 788968 && lastLocation.kind !== 311) {
36522                                 useResult = result.flags & 262144
36523                                     ? lastLocation === location.type ||
36524                                         lastLocation.kind === 160 ||
36525                                         lastLocation.kind === 159
36526                                     : false;
36527                             }
36528                             if (meaning & result.flags & 3) {
36529                                 if (useOuterVariableScopeInParameter(result, location, lastLocation)) {
36530                                     useResult = false;
36531                                 }
36532                                 else if (result.flags & 1) {
36533                                     useResult =
36534                                         lastLocation.kind === 160 ||
36535                                             (lastLocation === location.type &&
36536                                                 !!ts.findAncestor(result.valueDeclaration, ts.isParameter));
36537                                 }
36538                             }
36539                         }
36540                         else if (location.kind === 184) {
36541                             useResult = lastLocation === location.trueType;
36542                         }
36543                         if (useResult) {
36544                             break loop;
36545                         }
36546                         else {
36547                             result = undefined;
36548                         }
36549                     }
36550                 }
36551                 withinDeferredContext = withinDeferredContext || getIsDeferredContext(location, lastLocation);
36552                 switch (location.kind) {
36553                     case 297:
36554                         if (!ts.isExternalOrCommonJsModule(location))
36555                             break;
36556                         isInExternalModule = true;
36557                     case 256:
36558                         var moduleExports = getSymbolOfNode(location).exports || emptySymbols;
36559                         if (location.kind === 297 || (ts.isModuleDeclaration(location) && location.flags & 8388608 && !ts.isGlobalScopeAugmentation(location))) {
36560                             if (result = moduleExports.get("default")) {
36561                                 var localSymbol = ts.getLocalSymbolForExportDefault(result);
36562                                 if (localSymbol && (result.flags & meaning) && localSymbol.escapedName === name) {
36563                                     break loop;
36564                                 }
36565                                 result = undefined;
36566                             }
36567                             var moduleExport = moduleExports.get(name);
36568                             if (moduleExport &&
36569                                 moduleExport.flags === 2097152 &&
36570                                 (ts.getDeclarationOfKind(moduleExport, 270) || ts.getDeclarationOfKind(moduleExport, 269))) {
36571                                 break;
36572                             }
36573                         }
36574                         if (name !== "default" && (result = lookup(moduleExports, name, meaning & 2623475))) {
36575                             if (ts.isSourceFile(location) && location.commonJsModuleIndicator && !result.declarations.some(ts.isJSDocTypeAlias)) {
36576                                 result = undefined;
36577                             }
36578                             else {
36579                                 break loop;
36580                             }
36581                         }
36582                         break;
36583                     case 255:
36584                         if (result = lookup(getSymbolOfNode(location).exports, name, meaning & 8)) {
36585                             break loop;
36586                         }
36587                         break;
36588                     case 163:
36589                         if (!ts.hasSyntacticModifier(location, 32)) {
36590                             var ctor = findConstructorDeclaration(location.parent);
36591                             if (ctor && ctor.locals) {
36592                                 if (lookup(ctor.locals, name, meaning & 111551)) {
36593                                     propertyWithInvalidInitializer = location;
36594                                 }
36595                             }
36596                         }
36597                         break;
36598                     case 252:
36599                     case 221:
36600                     case 253:
36601                         if (result = lookup(getSymbolOfNode(location).members || emptySymbols, name, meaning & 788968)) {
36602                             if (!isTypeParameterSymbolDeclaredInContainer(result, location)) {
36603                                 result = undefined;
36604                                 break;
36605                             }
36606                             if (lastLocation && ts.hasSyntacticModifier(lastLocation, 32)) {
36607                                 error(errorLocation, ts.Diagnostics.Static_members_cannot_reference_class_type_parameters);
36608                                 return undefined;
36609                             }
36610                             break loop;
36611                         }
36612                         if (location.kind === 221 && meaning & 32) {
36613                             var className = location.name;
36614                             if (className && name === className.escapedText) {
36615                                 result = location.symbol;
36616                                 break loop;
36617                             }
36618                         }
36619                         break;
36620                     case 223:
36621                         if (lastLocation === location.expression && location.parent.token === 93) {
36622                             var container = location.parent.parent;
36623                             if (ts.isClassLike(container) && (result = lookup(getSymbolOfNode(container).members, name, meaning & 788968))) {
36624                                 if (nameNotFoundMessage) {
36625                                     error(errorLocation, ts.Diagnostics.Base_class_expressions_cannot_reference_class_type_parameters);
36626                                 }
36627                                 return undefined;
36628                             }
36629                         }
36630                         break;
36631                     case 158:
36632                         grandparent = location.parent.parent;
36633                         if (ts.isClassLike(grandparent) || grandparent.kind === 253) {
36634                             if (result = lookup(getSymbolOfNode(grandparent).members, name, meaning & 788968)) {
36635                                 error(errorLocation, ts.Diagnostics.A_computed_property_name_cannot_reference_a_type_parameter_from_its_containing_type);
36636                                 return undefined;
36637                             }
36638                         }
36639                         break;
36640                     case 209:
36641                         if (compilerOptions.target >= 2) {
36642                             break;
36643                         }
36644                     case 165:
36645                     case 166:
36646                     case 167:
36647                     case 168:
36648                     case 251:
36649                         if (meaning & 3 && name === "arguments") {
36650                             result = argumentsSymbol;
36651                             break loop;
36652                         }
36653                         break;
36654                     case 208:
36655                         if (meaning & 3 && name === "arguments") {
36656                             result = argumentsSymbol;
36657                             break loop;
36658                         }
36659                         if (meaning & 16) {
36660                             var functionName = location.name;
36661                             if (functionName && name === functionName.escapedText) {
36662                                 result = location.symbol;
36663                                 break loop;
36664                             }
36665                         }
36666                         break;
36667                     case 161:
36668                         if (location.parent && location.parent.kind === 160) {
36669                             location = location.parent;
36670                         }
36671                         if (location.parent && (ts.isClassElement(location.parent) || location.parent.kind === 252)) {
36672                             location = location.parent;
36673                         }
36674                         break;
36675                     case 331:
36676                     case 324:
36677                     case 325:
36678                         location = ts.getJSDocHost(location);
36679                         break;
36680                     case 160:
36681                         if (lastLocation && (lastLocation === location.initializer ||
36682                             lastLocation === location.name && ts.isBindingPattern(lastLocation))) {
36683                             if (!associatedDeclarationForContainingInitializerOrBindingName) {
36684                                 associatedDeclarationForContainingInitializerOrBindingName = location;
36685                             }
36686                         }
36687                         break;
36688                     case 198:
36689                         if (lastLocation && (lastLocation === location.initializer ||
36690                             lastLocation === location.name && ts.isBindingPattern(lastLocation))) {
36691                             if (ts.isParameterDeclaration(location) && !associatedDeclarationForContainingInitializerOrBindingName) {
36692                                 associatedDeclarationForContainingInitializerOrBindingName = location;
36693                             }
36694                         }
36695                         break;
36696                     case 185:
36697                         if (meaning & 262144) {
36698                             var parameterName = location.typeParameter.name;
36699                             if (parameterName && name === parameterName.escapedText) {
36700                                 result = location.typeParameter.symbol;
36701                                 break loop;
36702                             }
36703                         }
36704                         break;
36705                 }
36706                 if (isSelfReferenceLocation(location)) {
36707                     lastSelfReferenceLocation = location;
36708                 }
36709                 lastLocation = location;
36710                 location = location.parent;
36711             }
36712             if (isUse && result && (!lastSelfReferenceLocation || result !== lastSelfReferenceLocation.symbol)) {
36713                 result.isReferenced |= meaning;
36714             }
36715             if (!result) {
36716                 if (lastLocation) {
36717                     ts.Debug.assert(lastLocation.kind === 297);
36718                     if (lastLocation.commonJsModuleIndicator && name === "exports" && meaning & lastLocation.symbol.flags) {
36719                         return lastLocation.symbol;
36720                     }
36721                 }
36722                 if (!excludeGlobals) {
36723                     result = lookup(globals, name, meaning);
36724                 }
36725             }
36726             if (!result) {
36727                 if (originalLocation && ts.isInJSFile(originalLocation) && originalLocation.parent) {
36728                     if (ts.isRequireCall(originalLocation.parent, false)) {
36729                         return requireSymbol;
36730                     }
36731                 }
36732             }
36733             if (!result) {
36734                 if (nameNotFoundMessage) {
36735                     if (!errorLocation ||
36736                         !checkAndReportErrorForMissingPrefix(errorLocation, name, nameArg) &&
36737                             !checkAndReportErrorForExtendingInterface(errorLocation) &&
36738                             !checkAndReportErrorForUsingTypeAsNamespace(errorLocation, name, meaning) &&
36739                             !checkAndReportErrorForExportingPrimitiveType(errorLocation, name) &&
36740                             !checkAndReportErrorForUsingTypeAsValue(errorLocation, name, meaning) &&
36741                             !checkAndReportErrorForUsingNamespaceModuleAsValue(errorLocation, name, meaning) &&
36742                             !checkAndReportErrorForUsingValueAsType(errorLocation, name, meaning)) {
36743                         var suggestion = void 0;
36744                         if (suggestedNameNotFoundMessage && suggestionCount < maximumSuggestionCount) {
36745                             suggestion = getSuggestedSymbolForNonexistentSymbol(originalLocation, name, meaning);
36746                             if (suggestion) {
36747                                 var suggestionName = symbolToString(suggestion);
36748                                 var diagnostic = error(errorLocation, suggestedNameNotFoundMessage, diagnosticName(nameArg), suggestionName);
36749                                 if (suggestion.valueDeclaration) {
36750                                     ts.addRelatedInfo(diagnostic, ts.createDiagnosticForNode(suggestion.valueDeclaration, ts.Diagnostics._0_is_declared_here, suggestionName));
36751                                 }
36752                             }
36753                         }
36754                         if (!suggestion) {
36755                             if (nameArg) {
36756                                 var lib = getSuggestedLibForNonExistentName(nameArg);
36757                                 if (lib) {
36758                                     error(errorLocation, nameNotFoundMessage, diagnosticName(nameArg), lib);
36759                                 }
36760                                 else {
36761                                     error(errorLocation, nameNotFoundMessage, diagnosticName(nameArg));
36762                                 }
36763                             }
36764                         }
36765                         suggestionCount++;
36766                     }
36767                 }
36768                 return undefined;
36769             }
36770             if (nameNotFoundMessage) {
36771                 if (propertyWithInvalidInitializer && !(compilerOptions.target === 99 && compilerOptions.useDefineForClassFields)) {
36772                     var propertyName = propertyWithInvalidInitializer.name;
36773                     error(errorLocation, ts.Diagnostics.Initializer_of_instance_member_variable_0_cannot_reference_identifier_1_declared_in_the_constructor, ts.declarationNameToString(propertyName), diagnosticName(nameArg));
36774                     return undefined;
36775                 }
36776                 if (errorLocation &&
36777                     (meaning & 2 ||
36778                         ((meaning & 32 || meaning & 384) && (meaning & 111551) === 111551))) {
36779                     var exportOrLocalSymbol = getExportSymbolOfValueSymbolIfExported(result);
36780                     if (exportOrLocalSymbol.flags & 2 || exportOrLocalSymbol.flags & 32 || exportOrLocalSymbol.flags & 384) {
36781                         checkResolvedBlockScopedVariable(exportOrLocalSymbol, errorLocation);
36782                     }
36783                 }
36784                 if (result && isInExternalModule && (meaning & 111551) === 111551 && !(originalLocation.flags & 4194304)) {
36785                     var merged = getMergedSymbol(result);
36786                     if (ts.length(merged.declarations) && ts.every(merged.declarations, function (d) { return ts.isNamespaceExportDeclaration(d) || ts.isSourceFile(d) && !!d.symbol.globalExports; })) {
36787                         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));
36788                     }
36789                 }
36790                 if (result && associatedDeclarationForContainingInitializerOrBindingName && !withinDeferredContext && (meaning & 111551) === 111551) {
36791                     var candidate = getMergedSymbol(getLateBoundSymbol(result));
36792                     var root = ts.getRootDeclaration(associatedDeclarationForContainingInitializerOrBindingName);
36793                     if (candidate === getSymbolOfNode(associatedDeclarationForContainingInitializerOrBindingName)) {
36794                         error(errorLocation, ts.Diagnostics.Parameter_0_cannot_reference_itself, ts.declarationNameToString(associatedDeclarationForContainingInitializerOrBindingName.name));
36795                     }
36796                     else if (candidate.valueDeclaration && candidate.valueDeclaration.pos > associatedDeclarationForContainingInitializerOrBindingName.pos && root.parent.locals && lookup(root.parent.locals, candidate.escapedName, meaning) === candidate) {
36797                         error(errorLocation, ts.Diagnostics.Parameter_0_cannot_reference_identifier_1_declared_after_it, ts.declarationNameToString(associatedDeclarationForContainingInitializerOrBindingName.name), ts.declarationNameToString(errorLocation));
36798                     }
36799                 }
36800                 if (result && errorLocation && meaning & 111551 && result.flags & 2097152) {
36801                     checkSymbolUsageInExpressionContext(result, name, errorLocation);
36802                 }
36803             }
36804             return result;
36805         }
36806         function checkSymbolUsageInExpressionContext(symbol, name, useSite) {
36807             if (!ts.isValidTypeOnlyAliasUseSite(useSite)) {
36808                 var typeOnlyDeclaration = getTypeOnlyAliasDeclaration(symbol);
36809                 if (typeOnlyDeclaration) {
36810                     var isExport = ts.typeOnlyDeclarationIsExport(typeOnlyDeclaration);
36811                     var message = isExport
36812                         ? ts.Diagnostics._0_cannot_be_used_as_a_value_because_it_was_exported_using_export_type
36813                         : ts.Diagnostics._0_cannot_be_used_as_a_value_because_it_was_imported_using_import_type;
36814                     var relatedMessage = isExport
36815                         ? ts.Diagnostics._0_was_exported_here
36816                         : ts.Diagnostics._0_was_imported_here;
36817                     var unescapedName = ts.unescapeLeadingUnderscores(name);
36818                     ts.addRelatedInfo(error(useSite, message, unescapedName), ts.createDiagnosticForNode(typeOnlyDeclaration, relatedMessage, unescapedName));
36819                 }
36820             }
36821         }
36822         function getIsDeferredContext(location, lastLocation) {
36823             if (location.kind !== 209 && location.kind !== 208) {
36824                 return ts.isTypeQueryNode(location) || ((ts.isFunctionLikeDeclaration(location) ||
36825                     (location.kind === 163 && !ts.hasSyntacticModifier(location, 32))) && (!lastLocation || lastLocation !== location.name));
36826             }
36827             if (lastLocation && lastLocation === location.name) {
36828                 return false;
36829             }
36830             if (location.asteriskToken || ts.hasSyntacticModifier(location, 256)) {
36831                 return true;
36832             }
36833             return !ts.getImmediatelyInvokedFunctionExpression(location);
36834         }
36835         function isSelfReferenceLocation(node) {
36836             switch (node.kind) {
36837                 case 251:
36838                 case 252:
36839                 case 253:
36840                 case 255:
36841                 case 254:
36842                 case 256:
36843                     return true;
36844                 default:
36845                     return false;
36846             }
36847         }
36848         function diagnosticName(nameArg) {
36849             return ts.isString(nameArg) ? ts.unescapeLeadingUnderscores(nameArg) : ts.declarationNameToString(nameArg);
36850         }
36851         function isTypeParameterSymbolDeclaredInContainer(symbol, container) {
36852             for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) {
36853                 var decl = _a[_i];
36854                 if (decl.kind === 159) {
36855                     var parent = ts.isJSDocTemplateTag(decl.parent) ? ts.getJSDocHost(decl.parent) : decl.parent;
36856                     if (parent === container) {
36857                         return !(ts.isJSDocTemplateTag(decl.parent) && ts.find(decl.parent.parent.tags, ts.isJSDocTypeAlias));
36858                     }
36859                 }
36860             }
36861             return false;
36862         }
36863         function checkAndReportErrorForMissingPrefix(errorLocation, name, nameArg) {
36864             if (!ts.isIdentifier(errorLocation) || errorLocation.escapedText !== name || isTypeReferenceIdentifier(errorLocation) || isInTypeQuery(errorLocation)) {
36865                 return false;
36866             }
36867             var container = ts.getThisContainer(errorLocation, false);
36868             var location = container;
36869             while (location) {
36870                 if (ts.isClassLike(location.parent)) {
36871                     var classSymbol = getSymbolOfNode(location.parent);
36872                     if (!classSymbol) {
36873                         break;
36874                     }
36875                     var constructorType = getTypeOfSymbol(classSymbol);
36876                     if (getPropertyOfType(constructorType, name)) {
36877                         error(errorLocation, ts.Diagnostics.Cannot_find_name_0_Did_you_mean_the_static_member_1_0, diagnosticName(nameArg), symbolToString(classSymbol));
36878                         return true;
36879                     }
36880                     if (location === container && !ts.hasSyntacticModifier(location, 32)) {
36881                         var instanceType = getDeclaredTypeOfSymbol(classSymbol).thisType;
36882                         if (getPropertyOfType(instanceType, name)) {
36883                             error(errorLocation, ts.Diagnostics.Cannot_find_name_0_Did_you_mean_the_instance_member_this_0, diagnosticName(nameArg));
36884                             return true;
36885                         }
36886                     }
36887                 }
36888                 location = location.parent;
36889             }
36890             return false;
36891         }
36892         function checkAndReportErrorForExtendingInterface(errorLocation) {
36893             var expression = getEntityNameForExtendingInterface(errorLocation);
36894             if (expression && resolveEntityName(expression, 64, true)) {
36895                 error(errorLocation, ts.Diagnostics.Cannot_extend_an_interface_0_Did_you_mean_implements, ts.getTextOfNode(expression));
36896                 return true;
36897             }
36898             return false;
36899         }
36900         function getEntityNameForExtendingInterface(node) {
36901             switch (node.kind) {
36902                 case 78:
36903                 case 201:
36904                     return node.parent ? getEntityNameForExtendingInterface(node.parent) : undefined;
36905                 case 223:
36906                     if (ts.isEntityNameExpression(node.expression)) {
36907                         return node.expression;
36908                     }
36909                 default:
36910                     return undefined;
36911             }
36912         }
36913         function checkAndReportErrorForUsingTypeAsNamespace(errorLocation, name, meaning) {
36914             var namespaceMeaning = 1920 | (ts.isInJSFile(errorLocation) ? 111551 : 0);
36915             if (meaning === namespaceMeaning) {
36916                 var symbol = resolveSymbol(resolveName(errorLocation, name, 788968 & ~namespaceMeaning, undefined, undefined, false));
36917                 var parent = errorLocation.parent;
36918                 if (symbol) {
36919                     if (ts.isQualifiedName(parent)) {
36920                         ts.Debug.assert(parent.left === errorLocation, "Should only be resolving left side of qualified name as a namespace");
36921                         var propName = parent.right.escapedText;
36922                         var propType = getPropertyOfType(getDeclaredTypeOfSymbol(symbol), propName);
36923                         if (propType) {
36924                             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));
36925                             return true;
36926                         }
36927                     }
36928                     error(errorLocation, ts.Diagnostics._0_only_refers_to_a_type_but_is_being_used_as_a_namespace_here, ts.unescapeLeadingUnderscores(name));
36929                     return true;
36930                 }
36931             }
36932             return false;
36933         }
36934         function checkAndReportErrorForUsingValueAsType(errorLocation, name, meaning) {
36935             if (meaning & (788968 & ~1920)) {
36936                 var symbol = resolveSymbol(resolveName(errorLocation, name, ~788968 & 111551, undefined, undefined, false));
36937                 if (symbol && !(symbol.flags & 1920)) {
36938                     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));
36939                     return true;
36940                 }
36941             }
36942             return false;
36943         }
36944         function isPrimitiveTypeName(name) {
36945             return name === "any" || name === "string" || name === "number" || name === "boolean" || name === "never" || name === "unknown";
36946         }
36947         function checkAndReportErrorForExportingPrimitiveType(errorLocation, name) {
36948             if (isPrimitiveTypeName(name) && errorLocation.parent.kind === 270) {
36949                 error(errorLocation, ts.Diagnostics.Cannot_export_0_Only_local_declarations_can_be_exported_from_a_module, name);
36950                 return true;
36951             }
36952             return false;
36953         }
36954         function checkAndReportErrorForUsingTypeAsValue(errorLocation, name, meaning) {
36955             if (meaning & (111551 & ~1024)) {
36956                 if (isPrimitiveTypeName(name)) {
36957                     error(errorLocation, ts.Diagnostics._0_only_refers_to_a_type_but_is_being_used_as_a_value_here, ts.unescapeLeadingUnderscores(name));
36958                     return true;
36959                 }
36960                 var symbol = resolveSymbol(resolveName(errorLocation, name, 788968 & ~111551, undefined, undefined, false));
36961                 if (symbol && !(symbol.flags & 1024)) {
36962                     var rawName = ts.unescapeLeadingUnderscores(name);
36963                     if (isES2015OrLaterConstructorName(name)) {
36964                         error(errorLocation, 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, rawName);
36965                     }
36966                     else if (maybeMappedType(errorLocation, symbol)) {
36967                         error(errorLocation, ts.Diagnostics._0_only_refers_to_a_type_but_is_being_used_as_a_value_here_Did_you_mean_to_use_1_in_0, rawName, rawName === "K" ? "P" : "K");
36968                     }
36969                     else {
36970                         error(errorLocation, ts.Diagnostics._0_only_refers_to_a_type_but_is_being_used_as_a_value_here, rawName);
36971                     }
36972                     return true;
36973                 }
36974             }
36975             return false;
36976         }
36977         function maybeMappedType(node, symbol) {
36978             var container = ts.findAncestor(node.parent, function (n) {
36979                 return ts.isComputedPropertyName(n) || ts.isPropertySignature(n) ? false : ts.isTypeLiteralNode(n) || "quit";
36980             });
36981             if (container && container.members.length === 1) {
36982                 var type = getDeclaredTypeOfSymbol(symbol);
36983                 return !!(type.flags & 1048576) && allTypesAssignableToKind(type, 384, true);
36984             }
36985             return false;
36986         }
36987         function isES2015OrLaterConstructorName(n) {
36988             switch (n) {
36989                 case "Promise":
36990                 case "Symbol":
36991                 case "Map":
36992                 case "WeakMap":
36993                 case "Set":
36994                 case "WeakSet":
36995                     return true;
36996             }
36997             return false;
36998         }
36999         function checkAndReportErrorForUsingNamespaceModuleAsValue(errorLocation, name, meaning) {
37000             if (meaning & (111551 & ~1024 & ~788968)) {
37001                 var symbol = resolveSymbol(resolveName(errorLocation, name, 1024 & ~111551, undefined, undefined, false));
37002                 if (symbol) {
37003                     error(errorLocation, ts.Diagnostics.Cannot_use_namespace_0_as_a_value, ts.unescapeLeadingUnderscores(name));
37004                     return true;
37005                 }
37006             }
37007             else if (meaning & (788968 & ~1024 & ~111551)) {
37008                 var symbol = resolveSymbol(resolveName(errorLocation, name, (512 | 1024) & ~788968, undefined, undefined, false));
37009                 if (symbol) {
37010                     error(errorLocation, ts.Diagnostics.Cannot_use_namespace_0_as_a_type, ts.unescapeLeadingUnderscores(name));
37011                     return true;
37012                 }
37013             }
37014             return false;
37015         }
37016         function checkResolvedBlockScopedVariable(result, errorLocation) {
37017             ts.Debug.assert(!!(result.flags & 2 || result.flags & 32 || result.flags & 384));
37018             if (result.flags & (16 | 1 | 67108864) && result.flags & 32) {
37019                 return;
37020             }
37021             var declaration = ts.find(result.declarations, function (d) { return ts.isBlockOrCatchScoped(d) || ts.isClassLike(d) || (d.kind === 255); });
37022             if (declaration === undefined)
37023                 return ts.Debug.fail("checkResolvedBlockScopedVariable could not find block-scoped declaration");
37024             if (!(declaration.flags & 8388608) && !isBlockScopedNameDeclaredBeforeUse(declaration, errorLocation)) {
37025                 var diagnosticMessage = void 0;
37026                 var declarationName = ts.declarationNameToString(ts.getNameOfDeclaration(declaration));
37027                 if (result.flags & 2) {
37028                     diagnosticMessage = error(errorLocation, ts.Diagnostics.Block_scoped_variable_0_used_before_its_declaration, declarationName);
37029                 }
37030                 else if (result.flags & 32) {
37031                     diagnosticMessage = error(errorLocation, ts.Diagnostics.Class_0_used_before_its_declaration, declarationName);
37032                 }
37033                 else if (result.flags & 256) {
37034                     diagnosticMessage = error(errorLocation, ts.Diagnostics.Enum_0_used_before_its_declaration, declarationName);
37035                 }
37036                 else {
37037                     ts.Debug.assert(!!(result.flags & 128));
37038                     if (compilerOptions.preserveConstEnums) {
37039                         diagnosticMessage = error(errorLocation, ts.Diagnostics.Enum_0_used_before_its_declaration, declarationName);
37040                     }
37041                 }
37042                 if (diagnosticMessage) {
37043                     ts.addRelatedInfo(diagnosticMessage, ts.createDiagnosticForNode(declaration, ts.Diagnostics._0_is_declared_here, declarationName));
37044                 }
37045             }
37046         }
37047         function isSameScopeDescendentOf(initial, parent, stopAt) {
37048             return !!parent && !!ts.findAncestor(initial, function (n) { return n === stopAt || ts.isFunctionLike(n) ? "quit" : n === parent; });
37049         }
37050         function getAnyImportSyntax(node) {
37051             switch (node.kind) {
37052                 case 260:
37053                     return node;
37054                 case 262:
37055                     return node.parent;
37056                 case 263:
37057                     return node.parent.parent;
37058                 case 265:
37059                     return node.parent.parent.parent;
37060                 default:
37061                     return undefined;
37062             }
37063         }
37064         function getDeclarationOfAliasSymbol(symbol) {
37065             return ts.find(symbol.declarations, isAliasSymbolDeclaration);
37066         }
37067         function isAliasSymbolDeclaration(node) {
37068             return node.kind === 260
37069                 || node.kind === 259
37070                 || node.kind === 262 && !!node.name
37071                 || node.kind === 263
37072                 || node.kind === 269
37073                 || node.kind === 265
37074                 || node.kind === 270
37075                 || node.kind === 266 && ts.exportAssignmentIsAlias(node)
37076                 || ts.isBinaryExpression(node) && ts.getAssignmentDeclarationKind(node) === 2 && ts.exportAssignmentIsAlias(node)
37077                 || ts.isAccessExpression(node)
37078                     && ts.isBinaryExpression(node.parent)
37079                     && node.parent.left === node
37080                     && node.parent.operatorToken.kind === 62
37081                     && isAliasableOrJsExpression(node.parent.right)
37082                 || node.kind === 289
37083                 || node.kind === 288 && isAliasableOrJsExpression(node.initializer)
37084                 || ts.isRequireVariableDeclaration(node, true);
37085         }
37086         function isAliasableOrJsExpression(e) {
37087             return ts.isAliasableExpression(e) || ts.isFunctionExpression(e) && isJSConstructor(e);
37088         }
37089         function getTargetOfImportEqualsDeclaration(node, dontResolveAlias) {
37090             var commonJSPropertyAccess = getCommonJSPropertyAccess(node);
37091             if (commonJSPropertyAccess) {
37092                 var name = ts.getLeftmostAccessExpression(commonJSPropertyAccess.expression).arguments[0];
37093                 return ts.isIdentifier(commonJSPropertyAccess.name)
37094                     ? resolveSymbol(getPropertyOfType(resolveExternalModuleTypeByLiteral(name), commonJSPropertyAccess.name.escapedText))
37095                     : undefined;
37096             }
37097             if (ts.isVariableDeclaration(node) || node.moduleReference.kind === 272) {
37098                 var immediate = resolveExternalModuleName(node, ts.getExternalModuleRequireArgument(node) || ts.getExternalModuleImportEqualsDeclarationExpression(node));
37099                 var resolved_4 = resolveExternalModuleSymbol(immediate);
37100                 markSymbolOfAliasDeclarationIfTypeOnly(node, immediate, resolved_4, false);
37101                 return resolved_4;
37102             }
37103             var resolved = getSymbolOfPartOfRightHandSideOfImportEquals(node.moduleReference, dontResolveAlias);
37104             checkAndReportErrorForResolvingImportAliasToTypeOnlySymbol(node, resolved);
37105             return resolved;
37106         }
37107         function checkAndReportErrorForResolvingImportAliasToTypeOnlySymbol(node, resolved) {
37108             if (markSymbolOfAliasDeclarationIfTypeOnly(node, undefined, resolved, false)) {
37109                 var typeOnlyDeclaration = getTypeOnlyAliasDeclaration(getSymbolOfNode(node));
37110                 var isExport = ts.typeOnlyDeclarationIsExport(typeOnlyDeclaration);
37111                 var message = isExport
37112                     ? ts.Diagnostics.An_import_alias_cannot_reference_a_declaration_that_was_exported_using_export_type
37113                     : ts.Diagnostics.An_import_alias_cannot_reference_a_declaration_that_was_imported_using_import_type;
37114                 var relatedMessage = isExport
37115                     ? ts.Diagnostics._0_was_exported_here
37116                     : ts.Diagnostics._0_was_imported_here;
37117                 var name = ts.unescapeLeadingUnderscores(typeOnlyDeclaration.name.escapedText);
37118                 ts.addRelatedInfo(error(node.moduleReference, message), ts.createDiagnosticForNode(typeOnlyDeclaration, relatedMessage, name));
37119             }
37120         }
37121         function resolveExportByName(moduleSymbol, name, sourceNode, dontResolveAlias) {
37122             var exportValue = moduleSymbol.exports.get("export=");
37123             var exportSymbol = exportValue ? getPropertyOfType(getTypeOfSymbol(exportValue), name) : moduleSymbol.exports.get(name);
37124             var resolved = resolveSymbol(exportSymbol, dontResolveAlias);
37125             markSymbolOfAliasDeclarationIfTypeOnly(sourceNode, exportSymbol, resolved, false);
37126             return resolved;
37127         }
37128         function isSyntacticDefault(node) {
37129             return ((ts.isExportAssignment(node) && !node.isExportEquals) || ts.hasSyntacticModifier(node, 512) || ts.isExportSpecifier(node));
37130         }
37131         function canHaveSyntheticDefault(file, moduleSymbol, dontResolveAlias) {
37132             if (!allowSyntheticDefaultImports) {
37133                 return false;
37134             }
37135             if (!file || file.isDeclarationFile) {
37136                 var defaultExportSymbol = resolveExportByName(moduleSymbol, "default", undefined, true);
37137                 if (defaultExportSymbol && ts.some(defaultExportSymbol.declarations, isSyntacticDefault)) {
37138                     return false;
37139                 }
37140                 if (resolveExportByName(moduleSymbol, ts.escapeLeadingUnderscores("__esModule"), undefined, dontResolveAlias)) {
37141                     return false;
37142                 }
37143                 return true;
37144             }
37145             if (!ts.isSourceFileJS(file)) {
37146                 return hasExportAssignmentSymbol(moduleSymbol);
37147             }
37148             return !file.externalModuleIndicator && !resolveExportByName(moduleSymbol, ts.escapeLeadingUnderscores("__esModule"), undefined, dontResolveAlias);
37149         }
37150         function getTargetOfImportClause(node, dontResolveAlias) {
37151             var moduleSymbol = resolveExternalModuleName(node, node.parent.moduleSpecifier);
37152             if (moduleSymbol) {
37153                 var exportDefaultSymbol = void 0;
37154                 if (ts.isShorthandAmbientModuleSymbol(moduleSymbol)) {
37155                     exportDefaultSymbol = moduleSymbol;
37156                 }
37157                 else {
37158                     exportDefaultSymbol = resolveExportByName(moduleSymbol, "default", node, dontResolveAlias);
37159                 }
37160                 var file = ts.find(moduleSymbol.declarations, ts.isSourceFile);
37161                 var hasSyntheticDefault = canHaveSyntheticDefault(file, moduleSymbol, dontResolveAlias);
37162                 if (!exportDefaultSymbol && !hasSyntheticDefault) {
37163                     if (hasExportAssignmentSymbol(moduleSymbol)) {
37164                         var compilerOptionName = moduleKind >= ts.ModuleKind.ES2015 ? "allowSyntheticDefaultImports" : "esModuleInterop";
37165                         var exportEqualsSymbol = moduleSymbol.exports.get("export=");
37166                         var exportAssignment = exportEqualsSymbol.valueDeclaration;
37167                         var err = error(node.name, ts.Diagnostics.Module_0_can_only_be_default_imported_using_the_1_flag, symbolToString(moduleSymbol), compilerOptionName);
37168                         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));
37169                     }
37170                     else {
37171                         reportNonDefaultExport(moduleSymbol, node);
37172                     }
37173                 }
37174                 else if (hasSyntheticDefault) {
37175                     var resolved = resolveExternalModuleSymbol(moduleSymbol, dontResolveAlias) || resolveSymbol(moduleSymbol, dontResolveAlias);
37176                     markSymbolOfAliasDeclarationIfTypeOnly(node, moduleSymbol, resolved, false);
37177                     return resolved;
37178                 }
37179                 markSymbolOfAliasDeclarationIfTypeOnly(node, exportDefaultSymbol, undefined, false);
37180                 return exportDefaultSymbol;
37181             }
37182         }
37183         function reportNonDefaultExport(moduleSymbol, node) {
37184             var _a, _b;
37185             if ((_a = moduleSymbol.exports) === null || _a === void 0 ? void 0 : _a.has(node.symbol.escapedName)) {
37186                 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));
37187             }
37188             else {
37189                 var diagnostic = error(node.name, ts.Diagnostics.Module_0_has_no_default_export, symbolToString(moduleSymbol));
37190                 var exportStar = (_b = moduleSymbol.exports) === null || _b === void 0 ? void 0 : _b.get("__export");
37191                 if (exportStar) {
37192                     var defaultExport = ts.find(exportStar.declarations, function (decl) {
37193                         var _a, _b;
37194                         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")));
37195                     });
37196                     if (defaultExport) {
37197                         ts.addRelatedInfo(diagnostic, ts.createDiagnosticForNode(defaultExport, ts.Diagnostics.export_Asterisk_does_not_re_export_a_default));
37198                     }
37199                 }
37200             }
37201         }
37202         function getTargetOfNamespaceImport(node, dontResolveAlias) {
37203             var moduleSpecifier = node.parent.parent.moduleSpecifier;
37204             var immediate = resolveExternalModuleName(node, moduleSpecifier);
37205             var resolved = resolveESModuleSymbol(immediate, moduleSpecifier, dontResolveAlias, false);
37206             markSymbolOfAliasDeclarationIfTypeOnly(node, immediate, resolved, false);
37207             return resolved;
37208         }
37209         function getTargetOfNamespaceExport(node, dontResolveAlias) {
37210             var moduleSpecifier = node.parent.moduleSpecifier;
37211             var immediate = moduleSpecifier && resolveExternalModuleName(node, moduleSpecifier);
37212             var resolved = moduleSpecifier && resolveESModuleSymbol(immediate, moduleSpecifier, dontResolveAlias, false);
37213             markSymbolOfAliasDeclarationIfTypeOnly(node, immediate, resolved, false);
37214             return resolved;
37215         }
37216         function combineValueAndTypeSymbols(valueSymbol, typeSymbol) {
37217             if (valueSymbol === unknownSymbol && typeSymbol === unknownSymbol) {
37218                 return unknownSymbol;
37219             }
37220             if (valueSymbol.flags & (788968 | 1920)) {
37221                 return valueSymbol;
37222             }
37223             var result = createSymbol(valueSymbol.flags | typeSymbol.flags, valueSymbol.escapedName);
37224             result.declarations = ts.deduplicate(ts.concatenate(valueSymbol.declarations, typeSymbol.declarations), ts.equateValues);
37225             result.parent = valueSymbol.parent || typeSymbol.parent;
37226             if (valueSymbol.valueDeclaration)
37227                 result.valueDeclaration = valueSymbol.valueDeclaration;
37228             if (typeSymbol.members)
37229                 result.members = new ts.Map(typeSymbol.members);
37230             if (valueSymbol.exports)
37231                 result.exports = new ts.Map(valueSymbol.exports);
37232             return result;
37233         }
37234         function getExportOfModule(symbol, name, specifier, dontResolveAlias) {
37235             if (symbol.flags & 1536) {
37236                 var exportSymbol = getExportsOfSymbol(symbol).get(name.escapedText);
37237                 var resolved = resolveSymbol(exportSymbol, dontResolveAlias);
37238                 markSymbolOfAliasDeclarationIfTypeOnly(specifier, exportSymbol, resolved, false);
37239                 return resolved;
37240             }
37241         }
37242         function getPropertyOfVariable(symbol, name) {
37243             if (symbol.flags & 3) {
37244                 var typeAnnotation = symbol.valueDeclaration.type;
37245                 if (typeAnnotation) {
37246                     return resolveSymbol(getPropertyOfType(getTypeFromTypeNode(typeAnnotation), name));
37247                 }
37248             }
37249         }
37250         function getExternalModuleMember(node, specifier, dontResolveAlias) {
37251             var _a;
37252             if (dontResolveAlias === void 0) { dontResolveAlias = false; }
37253             var moduleSpecifier = ts.getExternalModuleRequireArgument(node) || node.moduleSpecifier;
37254             var moduleSymbol = resolveExternalModuleName(node, moduleSpecifier);
37255             var name = !ts.isPropertyAccessExpression(specifier) && specifier.propertyName || specifier.name;
37256             if (!ts.isIdentifier(name)) {
37257                 return undefined;
37258             }
37259             var suppressInteropError = name.escapedText === "default" && !!(compilerOptions.allowSyntheticDefaultImports || compilerOptions.esModuleInterop);
37260             var targetSymbol = resolveESModuleSymbol(moduleSymbol, moduleSpecifier, dontResolveAlias, suppressInteropError);
37261             if (targetSymbol) {
37262                 if (name.escapedText) {
37263                     if (ts.isShorthandAmbientModuleSymbol(moduleSymbol)) {
37264                         return moduleSymbol;
37265                     }
37266                     var symbolFromVariable = void 0;
37267                     if (moduleSymbol && moduleSymbol.exports && moduleSymbol.exports.get("export=")) {
37268                         symbolFromVariable = getPropertyOfType(getTypeOfSymbol(targetSymbol), name.escapedText);
37269                     }
37270                     else {
37271                         symbolFromVariable = getPropertyOfVariable(targetSymbol, name.escapedText);
37272                     }
37273                     symbolFromVariable = resolveSymbol(symbolFromVariable, dontResolveAlias);
37274                     var symbolFromModule = getExportOfModule(targetSymbol, name, specifier, dontResolveAlias);
37275                     if (symbolFromModule === undefined && name.escapedText === "default") {
37276                         var file = ts.find(moduleSymbol.declarations, ts.isSourceFile);
37277                         if (canHaveSyntheticDefault(file, moduleSymbol, dontResolveAlias)) {
37278                             symbolFromModule = resolveExternalModuleSymbol(moduleSymbol, dontResolveAlias) || resolveSymbol(moduleSymbol, dontResolveAlias);
37279                         }
37280                     }
37281                     var symbol = symbolFromModule && symbolFromVariable && symbolFromModule !== symbolFromVariable ?
37282                         combineValueAndTypeSymbols(symbolFromVariable, symbolFromModule) :
37283                         symbolFromModule || symbolFromVariable;
37284                     if (!symbol) {
37285                         var moduleName = getFullyQualifiedName(moduleSymbol, node);
37286                         var declarationName = ts.declarationNameToString(name);
37287                         var suggestion = getSuggestedSymbolForNonexistentModule(name, targetSymbol);
37288                         if (suggestion !== undefined) {
37289                             var suggestionName = symbolToString(suggestion);
37290                             var diagnostic = error(name, ts.Diagnostics._0_has_no_exported_member_named_1_Did_you_mean_2, moduleName, declarationName, suggestionName);
37291                             if (suggestion.valueDeclaration) {
37292                                 ts.addRelatedInfo(diagnostic, ts.createDiagnosticForNode(suggestion.valueDeclaration, ts.Diagnostics._0_is_declared_here, suggestionName));
37293                             }
37294                         }
37295                         else {
37296                             if ((_a = moduleSymbol.exports) === null || _a === void 0 ? void 0 : _a.has("default")) {
37297                                 error(name, ts.Diagnostics.Module_0_has_no_exported_member_1_Did_you_mean_to_use_import_1_from_0_instead, moduleName, declarationName);
37298                             }
37299                             else {
37300                                 reportNonExportedMember(node, name, declarationName, moduleSymbol, moduleName);
37301                             }
37302                         }
37303                     }
37304                     return symbol;
37305                 }
37306             }
37307         }
37308         function reportNonExportedMember(node, name, declarationName, moduleSymbol, moduleName) {
37309             var _a;
37310             var localSymbol = (_a = moduleSymbol.valueDeclaration.locals) === null || _a === void 0 ? void 0 : _a.get(name.escapedText);
37311             var exports = moduleSymbol.exports;
37312             if (localSymbol) {
37313                 var exportedEqualsSymbol = exports === null || exports === void 0 ? void 0 : exports.get("export=");
37314                 if (exportedEqualsSymbol) {
37315                     getSymbolIfSameReference(exportedEqualsSymbol, localSymbol) ? reportInvalidImportEqualsExportMember(node, name, declarationName, moduleName) :
37316                         error(name, ts.Diagnostics.Module_0_has_no_exported_member_1, moduleName, declarationName);
37317                 }
37318                 else {
37319                     var exportedSymbol = exports ? ts.find(symbolsToArray(exports), function (symbol) { return !!getSymbolIfSameReference(symbol, localSymbol); }) : undefined;
37320                     var diagnostic = exportedSymbol ? error(name, ts.Diagnostics.Module_0_declares_1_locally_but_it_is_exported_as_2, moduleName, declarationName, symbolToString(exportedSymbol)) :
37321                         error(name, ts.Diagnostics.Module_0_declares_1_locally_but_it_is_not_exported, moduleName, declarationName);
37322                     ts.addRelatedInfo.apply(void 0, __spreadArrays([diagnostic], ts.map(localSymbol.declarations, function (decl, index) {
37323                         return ts.createDiagnosticForNode(decl, index === 0 ? ts.Diagnostics._0_is_declared_here : ts.Diagnostics.and_here, declarationName);
37324                     })));
37325                 }
37326             }
37327             else {
37328                 error(name, ts.Diagnostics.Module_0_has_no_exported_member_1, moduleName, declarationName);
37329             }
37330         }
37331         function reportInvalidImportEqualsExportMember(node, name, declarationName, moduleName) {
37332             if (moduleKind >= ts.ModuleKind.ES2015) {
37333                 var message = compilerOptions.esModuleInterop ? ts.Diagnostics._0_can_only_be_imported_by_using_a_default_import :
37334                     ts.Diagnostics._0_can_only_be_imported_by_turning_on_the_esModuleInterop_flag_and_using_a_default_import;
37335                 error(name, message, declarationName);
37336             }
37337             else {
37338                 if (ts.isInJSFile(node)) {
37339                     var message = compilerOptions.esModuleInterop ? ts.Diagnostics._0_can_only_be_imported_by_using_a_require_call_or_by_using_a_default_import :
37340                         ts.Diagnostics._0_can_only_be_imported_by_using_a_require_call_or_by_turning_on_the_esModuleInterop_flag_and_using_a_default_import;
37341                     error(name, message, declarationName);
37342                 }
37343                 else {
37344                     var message = compilerOptions.esModuleInterop ? ts.Diagnostics._0_can_only_be_imported_by_using_import_1_require_2_or_a_default_import :
37345                         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;
37346                     error(name, message, declarationName, declarationName, moduleName);
37347                 }
37348             }
37349         }
37350         function getTargetOfImportSpecifier(node, dontResolveAlias) {
37351             var root = ts.isBindingElement(node) ? ts.getRootDeclaration(node) : node.parent.parent.parent;
37352             var commonJSPropertyAccess = getCommonJSPropertyAccess(root);
37353             var resolved = getExternalModuleMember(root, commonJSPropertyAccess || node, dontResolveAlias);
37354             var name = node.propertyName || node.name;
37355             if (commonJSPropertyAccess && resolved && ts.isIdentifier(name)) {
37356                 return resolveSymbol(getPropertyOfType(getTypeOfSymbol(resolved), name.escapedText), dontResolveAlias);
37357             }
37358             markSymbolOfAliasDeclarationIfTypeOnly(node, undefined, resolved, false);
37359             return resolved;
37360         }
37361         function getCommonJSPropertyAccess(node) {
37362             if (ts.isVariableDeclaration(node) && node.initializer && ts.isPropertyAccessExpression(node.initializer)) {
37363                 return node.initializer;
37364             }
37365         }
37366         function getTargetOfNamespaceExportDeclaration(node, dontResolveAlias) {
37367             var resolved = resolveExternalModuleSymbol(node.parent.symbol, dontResolveAlias);
37368             markSymbolOfAliasDeclarationIfTypeOnly(node, undefined, resolved, false);
37369             return resolved;
37370         }
37371         function getTargetOfExportSpecifier(node, meaning, dontResolveAlias) {
37372             var resolved = node.parent.parent.moduleSpecifier ?
37373                 getExternalModuleMember(node.parent.parent, node, dontResolveAlias) :
37374                 resolveEntityName(node.propertyName || node.name, meaning, false, dontResolveAlias);
37375             markSymbolOfAliasDeclarationIfTypeOnly(node, undefined, resolved, false);
37376             return resolved;
37377         }
37378         function getTargetOfExportAssignment(node, dontResolveAlias) {
37379             var expression = ts.isExportAssignment(node) ? node.expression : node.right;
37380             var resolved = getTargetOfAliasLikeExpression(expression, dontResolveAlias);
37381             markSymbolOfAliasDeclarationIfTypeOnly(node, undefined, resolved, false);
37382             return resolved;
37383         }
37384         function getTargetOfAliasLikeExpression(expression, dontResolveAlias) {
37385             if (ts.isClassExpression(expression)) {
37386                 return checkExpressionCached(expression).symbol;
37387             }
37388             if (!ts.isEntityName(expression) && !ts.isEntityNameExpression(expression)) {
37389                 return undefined;
37390             }
37391             var aliasLike = resolveEntityName(expression, 111551 | 788968 | 1920, true, dontResolveAlias);
37392             if (aliasLike) {
37393                 return aliasLike;
37394             }
37395             checkExpressionCached(expression);
37396             return getNodeLinks(expression).resolvedSymbol;
37397         }
37398         function getTargetOfPropertyAssignment(node, dontRecursivelyResolve) {
37399             var expression = node.initializer;
37400             return getTargetOfAliasLikeExpression(expression, dontRecursivelyResolve);
37401         }
37402         function getTargetOfAccessExpression(node, dontRecursivelyResolve) {
37403             if (!(ts.isBinaryExpression(node.parent) && node.parent.left === node && node.parent.operatorToken.kind === 62)) {
37404                 return undefined;
37405             }
37406             return getTargetOfAliasLikeExpression(node.parent.right, dontRecursivelyResolve);
37407         }
37408         function getTargetOfAliasDeclaration(node, dontRecursivelyResolve) {
37409             if (dontRecursivelyResolve === void 0) { dontRecursivelyResolve = false; }
37410             switch (node.kind) {
37411                 case 260:
37412                 case 249:
37413                     return getTargetOfImportEqualsDeclaration(node, dontRecursivelyResolve);
37414                 case 262:
37415                     return getTargetOfImportClause(node, dontRecursivelyResolve);
37416                 case 263:
37417                     return getTargetOfNamespaceImport(node, dontRecursivelyResolve);
37418                 case 269:
37419                     return getTargetOfNamespaceExport(node, dontRecursivelyResolve);
37420                 case 265:
37421                 case 198:
37422                     return getTargetOfImportSpecifier(node, dontRecursivelyResolve);
37423                 case 270:
37424                     return getTargetOfExportSpecifier(node, 111551 | 788968 | 1920, dontRecursivelyResolve);
37425                 case 266:
37426                 case 216:
37427                     return getTargetOfExportAssignment(node, dontRecursivelyResolve);
37428                 case 259:
37429                     return getTargetOfNamespaceExportDeclaration(node, dontRecursivelyResolve);
37430                 case 289:
37431                     return resolveEntityName(node.name, 111551 | 788968 | 1920, true, dontRecursivelyResolve);
37432                 case 288:
37433                     return getTargetOfPropertyAssignment(node, dontRecursivelyResolve);
37434                 case 202:
37435                 case 201:
37436                     return getTargetOfAccessExpression(node, dontRecursivelyResolve);
37437                 default:
37438                     return ts.Debug.fail();
37439             }
37440         }
37441         function isNonLocalAlias(symbol, excludes) {
37442             if (excludes === void 0) { excludes = 111551 | 788968 | 1920; }
37443             if (!symbol)
37444                 return false;
37445             return (symbol.flags & (2097152 | excludes)) === 2097152 || !!(symbol.flags & 2097152 && symbol.flags & 67108864);
37446         }
37447         function resolveSymbol(symbol, dontResolveAlias) {
37448             return !dontResolveAlias && isNonLocalAlias(symbol) ? resolveAlias(symbol) : symbol;
37449         }
37450         function resolveAlias(symbol) {
37451             ts.Debug.assert((symbol.flags & 2097152) !== 0, "Should only get Alias here.");
37452             var links = getSymbolLinks(symbol);
37453             if (!links.target) {
37454                 links.target = resolvingSymbol;
37455                 var node = getDeclarationOfAliasSymbol(symbol);
37456                 if (!node)
37457                     return ts.Debug.fail();
37458                 var target = getTargetOfAliasDeclaration(node);
37459                 if (links.target === resolvingSymbol) {
37460                     links.target = target || unknownSymbol;
37461                 }
37462                 else {
37463                     error(node, ts.Diagnostics.Circular_definition_of_import_alias_0, symbolToString(symbol));
37464                 }
37465             }
37466             else if (links.target === resolvingSymbol) {
37467                 links.target = unknownSymbol;
37468             }
37469             return links.target;
37470         }
37471         function tryResolveAlias(symbol) {
37472             var links = getSymbolLinks(symbol);
37473             if (links.target !== resolvingSymbol) {
37474                 return resolveAlias(symbol);
37475             }
37476             return undefined;
37477         }
37478         function markSymbolOfAliasDeclarationIfTypeOnly(aliasDeclaration, immediateTarget, finalTarget, overwriteEmpty) {
37479             if (!aliasDeclaration || ts.isPropertyAccessExpression(aliasDeclaration))
37480                 return false;
37481             var sourceSymbol = getSymbolOfNode(aliasDeclaration);
37482             if (ts.isTypeOnlyImportOrExportDeclaration(aliasDeclaration)) {
37483                 var links_1 = getSymbolLinks(sourceSymbol);
37484                 links_1.typeOnlyDeclaration = aliasDeclaration;
37485                 return true;
37486             }
37487             var links = getSymbolLinks(sourceSymbol);
37488             return markSymbolOfAliasDeclarationIfTypeOnlyWorker(links, immediateTarget, overwriteEmpty)
37489                 || markSymbolOfAliasDeclarationIfTypeOnlyWorker(links, finalTarget, overwriteEmpty);
37490         }
37491         function markSymbolOfAliasDeclarationIfTypeOnlyWorker(aliasDeclarationLinks, target, overwriteEmpty) {
37492             var _a, _b, _c;
37493             if (target && (aliasDeclarationLinks.typeOnlyDeclaration === undefined || overwriteEmpty && aliasDeclarationLinks.typeOnlyDeclaration === false)) {
37494                 var exportSymbol = (_b = (_a = target.exports) === null || _a === void 0 ? void 0 : _a.get("export=")) !== null && _b !== void 0 ? _b : target;
37495                 var typeOnly = exportSymbol.declarations && ts.find(exportSymbol.declarations, ts.isTypeOnlyImportOrExportDeclaration);
37496                 aliasDeclarationLinks.typeOnlyDeclaration = (_c = typeOnly !== null && typeOnly !== void 0 ? typeOnly : getSymbolLinks(exportSymbol).typeOnlyDeclaration) !== null && _c !== void 0 ? _c : false;
37497             }
37498             return !!aliasDeclarationLinks.typeOnlyDeclaration;
37499         }
37500         function getTypeOnlyAliasDeclaration(symbol) {
37501             if (!(symbol.flags & 2097152)) {
37502                 return undefined;
37503             }
37504             var links = getSymbolLinks(symbol);
37505             return links.typeOnlyDeclaration || undefined;
37506         }
37507         function markExportAsReferenced(node) {
37508             var symbol = getSymbolOfNode(node);
37509             var target = resolveAlias(symbol);
37510             if (target) {
37511                 var markAlias = target === unknownSymbol ||
37512                     ((target.flags & 111551) && !isConstEnumOrConstEnumOnlyModule(target) && !getTypeOnlyAliasDeclaration(symbol));
37513                 if (markAlias) {
37514                     markAliasSymbolAsReferenced(symbol);
37515                 }
37516             }
37517         }
37518         function markAliasSymbolAsReferenced(symbol) {
37519             var links = getSymbolLinks(symbol);
37520             if (!links.referenced) {
37521                 links.referenced = true;
37522                 var node = getDeclarationOfAliasSymbol(symbol);
37523                 if (!node)
37524                     return ts.Debug.fail();
37525                 if (ts.isInternalModuleImportEqualsDeclaration(node)) {
37526                     var target = resolveSymbol(symbol);
37527                     if (target === unknownSymbol || target.flags & 111551) {
37528                         checkExpressionCached(node.moduleReference);
37529                     }
37530                 }
37531             }
37532         }
37533         function markConstEnumAliasAsReferenced(symbol) {
37534             var links = getSymbolLinks(symbol);
37535             if (!links.constEnumReferenced) {
37536                 links.constEnumReferenced = true;
37537             }
37538         }
37539         function getSymbolOfPartOfRightHandSideOfImportEquals(entityName, dontResolveAlias) {
37540             if (entityName.kind === 78 && ts.isRightSideOfQualifiedNameOrPropertyAccess(entityName)) {
37541                 entityName = entityName.parent;
37542             }
37543             if (entityName.kind === 78 || entityName.parent.kind === 157) {
37544                 return resolveEntityName(entityName, 1920, false, dontResolveAlias);
37545             }
37546             else {
37547                 ts.Debug.assert(entityName.parent.kind === 260);
37548                 return resolveEntityName(entityName, 111551 | 788968 | 1920, false, dontResolveAlias);
37549             }
37550         }
37551         function getFullyQualifiedName(symbol, containingLocation) {
37552             return symbol.parent ? getFullyQualifiedName(symbol.parent, containingLocation) + "." + symbolToString(symbol) : symbolToString(symbol, containingLocation, undefined, 16 | 4);
37553         }
37554         function resolveEntityName(name, meaning, ignoreErrors, dontResolveAlias, location) {
37555             if (ts.nodeIsMissing(name)) {
37556                 return undefined;
37557             }
37558             var namespaceMeaning = 1920 | (ts.isInJSFile(name) ? meaning & 111551 : 0);
37559             var symbol;
37560             if (name.kind === 78) {
37561                 var message = meaning === namespaceMeaning || ts.nodeIsSynthesized(name) ? ts.Diagnostics.Cannot_find_namespace_0 : getCannotFindNameDiagnosticForName(ts.getFirstIdentifier(name));
37562                 var symbolFromJSPrototype = ts.isInJSFile(name) && !ts.nodeIsSynthesized(name) ? resolveEntityNameFromAssignmentDeclaration(name, meaning) : undefined;
37563                 symbol = getMergedSymbol(resolveName(location || name, name.escapedText, meaning, ignoreErrors || symbolFromJSPrototype ? undefined : message, name, true));
37564                 if (!symbol) {
37565                     return getMergedSymbol(symbolFromJSPrototype);
37566                 }
37567             }
37568             else if (name.kind === 157 || name.kind === 201) {
37569                 var left = name.kind === 157 ? name.left : name.expression;
37570                 var right = name.kind === 157 ? name.right : name.name;
37571                 var namespace = resolveEntityName(left, namespaceMeaning, ignoreErrors, false, location);
37572                 if (!namespace || ts.nodeIsMissing(right)) {
37573                     return undefined;
37574                 }
37575                 else if (namespace === unknownSymbol) {
37576                     return namespace;
37577                 }
37578                 if (ts.isInJSFile(name)) {
37579                     if (namespace.valueDeclaration &&
37580                         ts.isVariableDeclaration(namespace.valueDeclaration) &&
37581                         namespace.valueDeclaration.initializer &&
37582                         isCommonJsRequire(namespace.valueDeclaration.initializer)) {
37583                         var moduleName = namespace.valueDeclaration.initializer.arguments[0];
37584                         var moduleSym = resolveExternalModuleName(moduleName, moduleName);
37585                         if (moduleSym) {
37586                             var resolvedModuleSymbol = resolveExternalModuleSymbol(moduleSym);
37587                             if (resolvedModuleSymbol) {
37588                                 namespace = resolvedModuleSymbol;
37589                             }
37590                         }
37591                     }
37592                 }
37593                 symbol = getMergedSymbol(getSymbol(getExportsOfSymbol(namespace), right.escapedText, meaning));
37594                 if (!symbol) {
37595                     if (!ignoreErrors) {
37596                         var namespaceName = getFullyQualifiedName(namespace);
37597                         var declarationName = ts.declarationNameToString(right);
37598                         var suggestion = getSuggestedSymbolForNonexistentModule(right, namespace);
37599                         suggestion ?
37600                             error(right, ts.Diagnostics._0_has_no_exported_member_named_1_Did_you_mean_2, namespaceName, declarationName, symbolToString(suggestion)) :
37601                             error(right, ts.Diagnostics.Namespace_0_has_no_exported_member_1, namespaceName, declarationName);
37602                     }
37603                     return undefined;
37604                 }
37605             }
37606             else {
37607                 throw ts.Debug.assertNever(name, "Unknown entity name kind.");
37608             }
37609             ts.Debug.assert((ts.getCheckFlags(symbol) & 1) === 0, "Should never get an instantiated symbol here.");
37610             if (!ts.nodeIsSynthesized(name) && ts.isEntityName(name) && (symbol.flags & 2097152 || name.parent.kind === 266)) {
37611                 markSymbolOfAliasDeclarationIfTypeOnly(ts.getAliasDeclarationFromName(name), symbol, undefined, true);
37612             }
37613             return (symbol.flags & meaning) || dontResolveAlias ? symbol : resolveAlias(symbol);
37614         }
37615         function resolveEntityNameFromAssignmentDeclaration(name, meaning) {
37616             if (isJSDocTypeReference(name.parent)) {
37617                 var secondaryLocation = getAssignmentDeclarationLocation(name.parent);
37618                 if (secondaryLocation) {
37619                     return resolveName(secondaryLocation, name.escapedText, meaning, undefined, name, true);
37620                 }
37621             }
37622         }
37623         function getAssignmentDeclarationLocation(node) {
37624             var typeAlias = ts.findAncestor(node, function (node) { return !(ts.isJSDocNode(node) || node.flags & 4194304) ? "quit" : ts.isJSDocTypeAlias(node); });
37625             if (typeAlias) {
37626                 return;
37627             }
37628             var host = ts.getJSDocHost(node);
37629             if (ts.isExpressionStatement(host) &&
37630                 ts.isBinaryExpression(host.expression) &&
37631                 ts.getAssignmentDeclarationKind(host.expression) === 3) {
37632                 var symbol = getSymbolOfNode(host.expression.left);
37633                 if (symbol) {
37634                     return getDeclarationOfJSPrototypeContainer(symbol);
37635                 }
37636             }
37637             if ((ts.isObjectLiteralMethod(host) || ts.isPropertyAssignment(host)) &&
37638                 ts.isBinaryExpression(host.parent.parent) &&
37639                 ts.getAssignmentDeclarationKind(host.parent.parent) === 6) {
37640                 var symbol = getSymbolOfNode(host.parent.parent.left);
37641                 if (symbol) {
37642                     return getDeclarationOfJSPrototypeContainer(symbol);
37643                 }
37644             }
37645             var sig = ts.getEffectiveJSDocHost(node);
37646             if (sig && ts.isFunctionLike(sig)) {
37647                 var symbol = getSymbolOfNode(sig);
37648                 return symbol && symbol.valueDeclaration;
37649             }
37650         }
37651         function getDeclarationOfJSPrototypeContainer(symbol) {
37652             var decl = symbol.parent.valueDeclaration;
37653             if (!decl) {
37654                 return undefined;
37655             }
37656             var initializer = ts.isAssignmentDeclaration(decl) ? ts.getAssignedExpandoInitializer(decl) :
37657                 ts.hasOnlyExpressionInitializer(decl) ? ts.getDeclaredExpandoInitializer(decl) :
37658                     undefined;
37659             return initializer || decl;
37660         }
37661         function getExpandoSymbol(symbol) {
37662             var decl = symbol.valueDeclaration;
37663             if (!decl || !ts.isInJSFile(decl) || symbol.flags & 524288 || ts.getExpandoInitializer(decl, false)) {
37664                 return undefined;
37665             }
37666             var init = ts.isVariableDeclaration(decl) ? ts.getDeclaredExpandoInitializer(decl) : ts.getAssignedExpandoInitializer(decl);
37667             if (init) {
37668                 var initSymbol = getSymbolOfNode(init);
37669                 if (initSymbol) {
37670                     return mergeJSSymbols(initSymbol, symbol);
37671                 }
37672             }
37673         }
37674         function resolveExternalModuleName(location, moduleReferenceExpression, ignoreErrors) {
37675             var isClassic = ts.getEmitModuleResolutionKind(compilerOptions) === ts.ModuleResolutionKind.Classic;
37676             var errorMessage = isClassic ?
37677                 ts.Diagnostics.Cannot_find_module_0_Did_you_mean_to_set_the_moduleResolution_option_to_node_or_to_add_aliases_to_the_paths_option
37678                 : ts.Diagnostics.Cannot_find_module_0_or_its_corresponding_type_declarations;
37679             return resolveExternalModuleNameWorker(location, moduleReferenceExpression, ignoreErrors ? undefined : errorMessage);
37680         }
37681         function resolveExternalModuleNameWorker(location, moduleReferenceExpression, moduleNotFoundError, isForAugmentation) {
37682             if (isForAugmentation === void 0) { isForAugmentation = false; }
37683             return ts.isStringLiteralLike(moduleReferenceExpression)
37684                 ? resolveExternalModule(location, moduleReferenceExpression.text, moduleNotFoundError, moduleReferenceExpression, isForAugmentation)
37685                 : undefined;
37686         }
37687         function resolveExternalModule(location, moduleReference, moduleNotFoundError, errorNode, isForAugmentation) {
37688             if (isForAugmentation === void 0) { isForAugmentation = false; }
37689             if (ts.startsWith(moduleReference, "@types/")) {
37690                 var diag = ts.Diagnostics.Cannot_import_type_declaration_files_Consider_importing_0_instead_of_1;
37691                 var withoutAtTypePrefix = ts.removePrefix(moduleReference, "@types/");
37692                 error(errorNode, diag, withoutAtTypePrefix, moduleReference);
37693             }
37694             var ambientModule = tryFindAmbientModule(moduleReference, true);
37695             if (ambientModule) {
37696                 return ambientModule;
37697             }
37698             var currentSourceFile = ts.getSourceFileOfNode(location);
37699             var resolvedModule = ts.getResolvedModule(currentSourceFile, moduleReference);
37700             var resolutionDiagnostic = resolvedModule && ts.getResolutionDiagnostic(compilerOptions, resolvedModule);
37701             var sourceFile = resolvedModule && !resolutionDiagnostic && host.getSourceFile(resolvedModule.resolvedFileName);
37702             if (sourceFile) {
37703                 if (sourceFile.symbol) {
37704                     if (resolvedModule.isExternalLibraryImport && !ts.resolutionExtensionIsTSOrJson(resolvedModule.extension)) {
37705                         errorOnImplicitAnyModule(false, errorNode, resolvedModule, moduleReference);
37706                     }
37707                     return getMergedSymbol(sourceFile.symbol);
37708                 }
37709                 if (moduleNotFoundError) {
37710                     error(errorNode, ts.Diagnostics.File_0_is_not_a_module, sourceFile.fileName);
37711                 }
37712                 return undefined;
37713             }
37714             if (patternAmbientModules) {
37715                 var pattern = ts.findBestPatternMatch(patternAmbientModules, function (_) { return _.pattern; }, moduleReference);
37716                 if (pattern) {
37717                     var augmentation = patternAmbientModuleAugmentations && patternAmbientModuleAugmentations.get(moduleReference);
37718                     if (augmentation) {
37719                         return getMergedSymbol(augmentation);
37720                     }
37721                     return getMergedSymbol(pattern.symbol);
37722                 }
37723             }
37724             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) {
37725                 if (isForAugmentation) {
37726                     var diag = ts.Diagnostics.Invalid_module_name_in_augmentation_Module_0_resolves_to_an_untyped_module_at_1_which_cannot_be_augmented;
37727                     error(errorNode, diag, moduleReference, resolvedModule.resolvedFileName);
37728                 }
37729                 else {
37730                     errorOnImplicitAnyModule(noImplicitAny && !!moduleNotFoundError, errorNode, resolvedModule, moduleReference);
37731                 }
37732                 return undefined;
37733             }
37734             if (moduleNotFoundError) {
37735                 if (resolvedModule) {
37736                     var redirect = host.getProjectReferenceRedirect(resolvedModule.resolvedFileName);
37737                     if (redirect) {
37738                         error(errorNode, ts.Diagnostics.Output_file_0_has_not_been_built_from_source_file_1, redirect, resolvedModule.resolvedFileName);
37739                         return undefined;
37740                     }
37741                 }
37742                 if (resolutionDiagnostic) {
37743                     error(errorNode, resolutionDiagnostic, moduleReference, resolvedModule.resolvedFileName);
37744                 }
37745                 else {
37746                     var tsExtension = ts.tryExtractTSExtension(moduleReference);
37747                     if (tsExtension) {
37748                         var diag = ts.Diagnostics.An_import_path_cannot_end_with_a_0_extension_Consider_importing_1_instead;
37749                         error(errorNode, diag, tsExtension, ts.removeExtension(moduleReference, tsExtension));
37750                     }
37751                     else if (!compilerOptions.resolveJsonModule &&
37752                         ts.fileExtensionIs(moduleReference, ".json") &&
37753                         ts.getEmitModuleResolutionKind(compilerOptions) === ts.ModuleResolutionKind.NodeJs &&
37754                         ts.hasJsonModuleEmitEnabled(compilerOptions)) {
37755                         error(errorNode, ts.Diagnostics.Cannot_find_module_0_Consider_using_resolveJsonModule_to_import_module_with_json_extension, moduleReference);
37756                     }
37757                     else {
37758                         error(errorNode, moduleNotFoundError, moduleReference);
37759                     }
37760                 }
37761             }
37762             return undefined;
37763         }
37764         function errorOnImplicitAnyModule(isError, errorNode, _a, moduleReference) {
37765             var packageId = _a.packageId, resolvedFileName = _a.resolvedFileName;
37766             var errorInfo = !ts.isExternalModuleNameRelative(moduleReference) && packageId
37767                 ? typesPackageExists(packageId.name)
37768                     ? 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))
37769                     : ts.chainDiagnosticMessages(undefined, ts.Diagnostics.Try_npm_i_save_dev_types_Slash_1_if_it_exists_or_add_a_new_declaration_d_ts_file_containing_declare_module_0, moduleReference, ts.mangleScopedPackageName(packageId.name))
37770                 : undefined;
37771             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));
37772         }
37773         function typesPackageExists(packageName) {
37774             return getPackagesSet().has(ts.getTypesPackageName(packageName));
37775         }
37776         function resolveExternalModuleSymbol(moduleSymbol, dontResolveAlias) {
37777             if (moduleSymbol === null || moduleSymbol === void 0 ? void 0 : moduleSymbol.exports) {
37778                 var exportEquals = resolveSymbol(moduleSymbol.exports.get("export="), dontResolveAlias);
37779                 var exported = getCommonJsExportEquals(getMergedSymbol(exportEquals), getMergedSymbol(moduleSymbol));
37780                 return getMergedSymbol(exported) || moduleSymbol;
37781             }
37782             return undefined;
37783         }
37784         function getCommonJsExportEquals(exported, moduleSymbol) {
37785             if (!exported || exported === unknownSymbol || exported === moduleSymbol || moduleSymbol.exports.size === 1 || exported.flags & 2097152) {
37786                 return exported;
37787             }
37788             var links = getSymbolLinks(exported);
37789             if (links.cjsExportMerged) {
37790                 return links.cjsExportMerged;
37791             }
37792             var merged = exported.flags & 33554432 ? exported : cloneSymbol(exported);
37793             merged.flags = merged.flags | 512;
37794             if (merged.exports === undefined) {
37795                 merged.exports = ts.createSymbolTable();
37796             }
37797             moduleSymbol.exports.forEach(function (s, name) {
37798                 if (name === "export=")
37799                     return;
37800                 merged.exports.set(name, merged.exports.has(name) ? mergeSymbol(merged.exports.get(name), s) : s);
37801             });
37802             getSymbolLinks(merged).cjsExportMerged = merged;
37803             return links.cjsExportMerged = merged;
37804         }
37805         function resolveESModuleSymbol(moduleSymbol, referencingLocation, dontResolveAlias, suppressInteropError) {
37806             var symbol = resolveExternalModuleSymbol(moduleSymbol, dontResolveAlias);
37807             if (!dontResolveAlias && symbol) {
37808                 if (!suppressInteropError && !(symbol.flags & (1536 | 3)) && !ts.getDeclarationOfKind(symbol, 297)) {
37809                     var compilerOptionName = moduleKind >= ts.ModuleKind.ES2015
37810                         ? "allowSyntheticDefaultImports"
37811                         : "esModuleInterop";
37812                     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);
37813                     return symbol;
37814                 }
37815                 if (compilerOptions.esModuleInterop) {
37816                     var referenceParent = referencingLocation.parent;
37817                     if ((ts.isImportDeclaration(referenceParent) && ts.getNamespaceDeclarationNode(referenceParent)) ||
37818                         ts.isImportCall(referenceParent)) {
37819                         var type = getTypeOfSymbol(symbol);
37820                         var sigs = getSignaturesOfStructuredType(type, 0);
37821                         if (!sigs || !sigs.length) {
37822                             sigs = getSignaturesOfStructuredType(type, 1);
37823                         }
37824                         if (sigs && sigs.length) {
37825                             var moduleType = getTypeWithSyntheticDefaultImportType(type, symbol, moduleSymbol);
37826                             var result = createSymbol(symbol.flags, symbol.escapedName);
37827                             result.declarations = symbol.declarations ? symbol.declarations.slice() : [];
37828                             result.parent = symbol.parent;
37829                             result.target = symbol;
37830                             result.originatingImport = referenceParent;
37831                             if (symbol.valueDeclaration)
37832                                 result.valueDeclaration = symbol.valueDeclaration;
37833                             if (symbol.constEnumOnlyModule)
37834                                 result.constEnumOnlyModule = true;
37835                             if (symbol.members)
37836                                 result.members = new ts.Map(symbol.members);
37837                             if (symbol.exports)
37838                                 result.exports = new ts.Map(symbol.exports);
37839                             var resolvedModuleType = resolveStructuredTypeMembers(moduleType);
37840                             result.type = createAnonymousType(result, resolvedModuleType.members, ts.emptyArray, ts.emptyArray, resolvedModuleType.stringIndexInfo, resolvedModuleType.numberIndexInfo);
37841                             return result;
37842                         }
37843                     }
37844                 }
37845             }
37846             return symbol;
37847         }
37848         function hasExportAssignmentSymbol(moduleSymbol) {
37849             return moduleSymbol.exports.get("export=") !== undefined;
37850         }
37851         function getExportsOfModuleAsArray(moduleSymbol) {
37852             return symbolsToArray(getExportsOfModule(moduleSymbol));
37853         }
37854         function getExportsAndPropertiesOfModule(moduleSymbol) {
37855             var exports = getExportsOfModuleAsArray(moduleSymbol);
37856             var exportEquals = resolveExternalModuleSymbol(moduleSymbol);
37857             if (exportEquals !== moduleSymbol) {
37858                 ts.addRange(exports, getPropertiesOfType(getTypeOfSymbol(exportEquals)));
37859             }
37860             return exports;
37861         }
37862         function tryGetMemberInModuleExports(memberName, moduleSymbol) {
37863             var symbolTable = getExportsOfModule(moduleSymbol);
37864             if (symbolTable) {
37865                 return symbolTable.get(memberName);
37866             }
37867         }
37868         function tryGetMemberInModuleExportsAndProperties(memberName, moduleSymbol) {
37869             var symbol = tryGetMemberInModuleExports(memberName, moduleSymbol);
37870             if (symbol) {
37871                 return symbol;
37872             }
37873             var exportEquals = resolveExternalModuleSymbol(moduleSymbol);
37874             if (exportEquals === moduleSymbol) {
37875                 return undefined;
37876             }
37877             var type = getTypeOfSymbol(exportEquals);
37878             return type.flags & 131068 ||
37879                 ts.getObjectFlags(type) & 1 ||
37880                 isArrayOrTupleLikeType(type)
37881                 ? undefined
37882                 : getPropertyOfType(type, memberName);
37883         }
37884         function getExportsOfSymbol(symbol) {
37885             return symbol.flags & 6256 ? getResolvedMembersOrExportsOfSymbol(symbol, "resolvedExports") :
37886                 symbol.flags & 1536 ? getExportsOfModule(symbol) :
37887                     symbol.exports || emptySymbols;
37888         }
37889         function getExportsOfModule(moduleSymbol) {
37890             var links = getSymbolLinks(moduleSymbol);
37891             return links.resolvedExports || (links.resolvedExports = getExportsOfModuleWorker(moduleSymbol));
37892         }
37893         function extendExportSymbols(target, source, lookupTable, exportNode) {
37894             if (!source)
37895                 return;
37896             source.forEach(function (sourceSymbol, id) {
37897                 if (id === "default")
37898                     return;
37899                 var targetSymbol = target.get(id);
37900                 if (!targetSymbol) {
37901                     target.set(id, sourceSymbol);
37902                     if (lookupTable && exportNode) {
37903                         lookupTable.set(id, {
37904                             specifierText: ts.getTextOfNode(exportNode.moduleSpecifier)
37905                         });
37906                     }
37907                 }
37908                 else if (lookupTable && exportNode && targetSymbol && resolveSymbol(targetSymbol) !== resolveSymbol(sourceSymbol)) {
37909                     var collisionTracker = lookupTable.get(id);
37910                     if (!collisionTracker.exportsWithDuplicate) {
37911                         collisionTracker.exportsWithDuplicate = [exportNode];
37912                     }
37913                     else {
37914                         collisionTracker.exportsWithDuplicate.push(exportNode);
37915                     }
37916                 }
37917             });
37918         }
37919         function getExportsOfModuleWorker(moduleSymbol) {
37920             var visitedSymbols = [];
37921             moduleSymbol = resolveExternalModuleSymbol(moduleSymbol);
37922             return visit(moduleSymbol) || emptySymbols;
37923             function visit(symbol) {
37924                 if (!(symbol && symbol.exports && ts.pushIfUnique(visitedSymbols, symbol))) {
37925                     return;
37926                 }
37927                 var symbols = new ts.Map(symbol.exports);
37928                 var exportStars = symbol.exports.get("__export");
37929                 if (exportStars) {
37930                     var nestedSymbols = ts.createSymbolTable();
37931                     var lookupTable_1 = new ts.Map();
37932                     for (var _i = 0, _a = exportStars.declarations; _i < _a.length; _i++) {
37933                         var node = _a[_i];
37934                         var resolvedModule = resolveExternalModuleName(node, node.moduleSpecifier);
37935                         var exportedSymbols = visit(resolvedModule);
37936                         extendExportSymbols(nestedSymbols, exportedSymbols, lookupTable_1, node);
37937                     }
37938                     lookupTable_1.forEach(function (_a, id) {
37939                         var exportsWithDuplicate = _a.exportsWithDuplicate;
37940                         if (id === "export=" || !(exportsWithDuplicate && exportsWithDuplicate.length) || symbols.has(id)) {
37941                             return;
37942                         }
37943                         for (var _i = 0, exportsWithDuplicate_1 = exportsWithDuplicate; _i < exportsWithDuplicate_1.length; _i++) {
37944                             var node = exportsWithDuplicate_1[_i];
37945                             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)));
37946                         }
37947                     });
37948                     extendExportSymbols(symbols, nestedSymbols);
37949                 }
37950                 return symbols;
37951             }
37952         }
37953         function getMergedSymbol(symbol) {
37954             var merged;
37955             return symbol && symbol.mergeId && (merged = mergedSymbols[symbol.mergeId]) ? merged : symbol;
37956         }
37957         function getSymbolOfNode(node) {
37958             return getMergedSymbol(node.symbol && getLateBoundSymbol(node.symbol));
37959         }
37960         function getParentOfSymbol(symbol) {
37961             return getMergedSymbol(symbol.parent && getLateBoundSymbol(symbol.parent));
37962         }
37963         function getAlternativeContainingModules(symbol, enclosingDeclaration) {
37964             var containingFile = ts.getSourceFileOfNode(enclosingDeclaration);
37965             var id = getNodeId(containingFile);
37966             var links = getSymbolLinks(symbol);
37967             var results;
37968             if (links.extendedContainersByFile && (results = links.extendedContainersByFile.get(id))) {
37969                 return results;
37970             }
37971             if (containingFile && containingFile.imports) {
37972                 for (var _i = 0, _a = containingFile.imports; _i < _a.length; _i++) {
37973                     var importRef = _a[_i];
37974                     if (ts.nodeIsSynthesized(importRef))
37975                         continue;
37976                     var resolvedModule = resolveExternalModuleName(enclosingDeclaration, importRef, true);
37977                     if (!resolvedModule)
37978                         continue;
37979                     var ref = getAliasForSymbolInContainer(resolvedModule, symbol);
37980                     if (!ref)
37981                         continue;
37982                     results = ts.append(results, resolvedModule);
37983                 }
37984                 if (ts.length(results)) {
37985                     (links.extendedContainersByFile || (links.extendedContainersByFile = new ts.Map())).set(id, results);
37986                     return results;
37987                 }
37988             }
37989             if (links.extendedContainers) {
37990                 return links.extendedContainers;
37991             }
37992             var otherFiles = host.getSourceFiles();
37993             for (var _b = 0, otherFiles_1 = otherFiles; _b < otherFiles_1.length; _b++) {
37994                 var file = otherFiles_1[_b];
37995                 if (!ts.isExternalModule(file))
37996                     continue;
37997                 var sym = getSymbolOfNode(file);
37998                 var ref = getAliasForSymbolInContainer(sym, symbol);
37999                 if (!ref)
38000                     continue;
38001                 results = ts.append(results, sym);
38002             }
38003             return links.extendedContainers = results || ts.emptyArray;
38004         }
38005         function getContainersOfSymbol(symbol, enclosingDeclaration, meaning) {
38006             var container = getParentOfSymbol(symbol);
38007             if (container && !(symbol.flags & 262144)) {
38008                 var additionalContainers = ts.mapDefined(container.declarations, fileSymbolIfFileSymbolExportEqualsContainer);
38009                 var reexportContainers = enclosingDeclaration && getAlternativeContainingModules(symbol, enclosingDeclaration);
38010                 var objectLiteralContainer = getVariableDeclarationOfObjectLiteral(container, meaning);
38011                 if (enclosingDeclaration && getAccessibleSymbolChain(container, enclosingDeclaration, 1920, false)) {
38012                     return ts.append(ts.concatenate(ts.concatenate([container], additionalContainers), reexportContainers), objectLiteralContainer);
38013                 }
38014                 var res = ts.append(ts.append(additionalContainers, container), objectLiteralContainer);
38015                 return ts.concatenate(res, reexportContainers);
38016             }
38017             var candidates = ts.mapDefined(symbol.declarations, function (d) {
38018                 if (!ts.isAmbientModule(d) && d.parent && hasNonGlobalAugmentationExternalModuleSymbol(d.parent)) {
38019                     return getSymbolOfNode(d.parent);
38020                 }
38021                 if (ts.isClassExpression(d) && ts.isBinaryExpression(d.parent) && d.parent.operatorToken.kind === 62 && ts.isAccessExpression(d.parent.left) && ts.isEntityNameExpression(d.parent.left.expression)) {
38022                     if (ts.isModuleExportsAccessExpression(d.parent.left) || ts.isExportsIdentifier(d.parent.left.expression)) {
38023                         return getSymbolOfNode(ts.getSourceFileOfNode(d));
38024                     }
38025                     checkExpressionCached(d.parent.left.expression);
38026                     return getNodeLinks(d.parent.left.expression).resolvedSymbol;
38027                 }
38028             });
38029             if (!ts.length(candidates)) {
38030                 return undefined;
38031             }
38032             return ts.mapDefined(candidates, function (candidate) { return getAliasForSymbolInContainer(candidate, symbol) ? candidate : undefined; });
38033             function fileSymbolIfFileSymbolExportEqualsContainer(d) {
38034                 return container && getFileSymbolIfFileSymbolExportEqualsContainer(d, container);
38035             }
38036         }
38037         function getVariableDeclarationOfObjectLiteral(symbol, meaning) {
38038             var firstDecl = !!ts.length(symbol.declarations) && ts.first(symbol.declarations);
38039             if (meaning & 111551 && firstDecl && firstDecl.parent && ts.isVariableDeclaration(firstDecl.parent)) {
38040                 if (ts.isObjectLiteralExpression(firstDecl) && firstDecl === firstDecl.parent.initializer || ts.isTypeLiteralNode(firstDecl) && firstDecl === firstDecl.parent.type) {
38041                     return getSymbolOfNode(firstDecl.parent);
38042                 }
38043             }
38044         }
38045         function getFileSymbolIfFileSymbolExportEqualsContainer(d, container) {
38046             var fileSymbol = getExternalModuleContainer(d);
38047             var exported = fileSymbol && fileSymbol.exports && fileSymbol.exports.get("export=");
38048             return exported && getSymbolIfSameReference(exported, container) ? fileSymbol : undefined;
38049         }
38050         function getAliasForSymbolInContainer(container, symbol) {
38051             if (container === getParentOfSymbol(symbol)) {
38052                 return symbol;
38053             }
38054             var exportEquals = container.exports && container.exports.get("export=");
38055             if (exportEquals && getSymbolIfSameReference(exportEquals, symbol)) {
38056                 return container;
38057             }
38058             var exports = getExportsOfSymbol(container);
38059             var quick = exports.get(symbol.escapedName);
38060             if (quick && getSymbolIfSameReference(quick, symbol)) {
38061                 return quick;
38062             }
38063             return ts.forEachEntry(exports, function (exported) {
38064                 if (getSymbolIfSameReference(exported, symbol)) {
38065                     return exported;
38066                 }
38067             });
38068         }
38069         function getSymbolIfSameReference(s1, s2) {
38070             if (getMergedSymbol(resolveSymbol(getMergedSymbol(s1))) === getMergedSymbol(resolveSymbol(getMergedSymbol(s2)))) {
38071                 return s1;
38072             }
38073         }
38074         function getExportSymbolOfValueSymbolIfExported(symbol) {
38075             return getMergedSymbol(symbol && (symbol.flags & 1048576) !== 0 ? symbol.exportSymbol : symbol);
38076         }
38077         function symbolIsValue(symbol) {
38078             return !!(symbol.flags & 111551 || symbol.flags & 2097152 && resolveAlias(symbol).flags & 111551 && !getTypeOnlyAliasDeclaration(symbol));
38079         }
38080         function findConstructorDeclaration(node) {
38081             var members = node.members;
38082             for (var _i = 0, members_3 = members; _i < members_3.length; _i++) {
38083                 var member = members_3[_i];
38084                 if (member.kind === 166 && ts.nodeIsPresent(member.body)) {
38085                     return member;
38086                 }
38087             }
38088         }
38089         function createType(flags) {
38090             var result = new Type(checker, flags);
38091             typeCount++;
38092             result.id = typeCount;
38093             typeCatalog.push(result);
38094             return result;
38095         }
38096         function createIntrinsicType(kind, intrinsicName, objectFlags) {
38097             if (objectFlags === void 0) { objectFlags = 0; }
38098             var type = createType(kind);
38099             type.intrinsicName = intrinsicName;
38100             type.objectFlags = objectFlags;
38101             return type;
38102         }
38103         function createBooleanType(trueFalseTypes) {
38104             var type = getUnionType(trueFalseTypes);
38105             type.flags |= 16;
38106             type.intrinsicName = "boolean";
38107             return type;
38108         }
38109         function createObjectType(objectFlags, symbol) {
38110             var type = createType(524288);
38111             type.objectFlags = objectFlags;
38112             type.symbol = symbol;
38113             type.members = undefined;
38114             type.properties = undefined;
38115             type.callSignatures = undefined;
38116             type.constructSignatures = undefined;
38117             type.stringIndexInfo = undefined;
38118             type.numberIndexInfo = undefined;
38119             return type;
38120         }
38121         function createTypeofType() {
38122             return getUnionType(ts.arrayFrom(typeofEQFacts.keys(), getLiteralType));
38123         }
38124         function createTypeParameter(symbol) {
38125             var type = createType(262144);
38126             if (symbol)
38127                 type.symbol = symbol;
38128             return type;
38129         }
38130         function isReservedMemberName(name) {
38131             return name.charCodeAt(0) === 95 &&
38132                 name.charCodeAt(1) === 95 &&
38133                 name.charCodeAt(2) !== 95 &&
38134                 name.charCodeAt(2) !== 64 &&
38135                 name.charCodeAt(2) !== 35;
38136         }
38137         function getNamedMembers(members) {
38138             var result;
38139             members.forEach(function (symbol, id) {
38140                 if (!isReservedMemberName(id) && symbolIsValue(symbol)) {
38141                     (result || (result = [])).push(symbol);
38142                 }
38143             });
38144             return result || ts.emptyArray;
38145         }
38146         function setStructuredTypeMembers(type, members, callSignatures, constructSignatures, stringIndexInfo, numberIndexInfo) {
38147             type.members = members;
38148             type.properties = members === emptySymbols ? ts.emptyArray : getNamedMembers(members);
38149             type.callSignatures = callSignatures;
38150             type.constructSignatures = constructSignatures;
38151             type.stringIndexInfo = stringIndexInfo;
38152             type.numberIndexInfo = numberIndexInfo;
38153             return type;
38154         }
38155         function createAnonymousType(symbol, members, callSignatures, constructSignatures, stringIndexInfo, numberIndexInfo) {
38156             return setStructuredTypeMembers(createObjectType(16, symbol), members, callSignatures, constructSignatures, stringIndexInfo, numberIndexInfo);
38157         }
38158         function forEachSymbolTableInScope(enclosingDeclaration, callback) {
38159             var result;
38160             var _loop_8 = function (location) {
38161                 if (location.locals && !isGlobalSourceFile(location)) {
38162                     if (result = callback(location.locals)) {
38163                         return { value: result };
38164                     }
38165                 }
38166                 switch (location.kind) {
38167                     case 297:
38168                         if (!ts.isExternalOrCommonJsModule(location)) {
38169                             break;
38170                         }
38171                     case 256:
38172                         var sym = getSymbolOfNode(location);
38173                         if (result = callback((sym === null || sym === void 0 ? void 0 : sym.exports) || emptySymbols)) {
38174                             return { value: result };
38175                         }
38176                         break;
38177                     case 252:
38178                     case 221:
38179                     case 253:
38180                         var table_1;
38181                         (getSymbolOfNode(location).members || emptySymbols).forEach(function (memberSymbol, key) {
38182                             if (memberSymbol.flags & (788968 & ~67108864)) {
38183                                 (table_1 || (table_1 = ts.createSymbolTable())).set(key, memberSymbol);
38184                             }
38185                         });
38186                         if (table_1 && (result = callback(table_1))) {
38187                             return { value: result };
38188                         }
38189                         break;
38190                 }
38191             };
38192             for (var location = enclosingDeclaration; location; location = location.parent) {
38193                 var state_2 = _loop_8(location);
38194                 if (typeof state_2 === "object")
38195                     return state_2.value;
38196             }
38197             return callback(globals);
38198         }
38199         function getQualifiedLeftMeaning(rightMeaning) {
38200             return rightMeaning === 111551 ? 111551 : 1920;
38201         }
38202         function getAccessibleSymbolChain(symbol, enclosingDeclaration, meaning, useOnlyExternalAliasing, visitedSymbolTablesMap) {
38203             if (visitedSymbolTablesMap === void 0) { visitedSymbolTablesMap = new ts.Map(); }
38204             if (!(symbol && !isPropertyOrMethodDeclarationSymbol(symbol))) {
38205                 return undefined;
38206             }
38207             var id = getSymbolId(symbol);
38208             var visitedSymbolTables = visitedSymbolTablesMap.get(id);
38209             if (!visitedSymbolTables) {
38210                 visitedSymbolTablesMap.set(id, visitedSymbolTables = []);
38211             }
38212             return forEachSymbolTableInScope(enclosingDeclaration, getAccessibleSymbolChainFromSymbolTable);
38213             function getAccessibleSymbolChainFromSymbolTable(symbols, ignoreQualification) {
38214                 if (!ts.pushIfUnique(visitedSymbolTables, symbols)) {
38215                     return undefined;
38216                 }
38217                 var result = trySymbolTable(symbols, ignoreQualification);
38218                 visitedSymbolTables.pop();
38219                 return result;
38220             }
38221             function canQualifySymbol(symbolFromSymbolTable, meaning) {
38222                 return !needsQualification(symbolFromSymbolTable, enclosingDeclaration, meaning) ||
38223                     !!getAccessibleSymbolChain(symbolFromSymbolTable.parent, enclosingDeclaration, getQualifiedLeftMeaning(meaning), useOnlyExternalAliasing, visitedSymbolTablesMap);
38224             }
38225             function isAccessible(symbolFromSymbolTable, resolvedAliasSymbol, ignoreQualification) {
38226                 return (symbol === (resolvedAliasSymbol || symbolFromSymbolTable) || getMergedSymbol(symbol) === getMergedSymbol(resolvedAliasSymbol || symbolFromSymbolTable)) &&
38227                     !ts.some(symbolFromSymbolTable.declarations, hasNonGlobalAugmentationExternalModuleSymbol) &&
38228                     (ignoreQualification || canQualifySymbol(getMergedSymbol(symbolFromSymbolTable), meaning));
38229             }
38230             function trySymbolTable(symbols, ignoreQualification) {
38231                 if (isAccessible(symbols.get(symbol.escapedName), undefined, ignoreQualification)) {
38232                     return [symbol];
38233                 }
38234                 var result = ts.forEachEntry(symbols, function (symbolFromSymbolTable) {
38235                     if (symbolFromSymbolTable.flags & 2097152
38236                         && symbolFromSymbolTable.escapedName !== "export="
38237                         && symbolFromSymbolTable.escapedName !== "default"
38238                         && !(ts.isUMDExportSymbol(symbolFromSymbolTable) && enclosingDeclaration && ts.isExternalModule(ts.getSourceFileOfNode(enclosingDeclaration)))
38239                         && (!useOnlyExternalAliasing || ts.some(symbolFromSymbolTable.declarations, ts.isExternalModuleImportEqualsDeclaration))
38240                         && (ignoreQualification || !ts.getDeclarationOfKind(symbolFromSymbolTable, 270))) {
38241                         var resolvedImportedSymbol = resolveAlias(symbolFromSymbolTable);
38242                         var candidate = getCandidateListForSymbol(symbolFromSymbolTable, resolvedImportedSymbol, ignoreQualification);
38243                         if (candidate) {
38244                             return candidate;
38245                         }
38246                     }
38247                     if (symbolFromSymbolTable.escapedName === symbol.escapedName && symbolFromSymbolTable.exportSymbol) {
38248                         if (isAccessible(getMergedSymbol(symbolFromSymbolTable.exportSymbol), undefined, ignoreQualification)) {
38249                             return [symbol];
38250                         }
38251                     }
38252                 });
38253                 return result || (symbols === globals ? getCandidateListForSymbol(globalThisSymbol, globalThisSymbol, ignoreQualification) : undefined);
38254             }
38255             function getCandidateListForSymbol(symbolFromSymbolTable, resolvedImportedSymbol, ignoreQualification) {
38256                 if (isAccessible(symbolFromSymbolTable, resolvedImportedSymbol, ignoreQualification)) {
38257                     return [symbolFromSymbolTable];
38258                 }
38259                 var candidateTable = getExportsOfSymbol(resolvedImportedSymbol);
38260                 var accessibleSymbolsFromExports = candidateTable && getAccessibleSymbolChainFromSymbolTable(candidateTable, true);
38261                 if (accessibleSymbolsFromExports && canQualifySymbol(symbolFromSymbolTable, getQualifiedLeftMeaning(meaning))) {
38262                     return [symbolFromSymbolTable].concat(accessibleSymbolsFromExports);
38263                 }
38264             }
38265         }
38266         function needsQualification(symbol, enclosingDeclaration, meaning) {
38267             var qualify = false;
38268             forEachSymbolTableInScope(enclosingDeclaration, function (symbolTable) {
38269                 var symbolFromSymbolTable = getMergedSymbol(symbolTable.get(symbol.escapedName));
38270                 if (!symbolFromSymbolTable) {
38271                     return false;
38272                 }
38273                 if (symbolFromSymbolTable === symbol) {
38274                     return true;
38275                 }
38276                 symbolFromSymbolTable = (symbolFromSymbolTable.flags & 2097152 && !ts.getDeclarationOfKind(symbolFromSymbolTable, 270)) ? resolveAlias(symbolFromSymbolTable) : symbolFromSymbolTable;
38277                 if (symbolFromSymbolTable.flags & meaning) {
38278                     qualify = true;
38279                     return true;
38280                 }
38281                 return false;
38282             });
38283             return qualify;
38284         }
38285         function isPropertyOrMethodDeclarationSymbol(symbol) {
38286             if (symbol.declarations && symbol.declarations.length) {
38287                 for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) {
38288                     var declaration = _a[_i];
38289                     switch (declaration.kind) {
38290                         case 163:
38291                         case 165:
38292                         case 167:
38293                         case 168:
38294                             continue;
38295                         default:
38296                             return false;
38297                     }
38298                 }
38299                 return true;
38300             }
38301             return false;
38302         }
38303         function isTypeSymbolAccessible(typeSymbol, enclosingDeclaration) {
38304             var access = isSymbolAccessibleWorker(typeSymbol, enclosingDeclaration, 788968, false, true);
38305             return access.accessibility === 0;
38306         }
38307         function isValueSymbolAccessible(typeSymbol, enclosingDeclaration) {
38308             var access = isSymbolAccessibleWorker(typeSymbol, enclosingDeclaration, 111551, false, true);
38309             return access.accessibility === 0;
38310         }
38311         function isSymbolAccessibleByFlags(typeSymbol, enclosingDeclaration, flags) {
38312             var access = isSymbolAccessibleWorker(typeSymbol, enclosingDeclaration, flags, false, false);
38313             return access.accessibility === 0;
38314         }
38315         function isAnySymbolAccessible(symbols, enclosingDeclaration, initialSymbol, meaning, shouldComputeAliasesToMakeVisible, allowModules) {
38316             if (!ts.length(symbols))
38317                 return;
38318             var hadAccessibleChain;
38319             var earlyModuleBail = false;
38320             for (var _i = 0, _a = symbols; _i < _a.length; _i++) {
38321                 var symbol = _a[_i];
38322                 var accessibleSymbolChain = getAccessibleSymbolChain(symbol, enclosingDeclaration, meaning, false);
38323                 if (accessibleSymbolChain) {
38324                     hadAccessibleChain = symbol;
38325                     var hasAccessibleDeclarations = hasVisibleDeclarations(accessibleSymbolChain[0], shouldComputeAliasesToMakeVisible);
38326                     if (hasAccessibleDeclarations) {
38327                         return hasAccessibleDeclarations;
38328                     }
38329                 }
38330                 else if (allowModules) {
38331                     if (ts.some(symbol.declarations, hasNonGlobalAugmentationExternalModuleSymbol)) {
38332                         if (shouldComputeAliasesToMakeVisible) {
38333                             earlyModuleBail = true;
38334                             continue;
38335                         }
38336                         return {
38337                             accessibility: 0
38338                         };
38339                     }
38340                 }
38341                 var containers = getContainersOfSymbol(symbol, enclosingDeclaration, meaning);
38342                 var parentResult = isAnySymbolAccessible(containers, enclosingDeclaration, initialSymbol, initialSymbol === symbol ? getQualifiedLeftMeaning(meaning) : meaning, shouldComputeAliasesToMakeVisible, allowModules);
38343                 if (parentResult) {
38344                     return parentResult;
38345                 }
38346             }
38347             if (earlyModuleBail) {
38348                 return {
38349                     accessibility: 0
38350                 };
38351             }
38352             if (hadAccessibleChain) {
38353                 return {
38354                     accessibility: 1,
38355                     errorSymbolName: symbolToString(initialSymbol, enclosingDeclaration, meaning),
38356                     errorModuleName: hadAccessibleChain !== initialSymbol ? symbolToString(hadAccessibleChain, enclosingDeclaration, 1920) : undefined,
38357                 };
38358             }
38359         }
38360         function isSymbolAccessible(symbol, enclosingDeclaration, meaning, shouldComputeAliasesToMakeVisible) {
38361             return isSymbolAccessibleWorker(symbol, enclosingDeclaration, meaning, shouldComputeAliasesToMakeVisible, true);
38362         }
38363         function isSymbolAccessibleWorker(symbol, enclosingDeclaration, meaning, shouldComputeAliasesToMakeVisible, allowModules) {
38364             if (symbol && enclosingDeclaration) {
38365                 var result = isAnySymbolAccessible([symbol], enclosingDeclaration, symbol, meaning, shouldComputeAliasesToMakeVisible, allowModules);
38366                 if (result) {
38367                     return result;
38368                 }
38369                 var symbolExternalModule = ts.forEach(symbol.declarations, getExternalModuleContainer);
38370                 if (symbolExternalModule) {
38371                     var enclosingExternalModule = getExternalModuleContainer(enclosingDeclaration);
38372                     if (symbolExternalModule !== enclosingExternalModule) {
38373                         return {
38374                             accessibility: 2,
38375                             errorSymbolName: symbolToString(symbol, enclosingDeclaration, meaning),
38376                             errorModuleName: symbolToString(symbolExternalModule)
38377                         };
38378                     }
38379                 }
38380                 return {
38381                     accessibility: 1,
38382                     errorSymbolName: symbolToString(symbol, enclosingDeclaration, meaning),
38383                 };
38384             }
38385             return { accessibility: 0 };
38386         }
38387         function getExternalModuleContainer(declaration) {
38388             var node = ts.findAncestor(declaration, hasExternalModuleSymbol);
38389             return node && getSymbolOfNode(node);
38390         }
38391         function hasExternalModuleSymbol(declaration) {
38392             return ts.isAmbientModule(declaration) || (declaration.kind === 297 && ts.isExternalOrCommonJsModule(declaration));
38393         }
38394         function hasNonGlobalAugmentationExternalModuleSymbol(declaration) {
38395             return ts.isModuleWithStringLiteralName(declaration) || (declaration.kind === 297 && ts.isExternalOrCommonJsModule(declaration));
38396         }
38397         function hasVisibleDeclarations(symbol, shouldComputeAliasToMakeVisible) {
38398             var aliasesToMakeVisible;
38399             if (!ts.every(ts.filter(symbol.declarations, function (d) { return d.kind !== 78; }), getIsDeclarationVisible)) {
38400                 return undefined;
38401             }
38402             return { accessibility: 0, aliasesToMakeVisible: aliasesToMakeVisible };
38403             function getIsDeclarationVisible(declaration) {
38404                 var _a, _b;
38405                 if (!isDeclarationVisible(declaration)) {
38406                     var anyImportSyntax = getAnyImportSyntax(declaration);
38407                     if (anyImportSyntax &&
38408                         !ts.hasSyntacticModifier(anyImportSyntax, 1) &&
38409                         isDeclarationVisible(anyImportSyntax.parent)) {
38410                         return addVisibleAlias(declaration, anyImportSyntax);
38411                     }
38412                     else if (ts.isVariableDeclaration(declaration) && ts.isVariableStatement(declaration.parent.parent) &&
38413                         !ts.hasSyntacticModifier(declaration.parent.parent, 1) &&
38414                         isDeclarationVisible(declaration.parent.parent.parent)) {
38415                         return addVisibleAlias(declaration, declaration.parent.parent);
38416                     }
38417                     else if (ts.isLateVisibilityPaintedStatement(declaration)
38418                         && !ts.hasSyntacticModifier(declaration, 1)
38419                         && isDeclarationVisible(declaration.parent)) {
38420                         return addVisibleAlias(declaration, declaration);
38421                     }
38422                     else if (symbol.flags & 2097152 && ts.isBindingElement(declaration) && ts.isInJSFile(declaration) && ((_a = declaration.parent) === null || _a === void 0 ? void 0 : _a.parent)
38423                         && ts.isVariableDeclaration(declaration.parent.parent)
38424                         && ((_b = declaration.parent.parent.parent) === null || _b === void 0 ? void 0 : _b.parent) && ts.isVariableStatement(declaration.parent.parent.parent.parent)
38425                         && !ts.hasSyntacticModifier(declaration.parent.parent.parent.parent, 1)
38426                         && declaration.parent.parent.parent.parent.parent
38427                         && isDeclarationVisible(declaration.parent.parent.parent.parent.parent)) {
38428                         return addVisibleAlias(declaration, declaration.parent.parent.parent.parent);
38429                     }
38430                     return false;
38431                 }
38432                 return true;
38433             }
38434             function addVisibleAlias(declaration, aliasingStatement) {
38435                 if (shouldComputeAliasToMakeVisible) {
38436                     getNodeLinks(declaration).isVisible = true;
38437                     aliasesToMakeVisible = ts.appendIfUnique(aliasesToMakeVisible, aliasingStatement);
38438                 }
38439                 return true;
38440             }
38441         }
38442         function isEntityNameVisible(entityName, enclosingDeclaration) {
38443             var meaning;
38444             if (entityName.parent.kind === 176 ||
38445                 ts.isExpressionWithTypeArgumentsInClassExtendsClause(entityName.parent) ||
38446                 entityName.parent.kind === 158) {
38447                 meaning = 111551 | 1048576;
38448             }
38449             else if (entityName.kind === 157 || entityName.kind === 201 ||
38450                 entityName.parent.kind === 260) {
38451                 meaning = 1920;
38452             }
38453             else {
38454                 meaning = 788968;
38455             }
38456             var firstIdentifier = ts.getFirstIdentifier(entityName);
38457             var symbol = resolveName(enclosingDeclaration, firstIdentifier.escapedText, meaning, undefined, undefined, false);
38458             if (symbol && symbol.flags & 262144 && meaning & 788968) {
38459                 return { accessibility: 0 };
38460             }
38461             return (symbol && hasVisibleDeclarations(symbol, true)) || {
38462                 accessibility: 1,
38463                 errorSymbolName: ts.getTextOfNode(firstIdentifier),
38464                 errorNode: firstIdentifier
38465             };
38466         }
38467         function symbolToString(symbol, enclosingDeclaration, meaning, flags, writer) {
38468             if (flags === void 0) { flags = 4; }
38469             var nodeFlags = 70221824;
38470             if (flags & 2) {
38471                 nodeFlags |= 128;
38472             }
38473             if (flags & 1) {
38474                 nodeFlags |= 512;
38475             }
38476             if (flags & 8) {
38477                 nodeFlags |= 16384;
38478             }
38479             if (flags & 16) {
38480                 nodeFlags |= 134217728;
38481             }
38482             var builder = flags & 4 ? nodeBuilder.symbolToExpression : nodeBuilder.symbolToEntityName;
38483             return writer ? symbolToStringWorker(writer).getText() : ts.usingSingleLineStringWriter(symbolToStringWorker);
38484             function symbolToStringWorker(writer) {
38485                 var entity = builder(symbol, meaning, enclosingDeclaration, nodeFlags);
38486                 var printer = (enclosingDeclaration === null || enclosingDeclaration === void 0 ? void 0 : enclosingDeclaration.kind) === 297 ? ts.createPrinter({ removeComments: true, neverAsciiEscape: true }) : ts.createPrinter({ removeComments: true });
38487                 var sourceFile = enclosingDeclaration && ts.getSourceFileOfNode(enclosingDeclaration);
38488                 printer.writeNode(4, entity, sourceFile, writer);
38489                 return writer;
38490             }
38491         }
38492         function signatureToString(signature, enclosingDeclaration, flags, kind, writer) {
38493             if (flags === void 0) { flags = 0; }
38494             return writer ? signatureToStringWorker(writer).getText() : ts.usingSingleLineStringWriter(signatureToStringWorker);
38495             function signatureToStringWorker(writer) {
38496                 var sigOutput;
38497                 if (flags & 262144) {
38498                     sigOutput = kind === 1 ? 175 : 174;
38499                 }
38500                 else {
38501                     sigOutput = kind === 1 ? 170 : 169;
38502                 }
38503                 var sig = nodeBuilder.signatureToSignatureDeclaration(signature, sigOutput, enclosingDeclaration, toNodeBuilderFlags(flags) | 70221824 | 512);
38504                 var printer = ts.createPrinter({ removeComments: true, omitTrailingSemicolon: true });
38505                 var sourceFile = enclosingDeclaration && ts.getSourceFileOfNode(enclosingDeclaration);
38506                 printer.writeNode(4, sig, sourceFile, ts.getTrailingSemicolonDeferringWriter(writer));
38507                 return writer;
38508             }
38509         }
38510         function typeToString(type, enclosingDeclaration, flags, writer) {
38511             if (flags === void 0) { flags = 1048576 | 16384; }
38512             if (writer === void 0) { writer = ts.createTextWriter(""); }
38513             var noTruncation = compilerOptions.noErrorTruncation || flags & 1;
38514             var typeNode = nodeBuilder.typeToTypeNode(type, enclosingDeclaration, toNodeBuilderFlags(flags) | 70221824 | (noTruncation ? 1 : 0), writer);
38515             if (typeNode === undefined)
38516                 return ts.Debug.fail("should always get typenode");
38517             var options = { removeComments: true };
38518             var printer = ts.createPrinter(options);
38519             var sourceFile = enclosingDeclaration && ts.getSourceFileOfNode(enclosingDeclaration);
38520             printer.writeNode(4, typeNode, sourceFile, writer);
38521             var result = writer.getText();
38522             var maxLength = noTruncation ? ts.noTruncationMaximumTruncationLength * 2 : ts.defaultMaximumTruncationLength * 2;
38523             if (maxLength && result && result.length >= maxLength) {
38524                 return result.substr(0, maxLength - "...".length) + "...";
38525             }
38526             return result;
38527         }
38528         function getTypeNamesForErrorDisplay(left, right) {
38529             var leftStr = symbolValueDeclarationIsContextSensitive(left.symbol) ? typeToString(left, left.symbol.valueDeclaration) : typeToString(left);
38530             var rightStr = symbolValueDeclarationIsContextSensitive(right.symbol) ? typeToString(right, right.symbol.valueDeclaration) : typeToString(right);
38531             if (leftStr === rightStr) {
38532                 leftStr = getTypeNameForErrorDisplay(left);
38533                 rightStr = getTypeNameForErrorDisplay(right);
38534             }
38535             return [leftStr, rightStr];
38536         }
38537         function getTypeNameForErrorDisplay(type) {
38538             return typeToString(type, undefined, 64);
38539         }
38540         function symbolValueDeclarationIsContextSensitive(symbol) {
38541             return symbol && symbol.valueDeclaration && ts.isExpression(symbol.valueDeclaration) && !isContextSensitive(symbol.valueDeclaration);
38542         }
38543         function toNodeBuilderFlags(flags) {
38544             if (flags === void 0) { flags = 0; }
38545             return flags & 814775659;
38546         }
38547         function isClassInstanceSide(type) {
38548             return !!type.symbol && !!(type.symbol.flags & 32) && (type === getDeclaredTypeOfClassOrInterface(type.symbol) || !!(ts.getObjectFlags(type) & 1073741824));
38549         }
38550         function createNodeBuilder() {
38551             return {
38552                 typeToTypeNode: function (type, enclosingDeclaration, flags, tracker) {
38553                     return withContext(enclosingDeclaration, flags, tracker, function (context) { return typeToTypeNodeHelper(type, context); });
38554                 },
38555                 indexInfoToIndexSignatureDeclaration: function (indexInfo, kind, enclosingDeclaration, flags, tracker) {
38556                     return withContext(enclosingDeclaration, flags, tracker, function (context) { return indexInfoToIndexSignatureDeclarationHelper(indexInfo, kind, context, undefined); });
38557                 },
38558                 signatureToSignatureDeclaration: function (signature, kind, enclosingDeclaration, flags, tracker) {
38559                     return withContext(enclosingDeclaration, flags, tracker, function (context) { return signatureToSignatureDeclarationHelper(signature, kind, context); });
38560                 },
38561                 symbolToEntityName: function (symbol, meaning, enclosingDeclaration, flags, tracker) {
38562                     return withContext(enclosingDeclaration, flags, tracker, function (context) { return symbolToName(symbol, context, meaning, false); });
38563                 },
38564                 symbolToExpression: function (symbol, meaning, enclosingDeclaration, flags, tracker) {
38565                     return withContext(enclosingDeclaration, flags, tracker, function (context) { return symbolToExpression(symbol, context, meaning); });
38566                 },
38567                 symbolToTypeParameterDeclarations: function (symbol, enclosingDeclaration, flags, tracker) {
38568                     return withContext(enclosingDeclaration, flags, tracker, function (context) { return typeParametersToTypeParameterDeclarations(symbol, context); });
38569                 },
38570                 symbolToParameterDeclaration: function (symbol, enclosingDeclaration, flags, tracker) {
38571                     return withContext(enclosingDeclaration, flags, tracker, function (context) { return symbolToParameterDeclaration(symbol, context); });
38572                 },
38573                 typeParameterToDeclaration: function (parameter, enclosingDeclaration, flags, tracker) {
38574                     return withContext(enclosingDeclaration, flags, tracker, function (context) { return typeParameterToDeclaration(parameter, context); });
38575                 },
38576                 symbolTableToDeclarationStatements: function (symbolTable, enclosingDeclaration, flags, tracker, bundled) {
38577                     return withContext(enclosingDeclaration, flags, tracker, function (context) { return symbolTableToDeclarationStatements(symbolTable, context, bundled); });
38578                 },
38579             };
38580             function withContext(enclosingDeclaration, flags, tracker, cb) {
38581                 var _a, _b;
38582                 ts.Debug.assert(enclosingDeclaration === undefined || (enclosingDeclaration.flags & 8) === 0);
38583                 var context = {
38584                     enclosingDeclaration: enclosingDeclaration,
38585                     flags: flags || 0,
38586                     tracker: tracker && tracker.trackSymbol ? tracker : { trackSymbol: ts.noop, moduleResolverHost: flags & 134217728 ? {
38587                             getCommonSourceDirectory: !!host.getCommonSourceDirectory ? function () { return host.getCommonSourceDirectory(); } : function () { return ""; },
38588                             getSourceFiles: function () { return host.getSourceFiles(); },
38589                             getCurrentDirectory: function () { return host.getCurrentDirectory(); },
38590                             getSymlinkCache: ts.maybeBind(host, host.getSymlinkCache),
38591                             useCaseSensitiveFileNames: ts.maybeBind(host, host.useCaseSensitiveFileNames),
38592                             redirectTargetsMap: host.redirectTargetsMap,
38593                             getProjectReferenceRedirect: function (fileName) { return host.getProjectReferenceRedirect(fileName); },
38594                             isSourceOfProjectReferenceRedirect: function (fileName) { return host.isSourceOfProjectReferenceRedirect(fileName); },
38595                             fileExists: function (fileName) { return host.fileExists(fileName); },
38596                         } : undefined },
38597                     encounteredError: false,
38598                     visitedTypes: undefined,
38599                     symbolDepth: undefined,
38600                     inferTypeParameters: undefined,
38601                     approximateLength: 0
38602                 };
38603                 var resultingNode = cb(context);
38604                 if (context.truncating && context.flags & 1) {
38605                     (_b = (_a = context.tracker) === null || _a === void 0 ? void 0 : _a.reportTruncationError) === null || _b === void 0 ? void 0 : _b.call(_a);
38606                 }
38607                 return context.encounteredError ? undefined : resultingNode;
38608             }
38609             function checkTruncationLength(context) {
38610                 if (context.truncating)
38611                     return context.truncating;
38612                 return context.truncating = context.approximateLength > ((context.flags & 1) ? ts.noTruncationMaximumTruncationLength : ts.defaultMaximumTruncationLength);
38613             }
38614             function typeToTypeNodeHelper(type, context) {
38615                 if (cancellationToken && cancellationToken.throwIfCancellationRequested) {
38616                     cancellationToken.throwIfCancellationRequested();
38617                 }
38618                 var inTypeAlias = context.flags & 8388608;
38619                 context.flags &= ~8388608;
38620                 if (!type) {
38621                     if (!(context.flags & 262144)) {
38622                         context.encounteredError = true;
38623                         return undefined;
38624                     }
38625                     context.approximateLength += 3;
38626                     return ts.factory.createKeywordTypeNode(128);
38627                 }
38628                 if (!(context.flags & 536870912)) {
38629                     type = getReducedType(type);
38630                 }
38631                 if (type.flags & 1) {
38632                     context.approximateLength += 3;
38633                     return ts.factory.createKeywordTypeNode(type === intrinsicMarkerType ? 136 : 128);
38634                 }
38635                 if (type.flags & 2) {
38636                     return ts.factory.createKeywordTypeNode(152);
38637                 }
38638                 if (type.flags & 4) {
38639                     context.approximateLength += 6;
38640                     return ts.factory.createKeywordTypeNode(147);
38641                 }
38642                 if (type.flags & 8) {
38643                     context.approximateLength += 6;
38644                     return ts.factory.createKeywordTypeNode(144);
38645                 }
38646                 if (type.flags & 64) {
38647                     context.approximateLength += 6;
38648                     return ts.factory.createKeywordTypeNode(155);
38649                 }
38650                 if (type.flags & 16) {
38651                     context.approximateLength += 7;
38652                     return ts.factory.createKeywordTypeNode(131);
38653                 }
38654                 if (type.flags & 1024 && !(type.flags & 1048576)) {
38655                     var parentSymbol = getParentOfSymbol(type.symbol);
38656                     var parentName = symbolToTypeNode(parentSymbol, context, 788968);
38657                     if (getDeclaredTypeOfSymbol(parentSymbol) === type) {
38658                         return parentName;
38659                     }
38660                     var memberName = ts.symbolName(type.symbol);
38661                     if (ts.isIdentifierText(memberName, 0)) {
38662                         return appendReferenceToType(parentName, ts.factory.createTypeReferenceNode(memberName, undefined));
38663                     }
38664                     if (ts.isImportTypeNode(parentName)) {
38665                         parentName.isTypeOf = true;
38666                         return ts.factory.createIndexedAccessTypeNode(parentName, ts.factory.createLiteralTypeNode(ts.factory.createStringLiteral(memberName)));
38667                     }
38668                     else if (ts.isTypeReferenceNode(parentName)) {
38669                         return ts.factory.createIndexedAccessTypeNode(ts.factory.createTypeQueryNode(parentName.typeName), ts.factory.createLiteralTypeNode(ts.factory.createStringLiteral(memberName)));
38670                     }
38671                     else {
38672                         return ts.Debug.fail("Unhandled type node kind returned from `symbolToTypeNode`.");
38673                     }
38674                 }
38675                 if (type.flags & 1056) {
38676                     return symbolToTypeNode(type.symbol, context, 788968);
38677                 }
38678                 if (type.flags & 128) {
38679                     context.approximateLength += (type.value.length + 2);
38680                     return ts.factory.createLiteralTypeNode(ts.setEmitFlags(ts.factory.createStringLiteral(type.value, !!(context.flags & 268435456)), 16777216));
38681                 }
38682                 if (type.flags & 256) {
38683                     var value = type.value;
38684                     context.approximateLength += ("" + value).length;
38685                     return ts.factory.createLiteralTypeNode(value < 0 ? ts.factory.createPrefixUnaryExpression(40, ts.factory.createNumericLiteral(-value)) : ts.factory.createNumericLiteral(value));
38686                 }
38687                 if (type.flags & 2048) {
38688                     context.approximateLength += (ts.pseudoBigIntToString(type.value).length) + 1;
38689                     return ts.factory.createLiteralTypeNode((ts.factory.createBigIntLiteral(type.value)));
38690                 }
38691                 if (type.flags & 512) {
38692                     context.approximateLength += type.intrinsicName.length;
38693                     return ts.factory.createLiteralTypeNode(type.intrinsicName === "true" ? ts.factory.createTrue() : ts.factory.createFalse());
38694                 }
38695                 if (type.flags & 8192) {
38696                     if (!(context.flags & 1048576)) {
38697                         if (isValueSymbolAccessible(type.symbol, context.enclosingDeclaration)) {
38698                             context.approximateLength += 6;
38699                             return symbolToTypeNode(type.symbol, context, 111551);
38700                         }
38701                         if (context.tracker.reportInaccessibleUniqueSymbolError) {
38702                             context.tracker.reportInaccessibleUniqueSymbolError();
38703                         }
38704                     }
38705                     context.approximateLength += 13;
38706                     return ts.factory.createTypeOperatorNode(151, ts.factory.createKeywordTypeNode(148));
38707                 }
38708                 if (type.flags & 16384) {
38709                     context.approximateLength += 4;
38710                     return ts.factory.createKeywordTypeNode(113);
38711                 }
38712                 if (type.flags & 32768) {
38713                     context.approximateLength += 9;
38714                     return ts.factory.createKeywordTypeNode(150);
38715                 }
38716                 if (type.flags & 65536) {
38717                     context.approximateLength += 4;
38718                     return ts.factory.createLiteralTypeNode(ts.factory.createNull());
38719                 }
38720                 if (type.flags & 131072) {
38721                     context.approximateLength += 5;
38722                     return ts.factory.createKeywordTypeNode(141);
38723                 }
38724                 if (type.flags & 4096) {
38725                     context.approximateLength += 6;
38726                     return ts.factory.createKeywordTypeNode(148);
38727                 }
38728                 if (type.flags & 67108864) {
38729                     context.approximateLength += 6;
38730                     return ts.factory.createKeywordTypeNode(145);
38731                 }
38732                 if (isThisTypeParameter(type)) {
38733                     if (context.flags & 4194304) {
38734                         if (!context.encounteredError && !(context.flags & 32768)) {
38735                             context.encounteredError = true;
38736                         }
38737                         if (context.tracker.reportInaccessibleThisError) {
38738                             context.tracker.reportInaccessibleThisError();
38739                         }
38740                     }
38741                     context.approximateLength += 4;
38742                     return ts.factory.createThisTypeNode();
38743                 }
38744                 if (!inTypeAlias && type.aliasSymbol && (context.flags & 16384 || isTypeSymbolAccessible(type.aliasSymbol, context.enclosingDeclaration))) {
38745                     var typeArgumentNodes = mapToTypeNodes(type.aliasTypeArguments, context);
38746                     if (isReservedMemberName(type.aliasSymbol.escapedName) && !(type.aliasSymbol.flags & 32))
38747                         return ts.factory.createTypeReferenceNode(ts.factory.createIdentifier(""), typeArgumentNodes);
38748                     return symbolToTypeNode(type.aliasSymbol, context, 788968, typeArgumentNodes);
38749                 }
38750                 var objectFlags = ts.getObjectFlags(type);
38751                 if (objectFlags & 4) {
38752                     ts.Debug.assert(!!(type.flags & 524288));
38753                     return type.node ? visitAndTransformType(type, typeReferenceToTypeNode) : typeReferenceToTypeNode(type);
38754                 }
38755                 if (type.flags & 262144 || objectFlags & 3) {
38756                     if (type.flags & 262144 && ts.contains(context.inferTypeParameters, type)) {
38757                         context.approximateLength += (ts.symbolName(type.symbol).length + 6);
38758                         return ts.factory.createInferTypeNode(typeParameterToDeclarationWithConstraint(type, context, undefined));
38759                     }
38760                     if (context.flags & 4 &&
38761                         type.flags & 262144 &&
38762                         !isTypeSymbolAccessible(type.symbol, context.enclosingDeclaration)) {
38763                         var name = typeParameterToName(type, context);
38764                         context.approximateLength += ts.idText(name).length;
38765                         return ts.factory.createTypeReferenceNode(ts.factory.createIdentifier(ts.idText(name)), undefined);
38766                     }
38767                     return type.symbol
38768                         ? symbolToTypeNode(type.symbol, context, 788968)
38769                         : ts.factory.createTypeReferenceNode(ts.factory.createIdentifier("?"), undefined);
38770                 }
38771                 if (type.flags & (1048576 | 2097152)) {
38772                     var types = type.flags & 1048576 ? formatUnionTypes(type.types) : type.types;
38773                     if (ts.length(types) === 1) {
38774                         return typeToTypeNodeHelper(types[0], context);
38775                     }
38776                     var typeNodes = mapToTypeNodes(types, context, true);
38777                     if (typeNodes && typeNodes.length > 0) {
38778                         var unionOrIntersectionTypeNode = type.flags & 1048576 ? ts.factory.createUnionTypeNode(typeNodes) : ts.factory.createIntersectionTypeNode(typeNodes);
38779                         return unionOrIntersectionTypeNode;
38780                     }
38781                     else {
38782                         if (!context.encounteredError && !(context.flags & 262144)) {
38783                             context.encounteredError = true;
38784                         }
38785                         return undefined;
38786                     }
38787                 }
38788                 if (objectFlags & (16 | 32)) {
38789                     ts.Debug.assert(!!(type.flags & 524288));
38790                     return createAnonymousTypeNode(type);
38791                 }
38792                 if (type.flags & 4194304) {
38793                     var indexedType = type.type;
38794                     context.approximateLength += 6;
38795                     var indexTypeNode = typeToTypeNodeHelper(indexedType, context);
38796                     return ts.factory.createTypeOperatorNode(138, indexTypeNode);
38797                 }
38798                 if (type.flags & 134217728) {
38799                     var texts_1 = type.texts;
38800                     var types_1 = type.types;
38801                     var templateHead = ts.factory.createTemplateHead(texts_1[0]);
38802                     var templateSpans = ts.factory.createNodeArray(ts.map(types_1, function (t, i) { return ts.factory.createTemplateLiteralTypeSpan(typeToTypeNodeHelper(t, context), (i < types_1.length - 1 ? ts.factory.createTemplateMiddle : ts.factory.createTemplateTail)(texts_1[i + 1])); }));
38803                     context.approximateLength += 2;
38804                     return ts.factory.createTemplateLiteralType(templateHead, templateSpans);
38805                 }
38806                 if (type.flags & 268435456) {
38807                     var typeNode = typeToTypeNodeHelper(type.type, context);
38808                     return symbolToTypeNode(type.symbol, context, 788968, [typeNode]);
38809                 }
38810                 if (type.flags & 8388608) {
38811                     var objectTypeNode = typeToTypeNodeHelper(type.objectType, context);
38812                     var indexTypeNode = typeToTypeNodeHelper(type.indexType, context);
38813                     context.approximateLength += 2;
38814                     return ts.factory.createIndexedAccessTypeNode(objectTypeNode, indexTypeNode);
38815                 }
38816                 if (type.flags & 16777216) {
38817                     var checkTypeNode = typeToTypeNodeHelper(type.checkType, context);
38818                     var saveInferTypeParameters = context.inferTypeParameters;
38819                     context.inferTypeParameters = type.root.inferTypeParameters;
38820                     var extendsTypeNode = typeToTypeNodeHelper(type.extendsType, context);
38821                     context.inferTypeParameters = saveInferTypeParameters;
38822                     var trueTypeNode = typeToTypeNodeOrCircularityElision(getTrueTypeFromConditionalType(type));
38823                     var falseTypeNode = typeToTypeNodeOrCircularityElision(getFalseTypeFromConditionalType(type));
38824                     context.approximateLength += 15;
38825                     return ts.factory.createConditionalTypeNode(checkTypeNode, extendsTypeNode, trueTypeNode, falseTypeNode);
38826                 }
38827                 if (type.flags & 33554432) {
38828                     return typeToTypeNodeHelper(type.baseType, context);
38829                 }
38830                 return ts.Debug.fail("Should be unreachable.");
38831                 function typeToTypeNodeOrCircularityElision(type) {
38832                     var _a, _b, _c;
38833                     if (type.flags & 1048576) {
38834                         if ((_a = context.visitedTypes) === null || _a === void 0 ? void 0 : _a.has(getTypeId(type))) {
38835                             if (!(context.flags & 131072)) {
38836                                 context.encounteredError = true;
38837                                 (_c = (_b = context.tracker) === null || _b === void 0 ? void 0 : _b.reportCyclicStructureError) === null || _c === void 0 ? void 0 : _c.call(_b);
38838                             }
38839                             return createElidedInformationPlaceholder(context);
38840                         }
38841                         return visitAndTransformType(type, function (type) { return typeToTypeNodeHelper(type, context); });
38842                     }
38843                     return typeToTypeNodeHelper(type, context);
38844                 }
38845                 function createMappedTypeNodeFromType(type) {
38846                     ts.Debug.assert(!!(type.flags & 524288));
38847                     var readonlyToken = type.declaration.readonlyToken ? ts.factory.createToken(type.declaration.readonlyToken.kind) : undefined;
38848                     var questionToken = type.declaration.questionToken ? ts.factory.createToken(type.declaration.questionToken.kind) : undefined;
38849                     var appropriateConstraintTypeNode;
38850                     if (isMappedTypeWithKeyofConstraintDeclaration(type)) {
38851                         appropriateConstraintTypeNode = ts.factory.createTypeOperatorNode(138, typeToTypeNodeHelper(getModifiersTypeFromMappedType(type), context));
38852                     }
38853                     else {
38854                         appropriateConstraintTypeNode = typeToTypeNodeHelper(getConstraintTypeFromMappedType(type), context);
38855                     }
38856                     var typeParameterNode = typeParameterToDeclarationWithConstraint(getTypeParameterFromMappedType(type), context, appropriateConstraintTypeNode);
38857                     var nameTypeNode = type.declaration.nameType ? typeToTypeNodeHelper(getNameTypeFromMappedType(type), context) : undefined;
38858                     var templateTypeNode = typeToTypeNodeHelper(getTemplateTypeFromMappedType(type), context);
38859                     var mappedTypeNode = ts.factory.createMappedTypeNode(readonlyToken, typeParameterNode, nameTypeNode, questionToken, templateTypeNode);
38860                     context.approximateLength += 10;
38861                     return ts.setEmitFlags(mappedTypeNode, 1);
38862                 }
38863                 function createAnonymousTypeNode(type) {
38864                     var _a;
38865                     var typeId = type.id;
38866                     var symbol = type.symbol;
38867                     if (symbol) {
38868                         var isInstanceType = isClassInstanceSide(type) ? 788968 : 111551;
38869                         if (isJSConstructor(symbol.valueDeclaration)) {
38870                             return symbolToTypeNode(symbol, context, isInstanceType);
38871                         }
38872                         else if (symbol.flags & 32 && !getBaseTypeVariableOfClass(symbol) && !(symbol.valueDeclaration.kind === 221 && context.flags & 2048) ||
38873                             symbol.flags & (384 | 512) ||
38874                             shouldWriteTypeOfFunctionSymbol()) {
38875                             return symbolToTypeNode(symbol, context, isInstanceType);
38876                         }
38877                         else if ((_a = context.visitedTypes) === null || _a === void 0 ? void 0 : _a.has(typeId)) {
38878                             var typeAlias = getTypeAliasForTypeLiteral(type);
38879                             if (typeAlias) {
38880                                 return symbolToTypeNode(typeAlias, context, 788968);
38881                             }
38882                             else {
38883                                 return createElidedInformationPlaceholder(context);
38884                             }
38885                         }
38886                         else {
38887                             return visitAndTransformType(type, createTypeNodeFromObjectType);
38888                         }
38889                     }
38890                     else {
38891                         return createTypeNodeFromObjectType(type);
38892                     }
38893                     function shouldWriteTypeOfFunctionSymbol() {
38894                         var _a;
38895                         var isStaticMethodSymbol = !!(symbol.flags & 8192) &&
38896                             ts.some(symbol.declarations, function (declaration) { return ts.hasSyntacticModifier(declaration, 32); });
38897                         var isNonLocalFunctionSymbol = !!(symbol.flags & 16) &&
38898                             (symbol.parent ||
38899                                 ts.forEach(symbol.declarations, function (declaration) {
38900                                     return declaration.parent.kind === 297 || declaration.parent.kind === 257;
38901                                 }));
38902                         if (isStaticMethodSymbol || isNonLocalFunctionSymbol) {
38903                             return (!!(context.flags & 4096) || ((_a = context.visitedTypes) === null || _a === void 0 ? void 0 : _a.has(typeId))) &&
38904                                 (!(context.flags & 8) || isValueSymbolAccessible(symbol, context.enclosingDeclaration));
38905                         }
38906                     }
38907                 }
38908                 function visitAndTransformType(type, transform) {
38909                     var typeId = type.id;
38910                     var isConstructorObject = ts.getObjectFlags(type) & 16 && type.symbol && type.symbol.flags & 32;
38911                     var id = ts.getObjectFlags(type) & 4 && type.node ? "N" + getNodeId(type.node) :
38912                         type.symbol ? (isConstructorObject ? "+" : "") + getSymbolId(type.symbol) :
38913                             undefined;
38914                     if (!context.visitedTypes) {
38915                         context.visitedTypes = new ts.Set();
38916                     }
38917                     if (id && !context.symbolDepth) {
38918                         context.symbolDepth = new ts.Map();
38919                     }
38920                     var depth;
38921                     if (id) {
38922                         depth = context.symbolDepth.get(id) || 0;
38923                         if (depth > 10) {
38924                             return createElidedInformationPlaceholder(context);
38925                         }
38926                         context.symbolDepth.set(id, depth + 1);
38927                     }
38928                     context.visitedTypes.add(typeId);
38929                     var result = transform(type);
38930                     context.visitedTypes.delete(typeId);
38931                     if (id) {
38932                         context.symbolDepth.set(id, depth);
38933                     }
38934                     return result;
38935                 }
38936                 function createTypeNodeFromObjectType(type) {
38937                     if (isGenericMappedType(type) || type.containsError) {
38938                         return createMappedTypeNodeFromType(type);
38939                     }
38940                     var resolved = resolveStructuredTypeMembers(type);
38941                     if (!resolved.properties.length && !resolved.stringIndexInfo && !resolved.numberIndexInfo) {
38942                         if (!resolved.callSignatures.length && !resolved.constructSignatures.length) {
38943                             context.approximateLength += 2;
38944                             return ts.setEmitFlags(ts.factory.createTypeLiteralNode(undefined), 1);
38945                         }
38946                         if (resolved.callSignatures.length === 1 && !resolved.constructSignatures.length) {
38947                             var signature = resolved.callSignatures[0];
38948                             var signatureNode = signatureToSignatureDeclarationHelper(signature, 174, context);
38949                             return signatureNode;
38950                         }
38951                         if (resolved.constructSignatures.length === 1 && !resolved.callSignatures.length) {
38952                             var signature = resolved.constructSignatures[0];
38953                             var signatureNode = signatureToSignatureDeclarationHelper(signature, 175, context);
38954                             return signatureNode;
38955                         }
38956                     }
38957                     var savedFlags = context.flags;
38958                     context.flags |= 4194304;
38959                     var members = createTypeNodesFromResolvedType(resolved);
38960                     context.flags = savedFlags;
38961                     var typeLiteralNode = ts.factory.createTypeLiteralNode(members);
38962                     context.approximateLength += 2;
38963                     return ts.setEmitFlags(typeLiteralNode, (context.flags & 1024) ? 0 : 1);
38964                 }
38965                 function typeReferenceToTypeNode(type) {
38966                     var typeArguments = getTypeArguments(type);
38967                     if (type.target === globalArrayType || type.target === globalReadonlyArrayType) {
38968                         if (context.flags & 2) {
38969                             var typeArgumentNode = typeToTypeNodeHelper(typeArguments[0], context);
38970                             return ts.factory.createTypeReferenceNode(type.target === globalArrayType ? "Array" : "ReadonlyArray", [typeArgumentNode]);
38971                         }
38972                         var elementType = typeToTypeNodeHelper(typeArguments[0], context);
38973                         var arrayType = ts.factory.createArrayTypeNode(elementType);
38974                         return type.target === globalArrayType ? arrayType : ts.factory.createTypeOperatorNode(142, arrayType);
38975                     }
38976                     else if (type.target.objectFlags & 8) {
38977                         if (typeArguments.length > 0) {
38978                             var arity = getTypeReferenceArity(type);
38979                             var tupleConstituentNodes = mapToTypeNodes(typeArguments.slice(0, arity), context);
38980                             if (tupleConstituentNodes) {
38981                                 if (type.target.labeledElementDeclarations) {
38982                                     for (var i = 0; i < tupleConstituentNodes.length; i++) {
38983                                         var flags = type.target.elementFlags[i];
38984                                         tupleConstituentNodes[i] = ts.factory.createNamedTupleMember(flags & 12 ? ts.factory.createToken(25) : undefined, ts.factory.createIdentifier(ts.unescapeLeadingUnderscores(getTupleElementLabel(type.target.labeledElementDeclarations[i]))), flags & 2 ? ts.factory.createToken(57) : undefined, flags & 4 ? ts.factory.createArrayTypeNode(tupleConstituentNodes[i]) :
38985                                             tupleConstituentNodes[i]);
38986                                     }
38987                                 }
38988                                 else {
38989                                     for (var i = 0; i < Math.min(arity, tupleConstituentNodes.length); i++) {
38990                                         var flags = type.target.elementFlags[i];
38991                                         tupleConstituentNodes[i] =
38992                                             flags & 12 ? ts.factory.createRestTypeNode(flags & 4 ? ts.factory.createArrayTypeNode(tupleConstituentNodes[i]) : tupleConstituentNodes[i]) :
38993                                                 flags & 2 ? ts.factory.createOptionalTypeNode(tupleConstituentNodes[i]) :
38994                                                     tupleConstituentNodes[i];
38995                                     }
38996                                 }
38997                                 var tupleTypeNode = ts.setEmitFlags(ts.factory.createTupleTypeNode(tupleConstituentNodes), 1);
38998                                 return type.target.readonly ? ts.factory.createTypeOperatorNode(142, tupleTypeNode) : tupleTypeNode;
38999                             }
39000                         }
39001                         if (context.encounteredError || (context.flags & 524288)) {
39002                             var tupleTypeNode = ts.setEmitFlags(ts.factory.createTupleTypeNode([]), 1);
39003                             return type.target.readonly ? ts.factory.createTypeOperatorNode(142, tupleTypeNode) : tupleTypeNode;
39004                         }
39005                         context.encounteredError = true;
39006                         return undefined;
39007                     }
39008                     else if (context.flags & 2048 &&
39009                         type.symbol.valueDeclaration &&
39010                         ts.isClassLike(type.symbol.valueDeclaration) &&
39011                         !isValueSymbolAccessible(type.symbol, context.enclosingDeclaration)) {
39012                         return createAnonymousTypeNode(type);
39013                     }
39014                     else {
39015                         var outerTypeParameters = type.target.outerTypeParameters;
39016                         var i = 0;
39017                         var resultType = void 0;
39018                         if (outerTypeParameters) {
39019                             var length_2 = outerTypeParameters.length;
39020                             while (i < length_2) {
39021                                 var start = i;
39022                                 var parent = getParentSymbolOfTypeParameter(outerTypeParameters[i]);
39023                                 do {
39024                                     i++;
39025                                 } while (i < length_2 && getParentSymbolOfTypeParameter(outerTypeParameters[i]) === parent);
39026                                 if (!ts.rangeEquals(outerTypeParameters, typeArguments, start, i)) {
39027                                     var typeArgumentSlice = mapToTypeNodes(typeArguments.slice(start, i), context);
39028                                     var flags_3 = context.flags;
39029                                     context.flags |= 16;
39030                                     var ref = symbolToTypeNode(parent, context, 788968, typeArgumentSlice);
39031                                     context.flags = flags_3;
39032                                     resultType = !resultType ? ref : appendReferenceToType(resultType, ref);
39033                                 }
39034                             }
39035                         }
39036                         var typeArgumentNodes = void 0;
39037                         if (typeArguments.length > 0) {
39038                             var typeParameterCount = (type.target.typeParameters || ts.emptyArray).length;
39039                             typeArgumentNodes = mapToTypeNodes(typeArguments.slice(i, typeParameterCount), context);
39040                         }
39041                         var flags = context.flags;
39042                         context.flags |= 16;
39043                         var finalRef = symbolToTypeNode(type.symbol, context, 788968, typeArgumentNodes);
39044                         context.flags = flags;
39045                         return !resultType ? finalRef : appendReferenceToType(resultType, finalRef);
39046                     }
39047                 }
39048                 function appendReferenceToType(root, ref) {
39049                     if (ts.isImportTypeNode(root)) {
39050                         var typeArguments = root.typeArguments;
39051                         var qualifier = root.qualifier;
39052                         if (qualifier) {
39053                             if (ts.isIdentifier(qualifier)) {
39054                                 qualifier = ts.factory.updateIdentifier(qualifier, typeArguments);
39055                             }
39056                             else {
39057                                 qualifier = ts.factory.updateQualifiedName(qualifier, qualifier.left, ts.factory.updateIdentifier(qualifier.right, typeArguments));
39058                             }
39059                         }
39060                         typeArguments = ref.typeArguments;
39061                         var ids = getAccessStack(ref);
39062                         for (var _i = 0, ids_1 = ids; _i < ids_1.length; _i++) {
39063                             var id = ids_1[_i];
39064                             qualifier = qualifier ? ts.factory.createQualifiedName(qualifier, id) : id;
39065                         }
39066                         return ts.factory.updateImportTypeNode(root, root.argument, qualifier, typeArguments, root.isTypeOf);
39067                     }
39068                     else {
39069                         var typeArguments = root.typeArguments;
39070                         var typeName = root.typeName;
39071                         if (ts.isIdentifier(typeName)) {
39072                             typeName = ts.factory.updateIdentifier(typeName, typeArguments);
39073                         }
39074                         else {
39075                             typeName = ts.factory.updateQualifiedName(typeName, typeName.left, ts.factory.updateIdentifier(typeName.right, typeArguments));
39076                         }
39077                         typeArguments = ref.typeArguments;
39078                         var ids = getAccessStack(ref);
39079                         for (var _a = 0, ids_2 = ids; _a < ids_2.length; _a++) {
39080                             var id = ids_2[_a];
39081                             typeName = ts.factory.createQualifiedName(typeName, id);
39082                         }
39083                         return ts.factory.updateTypeReferenceNode(root, typeName, typeArguments);
39084                     }
39085                 }
39086                 function getAccessStack(ref) {
39087                     var state = ref.typeName;
39088                     var ids = [];
39089                     while (!ts.isIdentifier(state)) {
39090                         ids.unshift(state.right);
39091                         state = state.left;
39092                     }
39093                     ids.unshift(state);
39094                     return ids;
39095                 }
39096                 function createTypeNodesFromResolvedType(resolvedType) {
39097                     if (checkTruncationLength(context)) {
39098                         return [ts.factory.createPropertySignature(undefined, "...", undefined, undefined)];
39099                     }
39100                     var typeElements = [];
39101                     for (var _i = 0, _a = resolvedType.callSignatures; _i < _a.length; _i++) {
39102                         var signature = _a[_i];
39103                         typeElements.push(signatureToSignatureDeclarationHelper(signature, 169, context));
39104                     }
39105                     for (var _b = 0, _c = resolvedType.constructSignatures; _b < _c.length; _b++) {
39106                         var signature = _c[_b];
39107                         typeElements.push(signatureToSignatureDeclarationHelper(signature, 170, context));
39108                     }
39109                     if (resolvedType.stringIndexInfo) {
39110                         var indexSignature = void 0;
39111                         if (resolvedType.objectFlags & 2048) {
39112                             indexSignature = indexInfoToIndexSignatureDeclarationHelper(createIndexInfo(anyType, resolvedType.stringIndexInfo.isReadonly, resolvedType.stringIndexInfo.declaration), 0, context, createElidedInformationPlaceholder(context));
39113                         }
39114                         else {
39115                             indexSignature = indexInfoToIndexSignatureDeclarationHelper(resolvedType.stringIndexInfo, 0, context, undefined);
39116                         }
39117                         typeElements.push(indexSignature);
39118                     }
39119                     if (resolvedType.numberIndexInfo) {
39120                         typeElements.push(indexInfoToIndexSignatureDeclarationHelper(resolvedType.numberIndexInfo, 1, context, undefined));
39121                     }
39122                     var properties = resolvedType.properties;
39123                     if (!properties) {
39124                         return typeElements;
39125                     }
39126                     var i = 0;
39127                     for (var _d = 0, properties_1 = properties; _d < properties_1.length; _d++) {
39128                         var propertySymbol = properties_1[_d];
39129                         i++;
39130                         if (context.flags & 2048) {
39131                             if (propertySymbol.flags & 4194304) {
39132                                 continue;
39133                             }
39134                             if (ts.getDeclarationModifierFlagsFromSymbol(propertySymbol) & (8 | 16) && context.tracker.reportPrivateInBaseOfClassExpression) {
39135                                 context.tracker.reportPrivateInBaseOfClassExpression(ts.unescapeLeadingUnderscores(propertySymbol.escapedName));
39136                             }
39137                         }
39138                         if (checkTruncationLength(context) && (i + 2 < properties.length - 1)) {
39139                             typeElements.push(ts.factory.createPropertySignature(undefined, "... " + (properties.length - i) + " more ...", undefined, undefined));
39140                             addPropertyToElementList(properties[properties.length - 1], context, typeElements);
39141                             break;
39142                         }
39143                         addPropertyToElementList(propertySymbol, context, typeElements);
39144                     }
39145                     return typeElements.length ? typeElements : undefined;
39146                 }
39147             }
39148             function createElidedInformationPlaceholder(context) {
39149                 context.approximateLength += 3;
39150                 if (!(context.flags & 1)) {
39151                     return ts.factory.createTypeReferenceNode(ts.factory.createIdentifier("..."), undefined);
39152                 }
39153                 return ts.factory.createKeywordTypeNode(128);
39154             }
39155             function addPropertyToElementList(propertySymbol, context, typeElements) {
39156                 var propertyIsReverseMapped = !!(ts.getCheckFlags(propertySymbol) & 8192);
39157                 var propertyType = propertyIsReverseMapped && context.flags & 33554432 ?
39158                     anyType : getTypeOfSymbol(propertySymbol);
39159                 var saveEnclosingDeclaration = context.enclosingDeclaration;
39160                 context.enclosingDeclaration = undefined;
39161                 if (context.tracker.trackSymbol && ts.getCheckFlags(propertySymbol) & 4096) {
39162                     var decl = ts.first(propertySymbol.declarations);
39163                     if (hasLateBindableName(decl)) {
39164                         if (ts.isBinaryExpression(decl)) {
39165                             var name = ts.getNameOfDeclaration(decl);
39166                             if (name && ts.isElementAccessExpression(name) && ts.isPropertyAccessEntityNameExpression(name.argumentExpression)) {
39167                                 trackComputedName(name.argumentExpression, saveEnclosingDeclaration, context);
39168                             }
39169                         }
39170                         else {
39171                             trackComputedName(decl.name.expression, saveEnclosingDeclaration, context);
39172                         }
39173                     }
39174                 }
39175                 context.enclosingDeclaration = saveEnclosingDeclaration;
39176                 var propertyName = getPropertyNameNodeForSymbol(propertySymbol, context);
39177                 context.approximateLength += (ts.symbolName(propertySymbol).length + 1);
39178                 var optionalToken = propertySymbol.flags & 16777216 ? ts.factory.createToken(57) : undefined;
39179                 if (propertySymbol.flags & (16 | 8192) && !getPropertiesOfObjectType(propertyType).length && !isReadonlySymbol(propertySymbol)) {
39180                     var signatures = getSignaturesOfType(filterType(propertyType, function (t) { return !(t.flags & 32768); }), 0);
39181                     for (var _i = 0, signatures_1 = signatures; _i < signatures_1.length; _i++) {
39182                         var signature = signatures_1[_i];
39183                         var methodDeclaration = signatureToSignatureDeclarationHelper(signature, 164, context, { name: propertyName, questionToken: optionalToken });
39184                         typeElements.push(preserveCommentsOn(methodDeclaration));
39185                     }
39186                 }
39187                 else {
39188                     var savedFlags = context.flags;
39189                     context.flags |= propertyIsReverseMapped ? 33554432 : 0;
39190                     var propertyTypeNode = void 0;
39191                     if (propertyIsReverseMapped && !!(savedFlags & 33554432)) {
39192                         propertyTypeNode = createElidedInformationPlaceholder(context);
39193                     }
39194                     else {
39195                         propertyTypeNode = propertyType ? serializeTypeForDeclaration(context, propertyType, propertySymbol, saveEnclosingDeclaration) : ts.factory.createKeywordTypeNode(128);
39196                     }
39197                     context.flags = savedFlags;
39198                     var modifiers = isReadonlySymbol(propertySymbol) ? [ts.factory.createToken(142)] : undefined;
39199                     if (modifiers) {
39200                         context.approximateLength += 9;
39201                     }
39202                     var propertySignature = ts.factory.createPropertySignature(modifiers, propertyName, optionalToken, propertyTypeNode);
39203                     typeElements.push(preserveCommentsOn(propertySignature));
39204                 }
39205                 function preserveCommentsOn(node) {
39206                     if (ts.some(propertySymbol.declarations, function (d) { return d.kind === 333; })) {
39207                         var d = ts.find(propertySymbol.declarations, function (d) { return d.kind === 333; });
39208                         var commentText = d.comment;
39209                         if (commentText) {
39210                             ts.setSyntheticLeadingComments(node, [{ kind: 3, text: "*\n * " + commentText.replace(/\n/g, "\n * ") + "\n ", pos: -1, end: -1, hasTrailingNewLine: true }]);
39211                         }
39212                     }
39213                     else if (propertySymbol.valueDeclaration) {
39214                         ts.setCommentRange(node, propertySymbol.valueDeclaration);
39215                     }
39216                     return node;
39217                 }
39218             }
39219             function mapToTypeNodes(types, context, isBareList) {
39220                 if (ts.some(types)) {
39221                     if (checkTruncationLength(context)) {
39222                         if (!isBareList) {
39223                             return [ts.factory.createTypeReferenceNode("...", undefined)];
39224                         }
39225                         else if (types.length > 2) {
39226                             return [
39227                                 typeToTypeNodeHelper(types[0], context),
39228                                 ts.factory.createTypeReferenceNode("... " + (types.length - 2) + " more ...", undefined),
39229                                 typeToTypeNodeHelper(types[types.length - 1], context)
39230                             ];
39231                         }
39232                     }
39233                     var mayHaveNameCollisions = !(context.flags & 64);
39234                     var seenNames = mayHaveNameCollisions ? ts.createUnderscoreEscapedMultiMap() : undefined;
39235                     var result_4 = [];
39236                     var i = 0;
39237                     for (var _i = 0, types_2 = types; _i < types_2.length; _i++) {
39238                         var type = types_2[_i];
39239                         i++;
39240                         if (checkTruncationLength(context) && (i + 2 < types.length - 1)) {
39241                             result_4.push(ts.factory.createTypeReferenceNode("... " + (types.length - i) + " more ...", undefined));
39242                             var typeNode_1 = typeToTypeNodeHelper(types[types.length - 1], context);
39243                             if (typeNode_1) {
39244                                 result_4.push(typeNode_1);
39245                             }
39246                             break;
39247                         }
39248                         context.approximateLength += 2;
39249                         var typeNode = typeToTypeNodeHelper(type, context);
39250                         if (typeNode) {
39251                             result_4.push(typeNode);
39252                             if (seenNames && ts.isIdentifierTypeReference(typeNode)) {
39253                                 seenNames.add(typeNode.typeName.escapedText, [type, result_4.length - 1]);
39254                             }
39255                         }
39256                     }
39257                     if (seenNames) {
39258                         var saveContextFlags = context.flags;
39259                         context.flags |= 64;
39260                         seenNames.forEach(function (types) {
39261                             if (!ts.arrayIsHomogeneous(types, function (_a, _b) {
39262                                 var a = _a[0];
39263                                 var b = _b[0];
39264                                 return typesAreSameReference(a, b);
39265                             })) {
39266                                 for (var _i = 0, types_3 = types; _i < types_3.length; _i++) {
39267                                     var _a = types_3[_i], type = _a[0], resultIndex = _a[1];
39268                                     result_4[resultIndex] = typeToTypeNodeHelper(type, context);
39269                                 }
39270                             }
39271                         });
39272                         context.flags = saveContextFlags;
39273                     }
39274                     return result_4;
39275                 }
39276             }
39277             function typesAreSameReference(a, b) {
39278                 return a === b
39279                     || !!a.symbol && a.symbol === b.symbol
39280                     || !!a.aliasSymbol && a.aliasSymbol === b.aliasSymbol;
39281             }
39282             function indexInfoToIndexSignatureDeclarationHelper(indexInfo, kind, context, typeNode) {
39283                 var name = ts.getNameFromIndexInfo(indexInfo) || "x";
39284                 var indexerTypeNode = ts.factory.createKeywordTypeNode(kind === 0 ? 147 : 144);
39285                 var indexingParameter = ts.factory.createParameterDeclaration(undefined, undefined, undefined, name, undefined, indexerTypeNode, undefined);
39286                 if (!typeNode) {
39287                     typeNode = typeToTypeNodeHelper(indexInfo.type || anyType, context);
39288                 }
39289                 if (!indexInfo.type && !(context.flags & 2097152)) {
39290                     context.encounteredError = true;
39291                 }
39292                 context.approximateLength += (name.length + 4);
39293                 return ts.factory.createIndexSignature(undefined, indexInfo.isReadonly ? [ts.factory.createToken(142)] : undefined, [indexingParameter], typeNode);
39294             }
39295             function signatureToSignatureDeclarationHelper(signature, kind, context, options) {
39296                 var _a, _b, _c, _d;
39297                 var suppressAny = context.flags & 256;
39298                 if (suppressAny)
39299                     context.flags &= ~256;
39300                 var typeParameters;
39301                 var typeArguments;
39302                 if (context.flags & 32 && signature.target && signature.mapper && signature.target.typeParameters) {
39303                     typeArguments = signature.target.typeParameters.map(function (parameter) { return typeToTypeNodeHelper(instantiateType(parameter, signature.mapper), context); });
39304                 }
39305                 else {
39306                     typeParameters = signature.typeParameters && signature.typeParameters.map(function (parameter) { return typeParameterToDeclaration(parameter, context); });
39307                 }
39308                 var expandedParams = getExpandedParameters(signature, true)[0];
39309                 var parameters = (ts.some(expandedParams, function (p) { return p !== expandedParams[expandedParams.length - 1] && !!(ts.getCheckFlags(p) & 32768); }) ? signature.parameters : expandedParams).map(function (parameter) { return symbolToParameterDeclaration(parameter, context, kind === 166, options === null || options === void 0 ? void 0 : options.privateSymbolVisitor, options === null || options === void 0 ? void 0 : options.bundledImports); });
39310                 if (signature.thisParameter) {
39311                     var thisParameter = symbolToParameterDeclaration(signature.thisParameter, context);
39312                     parameters.unshift(thisParameter);
39313                 }
39314                 var returnTypeNode;
39315                 var typePredicate = getTypePredicateOfSignature(signature);
39316                 if (typePredicate) {
39317                     var assertsModifier = typePredicate.kind === 2 || typePredicate.kind === 3 ?
39318                         ts.factory.createToken(127) :
39319                         undefined;
39320                     var parameterName = typePredicate.kind === 1 || typePredicate.kind === 3 ?
39321                         ts.setEmitFlags(ts.factory.createIdentifier(typePredicate.parameterName), 16777216) :
39322                         ts.factory.createThisTypeNode();
39323                     var typeNode = typePredicate.type && typeToTypeNodeHelper(typePredicate.type, context);
39324                     returnTypeNode = ts.factory.createTypePredicateNode(assertsModifier, parameterName, typeNode);
39325                 }
39326                 else {
39327                     var returnType = getReturnTypeOfSignature(signature);
39328                     if (returnType && !(suppressAny && isTypeAny(returnType))) {
39329                         returnTypeNode = serializeReturnTypeForSignature(context, returnType, signature, options === null || options === void 0 ? void 0 : options.privateSymbolVisitor, options === null || options === void 0 ? void 0 : options.bundledImports);
39330                     }
39331                     else if (!suppressAny) {
39332                         returnTypeNode = ts.factory.createKeywordTypeNode(128);
39333                     }
39334                 }
39335                 context.approximateLength += 3;
39336                 var node = kind === 169 ? ts.factory.createCallSignature(typeParameters, parameters, returnTypeNode) :
39337                     kind === 170 ? ts.factory.createConstructSignature(typeParameters, parameters, returnTypeNode) :
39338                         kind === 164 ? ts.factory.createMethodSignature(options === null || options === void 0 ? void 0 : options.modifiers, (_a = options === null || options === void 0 ? void 0 : options.name) !== null && _a !== void 0 ? _a : ts.factory.createIdentifier(""), options === null || options === void 0 ? void 0 : options.questionToken, typeParameters, parameters, returnTypeNode) :
39339                             kind === 165 ? ts.factory.createMethodDeclaration(undefined, options === null || options === void 0 ? void 0 : options.modifiers, undefined, (_b = options === null || options === void 0 ? void 0 : options.name) !== null && _b !== void 0 ? _b : ts.factory.createIdentifier(""), undefined, typeParameters, parameters, returnTypeNode, undefined) :
39340                                 kind === 166 ? ts.factory.createConstructorDeclaration(undefined, options === null || options === void 0 ? void 0 : options.modifiers, parameters, undefined) :
39341                                     kind === 167 ? ts.factory.createGetAccessorDeclaration(undefined, options === null || options === void 0 ? void 0 : options.modifiers, (_c = options === null || options === void 0 ? void 0 : options.name) !== null && _c !== void 0 ? _c : ts.factory.createIdentifier(""), parameters, returnTypeNode, undefined) :
39342                                         kind === 168 ? ts.factory.createSetAccessorDeclaration(undefined, options === null || options === void 0 ? void 0 : options.modifiers, (_d = options === null || options === void 0 ? void 0 : options.name) !== null && _d !== void 0 ? _d : ts.factory.createIdentifier(""), parameters, undefined) :
39343                                             kind === 171 ? ts.factory.createIndexSignature(undefined, options === null || options === void 0 ? void 0 : options.modifiers, parameters, returnTypeNode) :
39344                                                 kind === 308 ? ts.factory.createJSDocFunctionType(parameters, returnTypeNode) :
39345                                                     kind === 174 ? ts.factory.createFunctionTypeNode(typeParameters, parameters, returnTypeNode !== null && returnTypeNode !== void 0 ? returnTypeNode : ts.factory.createTypeReferenceNode(ts.factory.createIdentifier(""))) :
39346                                                         kind === 175 ? ts.factory.createConstructorTypeNode(typeParameters, parameters, returnTypeNode !== null && returnTypeNode !== void 0 ? returnTypeNode : ts.factory.createTypeReferenceNode(ts.factory.createIdentifier(""))) :
39347                                                             kind === 251 ? ts.factory.createFunctionDeclaration(undefined, options === null || options === void 0 ? void 0 : options.modifiers, undefined, (options === null || options === void 0 ? void 0 : options.name) ? ts.cast(options.name, ts.isIdentifier) : ts.factory.createIdentifier(""), typeParameters, parameters, returnTypeNode, undefined) :
39348                                                                 kind === 208 ? ts.factory.createFunctionExpression(options === null || options === void 0 ? void 0 : options.modifiers, undefined, (options === null || options === void 0 ? void 0 : options.name) ? ts.cast(options.name, ts.isIdentifier) : ts.factory.createIdentifier(""), typeParameters, parameters, returnTypeNode, ts.factory.createBlock([])) :
39349                                                                     kind === 209 ? ts.factory.createArrowFunction(options === null || options === void 0 ? void 0 : options.modifiers, typeParameters, parameters, returnTypeNode, undefined, ts.factory.createBlock([])) :
39350                                                                         ts.Debug.assertNever(kind);
39351                 if (typeArguments) {
39352                     node.typeArguments = ts.factory.createNodeArray(typeArguments);
39353                 }
39354                 return node;
39355             }
39356             function typeParameterToDeclarationWithConstraint(type, context, constraintNode) {
39357                 var savedContextFlags = context.flags;
39358                 context.flags &= ~512;
39359                 var name = typeParameterToName(type, context);
39360                 var defaultParameter = getDefaultFromTypeParameter(type);
39361                 var defaultParameterNode = defaultParameter && typeToTypeNodeHelper(defaultParameter, context);
39362                 context.flags = savedContextFlags;
39363                 return ts.factory.createTypeParameterDeclaration(name, constraintNode, defaultParameterNode);
39364             }
39365             function typeParameterToDeclaration(type, context, constraint) {
39366                 if (constraint === void 0) { constraint = getConstraintOfTypeParameter(type); }
39367                 var constraintNode = constraint && typeToTypeNodeHelper(constraint, context);
39368                 return typeParameterToDeclarationWithConstraint(type, context, constraintNode);
39369             }
39370             function symbolToParameterDeclaration(parameterSymbol, context, preserveModifierFlags, privateSymbolVisitor, bundledImports) {
39371                 var parameterDeclaration = ts.getDeclarationOfKind(parameterSymbol, 160);
39372                 if (!parameterDeclaration && !ts.isTransientSymbol(parameterSymbol)) {
39373                     parameterDeclaration = ts.getDeclarationOfKind(parameterSymbol, 326);
39374                 }
39375                 var parameterType = getTypeOfSymbol(parameterSymbol);
39376                 if (parameterDeclaration && isRequiredInitializedParameter(parameterDeclaration)) {
39377                     parameterType = getOptionalType(parameterType);
39378                 }
39379                 if ((context.flags & 1073741824) && parameterDeclaration && !ts.isJSDocParameterTag(parameterDeclaration) && isOptionalUninitializedParameter(parameterDeclaration)) {
39380                     parameterType = getTypeWithFacts(parameterType, 524288);
39381                 }
39382                 var parameterTypeNode = serializeTypeForDeclaration(context, parameterType, parameterSymbol, context.enclosingDeclaration, privateSymbolVisitor, bundledImports);
39383                 var modifiers = !(context.flags & 8192) && preserveModifierFlags && parameterDeclaration && parameterDeclaration.modifiers ? parameterDeclaration.modifiers.map(ts.factory.cloneNode) : undefined;
39384                 var isRest = parameterDeclaration && ts.isRestParameter(parameterDeclaration) || ts.getCheckFlags(parameterSymbol) & 32768;
39385                 var dotDotDotToken = isRest ? ts.factory.createToken(25) : undefined;
39386                 var name = parameterDeclaration ? parameterDeclaration.name ?
39387                     parameterDeclaration.name.kind === 78 ? ts.setEmitFlags(ts.factory.cloneNode(parameterDeclaration.name), 16777216) :
39388                         parameterDeclaration.name.kind === 157 ? ts.setEmitFlags(ts.factory.cloneNode(parameterDeclaration.name.right), 16777216) :
39389                             cloneBindingName(parameterDeclaration.name) :
39390                     ts.symbolName(parameterSymbol) :
39391                     ts.symbolName(parameterSymbol);
39392                 var isOptional = parameterDeclaration && isOptionalParameter(parameterDeclaration) || ts.getCheckFlags(parameterSymbol) & 16384;
39393                 var questionToken = isOptional ? ts.factory.createToken(57) : undefined;
39394                 var parameterNode = ts.factory.createParameterDeclaration(undefined, modifiers, dotDotDotToken, name, questionToken, parameterTypeNode, undefined);
39395                 context.approximateLength += ts.symbolName(parameterSymbol).length + 3;
39396                 return parameterNode;
39397                 function cloneBindingName(node) {
39398                     return elideInitializerAndSetEmitFlags(node);
39399                     function elideInitializerAndSetEmitFlags(node) {
39400                         if (context.tracker.trackSymbol && ts.isComputedPropertyName(node) && isLateBindableName(node)) {
39401                             trackComputedName(node.expression, context.enclosingDeclaration, context);
39402                         }
39403                         var visited = ts.visitEachChild(node, elideInitializerAndSetEmitFlags, ts.nullTransformationContext, undefined, elideInitializerAndSetEmitFlags);
39404                         if (ts.isBindingElement(visited)) {
39405                             visited = ts.factory.updateBindingElement(visited, visited.dotDotDotToken, visited.propertyName, visited.name, undefined);
39406                         }
39407                         if (!ts.nodeIsSynthesized(visited)) {
39408                             visited = ts.factory.cloneNode(visited);
39409                         }
39410                         return ts.setEmitFlags(visited, 1 | 16777216);
39411                     }
39412                 }
39413             }
39414             function trackComputedName(accessExpression, enclosingDeclaration, context) {
39415                 if (!context.tracker.trackSymbol)
39416                     return;
39417                 var firstIdentifier = ts.getFirstIdentifier(accessExpression);
39418                 var name = resolveName(firstIdentifier, firstIdentifier.escapedText, 111551 | 1048576, undefined, undefined, true);
39419                 if (name) {
39420                     context.tracker.trackSymbol(name, enclosingDeclaration, 111551);
39421                 }
39422             }
39423             function lookupSymbolChain(symbol, context, meaning, yieldModuleSymbol) {
39424                 context.tracker.trackSymbol(symbol, context.enclosingDeclaration, meaning);
39425                 return lookupSymbolChainWorker(symbol, context, meaning, yieldModuleSymbol);
39426             }
39427             function lookupSymbolChainWorker(symbol, context, meaning, yieldModuleSymbol) {
39428                 var chain;
39429                 var isTypeParameter = symbol.flags & 262144;
39430                 if (!isTypeParameter && (context.enclosingDeclaration || context.flags & 64) && !(context.flags & 134217728)) {
39431                     chain = ts.Debug.checkDefined(getSymbolChain(symbol, meaning, true));
39432                     ts.Debug.assert(chain && chain.length > 0);
39433                 }
39434                 else {
39435                     chain = [symbol];
39436                 }
39437                 return chain;
39438                 function getSymbolChain(symbol, meaning, endOfChain) {
39439                     var accessibleSymbolChain = getAccessibleSymbolChain(symbol, context.enclosingDeclaration, meaning, !!(context.flags & 128));
39440                     var parentSpecifiers;
39441                     if (!accessibleSymbolChain ||
39442                         needsQualification(accessibleSymbolChain[0], context.enclosingDeclaration, accessibleSymbolChain.length === 1 ? meaning : getQualifiedLeftMeaning(meaning))) {
39443                         var parents_1 = getContainersOfSymbol(accessibleSymbolChain ? accessibleSymbolChain[0] : symbol, context.enclosingDeclaration, meaning);
39444                         if (ts.length(parents_1)) {
39445                             parentSpecifiers = parents_1.map(function (symbol) {
39446                                 return ts.some(symbol.declarations, hasNonGlobalAugmentationExternalModuleSymbol)
39447                                     ? getSpecifierForModuleSymbol(symbol, context)
39448                                     : undefined;
39449                             });
39450                             var indices = parents_1.map(function (_, i) { return i; });
39451                             indices.sort(sortByBestName);
39452                             var sortedParents = indices.map(function (i) { return parents_1[i]; });
39453                             for (var _i = 0, sortedParents_1 = sortedParents; _i < sortedParents_1.length; _i++) {
39454                                 var parent = sortedParents_1[_i];
39455                                 var parentChain = getSymbolChain(parent, getQualifiedLeftMeaning(meaning), false);
39456                                 if (parentChain) {
39457                                     if (parent.exports && parent.exports.get("export=") &&
39458                                         getSymbolIfSameReference(parent.exports.get("export="), symbol)) {
39459                                         accessibleSymbolChain = parentChain;
39460                                         break;
39461                                     }
39462                                     accessibleSymbolChain = parentChain.concat(accessibleSymbolChain || [getAliasForSymbolInContainer(parent, symbol) || symbol]);
39463                                     break;
39464                                 }
39465                             }
39466                         }
39467                     }
39468                     if (accessibleSymbolChain) {
39469                         return accessibleSymbolChain;
39470                     }
39471                     if (endOfChain ||
39472                         !(symbol.flags & (2048 | 4096))) {
39473                         if (!endOfChain && !yieldModuleSymbol && !!ts.forEach(symbol.declarations, hasNonGlobalAugmentationExternalModuleSymbol)) {
39474                             return;
39475                         }
39476                         return [symbol];
39477                     }
39478                     function sortByBestName(a, b) {
39479                         var specifierA = parentSpecifiers[a];
39480                         var specifierB = parentSpecifiers[b];
39481                         if (specifierA && specifierB) {
39482                             var isBRelative = ts.pathIsRelative(specifierB);
39483                             if (ts.pathIsRelative(specifierA) === isBRelative) {
39484                                 return ts.moduleSpecifiers.countPathComponents(specifierA) - ts.moduleSpecifiers.countPathComponents(specifierB);
39485                             }
39486                             if (isBRelative) {
39487                                 return -1;
39488                             }
39489                             return 1;
39490                         }
39491                         return 0;
39492                     }
39493                 }
39494             }
39495             function typeParametersToTypeParameterDeclarations(symbol, context) {
39496                 var typeParameterNodes;
39497                 var targetSymbol = getTargetSymbol(symbol);
39498                 if (targetSymbol.flags & (32 | 64 | 524288)) {
39499                     typeParameterNodes = ts.factory.createNodeArray(ts.map(getLocalTypeParametersOfClassOrInterfaceOrTypeAlias(symbol), function (tp) { return typeParameterToDeclaration(tp, context); }));
39500                 }
39501                 return typeParameterNodes;
39502             }
39503             function lookupTypeParameterNodes(chain, index, context) {
39504                 var _a;
39505                 ts.Debug.assert(chain && 0 <= index && index < chain.length);
39506                 var symbol = chain[index];
39507                 var symbolId = getSymbolId(symbol);
39508                 if ((_a = context.typeParameterSymbolList) === null || _a === void 0 ? void 0 : _a.has(symbolId)) {
39509                     return undefined;
39510                 }
39511                 (context.typeParameterSymbolList || (context.typeParameterSymbolList = new ts.Set())).add(symbolId);
39512                 var typeParameterNodes;
39513                 if (context.flags & 512 && index < (chain.length - 1)) {
39514                     var parentSymbol = symbol;
39515                     var nextSymbol_1 = chain[index + 1];
39516                     if (ts.getCheckFlags(nextSymbol_1) & 1) {
39517                         var params = getTypeParametersOfClassOrInterface(parentSymbol.flags & 2097152 ? resolveAlias(parentSymbol) : parentSymbol);
39518                         typeParameterNodes = mapToTypeNodes(ts.map(params, function (t) { return getMappedType(t, nextSymbol_1.mapper); }), context);
39519                     }
39520                     else {
39521                         typeParameterNodes = typeParametersToTypeParameterDeclarations(symbol, context);
39522                     }
39523                 }
39524                 return typeParameterNodes;
39525             }
39526             function getTopmostIndexedAccessType(top) {
39527                 if (ts.isIndexedAccessTypeNode(top.objectType)) {
39528                     return getTopmostIndexedAccessType(top.objectType);
39529                 }
39530                 return top;
39531             }
39532             function getSpecifierForModuleSymbol(symbol, context) {
39533                 var _a;
39534                 var file = ts.getDeclarationOfKind(symbol, 297);
39535                 if (!file) {
39536                     var equivalentFileSymbol = ts.firstDefined(symbol.declarations, function (d) { return getFileSymbolIfFileSymbolExportEqualsContainer(d, symbol); });
39537                     if (equivalentFileSymbol) {
39538                         file = ts.getDeclarationOfKind(equivalentFileSymbol, 297);
39539                     }
39540                 }
39541                 if (file && file.moduleName !== undefined) {
39542                     return file.moduleName;
39543                 }
39544                 if (!file) {
39545                     if (context.tracker.trackReferencedAmbientModule) {
39546                         var ambientDecls = ts.filter(symbol.declarations, ts.isAmbientModule);
39547                         if (ts.length(ambientDecls)) {
39548                             for (var _i = 0, ambientDecls_1 = ambientDecls; _i < ambientDecls_1.length; _i++) {
39549                                 var decl = ambientDecls_1[_i];
39550                                 context.tracker.trackReferencedAmbientModule(decl, symbol);
39551                             }
39552                         }
39553                     }
39554                     if (ambientModuleSymbolRegex.test(symbol.escapedName)) {
39555                         return symbol.escapedName.substring(1, symbol.escapedName.length - 1);
39556                     }
39557                 }
39558                 if (!context.enclosingDeclaration || !context.tracker.moduleResolverHost) {
39559                     if (ambientModuleSymbolRegex.test(symbol.escapedName)) {
39560                         return symbol.escapedName.substring(1, symbol.escapedName.length - 1);
39561                     }
39562                     return ts.getSourceFileOfNode(ts.getNonAugmentationDeclaration(symbol)).fileName;
39563                 }
39564                 var contextFile = ts.getSourceFileOfNode(ts.getOriginalNode(context.enclosingDeclaration));
39565                 var links = getSymbolLinks(symbol);
39566                 var specifier = links.specifierCache && links.specifierCache.get(contextFile.path);
39567                 if (!specifier) {
39568                     var isBundle_1 = !!ts.outFile(compilerOptions);
39569                     var moduleResolverHost = context.tracker.moduleResolverHost;
39570                     var specifierCompilerOptions = isBundle_1 ? __assign(__assign({}, compilerOptions), { baseUrl: moduleResolverHost.getCommonSourceDirectory() }) : compilerOptions;
39571                     specifier = ts.first(ts.moduleSpecifiers.getModuleSpecifiers(symbol, specifierCompilerOptions, contextFile, moduleResolverHost, { importModuleSpecifierPreference: isBundle_1 ? "non-relative" : "relative", importModuleSpecifierEnding: isBundle_1 ? "minimal" : undefined }));
39572                     (_a = links.specifierCache) !== null && _a !== void 0 ? _a : (links.specifierCache = new ts.Map());
39573                     links.specifierCache.set(contextFile.path, specifier);
39574                 }
39575                 return specifier;
39576             }
39577             function symbolToTypeNode(symbol, context, meaning, overrideTypeArguments) {
39578                 var chain = lookupSymbolChain(symbol, context, meaning, !(context.flags & 16384));
39579                 var isTypeOf = meaning === 111551;
39580                 if (ts.some(chain[0].declarations, hasNonGlobalAugmentationExternalModuleSymbol)) {
39581                     var nonRootParts = chain.length > 1 ? createAccessFromSymbolChain(chain, chain.length - 1, 1) : undefined;
39582                     var typeParameterNodes = overrideTypeArguments || lookupTypeParameterNodes(chain, 0, context);
39583                     var specifier = getSpecifierForModuleSymbol(chain[0], context);
39584                     if (!(context.flags & 67108864) && ts.getEmitModuleResolutionKind(compilerOptions) === ts.ModuleResolutionKind.NodeJs && specifier.indexOf("/node_modules/") >= 0) {
39585                         context.encounteredError = true;
39586                         if (context.tracker.reportLikelyUnsafeImportRequiredError) {
39587                             context.tracker.reportLikelyUnsafeImportRequiredError(specifier);
39588                         }
39589                     }
39590                     var lit = ts.factory.createLiteralTypeNode(ts.factory.createStringLiteral(specifier));
39591                     if (context.tracker.trackExternalModuleSymbolOfImportTypeNode)
39592                         context.tracker.trackExternalModuleSymbolOfImportTypeNode(chain[0]);
39593                     context.approximateLength += specifier.length + 10;
39594                     if (!nonRootParts || ts.isEntityName(nonRootParts)) {
39595                         if (nonRootParts) {
39596                             var lastId = ts.isIdentifier(nonRootParts) ? nonRootParts : nonRootParts.right;
39597                             lastId.typeArguments = undefined;
39598                         }
39599                         return ts.factory.createImportTypeNode(lit, nonRootParts, typeParameterNodes, isTypeOf);
39600                     }
39601                     else {
39602                         var splitNode = getTopmostIndexedAccessType(nonRootParts);
39603                         var qualifier = splitNode.objectType.typeName;
39604                         return ts.factory.createIndexedAccessTypeNode(ts.factory.createImportTypeNode(lit, qualifier, typeParameterNodes, isTypeOf), splitNode.indexType);
39605                     }
39606                 }
39607                 var entityName = createAccessFromSymbolChain(chain, chain.length - 1, 0);
39608                 if (ts.isIndexedAccessTypeNode(entityName)) {
39609                     return entityName;
39610                 }
39611                 if (isTypeOf) {
39612                     return ts.factory.createTypeQueryNode(entityName);
39613                 }
39614                 else {
39615                     var lastId = ts.isIdentifier(entityName) ? entityName : entityName.right;
39616                     var lastTypeArgs = lastId.typeArguments;
39617                     lastId.typeArguments = undefined;
39618                     return ts.factory.createTypeReferenceNode(entityName, lastTypeArgs);
39619                 }
39620                 function createAccessFromSymbolChain(chain, index, stopper) {
39621                     var typeParameterNodes = index === (chain.length - 1) ? overrideTypeArguments : lookupTypeParameterNodes(chain, index, context);
39622                     var symbol = chain[index];
39623                     var parent = chain[index - 1];
39624                     var symbolName;
39625                     if (index === 0) {
39626                         context.flags |= 16777216;
39627                         symbolName = getNameOfSymbolAsWritten(symbol, context);
39628                         context.approximateLength += (symbolName ? symbolName.length : 0) + 1;
39629                         context.flags ^= 16777216;
39630                     }
39631                     else {
39632                         if (parent && getExportsOfSymbol(parent)) {
39633                             var exports_1 = getExportsOfSymbol(parent);
39634                             ts.forEachEntry(exports_1, function (ex, name) {
39635                                 if (getSymbolIfSameReference(ex, symbol) && !isLateBoundName(name) && name !== "export=") {
39636                                     symbolName = ts.unescapeLeadingUnderscores(name);
39637                                     return true;
39638                                 }
39639                             });
39640                         }
39641                     }
39642                     if (!symbolName) {
39643                         symbolName = getNameOfSymbolAsWritten(symbol, context);
39644                     }
39645                     context.approximateLength += symbolName.length + 1;
39646                     if (!(context.flags & 16) && parent &&
39647                         getMembersOfSymbol(parent) && getMembersOfSymbol(parent).get(symbol.escapedName) &&
39648                         getSymbolIfSameReference(getMembersOfSymbol(parent).get(symbol.escapedName), symbol)) {
39649                         var LHS = createAccessFromSymbolChain(chain, index - 1, stopper);
39650                         if (ts.isIndexedAccessTypeNode(LHS)) {
39651                             return ts.factory.createIndexedAccessTypeNode(LHS, ts.factory.createLiteralTypeNode(ts.factory.createStringLiteral(symbolName)));
39652                         }
39653                         else {
39654                             return ts.factory.createIndexedAccessTypeNode(ts.factory.createTypeReferenceNode(LHS, typeParameterNodes), ts.factory.createLiteralTypeNode(ts.factory.createStringLiteral(symbolName)));
39655                         }
39656                     }
39657                     var identifier = ts.setEmitFlags(ts.factory.createIdentifier(symbolName, typeParameterNodes), 16777216);
39658                     identifier.symbol = symbol;
39659                     if (index > stopper) {
39660                         var LHS = createAccessFromSymbolChain(chain, index - 1, stopper);
39661                         if (!ts.isEntityName(LHS)) {
39662                             return ts.Debug.fail("Impossible construct - an export of an indexed access cannot be reachable");
39663                         }
39664                         return ts.factory.createQualifiedName(LHS, identifier);
39665                     }
39666                     return identifier;
39667                 }
39668             }
39669             function typeParameterShadowsNameInScope(escapedName, context, type) {
39670                 var result = resolveName(context.enclosingDeclaration, escapedName, 788968, undefined, escapedName, false);
39671                 if (result) {
39672                     if (result.flags & 262144 && result === type.symbol) {
39673                         return false;
39674                     }
39675                     return true;
39676                 }
39677                 return false;
39678             }
39679             function typeParameterToName(type, context) {
39680                 var _a;
39681                 if (context.flags & 4 && context.typeParameterNames) {
39682                     var cached = context.typeParameterNames.get(getTypeId(type));
39683                     if (cached) {
39684                         return cached;
39685                     }
39686                 }
39687                 var result = symbolToName(type.symbol, context, 788968, true);
39688                 if (!(result.kind & 78)) {
39689                     return ts.factory.createIdentifier("(Missing type parameter)");
39690                 }
39691                 if (context.flags & 4) {
39692                     var rawtext = result.escapedText;
39693                     var i = 0;
39694                     var text = rawtext;
39695                     while (((_a = context.typeParameterNamesByText) === null || _a === void 0 ? void 0 : _a.has(text)) || typeParameterShadowsNameInScope(text, context, type)) {
39696                         i++;
39697                         text = rawtext + "_" + i;
39698                     }
39699                     if (text !== rawtext) {
39700                         result = ts.factory.createIdentifier(text, result.typeArguments);
39701                     }
39702                     (context.typeParameterNames || (context.typeParameterNames = new ts.Map())).set(getTypeId(type), result);
39703                     (context.typeParameterNamesByText || (context.typeParameterNamesByText = new ts.Set())).add(result.escapedText);
39704                 }
39705                 return result;
39706             }
39707             function symbolToName(symbol, context, meaning, expectsIdentifier) {
39708                 var chain = lookupSymbolChain(symbol, context, meaning);
39709                 if (expectsIdentifier && chain.length !== 1
39710                     && !context.encounteredError
39711                     && !(context.flags & 65536)) {
39712                     context.encounteredError = true;
39713                 }
39714                 return createEntityNameFromSymbolChain(chain, chain.length - 1);
39715                 function createEntityNameFromSymbolChain(chain, index) {
39716                     var typeParameterNodes = lookupTypeParameterNodes(chain, index, context);
39717                     var symbol = chain[index];
39718                     if (index === 0) {
39719                         context.flags |= 16777216;
39720                     }
39721                     var symbolName = getNameOfSymbolAsWritten(symbol, context);
39722                     if (index === 0) {
39723                         context.flags ^= 16777216;
39724                     }
39725                     var identifier = ts.setEmitFlags(ts.factory.createIdentifier(symbolName, typeParameterNodes), 16777216);
39726                     identifier.symbol = symbol;
39727                     return index > 0 ? ts.factory.createQualifiedName(createEntityNameFromSymbolChain(chain, index - 1), identifier) : identifier;
39728                 }
39729             }
39730             function symbolToExpression(symbol, context, meaning) {
39731                 var chain = lookupSymbolChain(symbol, context, meaning);
39732                 return createExpressionFromSymbolChain(chain, chain.length - 1);
39733                 function createExpressionFromSymbolChain(chain, index) {
39734                     var typeParameterNodes = lookupTypeParameterNodes(chain, index, context);
39735                     var symbol = chain[index];
39736                     if (index === 0) {
39737                         context.flags |= 16777216;
39738                     }
39739                     var symbolName = getNameOfSymbolAsWritten(symbol, context);
39740                     if (index === 0) {
39741                         context.flags ^= 16777216;
39742                     }
39743                     var firstChar = symbolName.charCodeAt(0);
39744                     if (ts.isSingleOrDoubleQuote(firstChar) && ts.some(symbol.declarations, hasNonGlobalAugmentationExternalModuleSymbol)) {
39745                         return ts.factory.createStringLiteral(getSpecifierForModuleSymbol(symbol, context));
39746                     }
39747                     var canUsePropertyAccess = firstChar === 35 ?
39748                         symbolName.length > 1 && ts.isIdentifierStart(symbolName.charCodeAt(1), languageVersion) :
39749                         ts.isIdentifierStart(firstChar, languageVersion);
39750                     if (index === 0 || canUsePropertyAccess) {
39751                         var identifier = ts.setEmitFlags(ts.factory.createIdentifier(symbolName, typeParameterNodes), 16777216);
39752                         identifier.symbol = symbol;
39753                         return index > 0 ? ts.factory.createPropertyAccessExpression(createExpressionFromSymbolChain(chain, index - 1), identifier) : identifier;
39754                     }
39755                     else {
39756                         if (firstChar === 91) {
39757                             symbolName = symbolName.substring(1, symbolName.length - 1);
39758                             firstChar = symbolName.charCodeAt(0);
39759                         }
39760                         var expression = void 0;
39761                         if (ts.isSingleOrDoubleQuote(firstChar)) {
39762                             expression = ts.factory.createStringLiteral(symbolName
39763                                 .substring(1, symbolName.length - 1)
39764                                 .replace(/\\./g, function (s) { return s.substring(1); }), firstChar === 39);
39765                         }
39766                         else if (("" + +symbolName) === symbolName) {
39767                             expression = ts.factory.createNumericLiteral(+symbolName);
39768                         }
39769                         if (!expression) {
39770                             expression = ts.setEmitFlags(ts.factory.createIdentifier(symbolName, typeParameterNodes), 16777216);
39771                             expression.symbol = symbol;
39772                         }
39773                         return ts.factory.createElementAccessExpression(createExpressionFromSymbolChain(chain, index - 1), expression);
39774                     }
39775                 }
39776             }
39777             function isStringNamed(d) {
39778                 var name = ts.getNameOfDeclaration(d);
39779                 return !!name && ts.isStringLiteral(name);
39780             }
39781             function isSingleQuotedStringNamed(d) {
39782                 var name = ts.getNameOfDeclaration(d);
39783                 return !!(name && ts.isStringLiteral(name) && (name.singleQuote || !ts.nodeIsSynthesized(name) && ts.startsWith(ts.getTextOfNode(name, false), "'")));
39784             }
39785             function getPropertyNameNodeForSymbol(symbol, context) {
39786                 var singleQuote = !!ts.length(symbol.declarations) && ts.every(symbol.declarations, isSingleQuotedStringNamed);
39787                 var fromNameType = getPropertyNameNodeForSymbolFromNameType(symbol, context, singleQuote);
39788                 if (fromNameType) {
39789                     return fromNameType;
39790                 }
39791                 if (ts.isKnownSymbol(symbol)) {
39792                     return ts.factory.createComputedPropertyName(ts.factory.createPropertyAccessExpression(ts.factory.createIdentifier("Symbol"), symbol.escapedName.substr(3)));
39793                 }
39794                 var rawName = ts.unescapeLeadingUnderscores(symbol.escapedName);
39795                 var stringNamed = !!ts.length(symbol.declarations) && ts.every(symbol.declarations, isStringNamed);
39796                 return createPropertyNameNodeForIdentifierOrLiteral(rawName, stringNamed, singleQuote);
39797             }
39798             function getPropertyNameNodeForSymbolFromNameType(symbol, context, singleQuote) {
39799                 var nameType = getSymbolLinks(symbol).nameType;
39800                 if (nameType) {
39801                     if (nameType.flags & 384) {
39802                         var name = "" + nameType.value;
39803                         if (!ts.isIdentifierText(name, compilerOptions.target) && !isNumericLiteralName(name)) {
39804                             return ts.factory.createStringLiteral(name, !!singleQuote);
39805                         }
39806                         if (isNumericLiteralName(name) && ts.startsWith(name, "-")) {
39807                             return ts.factory.createComputedPropertyName(ts.factory.createNumericLiteral(+name));
39808                         }
39809                         return createPropertyNameNodeForIdentifierOrLiteral(name);
39810                     }
39811                     if (nameType.flags & 8192) {
39812                         return ts.factory.createComputedPropertyName(symbolToExpression(nameType.symbol, context, 111551));
39813                     }
39814                 }
39815             }
39816             function createPropertyNameNodeForIdentifierOrLiteral(name, stringNamed, singleQuote) {
39817                 return ts.isIdentifierText(name, compilerOptions.target) ? ts.factory.createIdentifier(name) :
39818                     !stringNamed && isNumericLiteralName(name) && +name >= 0 ? ts.factory.createNumericLiteral(+name) :
39819                         ts.factory.createStringLiteral(name, !!singleQuote);
39820             }
39821             function cloneNodeBuilderContext(context) {
39822                 var initial = __assign({}, context);
39823                 if (initial.typeParameterNames) {
39824                     initial.typeParameterNames = new ts.Map(initial.typeParameterNames);
39825                 }
39826                 if (initial.typeParameterNamesByText) {
39827                     initial.typeParameterNamesByText = new ts.Set(initial.typeParameterNamesByText);
39828                 }
39829                 if (initial.typeParameterSymbolList) {
39830                     initial.typeParameterSymbolList = new ts.Set(initial.typeParameterSymbolList);
39831                 }
39832                 return initial;
39833             }
39834             function getDeclarationWithTypeAnnotation(symbol, enclosingDeclaration) {
39835                 return symbol.declarations && ts.find(symbol.declarations, function (s) { return !!ts.getEffectiveTypeAnnotationNode(s) && (!enclosingDeclaration || !!ts.findAncestor(s, function (n) { return n === enclosingDeclaration; })); });
39836             }
39837             function existingTypeNodeIsNotReferenceOrIsReferenceWithCompatibleTypeArgumentCount(existing, type) {
39838                 return !(ts.getObjectFlags(type) & 4) || !ts.isTypeReferenceNode(existing) || ts.length(existing.typeArguments) >= getMinTypeArgumentCount(type.target.typeParameters);
39839             }
39840             function serializeTypeForDeclaration(context, type, symbol, enclosingDeclaration, includePrivateSymbol, bundled) {
39841                 if (type !== errorType && enclosingDeclaration) {
39842                     var declWithExistingAnnotation = getDeclarationWithTypeAnnotation(symbol, enclosingDeclaration);
39843                     if (declWithExistingAnnotation && !ts.isFunctionLikeDeclaration(declWithExistingAnnotation)) {
39844                         var existing = ts.getEffectiveTypeAnnotationNode(declWithExistingAnnotation);
39845                         if (getTypeFromTypeNode(existing) === type && existingTypeNodeIsNotReferenceOrIsReferenceWithCompatibleTypeArgumentCount(existing, type)) {
39846                             var result_5 = serializeExistingTypeNode(context, existing, includePrivateSymbol, bundled);
39847                             if (result_5) {
39848                                 return result_5;
39849                             }
39850                         }
39851                     }
39852                 }
39853                 var oldFlags = context.flags;
39854                 if (type.flags & 8192 &&
39855                     type.symbol === symbol && (!context.enclosingDeclaration || ts.some(symbol.declarations, function (d) { return ts.getSourceFileOfNode(d) === ts.getSourceFileOfNode(context.enclosingDeclaration); }))) {
39856                     context.flags |= 1048576;
39857                 }
39858                 var result = typeToTypeNodeHelper(type, context);
39859                 context.flags = oldFlags;
39860                 return result;
39861             }
39862             function serializeReturnTypeForSignature(context, type, signature, includePrivateSymbol, bundled) {
39863                 if (type !== errorType && context.enclosingDeclaration) {
39864                     var annotation = signature.declaration && ts.getEffectiveReturnTypeNode(signature.declaration);
39865                     if (!!ts.findAncestor(annotation, function (n) { return n === context.enclosingDeclaration; }) && annotation && instantiateType(getTypeFromTypeNode(annotation), signature.mapper) === type && existingTypeNodeIsNotReferenceOrIsReferenceWithCompatibleTypeArgumentCount(annotation, type)) {
39866                         var result = serializeExistingTypeNode(context, annotation, includePrivateSymbol, bundled);
39867                         if (result) {
39868                             return result;
39869                         }
39870                     }
39871                 }
39872                 return typeToTypeNodeHelper(type, context);
39873             }
39874             function serializeExistingTypeNode(context, existing, includePrivateSymbol, bundled) {
39875                 if (cancellationToken && cancellationToken.throwIfCancellationRequested) {
39876                     cancellationToken.throwIfCancellationRequested();
39877                 }
39878                 var hadError = false;
39879                 var file = ts.getSourceFileOfNode(existing);
39880                 var transformed = ts.visitNode(existing, visitExistingNodeTreeSymbols);
39881                 if (hadError) {
39882                     return undefined;
39883                 }
39884                 return transformed === existing ? ts.setTextRange(ts.factory.cloneNode(existing), existing) : transformed;
39885                 function visitExistingNodeTreeSymbols(node) {
39886                     var _a, _b;
39887                     if (ts.isJSDocAllType(node) || node.kind === 310) {
39888                         return ts.factory.createKeywordTypeNode(128);
39889                     }
39890                     if (ts.isJSDocUnknownType(node)) {
39891                         return ts.factory.createKeywordTypeNode(152);
39892                     }
39893                     if (ts.isJSDocNullableType(node)) {
39894                         return ts.factory.createUnionTypeNode([ts.visitNode(node.type, visitExistingNodeTreeSymbols), ts.factory.createLiteralTypeNode(ts.factory.createNull())]);
39895                     }
39896                     if (ts.isJSDocOptionalType(node)) {
39897                         return ts.factory.createUnionTypeNode([ts.visitNode(node.type, visitExistingNodeTreeSymbols), ts.factory.createKeywordTypeNode(150)]);
39898                     }
39899                     if (ts.isJSDocNonNullableType(node)) {
39900                         return ts.visitNode(node.type, visitExistingNodeTreeSymbols);
39901                     }
39902                     if (ts.isJSDocVariadicType(node)) {
39903                         return ts.factory.createArrayTypeNode(ts.visitNode(node.type, visitExistingNodeTreeSymbols));
39904                     }
39905                     if (ts.isJSDocTypeLiteral(node)) {
39906                         return ts.factory.createTypeLiteralNode(ts.map(node.jsDocPropertyTags, function (t) {
39907                             var name = ts.isIdentifier(t.name) ? t.name : t.name.right;
39908                             var typeViaParent = getTypeOfPropertyOfType(getTypeFromTypeNode(node), name.escapedText);
39909                             var overrideTypeNode = typeViaParent && t.typeExpression && getTypeFromTypeNode(t.typeExpression.type) !== typeViaParent ? typeToTypeNodeHelper(typeViaParent, context) : undefined;
39910                             return ts.factory.createPropertySignature(undefined, name, t.typeExpression && ts.isJSDocOptionalType(t.typeExpression.type) ? ts.factory.createToken(57) : undefined, overrideTypeNode || (t.typeExpression && ts.visitNode(t.typeExpression.type, visitExistingNodeTreeSymbols)) || ts.factory.createKeywordTypeNode(128));
39911                         }));
39912                     }
39913                     if (ts.isTypeReferenceNode(node) && ts.isIdentifier(node.typeName) && node.typeName.escapedText === "") {
39914                         return ts.setOriginalNode(ts.factory.createKeywordTypeNode(128), node);
39915                     }
39916                     if ((ts.isExpressionWithTypeArguments(node) || ts.isTypeReferenceNode(node)) && ts.isJSDocIndexSignature(node)) {
39917                         return ts.factory.createTypeLiteralNode([ts.factory.createIndexSignature(undefined, undefined, [ts.factory.createParameterDeclaration(undefined, undefined, undefined, "x", undefined, ts.visitNode(node.typeArguments[0], visitExistingNodeTreeSymbols))], ts.visitNode(node.typeArguments[1], visitExistingNodeTreeSymbols))]);
39918                     }
39919                     if (ts.isJSDocFunctionType(node)) {
39920                         if (ts.isJSDocConstructSignature(node)) {
39921                             var newTypeNode_1;
39922                             return ts.factory.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.factory.createParameterDeclaration(undefined, undefined, getEffectiveDotDotDotForParameter(p), getNameForJSDocFunctionParameter(p, i), p.questionToken, ts.visitNode(p.type, visitExistingNodeTreeSymbols), undefined); }), ts.visitNode(newTypeNode_1 || node.type, visitExistingNodeTreeSymbols) || ts.factory.createKeywordTypeNode(128));
39923                         }
39924                         else {
39925                             return ts.factory.createFunctionTypeNode(ts.visitNodes(node.typeParameters, visitExistingNodeTreeSymbols), ts.map(node.parameters, function (p, i) { return ts.factory.createParameterDeclaration(undefined, undefined, getEffectiveDotDotDotForParameter(p), getNameForJSDocFunctionParameter(p, i), p.questionToken, ts.visitNode(p.type, visitExistingNodeTreeSymbols), undefined); }), ts.visitNode(node.type, visitExistingNodeTreeSymbols) || ts.factory.createKeywordTypeNode(128));
39926                         }
39927                     }
39928                     if (ts.isTypeReferenceNode(node) && ts.isInJSDoc(node) && (!existingTypeNodeIsNotReferenceOrIsReferenceWithCompatibleTypeArgumentCount(node, getTypeFromTypeNode(node)) || getIntendedTypeFromJSDocTypeReference(node) || unknownSymbol === resolveTypeReferenceName(getTypeReferenceName(node), 788968, true))) {
39929                         return ts.setOriginalNode(typeToTypeNodeHelper(getTypeFromTypeNode(node), context), node);
39930                     }
39931                     if (ts.isLiteralImportTypeNode(node)) {
39932                         return ts.factory.updateImportTypeNode(node, ts.factory.updateLiteralTypeNode(node.argument, rewriteModuleSpecifier(node, node.argument.literal)), node.qualifier, ts.visitNodes(node.typeArguments, visitExistingNodeTreeSymbols, ts.isTypeNode), node.isTypeOf);
39933                     }
39934                     if (ts.isEntityName(node) || ts.isEntityNameExpression(node)) {
39935                         var leftmost = ts.getFirstIdentifier(node);
39936                         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)))) {
39937                             hadError = true;
39938                             return node;
39939                         }
39940                         var sym = resolveEntityName(leftmost, 67108863, true, true);
39941                         if (sym) {
39942                             if (isSymbolAccessible(sym, context.enclosingDeclaration, 67108863, false).accessibility !== 0) {
39943                                 hadError = true;
39944                             }
39945                             else {
39946                                 (_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);
39947                                 includePrivateSymbol === null || includePrivateSymbol === void 0 ? void 0 : includePrivateSymbol(sym);
39948                             }
39949                             if (ts.isIdentifier(node)) {
39950                                 var name = sym.flags & 262144 ? typeParameterToName(getDeclaredTypeOfSymbol(sym), context) : ts.factory.cloneNode(node);
39951                                 name.symbol = sym;
39952                                 return ts.setEmitFlags(ts.setOriginalNode(name, node), 16777216);
39953                             }
39954                         }
39955                     }
39956                     if (file && ts.isTupleTypeNode(node) && (ts.getLineAndCharacterOfPosition(file, node.pos).line === ts.getLineAndCharacterOfPosition(file, node.end).line)) {
39957                         ts.setEmitFlags(node, 1);
39958                     }
39959                     return ts.visitEachChild(node, visitExistingNodeTreeSymbols, ts.nullTransformationContext);
39960                     function getEffectiveDotDotDotForParameter(p) {
39961                         return p.dotDotDotToken || (p.type && ts.isJSDocVariadicType(p.type) ? ts.factory.createToken(25) : undefined);
39962                     }
39963                     function getNameForJSDocFunctionParameter(p, index) {
39964                         return p.name && ts.isIdentifier(p.name) && p.name.escapedText === "this" ? "this"
39965                             : getEffectiveDotDotDotForParameter(p) ? "args"
39966                                 : "arg" + index;
39967                     }
39968                     function rewriteModuleSpecifier(parent, lit) {
39969                         if (bundled) {
39970                             if (context.tracker && context.tracker.moduleResolverHost) {
39971                                 var targetFile = getExternalModuleFileFromDeclaration(parent);
39972                                 if (targetFile) {
39973                                     var getCanonicalFileName = ts.createGetCanonicalFileName(!!host.useCaseSensitiveFileNames);
39974                                     var resolverHost = {
39975                                         getCanonicalFileName: getCanonicalFileName,
39976                                         getCurrentDirectory: function () { return context.tracker.moduleResolverHost.getCurrentDirectory(); },
39977                                         getCommonSourceDirectory: function () { return context.tracker.moduleResolverHost.getCommonSourceDirectory(); }
39978                                     };
39979                                     var newName = ts.getResolvedExternalModuleName(resolverHost, targetFile);
39980                                     return ts.factory.createStringLiteral(newName);
39981                                 }
39982                             }
39983                         }
39984                         else {
39985                             if (context.tracker && context.tracker.trackExternalModuleSymbolOfImportTypeNode) {
39986                                 var moduleSym = resolveExternalModuleNameWorker(lit, lit, undefined);
39987                                 if (moduleSym) {
39988                                     context.tracker.trackExternalModuleSymbolOfImportTypeNode(moduleSym);
39989                                 }
39990                             }
39991                         }
39992                         return lit;
39993                     }
39994                 }
39995             }
39996             function symbolTableToDeclarationStatements(symbolTable, context, bundled) {
39997                 var serializePropertySymbolForClass = makeSerializePropertySymbol(ts.factory.createPropertyDeclaration, 165, true);
39998                 var serializePropertySymbolForInterfaceWorker = makeSerializePropertySymbol(function (_decorators, mods, name, question, type) { return ts.factory.createPropertySignature(mods, name, question, type); }, 164, false);
39999                 var enclosingDeclaration = context.enclosingDeclaration;
40000                 var results = [];
40001                 var visitedSymbols = new ts.Set();
40002                 var deferredPrivatesStack = [];
40003                 var oldcontext = context;
40004                 context = __assign(__assign({}, oldcontext), { usedSymbolNames: new ts.Set(oldcontext.usedSymbolNames), remappedSymbolNames: new ts.Map(), tracker: __assign(__assign({}, oldcontext.tracker), { trackSymbol: function (sym, decl, meaning) {
40005                             var accessibleResult = isSymbolAccessible(sym, decl, meaning, false);
40006                             if (accessibleResult.accessibility === 0) {
40007                                 var chain = lookupSymbolChainWorker(sym, context, meaning);
40008                                 if (!(sym.flags & 4)) {
40009                                     includePrivateSymbol(chain[0]);
40010                                 }
40011                             }
40012                             else if (oldcontext.tracker && oldcontext.tracker.trackSymbol) {
40013                                 oldcontext.tracker.trackSymbol(sym, decl, meaning);
40014                             }
40015                         } }) });
40016                 ts.forEachEntry(symbolTable, function (symbol, name) {
40017                     var baseName = ts.unescapeLeadingUnderscores(name);
40018                     void getInternalSymbolName(symbol, baseName);
40019                 });
40020                 var addingDeclare = !bundled;
40021                 var exportEquals = symbolTable.get("export=");
40022                 if (exportEquals && symbolTable.size > 1 && exportEquals.flags & 2097152) {
40023                     symbolTable = ts.createSymbolTable();
40024                     symbolTable.set("export=", exportEquals);
40025                 }
40026                 visitSymbolTable(symbolTable);
40027                 return mergeRedundantStatements(results);
40028                 function isIdentifierAndNotUndefined(node) {
40029                     return !!node && node.kind === 78;
40030                 }
40031                 function getNamesOfDeclaration(statement) {
40032                     if (ts.isVariableStatement(statement)) {
40033                         return ts.filter(ts.map(statement.declarationList.declarations, ts.getNameOfDeclaration), isIdentifierAndNotUndefined);
40034                     }
40035                     return ts.filter([ts.getNameOfDeclaration(statement)], isIdentifierAndNotUndefined);
40036                 }
40037                 function flattenExportAssignedNamespace(statements) {
40038                     var exportAssignment = ts.find(statements, ts.isExportAssignment);
40039                     var nsIndex = ts.findIndex(statements, ts.isModuleDeclaration);
40040                     var ns = nsIndex !== -1 ? statements[nsIndex] : undefined;
40041                     if (ns && exportAssignment && exportAssignment.isExportEquals &&
40042                         ts.isIdentifier(exportAssignment.expression) && ts.isIdentifier(ns.name) && ts.idText(ns.name) === ts.idText(exportAssignment.expression) &&
40043                         ns.body && ts.isModuleBlock(ns.body)) {
40044                         var excessExports = ts.filter(statements, function (s) { return !!(ts.getEffectiveModifierFlags(s) & 1); });
40045                         var name_2 = ns.name;
40046                         var body = ns.body;
40047                         if (ts.length(excessExports)) {
40048                             ns = ts.factory.updateModuleDeclaration(ns, ns.decorators, ns.modifiers, ns.name, body = ts.factory.updateModuleBlock(body, ts.factory.createNodeArray(__spreadArrays(ns.body.statements, [ts.factory.createExportDeclaration(undefined, undefined, false, ts.factory.createNamedExports(ts.map(ts.flatMap(excessExports, function (e) { return getNamesOfDeclaration(e); }), function (id) { return ts.factory.createExportSpecifier(undefined, id); })), undefined)]))));
40049                             statements = __spreadArrays(statements.slice(0, nsIndex), [ns], statements.slice(nsIndex + 1));
40050                         }
40051                         if (!ts.find(statements, function (s) { return s !== ns && ts.nodeHasName(s, name_2); })) {
40052                             results = [];
40053                             var mixinExportFlag_1 = !ts.some(body.statements, function (s) { return ts.hasSyntacticModifier(s, 1) || ts.isExportAssignment(s) || ts.isExportDeclaration(s); });
40054                             ts.forEach(body.statements, function (s) {
40055                                 addResult(s, mixinExportFlag_1 ? 1 : 0);
40056                             });
40057                             statements = __spreadArrays(ts.filter(statements, function (s) { return s !== ns && s !== exportAssignment; }), results);
40058                         }
40059                     }
40060                     return statements;
40061                 }
40062                 function mergeExportDeclarations(statements) {
40063                     var exports = ts.filter(statements, function (d) { return ts.isExportDeclaration(d) && !d.moduleSpecifier && !!d.exportClause && ts.isNamedExports(d.exportClause); });
40064                     if (ts.length(exports) > 1) {
40065                         var nonExports = ts.filter(statements, function (d) { return !ts.isExportDeclaration(d) || !!d.moduleSpecifier || !d.exportClause; });
40066                         statements = __spreadArrays(nonExports, [ts.factory.createExportDeclaration(undefined, undefined, false, ts.factory.createNamedExports(ts.flatMap(exports, function (e) { return ts.cast(e.exportClause, ts.isNamedExports).elements; })), undefined)]);
40067                     }
40068                     var reexports = ts.filter(statements, function (d) { return ts.isExportDeclaration(d) && !!d.moduleSpecifier && !!d.exportClause && ts.isNamedExports(d.exportClause); });
40069                     if (ts.length(reexports) > 1) {
40070                         var groups = ts.group(reexports, function (decl) { return ts.isStringLiteral(decl.moduleSpecifier) ? ">" + decl.moduleSpecifier.text : ">"; });
40071                         if (groups.length !== reexports.length) {
40072                             var _loop_9 = function (group_1) {
40073                                 if (group_1.length > 1) {
40074                                     statements = __spreadArrays(ts.filter(statements, function (s) { return group_1.indexOf(s) === -1; }), [
40075                                         ts.factory.createExportDeclaration(undefined, undefined, false, ts.factory.createNamedExports(ts.flatMap(group_1, function (e) { return ts.cast(e.exportClause, ts.isNamedExports).elements; })), group_1[0].moduleSpecifier)
40076                                     ]);
40077                                 }
40078                             };
40079                             for (var _i = 0, groups_1 = groups; _i < groups_1.length; _i++) {
40080                                 var group_1 = groups_1[_i];
40081                                 _loop_9(group_1);
40082                             }
40083                         }
40084                     }
40085                     return statements;
40086                 }
40087                 function inlineExportModifiers(statements) {
40088                     var index = ts.findIndex(statements, function (d) { return ts.isExportDeclaration(d) && !d.moduleSpecifier && !!d.exportClause && ts.isNamedExports(d.exportClause); });
40089                     if (index >= 0) {
40090                         var exportDecl = statements[index];
40091                         var replacements = ts.mapDefined(exportDecl.exportClause.elements, function (e) {
40092                             if (!e.propertyName) {
40093                                 var indices = ts.indicesOf(statements);
40094                                 var associatedIndices = ts.filter(indices, function (i) { return ts.nodeHasName(statements[i], e.name); });
40095                                 if (ts.length(associatedIndices) && ts.every(associatedIndices, function (i) { return canHaveExportModifier(statements[i]); })) {
40096                                     for (var _i = 0, associatedIndices_1 = associatedIndices; _i < associatedIndices_1.length; _i++) {
40097                                         var index_1 = associatedIndices_1[_i];
40098                                         statements[index_1] = addExportModifier(statements[index_1]);
40099                                     }
40100                                     return undefined;
40101                                 }
40102                             }
40103                             return e;
40104                         });
40105                         if (!ts.length(replacements)) {
40106                             ts.orderedRemoveItemAt(statements, index);
40107                         }
40108                         else {
40109                             statements[index] = ts.factory.updateExportDeclaration(exportDecl, exportDecl.decorators, exportDecl.modifiers, exportDecl.isTypeOnly, ts.factory.updateNamedExports(exportDecl.exportClause, replacements), exportDecl.moduleSpecifier);
40110                         }
40111                     }
40112                     return statements;
40113                 }
40114                 function mergeRedundantStatements(statements) {
40115                     statements = flattenExportAssignedNamespace(statements);
40116                     statements = mergeExportDeclarations(statements);
40117                     statements = inlineExportModifiers(statements);
40118                     if (enclosingDeclaration &&
40119                         ((ts.isSourceFile(enclosingDeclaration) && ts.isExternalOrCommonJsModule(enclosingDeclaration)) || ts.isModuleDeclaration(enclosingDeclaration)) &&
40120                         (!ts.some(statements, ts.isExternalModuleIndicator) || (!ts.hasScopeMarker(statements) && ts.some(statements, ts.needsScopeMarker)))) {
40121                         statements.push(ts.createEmptyExports(ts.factory));
40122                     }
40123                     return statements;
40124                 }
40125                 function canHaveExportModifier(node) {
40126                     return ts.isEnumDeclaration(node) ||
40127                         ts.isVariableStatement(node) ||
40128                         ts.isFunctionDeclaration(node) ||
40129                         ts.isClassDeclaration(node) ||
40130                         (ts.isModuleDeclaration(node) && !ts.isExternalModuleAugmentation(node) && !ts.isGlobalScopeAugmentation(node)) ||
40131                         ts.isInterfaceDeclaration(node) ||
40132                         isTypeDeclaration(node);
40133                 }
40134                 function addExportModifier(node) {
40135                     var flags = (ts.getEffectiveModifierFlags(node) | 1) & ~2;
40136                     return ts.factory.updateModifiers(node, flags);
40137                 }
40138                 function removeExportModifier(node) {
40139                     var flags = ts.getEffectiveModifierFlags(node) & ~1;
40140                     return ts.factory.updateModifiers(node, flags);
40141                 }
40142                 function visitSymbolTable(symbolTable, suppressNewPrivateContext, propertyAsAlias) {
40143                     if (!suppressNewPrivateContext) {
40144                         deferredPrivatesStack.push(new ts.Map());
40145                     }
40146                     symbolTable.forEach(function (symbol) {
40147                         serializeSymbol(symbol, false, !!propertyAsAlias);
40148                     });
40149                     if (!suppressNewPrivateContext) {
40150                         deferredPrivatesStack[deferredPrivatesStack.length - 1].forEach(function (symbol) {
40151                             serializeSymbol(symbol, true, !!propertyAsAlias);
40152                         });
40153                         deferredPrivatesStack.pop();
40154                     }
40155                 }
40156                 function serializeSymbol(symbol, isPrivate, propertyAsAlias) {
40157                     var visitedSym = getMergedSymbol(symbol);
40158                     if (visitedSymbols.has(getSymbolId(visitedSym))) {
40159                         return;
40160                     }
40161                     visitedSymbols.add(getSymbolId(visitedSym));
40162                     var skipMembershipCheck = !isPrivate;
40163                     if (skipMembershipCheck || (!!ts.length(symbol.declarations) && ts.some(symbol.declarations, function (d) { return !!ts.findAncestor(d, function (n) { return n === enclosingDeclaration; }); }))) {
40164                         var oldContext = context;
40165                         context = cloneNodeBuilderContext(context);
40166                         var result = serializeSymbolWorker(symbol, isPrivate, propertyAsAlias);
40167                         context = oldContext;
40168                         return result;
40169                     }
40170                 }
40171                 function serializeSymbolWorker(symbol, isPrivate, propertyAsAlias) {
40172                     var symbolName = ts.unescapeLeadingUnderscores(symbol.escapedName);
40173                     var isDefault = symbol.escapedName === "default";
40174                     if (isPrivate && !(context.flags & 131072) && ts.isStringANonContextualKeyword(symbolName) && !isDefault) {
40175                         context.encounteredError = true;
40176                         return;
40177                     }
40178                     var needsPostExportDefault = isDefault && !!(symbol.flags & -113
40179                         || (symbol.flags & 16 && ts.length(getPropertiesOfType(getTypeOfSymbol(symbol))))) && !(symbol.flags & 2097152);
40180                     var needsExportDeclaration = !needsPostExportDefault && !isPrivate && ts.isStringANonContextualKeyword(symbolName) && !isDefault;
40181                     if (needsPostExportDefault || needsExportDeclaration) {
40182                         isPrivate = true;
40183                     }
40184                     var modifierFlags = (!isPrivate ? 1 : 0) | (isDefault && !needsPostExportDefault ? 512 : 0);
40185                     var isConstMergedWithNS = symbol.flags & 1536 &&
40186                         symbol.flags & (2 | 1 | 4) &&
40187                         symbol.escapedName !== "export=";
40188                     var isConstMergedWithNSPrintableAsSignatureMerge = isConstMergedWithNS && isTypeRepresentableAsFunctionNamespaceMerge(getTypeOfSymbol(symbol), symbol);
40189                     if (symbol.flags & (16 | 8192) || isConstMergedWithNSPrintableAsSignatureMerge) {
40190                         serializeAsFunctionNamespaceMerge(getTypeOfSymbol(symbol), symbol, getInternalSymbolName(symbol, symbolName), modifierFlags);
40191                     }
40192                     if (symbol.flags & 524288) {
40193                         serializeTypeAlias(symbol, symbolName, modifierFlags);
40194                     }
40195                     if (symbol.flags & (2 | 1 | 4)
40196                         && symbol.escapedName !== "export="
40197                         && !(symbol.flags & 4194304)
40198                         && !(symbol.flags & 32)
40199                         && !isConstMergedWithNSPrintableAsSignatureMerge) {
40200                         if (propertyAsAlias) {
40201                             var createdExport = serializeMaybeAliasAssignment(symbol);
40202                             if (createdExport) {
40203                                 needsExportDeclaration = false;
40204                                 needsPostExportDefault = false;
40205                             }
40206                         }
40207                         else {
40208                             var type = getTypeOfSymbol(symbol);
40209                             var localName = getInternalSymbolName(symbol, symbolName);
40210                             if (!(symbol.flags & 16) && isTypeRepresentableAsFunctionNamespaceMerge(type, symbol)) {
40211                                 serializeAsFunctionNamespaceMerge(type, symbol, localName, modifierFlags);
40212                             }
40213                             else {
40214                                 var flags = !(symbol.flags & 2) ? undefined
40215                                     : isConstVariable(symbol) ? 2
40216                                         : 1;
40217                                 var name = (needsPostExportDefault || !(symbol.flags & 4)) ? localName : getUnusedName(localName, symbol);
40218                                 var textRange = symbol.declarations && ts.find(symbol.declarations, function (d) { return ts.isVariableDeclaration(d); });
40219                                 if (textRange && ts.isVariableDeclarationList(textRange.parent) && textRange.parent.declarations.length === 1) {
40220                                     textRange = textRange.parent.parent;
40221                                 }
40222                                 var propertyAccessRequire = ts.find(symbol.declarations, ts.isPropertyAccessExpression);
40223                                 if (propertyAccessRequire && ts.isBinaryExpression(propertyAccessRequire.parent) && ts.isIdentifier(propertyAccessRequire.parent.right)
40224                                     && type.symbol && ts.isSourceFile(type.symbol.valueDeclaration)) {
40225                                     var alias = localName === propertyAccessRequire.parent.right.escapedText ? undefined : propertyAccessRequire.parent.right;
40226                                     addResult(ts.factory.createExportDeclaration(undefined, undefined, false, ts.factory.createNamedExports([ts.factory.createExportSpecifier(alias, localName)])), 0);
40227                                     context.tracker.trackSymbol(type.symbol, context.enclosingDeclaration, 111551);
40228                                 }
40229                                 else {
40230                                     var statement = ts.setTextRange(ts.factory.createVariableStatement(undefined, ts.factory.createVariableDeclarationList([
40231                                         ts.factory.createVariableDeclaration(name, undefined, serializeTypeForDeclaration(context, type, symbol, enclosingDeclaration, includePrivateSymbol, bundled))
40232                                     ], flags)), textRange);
40233                                     addResult(statement, name !== localName ? modifierFlags & ~1 : modifierFlags);
40234                                     if (name !== localName && !isPrivate) {
40235                                         addResult(ts.factory.createExportDeclaration(undefined, undefined, false, ts.factory.createNamedExports([ts.factory.createExportSpecifier(name, localName)])), 0);
40236                                         needsExportDeclaration = false;
40237                                         needsPostExportDefault = false;
40238                                     }
40239                                 }
40240                             }
40241                         }
40242                     }
40243                     if (symbol.flags & 384) {
40244                         serializeEnum(symbol, symbolName, modifierFlags);
40245                     }
40246                     if (symbol.flags & 32) {
40247                         if (symbol.flags & 4 && ts.isBinaryExpression(symbol.valueDeclaration.parent) && ts.isClassExpression(symbol.valueDeclaration.parent.right)) {
40248                             serializeAsAlias(symbol, getInternalSymbolName(symbol, symbolName), modifierFlags);
40249                         }
40250                         else {
40251                             serializeAsClass(symbol, getInternalSymbolName(symbol, symbolName), modifierFlags);
40252                         }
40253                     }
40254                     if ((symbol.flags & (512 | 1024) && (!isConstMergedWithNS || isTypeOnlyNamespace(symbol))) || isConstMergedWithNSPrintableAsSignatureMerge) {
40255                         serializeModule(symbol, symbolName, modifierFlags);
40256                     }
40257                     if (symbol.flags & 64 && !(symbol.flags & 32)) {
40258                         serializeInterface(symbol, symbolName, modifierFlags);
40259                     }
40260                     if (symbol.flags & 2097152) {
40261                         serializeAsAlias(symbol, getInternalSymbolName(symbol, symbolName), modifierFlags);
40262                     }
40263                     if (symbol.flags & 4 && symbol.escapedName === "export=") {
40264                         serializeMaybeAliasAssignment(symbol);
40265                     }
40266                     if (symbol.flags & 8388608) {
40267                         for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) {
40268                             var node = _a[_i];
40269                             var resolvedModule = resolveExternalModuleName(node, node.moduleSpecifier);
40270                             if (!resolvedModule)
40271                                 continue;
40272                             addResult(ts.factory.createExportDeclaration(undefined, undefined, false, undefined, ts.factory.createStringLiteral(getSpecifierForModuleSymbol(resolvedModule, context))), 0);
40273                         }
40274                     }
40275                     if (needsPostExportDefault) {
40276                         addResult(ts.factory.createExportAssignment(undefined, undefined, false, ts.factory.createIdentifier(getInternalSymbolName(symbol, symbolName))), 0);
40277                     }
40278                     else if (needsExportDeclaration) {
40279                         addResult(ts.factory.createExportDeclaration(undefined, undefined, false, ts.factory.createNamedExports([ts.factory.createExportSpecifier(getInternalSymbolName(symbol, symbolName), symbolName)])), 0);
40280                     }
40281                 }
40282                 function includePrivateSymbol(symbol) {
40283                     if (ts.some(symbol.declarations, ts.isParameterDeclaration))
40284                         return;
40285                     ts.Debug.assertIsDefined(deferredPrivatesStack[deferredPrivatesStack.length - 1]);
40286                     getUnusedName(ts.unescapeLeadingUnderscores(symbol.escapedName), symbol);
40287                     var isExternalImportAlias = !!(symbol.flags & 2097152) && !ts.some(symbol.declarations, function (d) {
40288                         return !!ts.findAncestor(d, ts.isExportDeclaration) ||
40289                             ts.isNamespaceExport(d) ||
40290                             (ts.isImportEqualsDeclaration(d) && !ts.isExternalModuleReference(d.moduleReference));
40291                     });
40292                     deferredPrivatesStack[isExternalImportAlias ? 0 : (deferredPrivatesStack.length - 1)].set(getSymbolId(symbol), symbol);
40293                 }
40294                 function isExportingScope(enclosingDeclaration) {
40295                     return ((ts.isSourceFile(enclosingDeclaration) && (ts.isExternalOrCommonJsModule(enclosingDeclaration) || ts.isJsonSourceFile(enclosingDeclaration))) ||
40296                         (ts.isAmbientModule(enclosingDeclaration) && !ts.isGlobalScopeAugmentation(enclosingDeclaration)));
40297                 }
40298                 function addResult(node, additionalModifierFlags) {
40299                     if (ts.canHaveModifiers(node)) {
40300                         var newModifierFlags = 0;
40301                         if (additionalModifierFlags & 1 &&
40302                             context.enclosingDeclaration &&
40303                             (isExportingScope(context.enclosingDeclaration) || ts.isModuleDeclaration(context.enclosingDeclaration)) &&
40304                             canHaveExportModifier(node)) {
40305                             newModifierFlags |= 1;
40306                         }
40307                         if (addingDeclare && !(newModifierFlags & 1) &&
40308                             (!context.enclosingDeclaration || !(context.enclosingDeclaration.flags & 8388608)) &&
40309                             (ts.isEnumDeclaration(node) || ts.isVariableStatement(node) || ts.isFunctionDeclaration(node) || ts.isClassDeclaration(node) || ts.isModuleDeclaration(node))) {
40310                             newModifierFlags |= 2;
40311                         }
40312                         if ((additionalModifierFlags & 512) && (ts.isClassDeclaration(node) || ts.isInterfaceDeclaration(node) || ts.isFunctionDeclaration(node))) {
40313                             newModifierFlags |= 512;
40314                         }
40315                         if (newModifierFlags) {
40316                             node = ts.factory.updateModifiers(node, newModifierFlags | ts.getEffectiveModifierFlags(node));
40317                         }
40318                     }
40319                     results.push(node);
40320                 }
40321                 function serializeTypeAlias(symbol, symbolName, modifierFlags) {
40322                     var aliasType = getDeclaredTypeOfTypeAlias(symbol);
40323                     var typeParams = getSymbolLinks(symbol).typeParameters;
40324                     var typeParamDecls = ts.map(typeParams, function (p) { return typeParameterToDeclaration(p, context); });
40325                     var jsdocAliasDecl = ts.find(symbol.declarations, ts.isJSDocTypeAlias);
40326                     var commentText = jsdocAliasDecl ? jsdocAliasDecl.comment || jsdocAliasDecl.parent.comment : undefined;
40327                     var oldFlags = context.flags;
40328                     context.flags |= 8388608;
40329                     addResult(ts.setSyntheticLeadingComments(ts.factory.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);
40330                     context.flags = oldFlags;
40331                 }
40332                 function serializeInterface(symbol, symbolName, modifierFlags) {
40333                     var interfaceType = getDeclaredTypeOfClassOrInterface(symbol);
40334                     var localParams = getLocalTypeParametersOfClassOrInterfaceOrTypeAlias(symbol);
40335                     var typeParamDecls = ts.map(localParams, function (p) { return typeParameterToDeclaration(p, context); });
40336                     var baseTypes = getBaseTypes(interfaceType);
40337                     var baseType = ts.length(baseTypes) ? getIntersectionType(baseTypes) : undefined;
40338                     var members = ts.flatMap(getPropertiesOfType(interfaceType), function (p) { return serializePropertySymbolForInterface(p, baseType); });
40339                     var callSignatures = serializeSignatures(0, interfaceType, baseType, 169);
40340                     var constructSignatures = serializeSignatures(1, interfaceType, baseType, 170);
40341                     var indexSignatures = serializeIndexSignatures(interfaceType, baseType);
40342                     var heritageClauses = !ts.length(baseTypes) ? undefined : [ts.factory.createHeritageClause(93, ts.mapDefined(baseTypes, function (b) { return trySerializeAsTypeReference(b, 111551); }))];
40343                     addResult(ts.factory.createInterfaceDeclaration(undefined, undefined, getInternalSymbolName(symbol, symbolName), typeParamDecls, heritageClauses, __spreadArrays(indexSignatures, constructSignatures, callSignatures, members)), modifierFlags);
40344                 }
40345                 function getNamespaceMembersForSerialization(symbol) {
40346                     return !symbol.exports ? [] : ts.filter(ts.arrayFrom(symbol.exports.values()), isNamespaceMember);
40347                 }
40348                 function isTypeOnlyNamespace(symbol) {
40349                     return ts.every(getNamespaceMembersForSerialization(symbol), function (m) { return !(resolveSymbol(m).flags & 111551); });
40350                 }
40351                 function serializeModule(symbol, symbolName, modifierFlags) {
40352                     var members = getNamespaceMembersForSerialization(symbol);
40353                     var locationMap = ts.arrayToMultiMap(members, function (m) { return m.parent && m.parent === symbol ? "real" : "merged"; });
40354                     var realMembers = locationMap.get("real") || ts.emptyArray;
40355                     var mergedMembers = locationMap.get("merged") || ts.emptyArray;
40356                     if (ts.length(realMembers)) {
40357                         var localName = getInternalSymbolName(symbol, symbolName);
40358                         serializeAsNamespaceDeclaration(realMembers, localName, modifierFlags, !!(symbol.flags & (16 | 67108864)));
40359                     }
40360                     if (ts.length(mergedMembers)) {
40361                         var containingFile_1 = ts.getSourceFileOfNode(context.enclosingDeclaration);
40362                         var localName = getInternalSymbolName(symbol, symbolName);
40363                         var nsBody = ts.factory.createModuleBlock([ts.factory.createExportDeclaration(undefined, undefined, false, ts.factory.createNamedExports(ts.mapDefined(ts.filter(mergedMembers, function (n) { return n.escapedName !== "export="; }), function (s) {
40364                                 var _a, _b;
40365                                 var name = ts.unescapeLeadingUnderscores(s.escapedName);
40366                                 var localName = getInternalSymbolName(s, name);
40367                                 var aliasDecl = s.declarations && getDeclarationOfAliasSymbol(s);
40368                                 if (containingFile_1 && (aliasDecl ? containingFile_1 !== ts.getSourceFileOfNode(aliasDecl) : !ts.some(s.declarations, function (d) { return ts.getSourceFileOfNode(d) === containingFile_1; }))) {
40369                                     (_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);
40370                                     return undefined;
40371                                 }
40372                                 var target = aliasDecl && getTargetOfAliasDeclaration(aliasDecl, true);
40373                                 includePrivateSymbol(target || s);
40374                                 var targetName = target ? getInternalSymbolName(target, ts.unescapeLeadingUnderscores(target.escapedName)) : localName;
40375                                 return ts.factory.createExportSpecifier(name === targetName ? undefined : targetName, name);
40376                             })))]);
40377                         addResult(ts.factory.createModuleDeclaration(undefined, undefined, ts.factory.createIdentifier(localName), nsBody, 16), 0);
40378                     }
40379                 }
40380                 function serializeEnum(symbol, symbolName, modifierFlags) {
40381                     addResult(ts.factory.createEnumDeclaration(undefined, ts.factory.createModifiersFromModifierFlags(isConstEnumSymbol(symbol) ? 2048 : 0), getInternalSymbolName(symbol, symbolName), ts.map(ts.filter(getPropertiesOfType(getTypeOfSymbol(symbol)), function (p) { return !!(p.flags & 8); }), function (p) {
40382                         var initializedValue = p.declarations && p.declarations[0] && ts.isEnumMember(p.declarations[0]) ? getConstantValue(p.declarations[0]) : undefined;
40383                         return ts.factory.createEnumMember(ts.unescapeLeadingUnderscores(p.escapedName), initializedValue === undefined ? undefined :
40384                             typeof initializedValue === "string" ? ts.factory.createStringLiteral(initializedValue) :
40385                                 ts.factory.createNumericLiteral(initializedValue));
40386                     })), modifierFlags);
40387                 }
40388                 function serializeAsFunctionNamespaceMerge(type, symbol, localName, modifierFlags) {
40389                     var signatures = getSignaturesOfType(type, 0);
40390                     for (var _i = 0, signatures_2 = signatures; _i < signatures_2.length; _i++) {
40391                         var sig = signatures_2[_i];
40392                         var decl = signatureToSignatureDeclarationHelper(sig, 251, context, { name: ts.factory.createIdentifier(localName), privateSymbolVisitor: includePrivateSymbol, bundledImports: bundled });
40393                         addResult(ts.setTextRange(decl, sig.declaration && ts.isVariableDeclaration(sig.declaration.parent) && sig.declaration.parent.parent || sig.declaration), modifierFlags);
40394                     }
40395                     if (!(symbol.flags & (512 | 1024) && !!symbol.exports && !!symbol.exports.size)) {
40396                         var props = ts.filter(getPropertiesOfType(type), isNamespaceMember);
40397                         serializeAsNamespaceDeclaration(props, localName, modifierFlags, true);
40398                     }
40399                 }
40400                 function serializeAsNamespaceDeclaration(props, localName, modifierFlags, suppressNewPrivateContext) {
40401                     if (ts.length(props)) {
40402                         var localVsRemoteMap = ts.arrayToMultiMap(props, function (p) {
40403                             return !ts.length(p.declarations) || ts.some(p.declarations, function (d) {
40404                                 return ts.getSourceFileOfNode(d) === ts.getSourceFileOfNode(context.enclosingDeclaration);
40405                             }) ? "local" : "remote";
40406                         });
40407                         var localProps = localVsRemoteMap.get("local") || ts.emptyArray;
40408                         var fakespace = ts.parseNodeFactory.createModuleDeclaration(undefined, undefined, ts.factory.createIdentifier(localName), ts.factory.createModuleBlock([]), 16);
40409                         ts.setParent(fakespace, enclosingDeclaration);
40410                         fakespace.locals = ts.createSymbolTable(props);
40411                         fakespace.symbol = props[0].parent;
40412                         var oldResults = results;
40413                         results = [];
40414                         var oldAddingDeclare = addingDeclare;
40415                         addingDeclare = false;
40416                         var subcontext = __assign(__assign({}, context), { enclosingDeclaration: fakespace });
40417                         var oldContext = context;
40418                         context = subcontext;
40419                         visitSymbolTable(ts.createSymbolTable(localProps), suppressNewPrivateContext, true);
40420                         context = oldContext;
40421                         addingDeclare = oldAddingDeclare;
40422                         var declarations = results;
40423                         results = oldResults;
40424                         var defaultReplaced = ts.map(declarations, function (d) { return ts.isExportAssignment(d) && !d.isExportEquals && ts.isIdentifier(d.expression) ? ts.factory.createExportDeclaration(undefined, undefined, false, ts.factory.createNamedExports([ts.factory.createExportSpecifier(d.expression, ts.factory.createIdentifier("default"))])) : d; });
40425                         var exportModifierStripped = ts.every(defaultReplaced, function (d) { return ts.hasSyntacticModifier(d, 1); }) ? ts.map(defaultReplaced, removeExportModifier) : defaultReplaced;
40426                         fakespace = ts.factory.updateModuleDeclaration(fakespace, fakespace.decorators, fakespace.modifiers, fakespace.name, ts.factory.createModuleBlock(exportModifierStripped));
40427                         addResult(fakespace, modifierFlags);
40428                     }
40429                 }
40430                 function isNamespaceMember(p) {
40431                     return !!(p.flags & (788968 | 1920 | 2097152)) ||
40432                         !(p.flags & 4194304 || p.escapedName === "prototype" || p.valueDeclaration && ts.getEffectiveModifierFlags(p.valueDeclaration) & 32 && ts.isClassLike(p.valueDeclaration.parent));
40433                 }
40434                 function serializeAsClass(symbol, localName, modifierFlags) {
40435                     var _a;
40436                     var localParams = getLocalTypeParametersOfClassOrInterfaceOrTypeAlias(symbol);
40437                     var typeParamDecls = ts.map(localParams, function (p) { return typeParameterToDeclaration(p, context); });
40438                     var classType = getDeclaredTypeOfClassOrInterface(symbol);
40439                     var baseTypes = getBaseTypes(classType);
40440                     var implementsExpressions = ts.mapDefined(getImplementsTypes(classType), serializeImplementedType);
40441                     var staticType = getTypeOfSymbol(symbol);
40442                     var isClass = !!((_a = staticType.symbol) === null || _a === void 0 ? void 0 : _a.valueDeclaration) && ts.isClassLike(staticType.symbol.valueDeclaration);
40443                     var staticBaseType = isClass
40444                         ? getBaseConstructorTypeOfClass(staticType)
40445                         : anyType;
40446                     var heritageClauses = __spreadArrays(!ts.length(baseTypes) ? [] : [ts.factory.createHeritageClause(93, ts.map(baseTypes, function (b) { return serializeBaseType(b, staticBaseType, localName); }))], !ts.length(implementsExpressions) ? [] : [ts.factory.createHeritageClause(116, implementsExpressions)]);
40447                     var symbolProps = getNonInterhitedProperties(classType, baseTypes, getPropertiesOfType(classType));
40448                     var publicSymbolProps = ts.filter(symbolProps, function (s) {
40449                         var valueDecl = s.valueDeclaration;
40450                         return valueDecl && !(ts.isNamedDeclaration(valueDecl) && ts.isPrivateIdentifier(valueDecl.name));
40451                     });
40452                     var hasPrivateIdentifier = ts.some(symbolProps, function (s) {
40453                         var valueDecl = s.valueDeclaration;
40454                         return valueDecl && ts.isNamedDeclaration(valueDecl) && ts.isPrivateIdentifier(valueDecl.name);
40455                     });
40456                     var privateProperties = hasPrivateIdentifier ?
40457                         [ts.factory.createPropertyDeclaration(undefined, undefined, ts.factory.createPrivateIdentifier("#private"), undefined, undefined, undefined)] :
40458                         ts.emptyArray;
40459                     var publicProperties = ts.flatMap(publicSymbolProps, function (p) { return serializePropertySymbolForClass(p, false, baseTypes[0]); });
40460                     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); });
40461                     var isNonConstructableClassLikeInJsFile = !isClass &&
40462                         !!symbol.valueDeclaration &&
40463                         ts.isInJSFile(symbol.valueDeclaration) &&
40464                         !ts.some(getSignaturesOfType(staticType, 1));
40465                     var constructors = isNonConstructableClassLikeInJsFile ?
40466                         [ts.factory.createConstructorDeclaration(undefined, ts.factory.createModifiersFromModifierFlags(8), [], undefined)] :
40467                         serializeSignatures(1, staticType, baseTypes[0], 166);
40468                     var indexSignatures = serializeIndexSignatures(classType, baseTypes[0]);
40469                     addResult(ts.setTextRange(ts.factory.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);
40470                 }
40471                 function serializeAsAlias(symbol, localName, modifierFlags) {
40472                     var _a, _b, _c, _d, _e;
40473                     var node = getDeclarationOfAliasSymbol(symbol);
40474                     if (!node)
40475                         return ts.Debug.fail();
40476                     var target = getMergedSymbol(getTargetOfAliasDeclaration(node, true));
40477                     if (!target) {
40478                         return;
40479                     }
40480                     var verbatimTargetName = ts.unescapeLeadingUnderscores(target.escapedName);
40481                     if (verbatimTargetName === "export=" && (compilerOptions.esModuleInterop || compilerOptions.allowSyntheticDefaultImports)) {
40482                         verbatimTargetName = "default";
40483                     }
40484                     var targetName = getInternalSymbolName(target, verbatimTargetName);
40485                     includePrivateSymbol(target);
40486                     switch (node.kind) {
40487                         case 198:
40488                             if (((_b = (_a = node.parent) === null || _a === void 0 ? void 0 : _a.parent) === null || _b === void 0 ? void 0 : _b.kind) === 249) {
40489                                 var specifier_1 = getSpecifierForModuleSymbol(target.parent || target, context);
40490                                 var propertyName = node.propertyName;
40491                                 addResult(ts.factory.createImportDeclaration(undefined, undefined, ts.factory.createImportClause(false, undefined, ts.factory.createNamedImports([ts.factory.createImportSpecifier(propertyName && ts.isIdentifier(propertyName) ? ts.factory.createIdentifier(ts.idText(propertyName)) : undefined, ts.factory.createIdentifier(localName))])), ts.factory.createStringLiteral(specifier_1)), 0);
40492                                 break;
40493                             }
40494                             ts.Debug.failBadSyntaxKind(((_c = node.parent) === null || _c === void 0 ? void 0 : _c.parent) || node, "Unhandled binding element grandparent kind in declaration serialization");
40495                             break;
40496                         case 289:
40497                             if (((_e = (_d = node.parent) === null || _d === void 0 ? void 0 : _d.parent) === null || _e === void 0 ? void 0 : _e.kind) === 216) {
40498                                 serializeExportSpecifier(ts.unescapeLeadingUnderscores(symbol.escapedName), targetName);
40499                             }
40500                             break;
40501                         case 249:
40502                             if (ts.isPropertyAccessExpression(node.initializer)) {
40503                                 var initializer = node.initializer;
40504                                 var uniqueName = ts.factory.createUniqueName(localName);
40505                                 var specifier_2 = getSpecifierForModuleSymbol(target.parent || target, context);
40506                                 addResult(ts.factory.createImportEqualsDeclaration(undefined, undefined, uniqueName, ts.factory.createExternalModuleReference(ts.factory.createStringLiteral(specifier_2))), 0);
40507                                 addResult(ts.factory.createImportEqualsDeclaration(undefined, undefined, ts.factory.createIdentifier(localName), ts.factory.createQualifiedName(uniqueName, initializer.name)), modifierFlags);
40508                                 break;
40509                             }
40510                         case 260:
40511                             if (target.escapedName === "export=" && ts.some(target.declarations, ts.isJsonSourceFile)) {
40512                                 serializeMaybeAliasAssignment(symbol);
40513                                 break;
40514                             }
40515                             var isLocalImport = !(target.flags & 512) && !ts.isVariableDeclaration(node);
40516                             addResult(ts.factory.createImportEqualsDeclaration(undefined, undefined, ts.factory.createIdentifier(localName), isLocalImport
40517                                 ? symbolToName(target, context, 67108863, false)
40518                                 : ts.factory.createExternalModuleReference(ts.factory.createStringLiteral(getSpecifierForModuleSymbol(target, context)))), isLocalImport ? modifierFlags : 0);
40519                             break;
40520                         case 259:
40521                             addResult(ts.factory.createNamespaceExportDeclaration(ts.idText(node.name)), 0);
40522                             break;
40523                         case 262:
40524                             addResult(ts.factory.createImportDeclaration(undefined, undefined, ts.factory.createImportClause(false, ts.factory.createIdentifier(localName), undefined), ts.factory.createStringLiteral(getSpecifierForModuleSymbol(target.parent || target, context))), 0);
40525                             break;
40526                         case 263:
40527                             addResult(ts.factory.createImportDeclaration(undefined, undefined, ts.factory.createImportClause(false, undefined, ts.factory.createNamespaceImport(ts.factory.createIdentifier(localName))), ts.factory.createStringLiteral(getSpecifierForModuleSymbol(target, context))), 0);
40528                             break;
40529                         case 269:
40530                             addResult(ts.factory.createExportDeclaration(undefined, undefined, false, ts.factory.createNamespaceExport(ts.factory.createIdentifier(localName)), ts.factory.createStringLiteral(getSpecifierForModuleSymbol(target, context))), 0);
40531                             break;
40532                         case 265:
40533                             addResult(ts.factory.createImportDeclaration(undefined, undefined, ts.factory.createImportClause(false, undefined, ts.factory.createNamedImports([
40534                                 ts.factory.createImportSpecifier(localName !== verbatimTargetName ? ts.factory.createIdentifier(verbatimTargetName) : undefined, ts.factory.createIdentifier(localName))
40535                             ])), ts.factory.createStringLiteral(getSpecifierForModuleSymbol(target.parent || target, context))), 0);
40536                             break;
40537                         case 270:
40538                             var specifier = node.parent.parent.moduleSpecifier;
40539                             serializeExportSpecifier(ts.unescapeLeadingUnderscores(symbol.escapedName), specifier ? verbatimTargetName : targetName, specifier && ts.isStringLiteralLike(specifier) ? ts.factory.createStringLiteral(specifier.text) : undefined);
40540                             break;
40541                         case 266:
40542                             serializeMaybeAliasAssignment(symbol);
40543                             break;
40544                         case 216:
40545                         case 201:
40546                         case 202:
40547                             if (symbol.escapedName === "default" || symbol.escapedName === "export=") {
40548                                 serializeMaybeAliasAssignment(symbol);
40549                             }
40550                             else {
40551                                 serializeExportSpecifier(localName, targetName);
40552                             }
40553                             break;
40554                         default:
40555                             return ts.Debug.failBadSyntaxKind(node, "Unhandled alias declaration kind in symbol serializer!");
40556                     }
40557                 }
40558                 function serializeExportSpecifier(localName, targetName, specifier) {
40559                     addResult(ts.factory.createExportDeclaration(undefined, undefined, false, ts.factory.createNamedExports([ts.factory.createExportSpecifier(localName !== targetName ? targetName : undefined, localName)]), specifier), 0);
40560                 }
40561                 function serializeMaybeAliasAssignment(symbol) {
40562                     if (symbol.flags & 4194304) {
40563                         return false;
40564                     }
40565                     var name = ts.unescapeLeadingUnderscores(symbol.escapedName);
40566                     var isExportEquals = name === "export=";
40567                     var isDefault = name === "default";
40568                     var isExportAssignmentCompatibleSymbolName = isExportEquals || isDefault;
40569                     var aliasDecl = symbol.declarations && getDeclarationOfAliasSymbol(symbol);
40570                     var target = aliasDecl && getTargetOfAliasDeclaration(aliasDecl, true);
40571                     if (target && ts.length(target.declarations) && ts.some(target.declarations, function (d) { return ts.getSourceFileOfNode(d) === ts.getSourceFileOfNode(enclosingDeclaration); })) {
40572                         var expr = aliasDecl && ((ts.isExportAssignment(aliasDecl) || ts.isBinaryExpression(aliasDecl)) ? ts.getExportAssignmentExpression(aliasDecl) : ts.getPropertyAssignmentAliasLikeExpression(aliasDecl));
40573                         var first_1 = expr && ts.isEntityNameExpression(expr) ? getFirstNonModuleExportsIdentifier(expr) : undefined;
40574                         var referenced = first_1 && resolveEntityName(first_1, 67108863, true, true, enclosingDeclaration);
40575                         if (referenced || target) {
40576                             includePrivateSymbol(referenced || target);
40577                         }
40578                         var oldTrack = context.tracker.trackSymbol;
40579                         context.tracker.trackSymbol = ts.noop;
40580                         if (isExportAssignmentCompatibleSymbolName) {
40581                             results.push(ts.factory.createExportAssignment(undefined, undefined, isExportEquals, symbolToExpression(target, context, 67108863)));
40582                         }
40583                         else {
40584                             if (first_1 === expr && first_1) {
40585                                 serializeExportSpecifier(name, ts.idText(first_1));
40586                             }
40587                             else if (expr && ts.isClassExpression(expr)) {
40588                                 serializeExportSpecifier(name, getInternalSymbolName(target, ts.symbolName(target)));
40589                             }
40590                             else {
40591                                 var varName = getUnusedName(name, symbol);
40592                                 addResult(ts.factory.createImportEqualsDeclaration(undefined, undefined, ts.factory.createIdentifier(varName), symbolToName(target, context, 67108863, false)), 0);
40593                                 serializeExportSpecifier(name, varName);
40594                             }
40595                         }
40596                         context.tracker.trackSymbol = oldTrack;
40597                         return true;
40598                     }
40599                     else {
40600                         var varName = getUnusedName(name, symbol);
40601                         var typeToSerialize = getWidenedType(getTypeOfSymbol(getMergedSymbol(symbol)));
40602                         if (isTypeRepresentableAsFunctionNamespaceMerge(typeToSerialize, symbol)) {
40603                             serializeAsFunctionNamespaceMerge(typeToSerialize, symbol, varName, isExportAssignmentCompatibleSymbolName ? 0 : 1);
40604                         }
40605                         else {
40606                             var statement = ts.factory.createVariableStatement(undefined, ts.factory.createVariableDeclarationList([
40607                                 ts.factory.createVariableDeclaration(varName, undefined, serializeTypeForDeclaration(context, typeToSerialize, symbol, enclosingDeclaration, includePrivateSymbol, bundled))
40608                             ], 2));
40609                             addResult(statement, target && target.flags & 4 && target.escapedName === "export=" ? 2
40610                                 : name === varName ? 1
40611                                     : 0);
40612                         }
40613                         if (isExportAssignmentCompatibleSymbolName) {
40614                             results.push(ts.factory.createExportAssignment(undefined, undefined, isExportEquals, ts.factory.createIdentifier(varName)));
40615                             return true;
40616                         }
40617                         else if (name !== varName) {
40618                             serializeExportSpecifier(name, varName);
40619                             return true;
40620                         }
40621                         return false;
40622                     }
40623                 }
40624                 function isTypeRepresentableAsFunctionNamespaceMerge(typeToSerialize, hostSymbol) {
40625                     var ctxSrc = ts.getSourceFileOfNode(context.enclosingDeclaration);
40626                     return ts.getObjectFlags(typeToSerialize) & (16 | 32) &&
40627                         !getIndexInfoOfType(typeToSerialize, 0) &&
40628                         !getIndexInfoOfType(typeToSerialize, 1) &&
40629                         !isClassInstanceSide(typeToSerialize) &&
40630                         !!(ts.length(ts.filter(getPropertiesOfType(typeToSerialize), isNamespaceMember)) || ts.length(getSignaturesOfType(typeToSerialize, 0))) &&
40631                         !ts.length(getSignaturesOfType(typeToSerialize, 1)) &&
40632                         !getDeclarationWithTypeAnnotation(hostSymbol, enclosingDeclaration) &&
40633                         !(typeToSerialize.symbol && ts.some(typeToSerialize.symbol.declarations, function (d) { return ts.getSourceFileOfNode(d) !== ctxSrc; })) &&
40634                         !ts.some(getPropertiesOfType(typeToSerialize), function (p) { return isLateBoundName(p.escapedName); }) &&
40635                         !ts.some(getPropertiesOfType(typeToSerialize), function (p) { return ts.some(p.declarations, function (d) { return ts.getSourceFileOfNode(d) !== ctxSrc; }); }) &&
40636                         ts.every(getPropertiesOfType(typeToSerialize), function (p) { return ts.isIdentifierText(ts.symbolName(p), languageVersion); });
40637                 }
40638                 function makeSerializePropertySymbol(createProperty, methodKind, useAccessors) {
40639                     return function serializePropertySymbol(p, isStatic, baseType) {
40640                         var modifierFlags = ts.getDeclarationModifierFlagsFromSymbol(p);
40641                         var isPrivate = !!(modifierFlags & 8);
40642                         if (isStatic && (p.flags & (788968 | 1920 | 2097152))) {
40643                             return [];
40644                         }
40645                         if (p.flags & 4194304 ||
40646                             (baseType && getPropertyOfType(baseType, p.escapedName)
40647                                 && isReadonlySymbol(getPropertyOfType(baseType, p.escapedName)) === isReadonlySymbol(p)
40648                                 && (p.flags & 16777216) === (getPropertyOfType(baseType, p.escapedName).flags & 16777216)
40649                                 && isTypeIdenticalTo(getTypeOfSymbol(p), getTypeOfPropertyOfType(baseType, p.escapedName)))) {
40650                             return [];
40651                         }
40652                         var flag = (modifierFlags & ~256) | (isStatic ? 32 : 0);
40653                         var name = getPropertyNameNodeForSymbol(p, context);
40654                         var firstPropertyLikeDecl = ts.find(p.declarations, ts.or(ts.isPropertyDeclaration, ts.isAccessor, ts.isVariableDeclaration, ts.isPropertySignature, ts.isBinaryExpression, ts.isPropertyAccessExpression));
40655                         if (p.flags & 98304 && useAccessors) {
40656                             var result = [];
40657                             if (p.flags & 65536) {
40658                                 result.push(ts.setTextRange(ts.factory.createSetAccessorDeclaration(undefined, ts.factory.createModifiersFromModifierFlags(flag), name, [ts.factory.createParameterDeclaration(undefined, undefined, undefined, "arg", undefined, isPrivate ? undefined : serializeTypeForDeclaration(context, getTypeOfSymbol(p), p, enclosingDeclaration, includePrivateSymbol, bundled))], undefined), ts.find(p.declarations, ts.isSetAccessor) || firstPropertyLikeDecl));
40659                             }
40660                             if (p.flags & 32768) {
40661                                 var isPrivate_1 = modifierFlags & 8;
40662                                 result.push(ts.setTextRange(ts.factory.createGetAccessorDeclaration(undefined, ts.factory.createModifiersFromModifierFlags(flag), name, [], isPrivate_1 ? undefined : serializeTypeForDeclaration(context, getTypeOfSymbol(p), p, enclosingDeclaration, includePrivateSymbol, bundled), undefined), ts.find(p.declarations, ts.isGetAccessor) || firstPropertyLikeDecl));
40663                             }
40664                             return result;
40665                         }
40666                         else if (p.flags & (4 | 3 | 98304)) {
40667                             return ts.setTextRange(createProperty(undefined, ts.factory.createModifiersFromModifierFlags((isReadonlySymbol(p) ? 64 : 0) | flag), name, p.flags & 16777216 ? ts.factory.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);
40668                         }
40669                         if (p.flags & (8192 | 16)) {
40670                             var type = getTypeOfSymbol(p);
40671                             var signatures = getSignaturesOfType(type, 0);
40672                             if (flag & 8) {
40673                                 return ts.setTextRange(createProperty(undefined, ts.factory.createModifiersFromModifierFlags((isReadonlySymbol(p) ? 64 : 0) | flag), name, p.flags & 16777216 ? ts.factory.createToken(57) : undefined, undefined, undefined), ts.find(p.declarations, ts.isFunctionLikeDeclaration) || signatures[0] && signatures[0].declaration || p.declarations[0]);
40674                             }
40675                             var results_1 = [];
40676                             for (var _i = 0, signatures_3 = signatures; _i < signatures_3.length; _i++) {
40677                                 var sig = signatures_3[_i];
40678                                 var decl = signatureToSignatureDeclarationHelper(sig, methodKind, context, {
40679                                     name: name,
40680                                     questionToken: p.flags & 16777216 ? ts.factory.createToken(57) : undefined,
40681                                     modifiers: flag ? ts.factory.createModifiersFromModifierFlags(flag) : undefined
40682                                 });
40683                                 results_1.push(ts.setTextRange(decl, sig.declaration));
40684                             }
40685                             return results_1;
40686                         }
40687                         return ts.Debug.fail("Unhandled class member kind! " + (p.__debugFlags || p.flags));
40688                     };
40689                 }
40690                 function serializePropertySymbolForInterface(p, baseType) {
40691                     return serializePropertySymbolForInterfaceWorker(p, false, baseType);
40692                 }
40693                 function serializeSignatures(kind, input, baseType, outputKind) {
40694                     var signatures = getSignaturesOfType(input, kind);
40695                     if (kind === 1) {
40696                         if (!baseType && ts.every(signatures, function (s) { return ts.length(s.parameters) === 0; })) {
40697                             return [];
40698                         }
40699                         if (baseType) {
40700                             var baseSigs = getSignaturesOfType(baseType, 1);
40701                             if (!ts.length(baseSigs) && ts.every(signatures, function (s) { return ts.length(s.parameters) === 0; })) {
40702                                 return [];
40703                             }
40704                             if (baseSigs.length === signatures.length) {
40705                                 var failed = false;
40706                                 for (var i = 0; i < baseSigs.length; i++) {
40707                                     if (!compareSignaturesIdentical(signatures[i], baseSigs[i], false, false, true, compareTypesIdentical)) {
40708                                         failed = true;
40709                                         break;
40710                                     }
40711                                 }
40712                                 if (!failed) {
40713                                     return [];
40714                                 }
40715                             }
40716                         }
40717                         var privateProtected = 0;
40718                         for (var _i = 0, signatures_4 = signatures; _i < signatures_4.length; _i++) {
40719                             var s = signatures_4[_i];
40720                             if (s.declaration) {
40721                                 privateProtected |= ts.getSelectedEffectiveModifierFlags(s.declaration, 8 | 16);
40722                             }
40723                         }
40724                         if (privateProtected) {
40725                             return [ts.setTextRange(ts.factory.createConstructorDeclaration(undefined, ts.factory.createModifiersFromModifierFlags(privateProtected), [], undefined), signatures[0].declaration)];
40726                         }
40727                     }
40728                     var results = [];
40729                     for (var _a = 0, signatures_5 = signatures; _a < signatures_5.length; _a++) {
40730                         var sig = signatures_5[_a];
40731                         var decl = signatureToSignatureDeclarationHelper(sig, outputKind, context);
40732                         results.push(ts.setTextRange(decl, sig.declaration));
40733                     }
40734                     return results;
40735                 }
40736                 function serializeIndexSignatures(input, baseType) {
40737                     var results = [];
40738                     for (var _i = 0, _a = [0, 1]; _i < _a.length; _i++) {
40739                         var type = _a[_i];
40740                         var info = getIndexInfoOfType(input, type);
40741                         if (info) {
40742                             if (baseType) {
40743                                 var baseInfo = getIndexInfoOfType(baseType, type);
40744                                 if (baseInfo) {
40745                                     if (isTypeIdenticalTo(info.type, baseInfo.type)) {
40746                                         continue;
40747                                     }
40748                                 }
40749                             }
40750                             results.push(indexInfoToIndexSignatureDeclarationHelper(info, type, context, undefined));
40751                         }
40752                     }
40753                     return results;
40754                 }
40755                 function serializeBaseType(t, staticType, rootName) {
40756                     var ref = trySerializeAsTypeReference(t, 111551);
40757                     if (ref) {
40758                         return ref;
40759                     }
40760                     var tempName = getUnusedName(rootName + "_base");
40761                     var statement = ts.factory.createVariableStatement(undefined, ts.factory.createVariableDeclarationList([
40762                         ts.factory.createVariableDeclaration(tempName, undefined, typeToTypeNodeHelper(staticType, context))
40763                     ], 2));
40764                     addResult(statement, 0);
40765                     return ts.factory.createExpressionWithTypeArguments(ts.factory.createIdentifier(tempName), undefined);
40766                 }
40767                 function trySerializeAsTypeReference(t, flags) {
40768                     var typeArgs;
40769                     var reference;
40770                     if (t.target && isSymbolAccessibleByFlags(t.target.symbol, enclosingDeclaration, flags)) {
40771                         typeArgs = ts.map(getTypeArguments(t), function (t) { return typeToTypeNodeHelper(t, context); });
40772                         reference = symbolToExpression(t.target.symbol, context, 788968);
40773                     }
40774                     else if (t.symbol && isSymbolAccessibleByFlags(t.symbol, enclosingDeclaration, flags)) {
40775                         reference = symbolToExpression(t.symbol, context, 788968);
40776                     }
40777                     if (reference) {
40778                         return ts.factory.createExpressionWithTypeArguments(reference, typeArgs);
40779                     }
40780                 }
40781                 function serializeImplementedType(t) {
40782                     var ref = trySerializeAsTypeReference(t, 788968);
40783                     if (ref) {
40784                         return ref;
40785                     }
40786                     if (t.symbol) {
40787                         return ts.factory.createExpressionWithTypeArguments(symbolToExpression(t.symbol, context, 788968), undefined);
40788                     }
40789                 }
40790                 function getUnusedName(input, symbol) {
40791                     var _a, _b;
40792                     var id = symbol ? getSymbolId(symbol) : undefined;
40793                     if (id) {
40794                         if (context.remappedSymbolNames.has(id)) {
40795                             return context.remappedSymbolNames.get(id);
40796                         }
40797                     }
40798                     if (symbol) {
40799                         input = getNameCandidateWorker(symbol, input);
40800                     }
40801                     var i = 0;
40802                     var original = input;
40803                     while ((_a = context.usedSymbolNames) === null || _a === void 0 ? void 0 : _a.has(input)) {
40804                         i++;
40805                         input = original + "_" + i;
40806                     }
40807                     (_b = context.usedSymbolNames) === null || _b === void 0 ? void 0 : _b.add(input);
40808                     if (id) {
40809                         context.remappedSymbolNames.set(id, input);
40810                     }
40811                     return input;
40812                 }
40813                 function getNameCandidateWorker(symbol, localName) {
40814                     if (localName === "default" || localName === "__class" || localName === "__function") {
40815                         var flags = context.flags;
40816                         context.flags |= 16777216;
40817                         var nameCandidate = getNameOfSymbolAsWritten(symbol, context);
40818                         context.flags = flags;
40819                         localName = nameCandidate.length > 0 && ts.isSingleOrDoubleQuote(nameCandidate.charCodeAt(0)) ? ts.stripQuotes(nameCandidate) : nameCandidate;
40820                     }
40821                     if (localName === "default") {
40822                         localName = "_default";
40823                     }
40824                     else if (localName === "export=") {
40825                         localName = "_exports";
40826                     }
40827                     localName = ts.isIdentifierText(localName, languageVersion) && !ts.isStringANonContextualKeyword(localName) ? localName : "_" + localName.replace(/[^a-zA-Z0-9]/g, "_");
40828                     return localName;
40829                 }
40830                 function getInternalSymbolName(symbol, localName) {
40831                     var id = getSymbolId(symbol);
40832                     if (context.remappedSymbolNames.has(id)) {
40833                         return context.remappedSymbolNames.get(id);
40834                     }
40835                     localName = getNameCandidateWorker(symbol, localName);
40836                     context.remappedSymbolNames.set(id, localName);
40837                     return localName;
40838                 }
40839             }
40840         }
40841         function typePredicateToString(typePredicate, enclosingDeclaration, flags, writer) {
40842             if (flags === void 0) { flags = 16384; }
40843             return writer ? typePredicateToStringWorker(writer).getText() : ts.usingSingleLineStringWriter(typePredicateToStringWorker);
40844             function typePredicateToStringWorker(writer) {
40845                 var predicate = ts.factory.createTypePredicateNode(typePredicate.kind === 2 || typePredicate.kind === 3 ? ts.factory.createToken(127) : undefined, typePredicate.kind === 1 || typePredicate.kind === 3 ? ts.factory.createIdentifier(typePredicate.parameterName) : ts.factory.createThisTypeNode(), typePredicate.type && nodeBuilder.typeToTypeNode(typePredicate.type, enclosingDeclaration, toNodeBuilderFlags(flags) | 70221824 | 512));
40846                 var printer = ts.createPrinter({ removeComments: true });
40847                 var sourceFile = enclosingDeclaration && ts.getSourceFileOfNode(enclosingDeclaration);
40848                 printer.writeNode(4, predicate, sourceFile, writer);
40849                 return writer;
40850             }
40851         }
40852         function formatUnionTypes(types) {
40853             var result = [];
40854             var flags = 0;
40855             for (var i = 0; i < types.length; i++) {
40856                 var t = types[i];
40857                 flags |= t.flags;
40858                 if (!(t.flags & 98304)) {
40859                     if (t.flags & (512 | 1024)) {
40860                         var baseType = t.flags & 512 ? booleanType : getBaseTypeOfEnumLiteralType(t);
40861                         if (baseType.flags & 1048576) {
40862                             var count = baseType.types.length;
40863                             if (i + count <= types.length && getRegularTypeOfLiteralType(types[i + count - 1]) === getRegularTypeOfLiteralType(baseType.types[count - 1])) {
40864                                 result.push(baseType);
40865                                 i += count - 1;
40866                                 continue;
40867                             }
40868                         }
40869                     }
40870                     result.push(t);
40871                 }
40872             }
40873             if (flags & 65536)
40874                 result.push(nullType);
40875             if (flags & 32768)
40876                 result.push(undefinedType);
40877             return result || types;
40878         }
40879         function visibilityToString(flags) {
40880             if (flags === 8) {
40881                 return "private";
40882             }
40883             if (flags === 16) {
40884                 return "protected";
40885             }
40886             return "public";
40887         }
40888         function getTypeAliasForTypeLiteral(type) {
40889             if (type.symbol && type.symbol.flags & 2048) {
40890                 var node = ts.walkUpParenthesizedTypes(type.symbol.declarations[0].parent);
40891                 if (node.kind === 254) {
40892                     return getSymbolOfNode(node);
40893                 }
40894             }
40895             return undefined;
40896         }
40897         function isTopLevelInExternalModuleAugmentation(node) {
40898             return node && node.parent &&
40899                 node.parent.kind === 257 &&
40900                 ts.isExternalModuleAugmentation(node.parent.parent);
40901         }
40902         function isDefaultBindingContext(location) {
40903             return location.kind === 297 || ts.isAmbientModule(location);
40904         }
40905         function getNameOfSymbolFromNameType(symbol, context) {
40906             var nameType = getSymbolLinks(symbol).nameType;
40907             if (nameType) {
40908                 if (nameType.flags & 384) {
40909                     var name = "" + nameType.value;
40910                     if (!ts.isIdentifierText(name, compilerOptions.target) && !isNumericLiteralName(name)) {
40911                         return "\"" + ts.escapeString(name, 34) + "\"";
40912                     }
40913                     if (isNumericLiteralName(name) && ts.startsWith(name, "-")) {
40914                         return "[" + name + "]";
40915                     }
40916                     return name;
40917                 }
40918                 if (nameType.flags & 8192) {
40919                     return "[" + getNameOfSymbolAsWritten(nameType.symbol, context) + "]";
40920                 }
40921             }
40922         }
40923         function getNameOfSymbolAsWritten(symbol, context) {
40924             if (context && symbol.escapedName === "default" && !(context.flags & 16384) &&
40925                 (!(context.flags & 16777216) ||
40926                     !symbol.declarations ||
40927                     (context.enclosingDeclaration && ts.findAncestor(symbol.declarations[0], isDefaultBindingContext) !== ts.findAncestor(context.enclosingDeclaration, isDefaultBindingContext)))) {
40928                 return "default";
40929             }
40930             if (symbol.declarations && symbol.declarations.length) {
40931                 var declaration = ts.firstDefined(symbol.declarations, function (d) { return ts.getNameOfDeclaration(d) ? d : undefined; });
40932                 var name_3 = declaration && ts.getNameOfDeclaration(declaration);
40933                 if (declaration && name_3) {
40934                     if (ts.isCallExpression(declaration) && ts.isBindableObjectDefinePropertyCall(declaration)) {
40935                         return ts.symbolName(symbol);
40936                     }
40937                     if (ts.isComputedPropertyName(name_3) && !(ts.getCheckFlags(symbol) & 4096)) {
40938                         var nameType = getSymbolLinks(symbol).nameType;
40939                         if (nameType && nameType.flags & 384) {
40940                             var result = getNameOfSymbolFromNameType(symbol, context);
40941                             if (result !== undefined) {
40942                                 return result;
40943                             }
40944                         }
40945                     }
40946                     return ts.declarationNameToString(name_3);
40947                 }
40948                 if (!declaration) {
40949                     declaration = symbol.declarations[0];
40950                 }
40951                 if (declaration.parent && declaration.parent.kind === 249) {
40952                     return ts.declarationNameToString(declaration.parent.name);
40953                 }
40954                 switch (declaration.kind) {
40955                     case 221:
40956                     case 208:
40957                     case 209:
40958                         if (context && !context.encounteredError && !(context.flags & 131072)) {
40959                             context.encounteredError = true;
40960                         }
40961                         return declaration.kind === 221 ? "(Anonymous class)" : "(Anonymous function)";
40962                 }
40963             }
40964             var name = getNameOfSymbolFromNameType(symbol, context);
40965             return name !== undefined ? name : ts.symbolName(symbol);
40966         }
40967         function isDeclarationVisible(node) {
40968             if (node) {
40969                 var links = getNodeLinks(node);
40970                 if (links.isVisible === undefined) {
40971                     links.isVisible = !!determineIfDeclarationIsVisible();
40972                 }
40973                 return links.isVisible;
40974             }
40975             return false;
40976             function determineIfDeclarationIsVisible() {
40977                 switch (node.kind) {
40978                     case 324:
40979                     case 331:
40980                     case 325:
40981                         return !!(node.parent && node.parent.parent && node.parent.parent.parent && ts.isSourceFile(node.parent.parent.parent));
40982                     case 198:
40983                         return isDeclarationVisible(node.parent.parent);
40984                     case 249:
40985                         if (ts.isBindingPattern(node.name) &&
40986                             !node.name.elements.length) {
40987                             return false;
40988                         }
40989                     case 256:
40990                     case 252:
40991                     case 253:
40992                     case 254:
40993                     case 251:
40994                     case 255:
40995                     case 260:
40996                         if (ts.isExternalModuleAugmentation(node)) {
40997                             return true;
40998                         }
40999                         var parent = getDeclarationContainer(node);
41000                         if (!(ts.getCombinedModifierFlags(node) & 1) &&
41001                             !(node.kind !== 260 && parent.kind !== 297 && parent.flags & 8388608)) {
41002                             return isGlobalSourceFile(parent);
41003                         }
41004                         return isDeclarationVisible(parent);
41005                     case 163:
41006                     case 162:
41007                     case 167:
41008                     case 168:
41009                     case 165:
41010                     case 164:
41011                         if (ts.hasEffectiveModifier(node, 8 | 16)) {
41012                             return false;
41013                         }
41014                     case 166:
41015                     case 170:
41016                     case 169:
41017                     case 171:
41018                     case 160:
41019                     case 257:
41020                     case 174:
41021                     case 175:
41022                     case 177:
41023                     case 173:
41024                     case 178:
41025                     case 179:
41026                     case 182:
41027                     case 183:
41028                     case 186:
41029                     case 192:
41030                         return isDeclarationVisible(node.parent);
41031                     case 262:
41032                     case 263:
41033                     case 265:
41034                         return false;
41035                     case 159:
41036                     case 297:
41037                     case 259:
41038                         return true;
41039                     case 266:
41040                         return false;
41041                     default:
41042                         return false;
41043                 }
41044             }
41045         }
41046         function collectLinkedAliases(node, setVisibility) {
41047             var exportSymbol;
41048             if (node.parent && node.parent.kind === 266) {
41049                 exportSymbol = resolveName(node, node.escapedText, 111551 | 788968 | 1920 | 2097152, undefined, node, false);
41050             }
41051             else if (node.parent.kind === 270) {
41052                 exportSymbol = getTargetOfExportSpecifier(node.parent, 111551 | 788968 | 1920 | 2097152);
41053             }
41054             var result;
41055             var visited;
41056             if (exportSymbol) {
41057                 visited = new ts.Set();
41058                 visited.add(getSymbolId(exportSymbol));
41059                 buildVisibleNodeList(exportSymbol.declarations);
41060             }
41061             return result;
41062             function buildVisibleNodeList(declarations) {
41063                 ts.forEach(declarations, function (declaration) {
41064                     var resultNode = getAnyImportSyntax(declaration) || declaration;
41065                     if (setVisibility) {
41066                         getNodeLinks(declaration).isVisible = true;
41067                     }
41068                     else {
41069                         result = result || [];
41070                         ts.pushIfUnique(result, resultNode);
41071                     }
41072                     if (ts.isInternalModuleImportEqualsDeclaration(declaration)) {
41073                         var internalModuleReference = declaration.moduleReference;
41074                         var firstIdentifier = ts.getFirstIdentifier(internalModuleReference);
41075                         var importSymbol = resolveName(declaration, firstIdentifier.escapedText, 111551 | 788968 | 1920, undefined, undefined, false);
41076                         if (importSymbol && visited) {
41077                             if (ts.tryAddToSet(visited, getSymbolId(importSymbol))) {
41078                                 buildVisibleNodeList(importSymbol.declarations);
41079                             }
41080                         }
41081                     }
41082                 });
41083             }
41084         }
41085         function pushTypeResolution(target, propertyName) {
41086             var resolutionCycleStartIndex = findResolutionCycleStartIndex(target, propertyName);
41087             if (resolutionCycleStartIndex >= 0) {
41088                 var length_3 = resolutionTargets.length;
41089                 for (var i = resolutionCycleStartIndex; i < length_3; i++) {
41090                     resolutionResults[i] = false;
41091                 }
41092                 return false;
41093             }
41094             resolutionTargets.push(target);
41095             resolutionResults.push(true);
41096             resolutionPropertyNames.push(propertyName);
41097             return true;
41098         }
41099         function findResolutionCycleStartIndex(target, propertyName) {
41100             for (var i = resolutionTargets.length - 1; i >= 0; i--) {
41101                 if (hasType(resolutionTargets[i], resolutionPropertyNames[i])) {
41102                     return -1;
41103                 }
41104                 if (resolutionTargets[i] === target && resolutionPropertyNames[i] === propertyName) {
41105                     return i;
41106                 }
41107             }
41108             return -1;
41109         }
41110         function hasType(target, propertyName) {
41111             switch (propertyName) {
41112                 case 0:
41113                     return !!getSymbolLinks(target).type;
41114                 case 5:
41115                     return !!(getNodeLinks(target).resolvedEnumType);
41116                 case 2:
41117                     return !!getSymbolLinks(target).declaredType;
41118                 case 1:
41119                     return !!target.resolvedBaseConstructorType;
41120                 case 3:
41121                     return !!target.resolvedReturnType;
41122                 case 4:
41123                     return !!target.immediateBaseConstraint;
41124                 case 6:
41125                     return !!target.resolvedTypeArguments;
41126                 case 7:
41127                     return !!target.baseTypesResolved;
41128             }
41129             return ts.Debug.assertNever(propertyName);
41130         }
41131         function popTypeResolution() {
41132             resolutionTargets.pop();
41133             resolutionPropertyNames.pop();
41134             return resolutionResults.pop();
41135         }
41136         function getDeclarationContainer(node) {
41137             return ts.findAncestor(ts.getRootDeclaration(node), function (node) {
41138                 switch (node.kind) {
41139                     case 249:
41140                     case 250:
41141                     case 265:
41142                     case 264:
41143                     case 263:
41144                     case 262:
41145                         return false;
41146                     default:
41147                         return true;
41148                 }
41149             }).parent;
41150         }
41151         function getTypeOfPrototypeProperty(prototype) {
41152             var classType = getDeclaredTypeOfSymbol(getParentOfSymbol(prototype));
41153             return classType.typeParameters ? createTypeReference(classType, ts.map(classType.typeParameters, function (_) { return anyType; })) : classType;
41154         }
41155         function getTypeOfPropertyOfType(type, name) {
41156             var prop = getPropertyOfType(type, name);
41157             return prop ? getTypeOfSymbol(prop) : undefined;
41158         }
41159         function getTypeOfPropertyOrIndexSignature(type, name) {
41160             return getTypeOfPropertyOfType(type, name) || isNumericLiteralName(name) && getIndexTypeOfType(type, 1) || getIndexTypeOfType(type, 0) || unknownType;
41161         }
41162         function isTypeAny(type) {
41163             return type && (type.flags & 1) !== 0;
41164         }
41165         function getTypeForBindingElementParent(node) {
41166             var symbol = getSymbolOfNode(node);
41167             return symbol && getSymbolLinks(symbol).type || getTypeForVariableLikeDeclaration(node, false);
41168         }
41169         function getRestType(source, properties, symbol) {
41170             source = filterType(source, function (t) { return !(t.flags & 98304); });
41171             if (source.flags & 131072) {
41172                 return emptyObjectType;
41173             }
41174             if (source.flags & 1048576) {
41175                 return mapType(source, function (t) { return getRestType(t, properties, symbol); });
41176             }
41177             var omitKeyType = getUnionType(ts.map(properties, getLiteralTypeFromPropertyName));
41178             if (isGenericObjectType(source) || isGenericIndexType(omitKeyType)) {
41179                 if (omitKeyType.flags & 131072) {
41180                     return source;
41181                 }
41182                 var omitTypeAlias = getGlobalOmitSymbol();
41183                 if (!omitTypeAlias) {
41184                     return errorType;
41185                 }
41186                 return getTypeAliasInstantiation(omitTypeAlias, [source, omitKeyType]);
41187             }
41188             var members = ts.createSymbolTable();
41189             for (var _i = 0, _a = getPropertiesOfType(source); _i < _a.length; _i++) {
41190                 var prop = _a[_i];
41191                 if (!isTypeAssignableTo(getLiteralTypeFromProperty(prop, 8576), omitKeyType)
41192                     && !(ts.getDeclarationModifierFlagsFromSymbol(prop) & (8 | 16))
41193                     && isSpreadableProperty(prop)) {
41194                     members.set(prop.escapedName, getSpreadSymbol(prop, false));
41195                 }
41196             }
41197             var stringIndexInfo = getIndexInfoOfType(source, 0);
41198             var numberIndexInfo = getIndexInfoOfType(source, 1);
41199             var result = createAnonymousType(symbol, members, ts.emptyArray, ts.emptyArray, stringIndexInfo, numberIndexInfo);
41200             result.objectFlags |= 131072;
41201             return result;
41202         }
41203         function getFlowTypeOfDestructuring(node, declaredType) {
41204             var reference = getSyntheticElementAccess(node);
41205             return reference ? getFlowTypeOfReference(reference, declaredType) : declaredType;
41206         }
41207         function getSyntheticElementAccess(node) {
41208             var parentAccess = getParentElementAccess(node);
41209             if (parentAccess && parentAccess.flowNode) {
41210                 var propName = getDestructuringPropertyName(node);
41211                 if (propName) {
41212                     var literal = ts.setTextRange(ts.parseNodeFactory.createStringLiteral(propName), node);
41213                     var lhsExpr = ts.isLeftHandSideExpression(parentAccess) ? parentAccess : ts.parseNodeFactory.createParenthesizedExpression(parentAccess);
41214                     var result = ts.setTextRange(ts.parseNodeFactory.createElementAccessExpression(lhsExpr, literal), node);
41215                     ts.setParent(literal, result);
41216                     ts.setParent(result, node);
41217                     if (lhsExpr !== parentAccess) {
41218                         ts.setParent(lhsExpr, result);
41219                     }
41220                     result.flowNode = parentAccess.flowNode;
41221                     return result;
41222                 }
41223             }
41224         }
41225         function getParentElementAccess(node) {
41226             var ancestor = node.parent.parent;
41227             switch (ancestor.kind) {
41228                 case 198:
41229                 case 288:
41230                     return getSyntheticElementAccess(ancestor);
41231                 case 199:
41232                     return getSyntheticElementAccess(node.parent);
41233                 case 249:
41234                     return ancestor.initializer;
41235                 case 216:
41236                     return ancestor.right;
41237             }
41238         }
41239         function getDestructuringPropertyName(node) {
41240             var parent = node.parent;
41241             if (node.kind === 198 && parent.kind === 196) {
41242                 return getLiteralPropertyNameText(node.propertyName || node.name);
41243             }
41244             if (node.kind === 288 || node.kind === 289) {
41245                 return getLiteralPropertyNameText(node.name);
41246             }
41247             return "" + parent.elements.indexOf(node);
41248         }
41249         function getLiteralPropertyNameText(name) {
41250             var type = getLiteralTypeFromPropertyName(name);
41251             return type.flags & (128 | 256) ? "" + type.value : undefined;
41252         }
41253         function getTypeForBindingElement(declaration) {
41254             var pattern = declaration.parent;
41255             var parentType = getTypeForBindingElementParent(pattern.parent);
41256             if (!parentType || isTypeAny(parentType)) {
41257                 return parentType;
41258             }
41259             if (strictNullChecks && declaration.flags & 8388608 && ts.isParameterDeclaration(declaration)) {
41260                 parentType = getNonNullableType(parentType);
41261             }
41262             else if (strictNullChecks && pattern.parent.initializer && !(getTypeFacts(getTypeOfInitializer(pattern.parent.initializer)) & 65536)) {
41263                 parentType = getTypeWithFacts(parentType, 524288);
41264             }
41265             var type;
41266             if (pattern.kind === 196) {
41267                 if (declaration.dotDotDotToken) {
41268                     parentType = getReducedType(parentType);
41269                     if (parentType.flags & 2 || !isValidSpreadType(parentType)) {
41270                         error(declaration, ts.Diagnostics.Rest_types_may_only_be_created_from_object_types);
41271                         return errorType;
41272                     }
41273                     var literalMembers = [];
41274                     for (var _i = 0, _a = pattern.elements; _i < _a.length; _i++) {
41275                         var element = _a[_i];
41276                         if (!element.dotDotDotToken) {
41277                             literalMembers.push(element.propertyName || element.name);
41278                         }
41279                     }
41280                     type = getRestType(parentType, literalMembers, declaration.symbol);
41281                 }
41282                 else {
41283                     var name = declaration.propertyName || declaration.name;
41284                     var indexType = getLiteralTypeFromPropertyName(name);
41285                     var declaredType = getConstraintForLocation(getIndexedAccessType(parentType, indexType, undefined, name, undefined, undefined, 16), declaration.name);
41286                     type = getFlowTypeOfDestructuring(declaration, declaredType);
41287                 }
41288             }
41289             else {
41290                 var elementType = checkIteratedTypeOrElementType(65 | (declaration.dotDotDotToken ? 0 : 128), parentType, undefinedType, pattern);
41291                 var index_2 = pattern.elements.indexOf(declaration);
41292                 if (declaration.dotDotDotToken) {
41293                     type = everyType(parentType, isTupleType) ?
41294                         mapType(parentType, function (t) { return sliceTupleType(t, index_2); }) :
41295                         createArrayType(elementType);
41296                 }
41297                 else if (isArrayLikeType(parentType)) {
41298                     var indexType = getLiteralType(index_2);
41299                     var accessFlags = hasDefaultValue(declaration) ? 8 : 0;
41300                     var declaredType = getConstraintForLocation(getIndexedAccessTypeOrUndefined(parentType, indexType, undefined, declaration.name, accessFlags | 16) || errorType, declaration.name);
41301                     type = getFlowTypeOfDestructuring(declaration, declaredType);
41302                 }
41303                 else {
41304                     type = elementType;
41305                 }
41306             }
41307             if (!declaration.initializer) {
41308                 return type;
41309             }
41310             if (ts.getEffectiveTypeAnnotationNode(ts.walkUpBindingElementsAndPatterns(declaration))) {
41311                 return strictNullChecks && !(getFalsyFlags(checkDeclarationInitializer(declaration)) & 32768) ?
41312                     getTypeWithFacts(type, 524288) :
41313                     type;
41314             }
41315             return widenTypeInferredFromInitializer(declaration, getUnionType([getTypeWithFacts(type, 524288), checkDeclarationInitializer(declaration)], 2));
41316         }
41317         function getTypeForDeclarationFromJSDocComment(declaration) {
41318             var jsdocType = ts.getJSDocType(declaration);
41319             if (jsdocType) {
41320                 return getTypeFromTypeNode(jsdocType);
41321             }
41322             return undefined;
41323         }
41324         function isNullOrUndefined(node) {
41325             var expr = ts.skipParentheses(node);
41326             return expr.kind === 103 || expr.kind === 78 && getResolvedSymbol(expr) === undefinedSymbol;
41327         }
41328         function isEmptyArrayLiteral(node) {
41329             var expr = ts.skipParentheses(node);
41330             return expr.kind === 199 && expr.elements.length === 0;
41331         }
41332         function addOptionality(type, optional) {
41333             if (optional === void 0) { optional = true; }
41334             return strictNullChecks && optional ? getOptionalType(type) : type;
41335         }
41336         function getTypeForVariableLikeDeclaration(declaration, includeOptionality) {
41337             if (ts.isVariableDeclaration(declaration) && declaration.parent.parent.kind === 238) {
41338                 var indexType = getIndexType(getNonNullableTypeIfNeeded(checkExpression(declaration.parent.parent.expression)));
41339                 return indexType.flags & (262144 | 4194304) ? getExtractStringType(indexType) : stringType;
41340             }
41341             if (ts.isVariableDeclaration(declaration) && declaration.parent.parent.kind === 239) {
41342                 var forOfStatement = declaration.parent.parent;
41343                 return checkRightHandSideOfForOf(forOfStatement) || anyType;
41344             }
41345             if (ts.isBindingPattern(declaration.parent)) {
41346                 return getTypeForBindingElement(declaration);
41347             }
41348             var isOptional = includeOptionality && (ts.isParameter(declaration) && isJSDocOptionalParameter(declaration)
41349                 || isOptionalJSDocPropertyLikeTag(declaration)
41350                 || !ts.isBindingElement(declaration) && !ts.isVariableDeclaration(declaration) && !!declaration.questionToken);
41351             var declaredType = tryGetTypeFromEffectiveTypeNode(declaration);
41352             if (declaredType) {
41353                 return addOptionality(declaredType, isOptional);
41354             }
41355             if ((noImplicitAny || ts.isInJSFile(declaration)) &&
41356                 ts.isVariableDeclaration(declaration) && !ts.isBindingPattern(declaration.name) &&
41357                 !(ts.getCombinedModifierFlags(declaration) & 1) && !(declaration.flags & 8388608)) {
41358                 if (!(ts.getCombinedNodeFlags(declaration) & 2) && (!declaration.initializer || isNullOrUndefined(declaration.initializer))) {
41359                     return autoType;
41360                 }
41361                 if (declaration.initializer && isEmptyArrayLiteral(declaration.initializer)) {
41362                     return autoArrayType;
41363                 }
41364             }
41365             if (ts.isParameter(declaration)) {
41366                 var func = declaration.parent;
41367                 if (func.kind === 168 && !hasNonBindableDynamicName(func)) {
41368                     var getter = ts.getDeclarationOfKind(getSymbolOfNode(declaration.parent), 167);
41369                     if (getter) {
41370                         var getterSignature = getSignatureFromDeclaration(getter);
41371                         var thisParameter = getAccessorThisParameter(func);
41372                         if (thisParameter && declaration === thisParameter) {
41373                             ts.Debug.assert(!thisParameter.type);
41374                             return getTypeOfSymbol(getterSignature.thisParameter);
41375                         }
41376                         return getReturnTypeOfSignature(getterSignature);
41377                     }
41378                 }
41379                 if (ts.isInJSFile(declaration)) {
41380                     var typeTag = ts.getJSDocType(func);
41381                     if (typeTag && ts.isFunctionTypeNode(typeTag)) {
41382                         var signature = getSignatureFromDeclaration(typeTag);
41383                         var pos = func.parameters.indexOf(declaration);
41384                         return declaration.dotDotDotToken ? getRestTypeAtPosition(signature, pos) : getTypeAtPosition(signature, pos);
41385                     }
41386                 }
41387                 var type = declaration.symbol.escapedName === "this" ? getContextualThisParameterType(func) : getContextuallyTypedParameterType(declaration);
41388                 if (type) {
41389                     return addOptionality(type, isOptional);
41390                 }
41391             }
41392             if (ts.hasOnlyExpressionInitializer(declaration) && !!declaration.initializer) {
41393                 if (ts.isInJSFile(declaration) && !ts.isParameter(declaration)) {
41394                     var containerObjectType = getJSContainerObjectType(declaration, getSymbolOfNode(declaration), ts.getDeclaredExpandoInitializer(declaration));
41395                     if (containerObjectType) {
41396                         return containerObjectType;
41397                     }
41398                 }
41399                 var type = widenTypeInferredFromInitializer(declaration, checkDeclarationInitializer(declaration));
41400                 return addOptionality(type, isOptional);
41401             }
41402             if (ts.isPropertyDeclaration(declaration) && !ts.hasStaticModifier(declaration) && (noImplicitAny || ts.isInJSFile(declaration))) {
41403                 var constructor = findConstructorDeclaration(declaration.parent);
41404                 var type = constructor ? getFlowTypeInConstructor(declaration.symbol, constructor) :
41405                     ts.getEffectiveModifierFlags(declaration) & 2 ? getTypeOfPropertyInBaseClass(declaration.symbol) :
41406                         undefined;
41407                 return type && addOptionality(type, isOptional);
41408             }
41409             if (ts.isJsxAttribute(declaration)) {
41410                 return trueType;
41411             }
41412             if (ts.isBindingPattern(declaration.name)) {
41413                 return getTypeFromBindingPattern(declaration.name, false, true);
41414             }
41415             return undefined;
41416         }
41417         function isConstructorDeclaredProperty(symbol) {
41418             if (symbol.valueDeclaration && ts.isBinaryExpression(symbol.valueDeclaration)) {
41419                 var links = getSymbolLinks(symbol);
41420                 if (links.isConstructorDeclaredProperty === undefined) {
41421                     links.isConstructorDeclaredProperty = false;
41422                     links.isConstructorDeclaredProperty = !!getDeclaringConstructor(symbol) && ts.every(symbol.declarations, function (declaration) {
41423                         return ts.isBinaryExpression(declaration) &&
41424                             isPossiblyAliasedThisProperty(declaration) &&
41425                             (declaration.left.kind !== 202 || ts.isStringOrNumericLiteralLike(declaration.left.argumentExpression)) &&
41426                             !getAnnotatedTypeForAssignmentDeclaration(undefined, declaration, symbol, declaration);
41427                     });
41428                 }
41429                 return links.isConstructorDeclaredProperty;
41430             }
41431             return false;
41432         }
41433         function isAutoTypedProperty(symbol) {
41434             var declaration = symbol.valueDeclaration;
41435             return declaration && ts.isPropertyDeclaration(declaration) && !ts.getEffectiveTypeAnnotationNode(declaration) &&
41436                 !declaration.initializer && (noImplicitAny || ts.isInJSFile(declaration));
41437         }
41438         function getDeclaringConstructor(symbol) {
41439             for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) {
41440                 var declaration = _a[_i];
41441                 var container = ts.getThisContainer(declaration, false);
41442                 if (container && (container.kind === 166 || isJSConstructor(container))) {
41443                     return container;
41444                 }
41445             }
41446         }
41447         function getFlowTypeInConstructor(symbol, constructor) {
41448             var accessName = ts.startsWith(symbol.escapedName, "__#")
41449                 ? ts.factory.createPrivateIdentifier(symbol.escapedName.split("@")[1])
41450                 : ts.unescapeLeadingUnderscores(symbol.escapedName);
41451             var reference = ts.factory.createPropertyAccessExpression(ts.factory.createThis(), accessName);
41452             ts.setParent(reference.expression, reference);
41453             ts.setParent(reference, constructor);
41454             reference.flowNode = constructor.returnFlowNode;
41455             var flowType = getFlowTypeOfProperty(reference, symbol);
41456             if (noImplicitAny && (flowType === autoType || flowType === autoArrayType)) {
41457                 error(symbol.valueDeclaration, ts.Diagnostics.Member_0_implicitly_has_an_1_type, symbolToString(symbol), typeToString(flowType));
41458             }
41459             return everyType(flowType, isNullableType) ? undefined : convertAutoToAny(flowType);
41460         }
41461         function getFlowTypeOfProperty(reference, prop) {
41462             var initialType = prop && (!isAutoTypedProperty(prop) || ts.getEffectiveModifierFlags(prop.valueDeclaration) & 2) && getTypeOfPropertyInBaseClass(prop) || undefinedType;
41463             return getFlowTypeOfReference(reference, autoType, initialType);
41464         }
41465         function getWidenedTypeForAssignmentDeclaration(symbol, resolvedSymbol) {
41466             var container = ts.getAssignedExpandoInitializer(symbol.valueDeclaration);
41467             if (container) {
41468                 var tag = ts.getJSDocTypeTag(container);
41469                 if (tag && tag.typeExpression) {
41470                     return getTypeFromTypeNode(tag.typeExpression);
41471                 }
41472                 var containerObjectType = getJSContainerObjectType(symbol.valueDeclaration, symbol, container);
41473                 return containerObjectType || getWidenedLiteralType(checkExpressionCached(container));
41474             }
41475             var type;
41476             var definedInConstructor = false;
41477             var definedInMethod = false;
41478             if (isConstructorDeclaredProperty(symbol)) {
41479                 type = getFlowTypeInConstructor(symbol, getDeclaringConstructor(symbol));
41480             }
41481             if (!type) {
41482                 var jsdocType = void 0;
41483                 var types = void 0;
41484                 for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) {
41485                     var declaration = _a[_i];
41486                     var expression = (ts.isBinaryExpression(declaration) || ts.isCallExpression(declaration)) ? declaration :
41487                         ts.isAccessExpression(declaration) ? ts.isBinaryExpression(declaration.parent) ? declaration.parent : declaration :
41488                             undefined;
41489                     if (!expression) {
41490                         continue;
41491                     }
41492                     var kind = ts.isAccessExpression(expression)
41493                         ? ts.getAssignmentDeclarationPropertyAccessKind(expression)
41494                         : ts.getAssignmentDeclarationKind(expression);
41495                     if (kind === 4 || ts.isBinaryExpression(expression) && isPossiblyAliasedThisProperty(expression, kind)) {
41496                         if (isDeclarationInConstructor(expression)) {
41497                             definedInConstructor = true;
41498                         }
41499                         else {
41500                             definedInMethod = true;
41501                         }
41502                     }
41503                     if (!ts.isCallExpression(expression)) {
41504                         jsdocType = getAnnotatedTypeForAssignmentDeclaration(jsdocType, expression, symbol, declaration);
41505                     }
41506                     if (!jsdocType) {
41507                         (types || (types = [])).push((ts.isBinaryExpression(expression) || ts.isCallExpression(expression)) ? getInitializerTypeFromAssignmentDeclaration(symbol, resolvedSymbol, expression, kind) : neverType);
41508                     }
41509                 }
41510                 type = jsdocType;
41511                 if (!type) {
41512                     if (!ts.length(types)) {
41513                         return errorType;
41514                     }
41515                     var constructorTypes = definedInConstructor ? getConstructorDefinedThisAssignmentTypes(types, symbol.declarations) : undefined;
41516                     if (definedInMethod) {
41517                         var propType = getTypeOfPropertyInBaseClass(symbol);
41518                         if (propType) {
41519                             (constructorTypes || (constructorTypes = [])).push(propType);
41520                             definedInConstructor = true;
41521                         }
41522                     }
41523                     var sourceTypes = ts.some(constructorTypes, function (t) { return !!(t.flags & ~98304); }) ? constructorTypes : types;
41524                     type = getUnionType(sourceTypes, 2);
41525                 }
41526             }
41527             var widened = getWidenedType(addOptionality(type, definedInMethod && !definedInConstructor));
41528             if (filterType(widened, function (t) { return !!(t.flags & ~98304); }) === neverType) {
41529                 reportImplicitAny(symbol.valueDeclaration, anyType);
41530                 return anyType;
41531             }
41532             return widened;
41533         }
41534         function getJSContainerObjectType(decl, symbol, init) {
41535             var _a, _b;
41536             if (!ts.isInJSFile(decl) || !init || !ts.isObjectLiteralExpression(init) || init.properties.length) {
41537                 return undefined;
41538             }
41539             var exports = ts.createSymbolTable();
41540             while (ts.isBinaryExpression(decl) || ts.isPropertyAccessExpression(decl)) {
41541                 var s_2 = getSymbolOfNode(decl);
41542                 if ((_a = s_2 === null || s_2 === void 0 ? void 0 : s_2.exports) === null || _a === void 0 ? void 0 : _a.size) {
41543                     mergeSymbolTable(exports, s_2.exports);
41544                 }
41545                 decl = ts.isBinaryExpression(decl) ? decl.parent : decl.parent.parent;
41546             }
41547             var s = getSymbolOfNode(decl);
41548             if ((_b = s === null || s === void 0 ? void 0 : s.exports) === null || _b === void 0 ? void 0 : _b.size) {
41549                 mergeSymbolTable(exports, s.exports);
41550             }
41551             var type = createAnonymousType(symbol, exports, ts.emptyArray, ts.emptyArray, undefined, undefined);
41552             type.objectFlags |= 16384;
41553             return type;
41554         }
41555         function getAnnotatedTypeForAssignmentDeclaration(declaredType, expression, symbol, declaration) {
41556             var typeNode = ts.getEffectiveTypeAnnotationNode(expression.parent);
41557             if (typeNode) {
41558                 var type = getWidenedType(getTypeFromTypeNode(typeNode));
41559                 if (!declaredType) {
41560                     return type;
41561                 }
41562                 else if (declaredType !== errorType && type !== errorType && !isTypeIdenticalTo(declaredType, type)) {
41563                     errorNextVariableOrPropertyDeclarationMustHaveSameType(undefined, declaredType, declaration, type);
41564                 }
41565             }
41566             if (symbol.parent) {
41567                 var typeNode_2 = ts.getEffectiveTypeAnnotationNode(symbol.parent.valueDeclaration);
41568                 if (typeNode_2) {
41569                     return getTypeOfPropertyOfType(getTypeFromTypeNode(typeNode_2), symbol.escapedName);
41570                 }
41571             }
41572             return declaredType;
41573         }
41574         function getInitializerTypeFromAssignmentDeclaration(symbol, resolvedSymbol, expression, kind) {
41575             if (ts.isCallExpression(expression)) {
41576                 if (resolvedSymbol) {
41577                     return getTypeOfSymbol(resolvedSymbol);
41578                 }
41579                 var objectLitType = checkExpressionCached(expression.arguments[2]);
41580                 var valueType = getTypeOfPropertyOfType(objectLitType, "value");
41581                 if (valueType) {
41582                     return valueType;
41583                 }
41584                 var getFunc = getTypeOfPropertyOfType(objectLitType, "get");
41585                 if (getFunc) {
41586                     var getSig = getSingleCallSignature(getFunc);
41587                     if (getSig) {
41588                         return getReturnTypeOfSignature(getSig);
41589                     }
41590                 }
41591                 var setFunc = getTypeOfPropertyOfType(objectLitType, "set");
41592                 if (setFunc) {
41593                     var setSig = getSingleCallSignature(setFunc);
41594                     if (setSig) {
41595                         return getTypeOfFirstParameterOfSignature(setSig);
41596                     }
41597                 }
41598                 return anyType;
41599             }
41600             if (containsSameNamedThisProperty(expression.left, expression.right)) {
41601                 return anyType;
41602             }
41603             var type = resolvedSymbol ? getTypeOfSymbol(resolvedSymbol) : getWidenedLiteralType(checkExpressionCached(expression.right));
41604             if (type.flags & 524288 &&
41605                 kind === 2 &&
41606                 symbol.escapedName === "export=") {
41607                 var exportedType = resolveStructuredTypeMembers(type);
41608                 var members_4 = ts.createSymbolTable();
41609                 ts.copyEntries(exportedType.members, members_4);
41610                 var initialSize = members_4.size;
41611                 if (resolvedSymbol && !resolvedSymbol.exports) {
41612                     resolvedSymbol.exports = ts.createSymbolTable();
41613                 }
41614                 (resolvedSymbol || symbol).exports.forEach(function (s, name) {
41615                     var _a;
41616                     var exportedMember = members_4.get(name);
41617                     if (exportedMember && exportedMember !== s) {
41618                         if (s.flags & 111551 && exportedMember.flags & 111551) {
41619                             if (ts.getSourceFileOfNode(s.valueDeclaration) !== ts.getSourceFileOfNode(exportedMember.valueDeclaration)) {
41620                                 var unescapedName = ts.unescapeLeadingUnderscores(s.escapedName);
41621                                 var exportedMemberName = ((_a = ts.tryCast(exportedMember.valueDeclaration, ts.isNamedDeclaration)) === null || _a === void 0 ? void 0 : _a.name) || exportedMember.valueDeclaration;
41622                                 ts.addRelatedInfo(error(s.valueDeclaration, ts.Diagnostics.Duplicate_identifier_0, unescapedName), ts.createDiagnosticForNode(exportedMemberName, ts.Diagnostics._0_was_also_declared_here, unescapedName));
41623                                 ts.addRelatedInfo(error(exportedMemberName, ts.Diagnostics.Duplicate_identifier_0, unescapedName), ts.createDiagnosticForNode(s.valueDeclaration, ts.Diagnostics._0_was_also_declared_here, unescapedName));
41624                             }
41625                             var union = createSymbol(s.flags | exportedMember.flags, name);
41626                             union.type = getUnionType([getTypeOfSymbol(s), getTypeOfSymbol(exportedMember)]);
41627                             union.valueDeclaration = exportedMember.valueDeclaration;
41628                             union.declarations = ts.concatenate(exportedMember.declarations, s.declarations);
41629                             members_4.set(name, union);
41630                         }
41631                         else {
41632                             members_4.set(name, mergeSymbol(s, exportedMember));
41633                         }
41634                     }
41635                     else {
41636                         members_4.set(name, s);
41637                     }
41638                 });
41639                 var result = createAnonymousType(initialSize !== members_4.size ? undefined : exportedType.symbol, members_4, exportedType.callSignatures, exportedType.constructSignatures, exportedType.stringIndexInfo, exportedType.numberIndexInfo);
41640                 result.objectFlags |= (ts.getObjectFlags(type) & 16384);
41641                 if (result.symbol && result.symbol.flags & 32 && type === getDeclaredTypeOfClassOrInterface(result.symbol)) {
41642                     result.objectFlags |= 1073741824;
41643                 }
41644                 return result;
41645             }
41646             if (isEmptyArrayLiteralType(type)) {
41647                 reportImplicitAny(expression, anyArrayType);
41648                 return anyArrayType;
41649             }
41650             return type;
41651         }
41652         function containsSameNamedThisProperty(thisProperty, expression) {
41653             return ts.isPropertyAccessExpression(thisProperty)
41654                 && thisProperty.expression.kind === 107
41655                 && ts.forEachChildRecursively(expression, function (n) { return isMatchingReference(thisProperty, n); });
41656         }
41657         function isDeclarationInConstructor(expression) {
41658             var thisContainer = ts.getThisContainer(expression, false);
41659             return thisContainer.kind === 166 ||
41660                 thisContainer.kind === 251 ||
41661                 (thisContainer.kind === 208 && !ts.isPrototypePropertyAssignment(thisContainer.parent));
41662         }
41663         function getConstructorDefinedThisAssignmentTypes(types, declarations) {
41664             ts.Debug.assert(types.length === declarations.length);
41665             return types.filter(function (_, i) {
41666                 var declaration = declarations[i];
41667                 var expression = ts.isBinaryExpression(declaration) ? declaration :
41668                     ts.isBinaryExpression(declaration.parent) ? declaration.parent : undefined;
41669                 return expression && isDeclarationInConstructor(expression);
41670             });
41671         }
41672         function getTypeFromBindingElement(element, includePatternInType, reportErrors) {
41673             if (element.initializer) {
41674                 var contextualType = ts.isBindingPattern(element.name) ? getTypeFromBindingPattern(element.name, true, false) : unknownType;
41675                 return addOptionality(widenTypeInferredFromInitializer(element, checkDeclarationInitializer(element, contextualType)));
41676             }
41677             if (ts.isBindingPattern(element.name)) {
41678                 return getTypeFromBindingPattern(element.name, includePatternInType, reportErrors);
41679             }
41680             if (reportErrors && !declarationBelongsToPrivateAmbientMember(element)) {
41681                 reportImplicitAny(element, anyType);
41682             }
41683             return includePatternInType ? nonInferrableAnyType : anyType;
41684         }
41685         function getTypeFromObjectBindingPattern(pattern, includePatternInType, reportErrors) {
41686             var members = ts.createSymbolTable();
41687             var stringIndexInfo;
41688             var objectFlags = 128 | 1048576;
41689             ts.forEach(pattern.elements, function (e) {
41690                 var name = e.propertyName || e.name;
41691                 if (e.dotDotDotToken) {
41692                     stringIndexInfo = createIndexInfo(anyType, false);
41693                     return;
41694                 }
41695                 var exprType = getLiteralTypeFromPropertyName(name);
41696                 if (!isTypeUsableAsPropertyName(exprType)) {
41697                     objectFlags |= 512;
41698                     return;
41699                 }
41700                 var text = getPropertyNameFromType(exprType);
41701                 var flags = 4 | (e.initializer ? 16777216 : 0);
41702                 var symbol = createSymbol(flags, text);
41703                 symbol.type = getTypeFromBindingElement(e, includePatternInType, reportErrors);
41704                 symbol.bindingElement = e;
41705                 members.set(symbol.escapedName, symbol);
41706             });
41707             var result = createAnonymousType(undefined, members, ts.emptyArray, ts.emptyArray, stringIndexInfo, undefined);
41708             result.objectFlags |= objectFlags;
41709             if (includePatternInType) {
41710                 result.pattern = pattern;
41711                 result.objectFlags |= 1048576;
41712             }
41713             return result;
41714         }
41715         function getTypeFromArrayBindingPattern(pattern, includePatternInType, reportErrors) {
41716             var elements = pattern.elements;
41717             var lastElement = ts.lastOrUndefined(elements);
41718             var restElement = lastElement && lastElement.kind === 198 && lastElement.dotDotDotToken ? lastElement : undefined;
41719             if (elements.length === 0 || elements.length === 1 && restElement) {
41720                 return languageVersion >= 2 ? createIterableType(anyType) : anyArrayType;
41721             }
41722             var elementTypes = ts.map(elements, function (e) { return ts.isOmittedExpression(e) ? anyType : getTypeFromBindingElement(e, includePatternInType, reportErrors); });
41723             var minLength = ts.findLastIndex(elements, function (e) { return !(e === restElement || ts.isOmittedExpression(e) || hasDefaultValue(e)); }, elements.length - 1) + 1;
41724             var elementFlags = ts.map(elements, function (e, i) { return e === restElement ? 4 : i >= minLength ? 2 : 1; });
41725             var result = createTupleType(elementTypes, elementFlags);
41726             if (includePatternInType) {
41727                 result = cloneTypeReference(result);
41728                 result.pattern = pattern;
41729                 result.objectFlags |= 1048576;
41730             }
41731             return result;
41732         }
41733         function getTypeFromBindingPattern(pattern, includePatternInType, reportErrors) {
41734             if (includePatternInType === void 0) { includePatternInType = false; }
41735             if (reportErrors === void 0) { reportErrors = false; }
41736             return pattern.kind === 196
41737                 ? getTypeFromObjectBindingPattern(pattern, includePatternInType, reportErrors)
41738                 : getTypeFromArrayBindingPattern(pattern, includePatternInType, reportErrors);
41739         }
41740         function getWidenedTypeForVariableLikeDeclaration(declaration, reportErrors) {
41741             return widenTypeForVariableLikeDeclaration(getTypeForVariableLikeDeclaration(declaration, true), declaration, reportErrors);
41742         }
41743         function widenTypeForVariableLikeDeclaration(type, declaration, reportErrors) {
41744             if (type) {
41745                 if (reportErrors) {
41746                     reportErrorsFromWidening(declaration, type);
41747                 }
41748                 if (type.flags & 8192 && (ts.isBindingElement(declaration) || !declaration.type) && type.symbol !== getSymbolOfNode(declaration)) {
41749                     type = esSymbolType;
41750                 }
41751                 return getWidenedType(type);
41752             }
41753             type = ts.isParameter(declaration) && declaration.dotDotDotToken ? anyArrayType : anyType;
41754             if (reportErrors) {
41755                 if (!declarationBelongsToPrivateAmbientMember(declaration)) {
41756                     reportImplicitAny(declaration, type);
41757                 }
41758             }
41759             return type;
41760         }
41761         function declarationBelongsToPrivateAmbientMember(declaration) {
41762             var root = ts.getRootDeclaration(declaration);
41763             var memberDeclaration = root.kind === 160 ? root.parent : root;
41764             return isPrivateWithinAmbient(memberDeclaration);
41765         }
41766         function tryGetTypeFromEffectiveTypeNode(declaration) {
41767             var typeNode = ts.getEffectiveTypeAnnotationNode(declaration);
41768             if (typeNode) {
41769                 return getTypeFromTypeNode(typeNode);
41770             }
41771         }
41772         function getTypeOfVariableOrParameterOrProperty(symbol) {
41773             var links = getSymbolLinks(symbol);
41774             if (!links.type) {
41775                 var type = getTypeOfVariableOrParameterOrPropertyWorker(symbol);
41776                 if (!links.type) {
41777                     links.type = type;
41778                 }
41779             }
41780             return links.type;
41781         }
41782         function getTypeOfVariableOrParameterOrPropertyWorker(symbol) {
41783             if (symbol.flags & 4194304) {
41784                 return getTypeOfPrototypeProperty(symbol);
41785             }
41786             if (symbol === requireSymbol) {
41787                 return anyType;
41788             }
41789             if (symbol.flags & 134217728) {
41790                 var fileSymbol = getSymbolOfNode(ts.getSourceFileOfNode(symbol.valueDeclaration));
41791                 var members = ts.createSymbolTable();
41792                 members.set("exports", fileSymbol);
41793                 return createAnonymousType(symbol, members, ts.emptyArray, ts.emptyArray, undefined, undefined);
41794             }
41795             var declaration = symbol.valueDeclaration;
41796             if (ts.isCatchClauseVariableDeclarationOrBindingElement(declaration)) {
41797                 var decl = declaration;
41798                 if (!decl.type)
41799                     return anyType;
41800                 var type_1 = getTypeOfNode(decl.type);
41801                 return isTypeAny(type_1) || type_1 === unknownType ? type_1 : errorType;
41802             }
41803             if (ts.isSourceFile(declaration) && ts.isJsonSourceFile(declaration)) {
41804                 if (!declaration.statements.length) {
41805                     return emptyObjectType;
41806                 }
41807                 return getWidenedType(getWidenedLiteralType(checkExpression(declaration.statements[0].expression)));
41808             }
41809             if (!pushTypeResolution(symbol, 0)) {
41810                 if (symbol.flags & 512 && !(symbol.flags & 67108864)) {
41811                     return getTypeOfFuncClassEnumModule(symbol);
41812                 }
41813                 return reportCircularityError(symbol);
41814             }
41815             var type;
41816             if (declaration.kind === 266) {
41817                 type = widenTypeForVariableLikeDeclaration(checkExpressionCached(declaration.expression), declaration);
41818             }
41819             else if (ts.isBinaryExpression(declaration) ||
41820                 (ts.isInJSFile(declaration) &&
41821                     (ts.isCallExpression(declaration) || (ts.isPropertyAccessExpression(declaration) || ts.isBindableStaticElementAccessExpression(declaration)) && ts.isBinaryExpression(declaration.parent)))) {
41822                 type = getWidenedTypeForAssignmentDeclaration(symbol);
41823             }
41824             else if (ts.isPropertyAccessExpression(declaration)
41825                 || ts.isElementAccessExpression(declaration)
41826                 || ts.isIdentifier(declaration)
41827                 || ts.isStringLiteralLike(declaration)
41828                 || ts.isNumericLiteral(declaration)
41829                 || ts.isClassDeclaration(declaration)
41830                 || ts.isFunctionDeclaration(declaration)
41831                 || (ts.isMethodDeclaration(declaration) && !ts.isObjectLiteralMethod(declaration))
41832                 || ts.isMethodSignature(declaration)
41833                 || ts.isSourceFile(declaration)) {
41834                 if (symbol.flags & (16 | 8192 | 32 | 384 | 512)) {
41835                     return getTypeOfFuncClassEnumModule(symbol);
41836                 }
41837                 type = ts.isBinaryExpression(declaration.parent) ?
41838                     getWidenedTypeForAssignmentDeclaration(symbol) :
41839                     tryGetTypeFromEffectiveTypeNode(declaration) || anyType;
41840             }
41841             else if (ts.isPropertyAssignment(declaration)) {
41842                 type = tryGetTypeFromEffectiveTypeNode(declaration) || checkPropertyAssignment(declaration);
41843             }
41844             else if (ts.isJsxAttribute(declaration)) {
41845                 type = tryGetTypeFromEffectiveTypeNode(declaration) || checkJsxAttribute(declaration);
41846             }
41847             else if (ts.isShorthandPropertyAssignment(declaration)) {
41848                 type = tryGetTypeFromEffectiveTypeNode(declaration) || checkExpressionForMutableLocation(declaration.name, 0);
41849             }
41850             else if (ts.isObjectLiteralMethod(declaration)) {
41851                 type = tryGetTypeFromEffectiveTypeNode(declaration) || checkObjectLiteralMethod(declaration, 0);
41852             }
41853             else if (ts.isParameter(declaration)
41854                 || ts.isPropertyDeclaration(declaration)
41855                 || ts.isPropertySignature(declaration)
41856                 || ts.isVariableDeclaration(declaration)
41857                 || ts.isBindingElement(declaration)
41858                 || ts.isJSDocPropertyLikeTag(declaration)) {
41859                 type = getWidenedTypeForVariableLikeDeclaration(declaration, true);
41860             }
41861             else if (ts.isEnumDeclaration(declaration)) {
41862                 type = getTypeOfFuncClassEnumModule(symbol);
41863             }
41864             else if (ts.isEnumMember(declaration)) {
41865                 type = getTypeOfEnumMember(symbol);
41866             }
41867             else if (ts.isAccessor(declaration)) {
41868                 type = resolveTypeOfAccessors(symbol);
41869             }
41870             else {
41871                 return ts.Debug.fail("Unhandled declaration kind! " + ts.Debug.formatSyntaxKind(declaration.kind) + " for " + ts.Debug.formatSymbol(symbol));
41872             }
41873             if (!popTypeResolution()) {
41874                 if (symbol.flags & 512 && !(symbol.flags & 67108864)) {
41875                     return getTypeOfFuncClassEnumModule(symbol);
41876                 }
41877                 return reportCircularityError(symbol);
41878             }
41879             return type;
41880         }
41881         function getAnnotatedAccessorTypeNode(accessor) {
41882             if (accessor) {
41883                 if (accessor.kind === 167) {
41884                     var getterTypeAnnotation = ts.getEffectiveReturnTypeNode(accessor);
41885                     return getterTypeAnnotation;
41886                 }
41887                 else {
41888                     var setterTypeAnnotation = ts.getEffectiveSetAccessorTypeAnnotationNode(accessor);
41889                     return setterTypeAnnotation;
41890                 }
41891             }
41892             return undefined;
41893         }
41894         function getAnnotatedAccessorType(accessor) {
41895             var node = getAnnotatedAccessorTypeNode(accessor);
41896             return node && getTypeFromTypeNode(node);
41897         }
41898         function getAnnotatedAccessorThisParameter(accessor) {
41899             var parameter = getAccessorThisParameter(accessor);
41900             return parameter && parameter.symbol;
41901         }
41902         function getThisTypeOfDeclaration(declaration) {
41903             return getThisTypeOfSignature(getSignatureFromDeclaration(declaration));
41904         }
41905         function getTypeOfAccessors(symbol) {
41906             var links = getSymbolLinks(symbol);
41907             return links.type || (links.type = getTypeOfAccessorsWorker(symbol));
41908         }
41909         function getTypeOfAccessorsWorker(symbol) {
41910             if (!pushTypeResolution(symbol, 0)) {
41911                 return errorType;
41912             }
41913             var type = resolveTypeOfAccessors(symbol);
41914             if (!popTypeResolution()) {
41915                 type = anyType;
41916                 if (noImplicitAny) {
41917                     var getter = ts.getDeclarationOfKind(symbol, 167);
41918                     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));
41919                 }
41920             }
41921             return type;
41922         }
41923         function resolveTypeOfAccessors(symbol) {
41924             var getter = ts.getDeclarationOfKind(symbol, 167);
41925             var setter = ts.getDeclarationOfKind(symbol, 168);
41926             if (getter && ts.isInJSFile(getter)) {
41927                 var jsDocType = getTypeForDeclarationFromJSDocComment(getter);
41928                 if (jsDocType) {
41929                     return jsDocType;
41930                 }
41931             }
41932             var getterReturnType = getAnnotatedAccessorType(getter);
41933             if (getterReturnType) {
41934                 return getterReturnType;
41935             }
41936             else {
41937                 var setterParameterType = getAnnotatedAccessorType(setter);
41938                 if (setterParameterType) {
41939                     return setterParameterType;
41940                 }
41941                 else {
41942                     if (getter && getter.body) {
41943                         return getReturnTypeFromBody(getter);
41944                     }
41945                     else {
41946                         if (setter) {
41947                             if (!isPrivateWithinAmbient(setter)) {
41948                                 errorOrSuggestion(noImplicitAny, setter, ts.Diagnostics.Property_0_implicitly_has_type_any_because_its_set_accessor_lacks_a_parameter_type_annotation, symbolToString(symbol));
41949                             }
41950                         }
41951                         else {
41952                             ts.Debug.assert(!!getter, "there must exist a getter as we are current checking either setter or getter in this function");
41953                             if (!isPrivateWithinAmbient(getter)) {
41954                                 errorOrSuggestion(noImplicitAny, getter, ts.Diagnostics.Property_0_implicitly_has_type_any_because_its_get_accessor_lacks_a_return_type_annotation, symbolToString(symbol));
41955                             }
41956                         }
41957                         return anyType;
41958                     }
41959                 }
41960             }
41961         }
41962         function getBaseTypeVariableOfClass(symbol) {
41963             var baseConstructorType = getBaseConstructorTypeOfClass(getDeclaredTypeOfClassOrInterface(symbol));
41964             return baseConstructorType.flags & 8650752 ? baseConstructorType :
41965                 baseConstructorType.flags & 2097152 ? ts.find(baseConstructorType.types, function (t) { return !!(t.flags & 8650752); }) :
41966                     undefined;
41967         }
41968         function getTypeOfFuncClassEnumModule(symbol) {
41969             var links = getSymbolLinks(symbol);
41970             var originalLinks = links;
41971             if (!links.type) {
41972                 var expando = symbol.valueDeclaration && getSymbolOfExpando(symbol.valueDeclaration, false);
41973                 if (expando) {
41974                     var merged = mergeJSSymbols(symbol, expando);
41975                     if (merged) {
41976                         symbol = links = merged;
41977                     }
41978                 }
41979                 originalLinks.type = links.type = getTypeOfFuncClassEnumModuleWorker(symbol);
41980             }
41981             return links.type;
41982         }
41983         function getTypeOfFuncClassEnumModuleWorker(symbol) {
41984             var declaration = symbol.valueDeclaration;
41985             if (symbol.flags & 1536 && ts.isShorthandAmbientModuleSymbol(symbol)) {
41986                 return anyType;
41987             }
41988             else if (declaration && (declaration.kind === 216 ||
41989                 ts.isAccessExpression(declaration) &&
41990                     declaration.parent.kind === 216)) {
41991                 return getWidenedTypeForAssignmentDeclaration(symbol);
41992             }
41993             else if (symbol.flags & 512 && declaration && ts.isSourceFile(declaration) && declaration.commonJsModuleIndicator) {
41994                 var resolvedModule = resolveExternalModuleSymbol(symbol);
41995                 if (resolvedModule !== symbol) {
41996                     if (!pushTypeResolution(symbol, 0)) {
41997                         return errorType;
41998                     }
41999                     var exportEquals = getMergedSymbol(symbol.exports.get("export="));
42000                     var type_2 = getWidenedTypeForAssignmentDeclaration(exportEquals, exportEquals === resolvedModule ? undefined : resolvedModule);
42001                     if (!popTypeResolution()) {
42002                         return reportCircularityError(symbol);
42003                     }
42004                     return type_2;
42005                 }
42006             }
42007             var type = createObjectType(16, symbol);
42008             if (symbol.flags & 32) {
42009                 var baseTypeVariable = getBaseTypeVariableOfClass(symbol);
42010                 return baseTypeVariable ? getIntersectionType([type, baseTypeVariable]) : type;
42011             }
42012             else {
42013                 return strictNullChecks && symbol.flags & 16777216 ? getOptionalType(type) : type;
42014             }
42015         }
42016         function getTypeOfEnumMember(symbol) {
42017             var links = getSymbolLinks(symbol);
42018             return links.type || (links.type = getDeclaredTypeOfEnumMember(symbol));
42019         }
42020         function getTypeOfAlias(symbol) {
42021             var links = getSymbolLinks(symbol);
42022             if (!links.type) {
42023                 var targetSymbol = resolveAlias(symbol);
42024                 links.type = targetSymbol.flags & 111551
42025                     ? getTypeOfSymbol(targetSymbol)
42026                     : errorType;
42027             }
42028             return links.type;
42029         }
42030         function getTypeOfInstantiatedSymbol(symbol) {
42031             var links = getSymbolLinks(symbol);
42032             if (!links.type) {
42033                 if (!pushTypeResolution(symbol, 0)) {
42034                     return links.type = errorType;
42035                 }
42036                 var type = instantiateType(getTypeOfSymbol(links.target), links.mapper);
42037                 if (!popTypeResolution()) {
42038                     type = reportCircularityError(symbol);
42039                 }
42040                 links.type = type;
42041             }
42042             return links.type;
42043         }
42044         function reportCircularityError(symbol) {
42045             var declaration = symbol.valueDeclaration;
42046             if (ts.getEffectiveTypeAnnotationNode(declaration)) {
42047                 error(symbol.valueDeclaration, ts.Diagnostics._0_is_referenced_directly_or_indirectly_in_its_own_type_annotation, symbolToString(symbol));
42048                 return errorType;
42049             }
42050             if (noImplicitAny && (declaration.kind !== 160 || declaration.initializer)) {
42051                 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));
42052             }
42053             return anyType;
42054         }
42055         function getTypeOfSymbolWithDeferredType(symbol) {
42056             var links = getSymbolLinks(symbol);
42057             if (!links.type) {
42058                 ts.Debug.assertIsDefined(links.deferralParent);
42059                 ts.Debug.assertIsDefined(links.deferralConstituents);
42060                 links.type = links.deferralParent.flags & 1048576 ? getUnionType(links.deferralConstituents) : getIntersectionType(links.deferralConstituents);
42061             }
42062             return links.type;
42063         }
42064         function getTypeOfSymbol(symbol) {
42065             var checkFlags = ts.getCheckFlags(symbol);
42066             if (checkFlags & 65536) {
42067                 return getTypeOfSymbolWithDeferredType(symbol);
42068             }
42069             if (checkFlags & 1) {
42070                 return getTypeOfInstantiatedSymbol(symbol);
42071             }
42072             if (checkFlags & 262144) {
42073                 return getTypeOfMappedSymbol(symbol);
42074             }
42075             if (checkFlags & 8192) {
42076                 return getTypeOfReverseMappedSymbol(symbol);
42077             }
42078             if (symbol.flags & (3 | 4)) {
42079                 return getTypeOfVariableOrParameterOrProperty(symbol);
42080             }
42081             if (symbol.flags & (16 | 8192 | 32 | 384 | 512)) {
42082                 return getTypeOfFuncClassEnumModule(symbol);
42083             }
42084             if (symbol.flags & 8) {
42085                 return getTypeOfEnumMember(symbol);
42086             }
42087             if (symbol.flags & 98304) {
42088                 return getTypeOfAccessors(symbol);
42089             }
42090             if (symbol.flags & 2097152) {
42091                 return getTypeOfAlias(symbol);
42092             }
42093             return errorType;
42094         }
42095         function isReferenceToType(type, target) {
42096             return type !== undefined
42097                 && target !== undefined
42098                 && (ts.getObjectFlags(type) & 4) !== 0
42099                 && type.target === target;
42100         }
42101         function getTargetType(type) {
42102             return ts.getObjectFlags(type) & 4 ? type.target : type;
42103         }
42104         function hasBaseType(type, checkBase) {
42105             return check(type);
42106             function check(type) {
42107                 if (ts.getObjectFlags(type) & (3 | 4)) {
42108                     var target = getTargetType(type);
42109                     return target === checkBase || ts.some(getBaseTypes(target), check);
42110                 }
42111                 else if (type.flags & 2097152) {
42112                     return ts.some(type.types, check);
42113                 }
42114                 return false;
42115             }
42116         }
42117         function appendTypeParameters(typeParameters, declarations) {
42118             for (var _i = 0, declarations_2 = declarations; _i < declarations_2.length; _i++) {
42119                 var declaration = declarations_2[_i];
42120                 typeParameters = ts.appendIfUnique(typeParameters, getDeclaredTypeOfTypeParameter(getSymbolOfNode(declaration)));
42121             }
42122             return typeParameters;
42123         }
42124         function getOuterTypeParameters(node, includeThisTypes) {
42125             while (true) {
42126                 node = node.parent;
42127                 if (node && ts.isBinaryExpression(node)) {
42128                     var assignmentKind = ts.getAssignmentDeclarationKind(node);
42129                     if (assignmentKind === 6 || assignmentKind === 3) {
42130                         var symbol = getSymbolOfNode(node.left);
42131                         if (symbol && symbol.parent && !ts.findAncestor(symbol.parent.valueDeclaration, function (d) { return node === d; })) {
42132                             node = symbol.parent.valueDeclaration;
42133                         }
42134                     }
42135                 }
42136                 if (!node) {
42137                     return undefined;
42138                 }
42139                 switch (node.kind) {
42140                     case 232:
42141                     case 252:
42142                     case 221:
42143                     case 253:
42144                     case 169:
42145                     case 170:
42146                     case 164:
42147                     case 174:
42148                     case 175:
42149                     case 308:
42150                     case 251:
42151                     case 165:
42152                     case 208:
42153                     case 209:
42154                     case 254:
42155                     case 330:
42156                     case 331:
42157                     case 325:
42158                     case 324:
42159                     case 190:
42160                     case 184:
42161                         var outerTypeParameters = getOuterTypeParameters(node, includeThisTypes);
42162                         if (node.kind === 190) {
42163                             return ts.append(outerTypeParameters, getDeclaredTypeOfTypeParameter(getSymbolOfNode(node.typeParameter)));
42164                         }
42165                         else if (node.kind === 184) {
42166                             return ts.concatenate(outerTypeParameters, getInferTypeParameters(node));
42167                         }
42168                         else if (node.kind === 232 && !ts.isInJSFile(node)) {
42169                             break;
42170                         }
42171                         var outerAndOwnTypeParameters = appendTypeParameters(outerTypeParameters, ts.getEffectiveTypeParameterDeclarations(node));
42172                         var thisType = includeThisTypes &&
42173                             (node.kind === 252 || node.kind === 221 || node.kind === 253 || isJSConstructor(node)) &&
42174                             getDeclaredTypeOfClassOrInterface(getSymbolOfNode(node)).thisType;
42175                         return thisType ? ts.append(outerAndOwnTypeParameters, thisType) : outerAndOwnTypeParameters;
42176                     case 326:
42177                         var paramSymbol = ts.getParameterSymbolFromJSDoc(node);
42178                         if (paramSymbol) {
42179                             node = paramSymbol.valueDeclaration;
42180                         }
42181                         break;
42182                 }
42183             }
42184         }
42185         function getOuterTypeParametersOfClassOrInterface(symbol) {
42186             var declaration = symbol.flags & 32 ? symbol.valueDeclaration : ts.getDeclarationOfKind(symbol, 253);
42187             ts.Debug.assert(!!declaration, "Class was missing valueDeclaration -OR- non-class had no interface declarations");
42188             return getOuterTypeParameters(declaration);
42189         }
42190         function getLocalTypeParametersOfClassOrInterfaceOrTypeAlias(symbol) {
42191             var result;
42192             for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) {
42193                 var node = _a[_i];
42194                 if (node.kind === 253 ||
42195                     node.kind === 252 ||
42196                     node.kind === 221 ||
42197                     isJSConstructor(node) ||
42198                     ts.isTypeAlias(node)) {
42199                     var declaration = node;
42200                     result = appendTypeParameters(result, ts.getEffectiveTypeParameterDeclarations(declaration));
42201                 }
42202             }
42203             return result;
42204         }
42205         function getTypeParametersOfClassOrInterface(symbol) {
42206             return ts.concatenate(getOuterTypeParametersOfClassOrInterface(symbol), getLocalTypeParametersOfClassOrInterfaceOrTypeAlias(symbol));
42207         }
42208         function isMixinConstructorType(type) {
42209             var signatures = getSignaturesOfType(type, 1);
42210             if (signatures.length === 1) {
42211                 var s = signatures[0];
42212                 return !s.typeParameters && s.parameters.length === 1 && signatureHasRestParameter(s) && getElementTypeOfArrayType(getTypeOfParameter(s.parameters[0])) === anyType;
42213             }
42214             return false;
42215         }
42216         function isConstructorType(type) {
42217             if (getSignaturesOfType(type, 1).length > 0) {
42218                 return true;
42219             }
42220             if (type.flags & 8650752) {
42221                 var constraint = getBaseConstraintOfType(type);
42222                 return !!constraint && isMixinConstructorType(constraint);
42223             }
42224             return false;
42225         }
42226         function getBaseTypeNodeOfClass(type) {
42227             return ts.getEffectiveBaseTypeNode(type.symbol.valueDeclaration);
42228         }
42229         function getConstructorsForTypeArguments(type, typeArgumentNodes, location) {
42230             var typeArgCount = ts.length(typeArgumentNodes);
42231             var isJavascript = ts.isInJSFile(location);
42232             return ts.filter(getSignaturesOfType(type, 1), function (sig) { return (isJavascript || typeArgCount >= getMinTypeArgumentCount(sig.typeParameters)) && typeArgCount <= ts.length(sig.typeParameters); });
42233         }
42234         function getInstantiatedConstructorsForTypeArguments(type, typeArgumentNodes, location) {
42235             var signatures = getConstructorsForTypeArguments(type, typeArgumentNodes, location);
42236             var typeArguments = ts.map(typeArgumentNodes, getTypeFromTypeNode);
42237             return ts.sameMap(signatures, function (sig) { return ts.some(sig.typeParameters) ? getSignatureInstantiation(sig, typeArguments, ts.isInJSFile(location)) : sig; });
42238         }
42239         function getBaseConstructorTypeOfClass(type) {
42240             if (!type.resolvedBaseConstructorType) {
42241                 var decl = type.symbol.valueDeclaration;
42242                 var extended = ts.getEffectiveBaseTypeNode(decl);
42243                 var baseTypeNode = getBaseTypeNodeOfClass(type);
42244                 if (!baseTypeNode) {
42245                     return type.resolvedBaseConstructorType = undefinedType;
42246                 }
42247                 if (!pushTypeResolution(type, 1)) {
42248                     return errorType;
42249                 }
42250                 var baseConstructorType = checkExpression(baseTypeNode.expression);
42251                 if (extended && baseTypeNode !== extended) {
42252                     ts.Debug.assert(!extended.typeArguments);
42253                     checkExpression(extended.expression);
42254                 }
42255                 if (baseConstructorType.flags & (524288 | 2097152)) {
42256                     resolveStructuredTypeMembers(baseConstructorType);
42257                 }
42258                 if (!popTypeResolution()) {
42259                     error(type.symbol.valueDeclaration, ts.Diagnostics._0_is_referenced_directly_or_indirectly_in_its_own_base_expression, symbolToString(type.symbol));
42260                     return type.resolvedBaseConstructorType = errorType;
42261                 }
42262                 if (!(baseConstructorType.flags & 1) && baseConstructorType !== nullWideningType && !isConstructorType(baseConstructorType)) {
42263                     var err = error(baseTypeNode.expression, ts.Diagnostics.Type_0_is_not_a_constructor_function_type, typeToString(baseConstructorType));
42264                     if (baseConstructorType.flags & 262144) {
42265                         var constraint = getConstraintFromTypeParameter(baseConstructorType);
42266                         var ctorReturn = unknownType;
42267                         if (constraint) {
42268                             var ctorSig = getSignaturesOfType(constraint, 1);
42269                             if (ctorSig[0]) {
42270                                 ctorReturn = getReturnTypeOfSignature(ctorSig[0]);
42271                             }
42272                         }
42273                         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)));
42274                     }
42275                     return type.resolvedBaseConstructorType = errorType;
42276                 }
42277                 type.resolvedBaseConstructorType = baseConstructorType;
42278             }
42279             return type.resolvedBaseConstructorType;
42280         }
42281         function getImplementsTypes(type) {
42282             var resolvedImplementsTypes = ts.emptyArray;
42283             for (var _i = 0, _a = type.symbol.declarations; _i < _a.length; _i++) {
42284                 var declaration = _a[_i];
42285                 var implementsTypeNodes = ts.getEffectiveImplementsTypeNodes(declaration);
42286                 if (!implementsTypeNodes)
42287                     continue;
42288                 for (var _b = 0, implementsTypeNodes_1 = implementsTypeNodes; _b < implementsTypeNodes_1.length; _b++) {
42289                     var node = implementsTypeNodes_1[_b];
42290                     var implementsType = getTypeFromTypeNode(node);
42291                     if (implementsType !== errorType) {
42292                         if (resolvedImplementsTypes === ts.emptyArray) {
42293                             resolvedImplementsTypes = [implementsType];
42294                         }
42295                         else {
42296                             resolvedImplementsTypes.push(implementsType);
42297                         }
42298                     }
42299                 }
42300             }
42301             return resolvedImplementsTypes;
42302         }
42303         function reportCircularBaseType(node, type) {
42304             error(node, ts.Diagnostics.Type_0_recursively_references_itself_as_a_base_type, typeToString(type, undefined, 2));
42305         }
42306         function getBaseTypes(type) {
42307             if (!type.baseTypesResolved) {
42308                 if (pushTypeResolution(type, 7)) {
42309                     if (type.objectFlags & 8) {
42310                         type.resolvedBaseTypes = [getTupleBaseType(type)];
42311                     }
42312                     else if (type.symbol.flags & (32 | 64)) {
42313                         if (type.symbol.flags & 32) {
42314                             resolveBaseTypesOfClass(type);
42315                         }
42316                         if (type.symbol.flags & 64) {
42317                             resolveBaseTypesOfInterface(type);
42318                         }
42319                     }
42320                     else {
42321                         ts.Debug.fail("type must be class or interface");
42322                     }
42323                     if (!popTypeResolution()) {
42324                         for (var _i = 0, _a = type.symbol.declarations; _i < _a.length; _i++) {
42325                             var declaration = _a[_i];
42326                             if (declaration.kind === 252 || declaration.kind === 253) {
42327                                 reportCircularBaseType(declaration, type);
42328                             }
42329                         }
42330                     }
42331                 }
42332                 type.baseTypesResolved = true;
42333             }
42334             return type.resolvedBaseTypes;
42335         }
42336         function getTupleBaseType(type) {
42337             var elementTypes = ts.sameMap(type.typeParameters, function (t, i) { return type.elementFlags[i] & 8 ? getIndexedAccessType(t, numberType) : t; });
42338             return createArrayType(getUnionType(elementTypes || ts.emptyArray), type.readonly);
42339         }
42340         function resolveBaseTypesOfClass(type) {
42341             type.resolvedBaseTypes = ts.resolvingEmptyArray;
42342             var baseConstructorType = getApparentType(getBaseConstructorTypeOfClass(type));
42343             if (!(baseConstructorType.flags & (524288 | 2097152 | 1))) {
42344                 return type.resolvedBaseTypes = ts.emptyArray;
42345             }
42346             var baseTypeNode = getBaseTypeNodeOfClass(type);
42347             var baseType;
42348             var originalBaseType = baseConstructorType.symbol ? getDeclaredTypeOfSymbol(baseConstructorType.symbol) : undefined;
42349             if (baseConstructorType.symbol && baseConstructorType.symbol.flags & 32 &&
42350                 areAllOuterTypeParametersApplied(originalBaseType)) {
42351                 baseType = getTypeFromClassOrInterfaceReference(baseTypeNode, baseConstructorType.symbol);
42352             }
42353             else if (baseConstructorType.flags & 1) {
42354                 baseType = baseConstructorType;
42355             }
42356             else {
42357                 var constructors = getInstantiatedConstructorsForTypeArguments(baseConstructorType, baseTypeNode.typeArguments, baseTypeNode);
42358                 if (!constructors.length) {
42359                     error(baseTypeNode.expression, ts.Diagnostics.No_base_constructor_has_the_specified_number_of_type_arguments);
42360                     return type.resolvedBaseTypes = ts.emptyArray;
42361                 }
42362                 baseType = getReturnTypeOfSignature(constructors[0]);
42363             }
42364             if (baseType === errorType) {
42365                 return type.resolvedBaseTypes = ts.emptyArray;
42366             }
42367             var reducedBaseType = getReducedType(baseType);
42368             if (!isValidBaseType(reducedBaseType)) {
42369                 var elaboration = elaborateNeverIntersection(undefined, baseType);
42370                 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));
42371                 diagnostics.add(ts.createDiagnosticForNodeFromMessageChain(baseTypeNode.expression, diagnostic));
42372                 return type.resolvedBaseTypes = ts.emptyArray;
42373             }
42374             if (type === reducedBaseType || hasBaseType(reducedBaseType, type)) {
42375                 error(type.symbol.valueDeclaration, ts.Diagnostics.Type_0_recursively_references_itself_as_a_base_type, typeToString(type, undefined, 2));
42376                 return type.resolvedBaseTypes = ts.emptyArray;
42377             }
42378             if (type.resolvedBaseTypes === ts.resolvingEmptyArray) {
42379                 type.members = undefined;
42380             }
42381             return type.resolvedBaseTypes = [reducedBaseType];
42382         }
42383         function areAllOuterTypeParametersApplied(type) {
42384             var outerTypeParameters = type.outerTypeParameters;
42385             if (outerTypeParameters) {
42386                 var last_1 = outerTypeParameters.length - 1;
42387                 var typeArguments = getTypeArguments(type);
42388                 return outerTypeParameters[last_1].symbol !== typeArguments[last_1].symbol;
42389             }
42390             return true;
42391         }
42392         function isValidBaseType(type) {
42393             if (type.flags & 262144) {
42394                 var constraint = getBaseConstraintOfType(type);
42395                 if (constraint) {
42396                     return isValidBaseType(constraint);
42397                 }
42398             }
42399             return !!(type.flags & (524288 | 67108864 | 1) && !isGenericMappedType(type) ||
42400                 type.flags & 2097152 && ts.every(type.types, isValidBaseType));
42401         }
42402         function resolveBaseTypesOfInterface(type) {
42403             type.resolvedBaseTypes = type.resolvedBaseTypes || ts.emptyArray;
42404             for (var _i = 0, _a = type.symbol.declarations; _i < _a.length; _i++) {
42405                 var declaration = _a[_i];
42406                 if (declaration.kind === 253 && ts.getInterfaceBaseTypeNodes(declaration)) {
42407                     for (var _b = 0, _c = ts.getInterfaceBaseTypeNodes(declaration); _b < _c.length; _b++) {
42408                         var node = _c[_b];
42409                         var baseType = getReducedType(getTypeFromTypeNode(node));
42410                         if (baseType !== errorType) {
42411                             if (isValidBaseType(baseType)) {
42412                                 if (type !== baseType && !hasBaseType(baseType, type)) {
42413                                     if (type.resolvedBaseTypes === ts.emptyArray) {
42414                                         type.resolvedBaseTypes = [baseType];
42415                                     }
42416                                     else {
42417                                         type.resolvedBaseTypes.push(baseType);
42418                                     }
42419                                 }
42420                                 else {
42421                                     reportCircularBaseType(declaration, type);
42422                                 }
42423                             }
42424                             else {
42425                                 error(node, ts.Diagnostics.An_interface_can_only_extend_an_object_type_or_intersection_of_object_types_with_statically_known_members);
42426                             }
42427                         }
42428                     }
42429                 }
42430             }
42431         }
42432         function isThislessInterface(symbol) {
42433             for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) {
42434                 var declaration = _a[_i];
42435                 if (declaration.kind === 253) {
42436                     if (declaration.flags & 128) {
42437                         return false;
42438                     }
42439                     var baseTypeNodes = ts.getInterfaceBaseTypeNodes(declaration);
42440                     if (baseTypeNodes) {
42441                         for (var _b = 0, baseTypeNodes_1 = baseTypeNodes; _b < baseTypeNodes_1.length; _b++) {
42442                             var node = baseTypeNodes_1[_b];
42443                             if (ts.isEntityNameExpression(node.expression)) {
42444                                 var baseSymbol = resolveEntityName(node.expression, 788968, true);
42445                                 if (!baseSymbol || !(baseSymbol.flags & 64) || getDeclaredTypeOfClassOrInterface(baseSymbol).thisType) {
42446                                     return false;
42447                                 }
42448                             }
42449                         }
42450                     }
42451                 }
42452             }
42453             return true;
42454         }
42455         function getDeclaredTypeOfClassOrInterface(symbol) {
42456             var links = getSymbolLinks(symbol);
42457             var originalLinks = links;
42458             if (!links.declaredType) {
42459                 var kind = symbol.flags & 32 ? 1 : 2;
42460                 var merged = mergeJSSymbols(symbol, getAssignedClassSymbol(symbol.valueDeclaration));
42461                 if (merged) {
42462                     symbol = links = merged;
42463                 }
42464                 var type = originalLinks.declaredType = links.declaredType = createObjectType(kind, symbol);
42465                 var outerTypeParameters = getOuterTypeParametersOfClassOrInterface(symbol);
42466                 var localTypeParameters = getLocalTypeParametersOfClassOrInterfaceOrTypeAlias(symbol);
42467                 if (outerTypeParameters || localTypeParameters || kind === 1 || !isThislessInterface(symbol)) {
42468                     type.objectFlags |= 4;
42469                     type.typeParameters = ts.concatenate(outerTypeParameters, localTypeParameters);
42470                     type.outerTypeParameters = outerTypeParameters;
42471                     type.localTypeParameters = localTypeParameters;
42472                     type.instantiations = new ts.Map();
42473                     type.instantiations.set(getTypeListId(type.typeParameters), type);
42474                     type.target = type;
42475                     type.resolvedTypeArguments = type.typeParameters;
42476                     type.thisType = createTypeParameter(symbol);
42477                     type.thisType.isThisType = true;
42478                     type.thisType.constraint = type;
42479                 }
42480             }
42481             return links.declaredType;
42482         }
42483         function getDeclaredTypeOfTypeAlias(symbol) {
42484             var links = getSymbolLinks(symbol);
42485             if (!links.declaredType) {
42486                 if (!pushTypeResolution(symbol, 2)) {
42487                     return errorType;
42488                 }
42489                 var declaration = ts.Debug.checkDefined(ts.find(symbol.declarations, ts.isTypeAlias), "Type alias symbol with no valid declaration found");
42490                 var typeNode = ts.isJSDocTypeAlias(declaration) ? declaration.typeExpression : declaration.type;
42491                 var type = typeNode ? getTypeFromTypeNode(typeNode) : errorType;
42492                 if (popTypeResolution()) {
42493                     var typeParameters = getLocalTypeParametersOfClassOrInterfaceOrTypeAlias(symbol);
42494                     if (typeParameters) {
42495                         links.typeParameters = typeParameters;
42496                         links.instantiations = new ts.Map();
42497                         links.instantiations.set(getTypeListId(typeParameters), type);
42498                     }
42499                 }
42500                 else {
42501                     type = errorType;
42502                     error(ts.isNamedDeclaration(declaration) ? declaration.name : declaration || declaration, ts.Diagnostics.Type_alias_0_circularly_references_itself, symbolToString(symbol));
42503                 }
42504                 links.declaredType = type;
42505             }
42506             return links.declaredType;
42507         }
42508         function isStringConcatExpression(expr) {
42509             if (ts.isStringLiteralLike(expr)) {
42510                 return true;
42511             }
42512             else if (expr.kind === 216) {
42513                 return isStringConcatExpression(expr.left) && isStringConcatExpression(expr.right);
42514             }
42515             return false;
42516         }
42517         function isLiteralEnumMember(member) {
42518             var expr = member.initializer;
42519             if (!expr) {
42520                 return !(member.flags & 8388608);
42521             }
42522             switch (expr.kind) {
42523                 case 10:
42524                 case 8:
42525                 case 14:
42526                     return true;
42527                 case 214:
42528                     return expr.operator === 40 &&
42529                         expr.operand.kind === 8;
42530                 case 78:
42531                     return ts.nodeIsMissing(expr) || !!getSymbolOfNode(member.parent).exports.get(expr.escapedText);
42532                 case 216:
42533                     return isStringConcatExpression(expr);
42534                 default:
42535                     return false;
42536             }
42537         }
42538         function getEnumKind(symbol) {
42539             var links = getSymbolLinks(symbol);
42540             if (links.enumKind !== undefined) {
42541                 return links.enumKind;
42542             }
42543             var hasNonLiteralMember = false;
42544             for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) {
42545                 var declaration = _a[_i];
42546                 if (declaration.kind === 255) {
42547                     for (var _b = 0, _c = declaration.members; _b < _c.length; _b++) {
42548                         var member = _c[_b];
42549                         if (member.initializer && ts.isStringLiteralLike(member.initializer)) {
42550                             return links.enumKind = 1;
42551                         }
42552                         if (!isLiteralEnumMember(member)) {
42553                             hasNonLiteralMember = true;
42554                         }
42555                     }
42556                 }
42557             }
42558             return links.enumKind = hasNonLiteralMember ? 0 : 1;
42559         }
42560         function getBaseTypeOfEnumLiteralType(type) {
42561             return type.flags & 1024 && !(type.flags & 1048576) ? getDeclaredTypeOfSymbol(getParentOfSymbol(type.symbol)) : type;
42562         }
42563         function getDeclaredTypeOfEnum(symbol) {
42564             var links = getSymbolLinks(symbol);
42565             if (links.declaredType) {
42566                 return links.declaredType;
42567             }
42568             if (getEnumKind(symbol) === 1) {
42569                 enumCount++;
42570                 var memberTypeList = [];
42571                 for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) {
42572                     var declaration = _a[_i];
42573                     if (declaration.kind === 255) {
42574                         for (var _b = 0, _c = declaration.members; _b < _c.length; _b++) {
42575                             var member = _c[_b];
42576                             var value = getEnumMemberValue(member);
42577                             var memberType = getFreshTypeOfLiteralType(getLiteralType(value !== undefined ? value : 0, enumCount, getSymbolOfNode(member)));
42578                             getSymbolLinks(getSymbolOfNode(member)).declaredType = memberType;
42579                             memberTypeList.push(getRegularTypeOfLiteralType(memberType));
42580                         }
42581                     }
42582                 }
42583                 if (memberTypeList.length) {
42584                     var enumType_1 = getUnionType(memberTypeList, 1, symbol, undefined);
42585                     if (enumType_1.flags & 1048576) {
42586                         enumType_1.flags |= 1024;
42587                         enumType_1.symbol = symbol;
42588                     }
42589                     return links.declaredType = enumType_1;
42590                 }
42591             }
42592             var enumType = createType(32);
42593             enumType.symbol = symbol;
42594             return links.declaredType = enumType;
42595         }
42596         function getDeclaredTypeOfEnumMember(symbol) {
42597             var links = getSymbolLinks(symbol);
42598             if (!links.declaredType) {
42599                 var enumType = getDeclaredTypeOfEnum(getParentOfSymbol(symbol));
42600                 if (!links.declaredType) {
42601                     links.declaredType = enumType;
42602                 }
42603             }
42604             return links.declaredType;
42605         }
42606         function getDeclaredTypeOfTypeParameter(symbol) {
42607             var links = getSymbolLinks(symbol);
42608             return links.declaredType || (links.declaredType = createTypeParameter(symbol));
42609         }
42610         function getDeclaredTypeOfAlias(symbol) {
42611             var links = getSymbolLinks(symbol);
42612             return links.declaredType || (links.declaredType = getDeclaredTypeOfSymbol(resolveAlias(symbol)));
42613         }
42614         function getDeclaredTypeOfSymbol(symbol) {
42615             return tryGetDeclaredTypeOfSymbol(symbol) || errorType;
42616         }
42617         function tryGetDeclaredTypeOfSymbol(symbol) {
42618             if (symbol.flags & (32 | 64)) {
42619                 return getDeclaredTypeOfClassOrInterface(symbol);
42620             }
42621             if (symbol.flags & 524288) {
42622                 return getDeclaredTypeOfTypeAlias(symbol);
42623             }
42624             if (symbol.flags & 262144) {
42625                 return getDeclaredTypeOfTypeParameter(symbol);
42626             }
42627             if (symbol.flags & 384) {
42628                 return getDeclaredTypeOfEnum(symbol);
42629             }
42630             if (symbol.flags & 8) {
42631                 return getDeclaredTypeOfEnumMember(symbol);
42632             }
42633             if (symbol.flags & 2097152) {
42634                 return getDeclaredTypeOfAlias(symbol);
42635             }
42636             return undefined;
42637         }
42638         function isThislessType(node) {
42639             switch (node.kind) {
42640                 case 128:
42641                 case 152:
42642                 case 147:
42643                 case 144:
42644                 case 155:
42645                 case 131:
42646                 case 148:
42647                 case 145:
42648                 case 113:
42649                 case 150:
42650                 case 141:
42651                 case 191:
42652                     return true;
42653                 case 178:
42654                     return isThislessType(node.elementType);
42655                 case 173:
42656                     return !node.typeArguments || node.typeArguments.every(isThislessType);
42657             }
42658             return false;
42659         }
42660         function isThislessTypeParameter(node) {
42661             var constraint = ts.getEffectiveConstraintOfTypeParameter(node);
42662             return !constraint || isThislessType(constraint);
42663         }
42664         function isThislessVariableLikeDeclaration(node) {
42665             var typeNode = ts.getEffectiveTypeAnnotationNode(node);
42666             return typeNode ? isThislessType(typeNode) : !ts.hasInitializer(node);
42667         }
42668         function isThislessFunctionLikeDeclaration(node) {
42669             var returnType = ts.getEffectiveReturnTypeNode(node);
42670             var typeParameters = ts.getEffectiveTypeParameterDeclarations(node);
42671             return (node.kind === 166 || (!!returnType && isThislessType(returnType))) &&
42672                 node.parameters.every(isThislessVariableLikeDeclaration) &&
42673                 typeParameters.every(isThislessTypeParameter);
42674         }
42675         function isThisless(symbol) {
42676             if (symbol.declarations && symbol.declarations.length === 1) {
42677                 var declaration = symbol.declarations[0];
42678                 if (declaration) {
42679                     switch (declaration.kind) {
42680                         case 163:
42681                         case 162:
42682                             return isThislessVariableLikeDeclaration(declaration);
42683                         case 165:
42684                         case 164:
42685                         case 166:
42686                         case 167:
42687                         case 168:
42688                             return isThislessFunctionLikeDeclaration(declaration);
42689                     }
42690                 }
42691             }
42692             return false;
42693         }
42694         function createInstantiatedSymbolTable(symbols, mapper, mappingThisOnly) {
42695             var result = ts.createSymbolTable();
42696             for (var _i = 0, symbols_2 = symbols; _i < symbols_2.length; _i++) {
42697                 var symbol = symbols_2[_i];
42698                 result.set(symbol.escapedName, mappingThisOnly && isThisless(symbol) ? symbol : instantiateSymbol(symbol, mapper));
42699             }
42700             return result;
42701         }
42702         function addInheritedMembers(symbols, baseSymbols) {
42703             for (var _i = 0, baseSymbols_1 = baseSymbols; _i < baseSymbols_1.length; _i++) {
42704                 var s = baseSymbols_1[_i];
42705                 if (!symbols.has(s.escapedName) && !isStaticPrivateIdentifierProperty(s)) {
42706                     symbols.set(s.escapedName, s);
42707                 }
42708             }
42709         }
42710         function isStaticPrivateIdentifierProperty(s) {
42711             return !!s.valueDeclaration && ts.isPrivateIdentifierPropertyDeclaration(s.valueDeclaration) && ts.hasSyntacticModifier(s.valueDeclaration, 32);
42712         }
42713         function resolveDeclaredMembers(type) {
42714             if (!type.declaredProperties) {
42715                 var symbol = type.symbol;
42716                 var members = getMembersOfSymbol(symbol);
42717                 type.declaredProperties = getNamedMembers(members);
42718                 type.declaredCallSignatures = ts.emptyArray;
42719                 type.declaredConstructSignatures = ts.emptyArray;
42720                 type.declaredCallSignatures = getSignaturesOfSymbol(members.get("__call"));
42721                 type.declaredConstructSignatures = getSignaturesOfSymbol(members.get("__new"));
42722                 type.declaredStringIndexInfo = getIndexInfoOfSymbol(symbol, 0);
42723                 type.declaredNumberIndexInfo = getIndexInfoOfSymbol(symbol, 1);
42724             }
42725             return type;
42726         }
42727         function isTypeUsableAsPropertyName(type) {
42728             return !!(type.flags & 8576);
42729         }
42730         function isLateBindableName(node) {
42731             if (!ts.isComputedPropertyName(node) && !ts.isElementAccessExpression(node)) {
42732                 return false;
42733             }
42734             var expr = ts.isComputedPropertyName(node) ? node.expression : node.argumentExpression;
42735             return ts.isEntityNameExpression(expr)
42736                 && isTypeUsableAsPropertyName(ts.isComputedPropertyName(node) ? checkComputedPropertyName(node) : checkExpressionCached(expr));
42737         }
42738         function isLateBoundName(name) {
42739             return name.charCodeAt(0) === 95 &&
42740                 name.charCodeAt(1) === 95 &&
42741                 name.charCodeAt(2) === 64;
42742         }
42743         function hasLateBindableName(node) {
42744             var name = ts.getNameOfDeclaration(node);
42745             return !!name && isLateBindableName(name);
42746         }
42747         function hasNonBindableDynamicName(node) {
42748             return ts.hasDynamicName(node) && !hasLateBindableName(node);
42749         }
42750         function isNonBindableDynamicName(node) {
42751             return ts.isDynamicName(node) && !isLateBindableName(node);
42752         }
42753         function getPropertyNameFromType(type) {
42754             if (type.flags & 8192) {
42755                 return type.escapedName;
42756             }
42757             if (type.flags & (128 | 256)) {
42758                 return ts.escapeLeadingUnderscores("" + type.value);
42759             }
42760             return ts.Debug.fail();
42761         }
42762         function addDeclarationToLateBoundSymbol(symbol, member, symbolFlags) {
42763             ts.Debug.assert(!!(ts.getCheckFlags(symbol) & 4096), "Expected a late-bound symbol.");
42764             symbol.flags |= symbolFlags;
42765             getSymbolLinks(member.symbol).lateSymbol = symbol;
42766             if (!symbol.declarations) {
42767                 symbol.declarations = [member];
42768             }
42769             else {
42770                 symbol.declarations.push(member);
42771             }
42772             if (symbolFlags & 111551) {
42773                 if (!symbol.valueDeclaration || symbol.valueDeclaration.kind !== member.kind) {
42774                     symbol.valueDeclaration = member;
42775                 }
42776             }
42777         }
42778         function lateBindMember(parent, earlySymbols, lateSymbols, decl) {
42779             ts.Debug.assert(!!decl.symbol, "The member is expected to have a symbol.");
42780             var links = getNodeLinks(decl);
42781             if (!links.resolvedSymbol) {
42782                 links.resolvedSymbol = decl.symbol;
42783                 var declName = ts.isBinaryExpression(decl) ? decl.left : decl.name;
42784                 var type = ts.isElementAccessExpression(declName) ? checkExpressionCached(declName.argumentExpression) : checkComputedPropertyName(declName);
42785                 if (isTypeUsableAsPropertyName(type)) {
42786                     var memberName = getPropertyNameFromType(type);
42787                     var symbolFlags = decl.symbol.flags;
42788                     var lateSymbol = lateSymbols.get(memberName);
42789                     if (!lateSymbol)
42790                         lateSymbols.set(memberName, lateSymbol = createSymbol(0, memberName, 4096));
42791                     var earlySymbol = earlySymbols && earlySymbols.get(memberName);
42792                     if (lateSymbol.flags & getExcludedSymbolFlags(symbolFlags) || earlySymbol) {
42793                         var declarations = earlySymbol ? ts.concatenate(earlySymbol.declarations, lateSymbol.declarations) : lateSymbol.declarations;
42794                         var name_4 = !(type.flags & 8192) && ts.unescapeLeadingUnderscores(memberName) || ts.declarationNameToString(declName);
42795                         ts.forEach(declarations, function (declaration) { return error(ts.getNameOfDeclaration(declaration) || declaration, ts.Diagnostics.Property_0_was_also_declared_here, name_4); });
42796                         error(declName || decl, ts.Diagnostics.Duplicate_property_0, name_4);
42797                         lateSymbol = createSymbol(0, memberName, 4096);
42798                     }
42799                     lateSymbol.nameType = type;
42800                     addDeclarationToLateBoundSymbol(lateSymbol, decl, symbolFlags);
42801                     if (lateSymbol.parent) {
42802                         ts.Debug.assert(lateSymbol.parent === parent, "Existing symbol parent should match new one");
42803                     }
42804                     else {
42805                         lateSymbol.parent = parent;
42806                     }
42807                     return links.resolvedSymbol = lateSymbol;
42808                 }
42809             }
42810             return links.resolvedSymbol;
42811         }
42812         function getResolvedMembersOrExportsOfSymbol(symbol, resolutionKind) {
42813             var links = getSymbolLinks(symbol);
42814             if (!links[resolutionKind]) {
42815                 var isStatic = resolutionKind === "resolvedExports";
42816                 var earlySymbols = !isStatic ? symbol.members :
42817                     symbol.flags & 1536 ? getExportsOfModuleWorker(symbol) :
42818                         symbol.exports;
42819                 links[resolutionKind] = earlySymbols || emptySymbols;
42820                 var lateSymbols = ts.createSymbolTable();
42821                 for (var _i = 0, _a = symbol.declarations || ts.emptyArray; _i < _a.length; _i++) {
42822                     var decl = _a[_i];
42823                     var members = ts.getMembersOfDeclaration(decl);
42824                     if (members) {
42825                         for (var _b = 0, members_5 = members; _b < members_5.length; _b++) {
42826                             var member = members_5[_b];
42827                             if (isStatic === ts.hasStaticModifier(member) && hasLateBindableName(member)) {
42828                                 lateBindMember(symbol, earlySymbols, lateSymbols, member);
42829                             }
42830                         }
42831                     }
42832                 }
42833                 var assignments = symbol.assignmentDeclarationMembers;
42834                 if (assignments) {
42835                     var decls = ts.arrayFrom(assignments.values());
42836                     for (var _c = 0, decls_1 = decls; _c < decls_1.length; _c++) {
42837                         var member = decls_1[_c];
42838                         var assignmentKind = ts.getAssignmentDeclarationKind(member);
42839                         var isInstanceMember = assignmentKind === 3
42840                             || ts.isBinaryExpression(member) && isPossiblyAliasedThisProperty(member, assignmentKind)
42841                             || assignmentKind === 9
42842                             || assignmentKind === 6;
42843                         if (isStatic === !isInstanceMember && hasLateBindableName(member)) {
42844                             lateBindMember(symbol, earlySymbols, lateSymbols, member);
42845                         }
42846                     }
42847                 }
42848                 links[resolutionKind] = combineSymbolTables(earlySymbols, lateSymbols) || emptySymbols;
42849             }
42850             return links[resolutionKind];
42851         }
42852         function getMembersOfSymbol(symbol) {
42853             return symbol.flags & 6256
42854                 ? getResolvedMembersOrExportsOfSymbol(symbol, "resolvedMembers")
42855                 : symbol.members || emptySymbols;
42856         }
42857         function getLateBoundSymbol(symbol) {
42858             if (symbol.flags & 106500 && symbol.escapedName === "__computed") {
42859                 var links = getSymbolLinks(symbol);
42860                 if (!links.lateSymbol && ts.some(symbol.declarations, hasLateBindableName)) {
42861                     var parent = getMergedSymbol(symbol.parent);
42862                     if (ts.some(symbol.declarations, ts.hasStaticModifier)) {
42863                         getExportsOfSymbol(parent);
42864                     }
42865                     else {
42866                         getMembersOfSymbol(parent);
42867                     }
42868                 }
42869                 return links.lateSymbol || (links.lateSymbol = symbol);
42870             }
42871             return symbol;
42872         }
42873         function getTypeWithThisArgument(type, thisArgument, needApparentType) {
42874             if (ts.getObjectFlags(type) & 4) {
42875                 var target = type.target;
42876                 var typeArguments = getTypeArguments(type);
42877                 if (ts.length(target.typeParameters) === ts.length(typeArguments)) {
42878                     var ref = createTypeReference(target, ts.concatenate(typeArguments, [thisArgument || target.thisType]));
42879                     return needApparentType ? getApparentType(ref) : ref;
42880                 }
42881             }
42882             else if (type.flags & 2097152) {
42883                 return getIntersectionType(ts.map(type.types, function (t) { return getTypeWithThisArgument(t, thisArgument, needApparentType); }));
42884             }
42885             return needApparentType ? getApparentType(type) : type;
42886         }
42887         function resolveObjectTypeMembers(type, source, typeParameters, typeArguments) {
42888             var mapper;
42889             var members;
42890             var callSignatures;
42891             var constructSignatures;
42892             var stringIndexInfo;
42893             var numberIndexInfo;
42894             if (ts.rangeEquals(typeParameters, typeArguments, 0, typeParameters.length)) {
42895                 members = source.symbol ? getMembersOfSymbol(source.symbol) : ts.createSymbolTable(source.declaredProperties);
42896                 callSignatures = source.declaredCallSignatures;
42897                 constructSignatures = source.declaredConstructSignatures;
42898                 stringIndexInfo = source.declaredStringIndexInfo;
42899                 numberIndexInfo = source.declaredNumberIndexInfo;
42900             }
42901             else {
42902                 mapper = createTypeMapper(typeParameters, typeArguments);
42903                 members = createInstantiatedSymbolTable(source.declaredProperties, mapper, typeParameters.length === 1);
42904                 callSignatures = instantiateSignatures(source.declaredCallSignatures, mapper);
42905                 constructSignatures = instantiateSignatures(source.declaredConstructSignatures, mapper);
42906                 stringIndexInfo = instantiateIndexInfo(source.declaredStringIndexInfo, mapper);
42907                 numberIndexInfo = instantiateIndexInfo(source.declaredNumberIndexInfo, mapper);
42908             }
42909             var baseTypes = getBaseTypes(source);
42910             if (baseTypes.length) {
42911                 if (source.symbol && members === getMembersOfSymbol(source.symbol)) {
42912                     members = ts.createSymbolTable(source.declaredProperties);
42913                 }
42914                 setStructuredTypeMembers(type, members, callSignatures, constructSignatures, stringIndexInfo, numberIndexInfo);
42915                 var thisArgument = ts.lastOrUndefined(typeArguments);
42916                 for (var _i = 0, baseTypes_1 = baseTypes; _i < baseTypes_1.length; _i++) {
42917                     var baseType = baseTypes_1[_i];
42918                     var instantiatedBaseType = thisArgument ? getTypeWithThisArgument(instantiateType(baseType, mapper), thisArgument) : baseType;
42919                     addInheritedMembers(members, getPropertiesOfType(instantiatedBaseType));
42920                     callSignatures = ts.concatenate(callSignatures, getSignaturesOfType(instantiatedBaseType, 0));
42921                     constructSignatures = ts.concatenate(constructSignatures, getSignaturesOfType(instantiatedBaseType, 1));
42922                     if (!stringIndexInfo) {
42923                         stringIndexInfo = instantiatedBaseType === anyType ?
42924                             createIndexInfo(anyType, false) :
42925                             getIndexInfoOfType(instantiatedBaseType, 0);
42926                     }
42927                     numberIndexInfo = numberIndexInfo || getIndexInfoOfType(instantiatedBaseType, 1);
42928                 }
42929             }
42930             setStructuredTypeMembers(type, members, callSignatures, constructSignatures, stringIndexInfo, numberIndexInfo);
42931         }
42932         function resolveClassOrInterfaceMembers(type) {
42933             resolveObjectTypeMembers(type, resolveDeclaredMembers(type), ts.emptyArray, ts.emptyArray);
42934         }
42935         function resolveTypeReferenceMembers(type) {
42936             var source = resolveDeclaredMembers(type.target);
42937             var typeParameters = ts.concatenate(source.typeParameters, [source.thisType]);
42938             var typeArguments = getTypeArguments(type);
42939             var paddedTypeArguments = typeArguments.length === typeParameters.length ? typeArguments : ts.concatenate(typeArguments, [type]);
42940             resolveObjectTypeMembers(type, source, typeParameters, paddedTypeArguments);
42941         }
42942         function createSignature(declaration, typeParameters, thisParameter, parameters, resolvedReturnType, resolvedTypePredicate, minArgumentCount, flags) {
42943             var sig = new Signature(checker, flags);
42944             sig.declaration = declaration;
42945             sig.typeParameters = typeParameters;
42946             sig.parameters = parameters;
42947             sig.thisParameter = thisParameter;
42948             sig.resolvedReturnType = resolvedReturnType;
42949             sig.resolvedTypePredicate = resolvedTypePredicate;
42950             sig.minArgumentCount = minArgumentCount;
42951             sig.resolvedMinArgumentCount = undefined;
42952             sig.target = undefined;
42953             sig.mapper = undefined;
42954             sig.unionSignatures = undefined;
42955             return sig;
42956         }
42957         function cloneSignature(sig) {
42958             var result = createSignature(sig.declaration, sig.typeParameters, sig.thisParameter, sig.parameters, undefined, undefined, sig.minArgumentCount, sig.flags & 19);
42959             result.target = sig.target;
42960             result.mapper = sig.mapper;
42961             result.unionSignatures = sig.unionSignatures;
42962             return result;
42963         }
42964         function createUnionSignature(signature, unionSignatures) {
42965             var result = cloneSignature(signature);
42966             result.unionSignatures = unionSignatures;
42967             result.target = undefined;
42968             result.mapper = undefined;
42969             return result;
42970         }
42971         function getOptionalCallSignature(signature, callChainFlags) {
42972             if ((signature.flags & 12) === callChainFlags) {
42973                 return signature;
42974             }
42975             if (!signature.optionalCallSignatureCache) {
42976                 signature.optionalCallSignatureCache = {};
42977             }
42978             var key = callChainFlags === 4 ? "inner" : "outer";
42979             return signature.optionalCallSignatureCache[key]
42980                 || (signature.optionalCallSignatureCache[key] = createOptionalCallSignature(signature, callChainFlags));
42981         }
42982         function createOptionalCallSignature(signature, callChainFlags) {
42983             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.");
42984             var result = cloneSignature(signature);
42985             result.flags |= callChainFlags;
42986             return result;
42987         }
42988         function getExpandedParameters(sig, skipUnionExpanding) {
42989             if (signatureHasRestParameter(sig)) {
42990                 var restIndex_1 = sig.parameters.length - 1;
42991                 var restType = getTypeOfSymbol(sig.parameters[restIndex_1]);
42992                 if (isTupleType(restType)) {
42993                     return [expandSignatureParametersWithTupleMembers(restType, restIndex_1)];
42994                 }
42995                 else if (!skipUnionExpanding && restType.flags & 1048576 && ts.every(restType.types, isTupleType)) {
42996                     return ts.map(restType.types, function (t) { return expandSignatureParametersWithTupleMembers(t, restIndex_1); });
42997                 }
42998             }
42999             return [sig.parameters];
43000             function expandSignatureParametersWithTupleMembers(restType, restIndex) {
43001                 var elementTypes = getTypeArguments(restType);
43002                 var associatedNames = restType.target.labeledElementDeclarations;
43003                 var restParams = ts.map(elementTypes, function (t, i) {
43004                     var tupleLabelName = !!associatedNames && getTupleElementLabel(associatedNames[i]);
43005                     var name = tupleLabelName || getParameterNameAtPosition(sig, restIndex + i, restType);
43006                     var flags = restType.target.elementFlags[i];
43007                     var checkFlags = flags & 12 ? 32768 :
43008                         flags & 2 ? 16384 : 0;
43009                     var symbol = createSymbol(1, name, checkFlags);
43010                     symbol.type = flags & 4 ? createArrayType(t) : t;
43011                     return symbol;
43012                 });
43013                 return ts.concatenate(sig.parameters.slice(0, restIndex), restParams);
43014             }
43015         }
43016         function getDefaultConstructSignatures(classType) {
43017             var baseConstructorType = getBaseConstructorTypeOfClass(classType);
43018             var baseSignatures = getSignaturesOfType(baseConstructorType, 1);
43019             if (baseSignatures.length === 0) {
43020                 return [createSignature(undefined, classType.localTypeParameters, undefined, ts.emptyArray, classType, undefined, 0, 0)];
43021             }
43022             var baseTypeNode = getBaseTypeNodeOfClass(classType);
43023             var isJavaScript = ts.isInJSFile(baseTypeNode);
43024             var typeArguments = typeArgumentsFromTypeReferenceNode(baseTypeNode);
43025             var typeArgCount = ts.length(typeArguments);
43026             var result = [];
43027             for (var _i = 0, baseSignatures_1 = baseSignatures; _i < baseSignatures_1.length; _i++) {
43028                 var baseSig = baseSignatures_1[_i];
43029                 var minTypeArgumentCount = getMinTypeArgumentCount(baseSig.typeParameters);
43030                 var typeParamCount = ts.length(baseSig.typeParameters);
43031                 if (isJavaScript || typeArgCount >= minTypeArgumentCount && typeArgCount <= typeParamCount) {
43032                     var sig = typeParamCount ? createSignatureInstantiation(baseSig, fillMissingTypeArguments(typeArguments, baseSig.typeParameters, minTypeArgumentCount, isJavaScript)) : cloneSignature(baseSig);
43033                     sig.typeParameters = classType.localTypeParameters;
43034                     sig.resolvedReturnType = classType;
43035                     result.push(sig);
43036                 }
43037             }
43038             return result;
43039         }
43040         function findMatchingSignature(signatureList, signature, partialMatch, ignoreThisTypes, ignoreReturnTypes) {
43041             for (var _i = 0, signatureList_1 = signatureList; _i < signatureList_1.length; _i++) {
43042                 var s = signatureList_1[_i];
43043                 if (compareSignaturesIdentical(s, signature, partialMatch, ignoreThisTypes, ignoreReturnTypes, partialMatch ? compareTypesSubtypeOf : compareTypesIdentical)) {
43044                     return s;
43045                 }
43046             }
43047         }
43048         function findMatchingSignatures(signatureLists, signature, listIndex) {
43049             if (signature.typeParameters) {
43050                 if (listIndex > 0) {
43051                     return undefined;
43052                 }
43053                 for (var i = 1; i < signatureLists.length; i++) {
43054                     if (!findMatchingSignature(signatureLists[i], signature, false, false, false)) {
43055                         return undefined;
43056                     }
43057                 }
43058                 return [signature];
43059             }
43060             var result;
43061             for (var i = 0; i < signatureLists.length; i++) {
43062                 var match = i === listIndex ? signature : findMatchingSignature(signatureLists[i], signature, true, false, true);
43063                 if (!match) {
43064                     return undefined;
43065                 }
43066                 result = ts.appendIfUnique(result, match);
43067             }
43068             return result;
43069         }
43070         function getUnionSignatures(signatureLists) {
43071             var result;
43072             var indexWithLengthOverOne;
43073             for (var i = 0; i < signatureLists.length; i++) {
43074                 if (signatureLists[i].length === 0)
43075                     return ts.emptyArray;
43076                 if (signatureLists[i].length > 1) {
43077                     indexWithLengthOverOne = indexWithLengthOverOne === undefined ? i : -1;
43078                 }
43079                 for (var _i = 0, _a = signatureLists[i]; _i < _a.length; _i++) {
43080                     var signature = _a[_i];
43081                     if (!result || !findMatchingSignature(result, signature, false, false, true)) {
43082                         var unionSignatures = findMatchingSignatures(signatureLists, signature, i);
43083                         if (unionSignatures) {
43084                             var s = signature;
43085                             if (unionSignatures.length > 1) {
43086                                 var thisParameter = signature.thisParameter;
43087                                 var firstThisParameterOfUnionSignatures = ts.forEach(unionSignatures, function (sig) { return sig.thisParameter; });
43088                                 if (firstThisParameterOfUnionSignatures) {
43089                                     var thisType = getIntersectionType(ts.mapDefined(unionSignatures, function (sig) { return sig.thisParameter && getTypeOfSymbol(sig.thisParameter); }));
43090                                     thisParameter = createSymbolWithType(firstThisParameterOfUnionSignatures, thisType);
43091                                 }
43092                                 s = createUnionSignature(signature, unionSignatures);
43093                                 s.thisParameter = thisParameter;
43094                             }
43095                             (result || (result = [])).push(s);
43096                         }
43097                     }
43098                 }
43099             }
43100             if (!ts.length(result) && indexWithLengthOverOne !== -1) {
43101                 var masterList = signatureLists[indexWithLengthOverOne !== undefined ? indexWithLengthOverOne : 0];
43102                 var results = masterList.slice();
43103                 var _loop_10 = function (signatures) {
43104                     if (signatures !== masterList) {
43105                         var signature_1 = signatures[0];
43106                         ts.Debug.assert(!!signature_1, "getUnionSignatures bails early on empty signature lists and should not have empty lists on second pass");
43107                         results = signature_1.typeParameters && ts.some(results, function (s) { return !!s.typeParameters; }) ? undefined : ts.map(results, function (sig) { return combineSignaturesOfUnionMembers(sig, signature_1); });
43108                         if (!results) {
43109                             return "break";
43110                         }
43111                     }
43112                 };
43113                 for (var _b = 0, signatureLists_1 = signatureLists; _b < signatureLists_1.length; _b++) {
43114                     var signatures = signatureLists_1[_b];
43115                     var state_3 = _loop_10(signatures);
43116                     if (state_3 === "break")
43117                         break;
43118                 }
43119                 result = results;
43120             }
43121             return result || ts.emptyArray;
43122         }
43123         function combineUnionThisParam(left, right) {
43124             if (!left || !right) {
43125                 return left || right;
43126             }
43127             var thisType = getIntersectionType([getTypeOfSymbol(left), getTypeOfSymbol(right)]);
43128             return createSymbolWithType(left, thisType);
43129         }
43130         function combineUnionParameters(left, right) {
43131             var leftCount = getParameterCount(left);
43132             var rightCount = getParameterCount(right);
43133             var longest = leftCount >= rightCount ? left : right;
43134             var shorter = longest === left ? right : left;
43135             var longestCount = longest === left ? leftCount : rightCount;
43136             var eitherHasEffectiveRest = (hasEffectiveRestParameter(left) || hasEffectiveRestParameter(right));
43137             var needsExtraRestElement = eitherHasEffectiveRest && !hasEffectiveRestParameter(longest);
43138             var params = new Array(longestCount + (needsExtraRestElement ? 1 : 0));
43139             for (var i = 0; i < longestCount; i++) {
43140                 var longestParamType = tryGetTypeAtPosition(longest, i);
43141                 var shorterParamType = tryGetTypeAtPosition(shorter, i) || unknownType;
43142                 var unionParamType = getIntersectionType([longestParamType, shorterParamType]);
43143                 var isRestParam = eitherHasEffectiveRest && !needsExtraRestElement && i === (longestCount - 1);
43144                 var isOptional = i >= getMinArgumentCount(longest) && i >= getMinArgumentCount(shorter);
43145                 var leftName = i >= leftCount ? undefined : getParameterNameAtPosition(left, i);
43146                 var rightName = i >= rightCount ? undefined : getParameterNameAtPosition(right, i);
43147                 var paramName = leftName === rightName ? leftName :
43148                     !leftName ? rightName :
43149                         !rightName ? leftName :
43150                             undefined;
43151                 var paramSymbol = createSymbol(1 | (isOptional && !isRestParam ? 16777216 : 0), paramName || "arg" + i);
43152                 paramSymbol.type = isRestParam ? createArrayType(unionParamType) : unionParamType;
43153                 params[i] = paramSymbol;
43154             }
43155             if (needsExtraRestElement) {
43156                 var restParamSymbol = createSymbol(1, "args");
43157                 restParamSymbol.type = createArrayType(getTypeAtPosition(shorter, longestCount));
43158                 params[longestCount] = restParamSymbol;
43159             }
43160             return params;
43161         }
43162         function combineSignaturesOfUnionMembers(left, right) {
43163             var declaration = left.declaration;
43164             var params = combineUnionParameters(left, right);
43165             var thisParam = combineUnionThisParam(left.thisParameter, right.thisParameter);
43166             var minArgCount = Math.max(left.minArgumentCount, right.minArgumentCount);
43167             var result = createSignature(declaration, left.typeParameters || right.typeParameters, thisParam, params, undefined, undefined, minArgCount, (left.flags | right.flags) & 19);
43168             result.unionSignatures = ts.concatenate(left.unionSignatures || [left], [right]);
43169             return result;
43170         }
43171         function getUnionIndexInfo(types, kind) {
43172             var indexTypes = [];
43173             var isAnyReadonly = false;
43174             for (var _i = 0, types_4 = types; _i < types_4.length; _i++) {
43175                 var type = types_4[_i];
43176                 var indexInfo = getIndexInfoOfType(getApparentType(type), kind);
43177                 if (!indexInfo) {
43178                     return undefined;
43179                 }
43180                 indexTypes.push(indexInfo.type);
43181                 isAnyReadonly = isAnyReadonly || indexInfo.isReadonly;
43182             }
43183             return createIndexInfo(getUnionType(indexTypes, 2), isAnyReadonly);
43184         }
43185         function resolveUnionTypeMembers(type) {
43186             var callSignatures = getUnionSignatures(ts.map(type.types, function (t) { return t === globalFunctionType ? [unknownSignature] : getSignaturesOfType(t, 0); }));
43187             var constructSignatures = getUnionSignatures(ts.map(type.types, function (t) { return getSignaturesOfType(t, 1); }));
43188             var stringIndexInfo = getUnionIndexInfo(type.types, 0);
43189             var numberIndexInfo = getUnionIndexInfo(type.types, 1);
43190             setStructuredTypeMembers(type, emptySymbols, callSignatures, constructSignatures, stringIndexInfo, numberIndexInfo);
43191         }
43192         function intersectTypes(type1, type2) {
43193             return !type1 ? type2 : !type2 ? type1 : getIntersectionType([type1, type2]);
43194         }
43195         function intersectIndexInfos(info1, info2) {
43196             return !info1 ? info2 : !info2 ? info1 : createIndexInfo(getIntersectionType([info1.type, info2.type]), info1.isReadonly && info2.isReadonly);
43197         }
43198         function unionSpreadIndexInfos(info1, info2) {
43199             return info1 && info2 && createIndexInfo(getUnionType([info1.type, info2.type]), info1.isReadonly || info2.isReadonly);
43200         }
43201         function findMixins(types) {
43202             var constructorTypeCount = ts.countWhere(types, function (t) { return getSignaturesOfType(t, 1).length > 0; });
43203             var mixinFlags = ts.map(types, isMixinConstructorType);
43204             if (constructorTypeCount > 0 && constructorTypeCount === ts.countWhere(mixinFlags, function (b) { return b; })) {
43205                 var firstMixinIndex = mixinFlags.indexOf(true);
43206                 mixinFlags[firstMixinIndex] = false;
43207             }
43208             return mixinFlags;
43209         }
43210         function includeMixinType(type, types, mixinFlags, index) {
43211             var mixedTypes = [];
43212             for (var i = 0; i < types.length; i++) {
43213                 if (i === index) {
43214                     mixedTypes.push(type);
43215                 }
43216                 else if (mixinFlags[i]) {
43217                     mixedTypes.push(getReturnTypeOfSignature(getSignaturesOfType(types[i], 1)[0]));
43218                 }
43219             }
43220             return getIntersectionType(mixedTypes);
43221         }
43222         function resolveIntersectionTypeMembers(type) {
43223             var callSignatures;
43224             var constructSignatures;
43225             var stringIndexInfo;
43226             var numberIndexInfo;
43227             var types = type.types;
43228             var mixinFlags = findMixins(types);
43229             var mixinCount = ts.countWhere(mixinFlags, function (b) { return b; });
43230             var _loop_11 = function (i) {
43231                 var t = type.types[i];
43232                 if (!mixinFlags[i]) {
43233                     var signatures = getSignaturesOfType(t, 1);
43234                     if (signatures.length && mixinCount > 0) {
43235                         signatures = ts.map(signatures, function (s) {
43236                             var clone = cloneSignature(s);
43237                             clone.resolvedReturnType = includeMixinType(getReturnTypeOfSignature(s), types, mixinFlags, i);
43238                             return clone;
43239                         });
43240                     }
43241                     constructSignatures = appendSignatures(constructSignatures, signatures);
43242                 }
43243                 callSignatures = appendSignatures(callSignatures, getSignaturesOfType(t, 0));
43244                 stringIndexInfo = intersectIndexInfos(stringIndexInfo, getIndexInfoOfType(t, 0));
43245                 numberIndexInfo = intersectIndexInfos(numberIndexInfo, getIndexInfoOfType(t, 1));
43246             };
43247             for (var i = 0; i < types.length; i++) {
43248                 _loop_11(i);
43249             }
43250             setStructuredTypeMembers(type, emptySymbols, callSignatures || ts.emptyArray, constructSignatures || ts.emptyArray, stringIndexInfo, numberIndexInfo);
43251         }
43252         function appendSignatures(signatures, newSignatures) {
43253             var _loop_12 = function (sig) {
43254                 if (!signatures || ts.every(signatures, function (s) { return !compareSignaturesIdentical(s, sig, false, false, false, compareTypesIdentical); })) {
43255                     signatures = ts.append(signatures, sig);
43256                 }
43257             };
43258             for (var _i = 0, newSignatures_1 = newSignatures; _i < newSignatures_1.length; _i++) {
43259                 var sig = newSignatures_1[_i];
43260                 _loop_12(sig);
43261             }
43262             return signatures;
43263         }
43264         function resolveAnonymousTypeMembers(type) {
43265             var symbol = getMergedSymbol(type.symbol);
43266             if (type.target) {
43267                 setStructuredTypeMembers(type, emptySymbols, ts.emptyArray, ts.emptyArray, undefined, undefined);
43268                 var members = createInstantiatedSymbolTable(getPropertiesOfObjectType(type.target), type.mapper, false);
43269                 var callSignatures = instantiateSignatures(getSignaturesOfType(type.target, 0), type.mapper);
43270                 var constructSignatures = instantiateSignatures(getSignaturesOfType(type.target, 1), type.mapper);
43271                 var stringIndexInfo = instantiateIndexInfo(getIndexInfoOfType(type.target, 0), type.mapper);
43272                 var numberIndexInfo = instantiateIndexInfo(getIndexInfoOfType(type.target, 1), type.mapper);
43273                 setStructuredTypeMembers(type, members, callSignatures, constructSignatures, stringIndexInfo, numberIndexInfo);
43274             }
43275             else if (symbol.flags & 2048) {
43276                 setStructuredTypeMembers(type, emptySymbols, ts.emptyArray, ts.emptyArray, undefined, undefined);
43277                 var members = getMembersOfSymbol(symbol);
43278                 var callSignatures = getSignaturesOfSymbol(members.get("__call"));
43279                 var constructSignatures = getSignaturesOfSymbol(members.get("__new"));
43280                 var stringIndexInfo = getIndexInfoOfSymbol(symbol, 0);
43281                 var numberIndexInfo = getIndexInfoOfSymbol(symbol, 1);
43282                 setStructuredTypeMembers(type, members, callSignatures, constructSignatures, stringIndexInfo, numberIndexInfo);
43283             }
43284             else {
43285                 var members = emptySymbols;
43286                 var stringIndexInfo = void 0;
43287                 if (symbol.exports) {
43288                     members = getExportsOfSymbol(symbol);
43289                     if (symbol === globalThisSymbol) {
43290                         var varsOnly_1 = new ts.Map();
43291                         members.forEach(function (p) {
43292                             if (!(p.flags & 418)) {
43293                                 varsOnly_1.set(p.escapedName, p);
43294                             }
43295                         });
43296                         members = varsOnly_1;
43297                     }
43298                 }
43299                 setStructuredTypeMembers(type, members, ts.emptyArray, ts.emptyArray, undefined, undefined);
43300                 if (symbol.flags & 32) {
43301                     var classType = getDeclaredTypeOfClassOrInterface(symbol);
43302                     var baseConstructorType = getBaseConstructorTypeOfClass(classType);
43303                     if (baseConstructorType.flags & (524288 | 2097152 | 8650752)) {
43304                         members = ts.createSymbolTable(getNamedMembers(members));
43305                         addInheritedMembers(members, getPropertiesOfType(baseConstructorType));
43306                     }
43307                     else if (baseConstructorType === anyType) {
43308                         stringIndexInfo = createIndexInfo(anyType, false);
43309                     }
43310                 }
43311                 var numberIndexInfo = symbol.flags & 384 && (getDeclaredTypeOfSymbol(symbol).flags & 32 ||
43312                     ts.some(type.properties, function (prop) { return !!(getTypeOfSymbol(prop).flags & 296); })) ? enumNumberIndexInfo : undefined;
43313                 setStructuredTypeMembers(type, members, ts.emptyArray, ts.emptyArray, stringIndexInfo, numberIndexInfo);
43314                 if (symbol.flags & (16 | 8192)) {
43315                     type.callSignatures = getSignaturesOfSymbol(symbol);
43316                 }
43317                 if (symbol.flags & 32) {
43318                     var classType_1 = getDeclaredTypeOfClassOrInterface(symbol);
43319                     var constructSignatures = symbol.members ? getSignaturesOfSymbol(symbol.members.get("__constructor")) : ts.emptyArray;
43320                     if (symbol.flags & 16) {
43321                         constructSignatures = ts.addRange(constructSignatures.slice(), ts.mapDefined(type.callSignatures, function (sig) { return isJSConstructor(sig.declaration) ?
43322                             createSignature(sig.declaration, sig.typeParameters, sig.thisParameter, sig.parameters, classType_1, undefined, sig.minArgumentCount, sig.flags & 19) :
43323                             undefined; }));
43324                     }
43325                     if (!constructSignatures.length) {
43326                         constructSignatures = getDefaultConstructSignatures(classType_1);
43327                     }
43328                     type.constructSignatures = constructSignatures;
43329                 }
43330             }
43331         }
43332         function resolveReverseMappedTypeMembers(type) {
43333             var indexInfo = getIndexInfoOfType(type.source, 0);
43334             var modifiers = getMappedTypeModifiers(type.mappedType);
43335             var readonlyMask = modifiers & 1 ? false : true;
43336             var optionalMask = modifiers & 4 ? 0 : 16777216;
43337             var stringIndexInfo = indexInfo && createIndexInfo(inferReverseMappedType(indexInfo.type, type.mappedType, type.constraintType), readonlyMask && indexInfo.isReadonly);
43338             var members = ts.createSymbolTable();
43339             for (var _i = 0, _a = getPropertiesOfType(type.source); _i < _a.length; _i++) {
43340                 var prop = _a[_i];
43341                 var checkFlags = 8192 | (readonlyMask && isReadonlySymbol(prop) ? 8 : 0);
43342                 var inferredProp = createSymbol(4 | prop.flags & optionalMask, prop.escapedName, checkFlags);
43343                 inferredProp.declarations = prop.declarations;
43344                 inferredProp.nameType = getSymbolLinks(prop).nameType;
43345                 inferredProp.propertyType = getTypeOfSymbol(prop);
43346                 inferredProp.mappedType = type.mappedType;
43347                 inferredProp.constraintType = type.constraintType;
43348                 members.set(prop.escapedName, inferredProp);
43349             }
43350             setStructuredTypeMembers(type, members, ts.emptyArray, ts.emptyArray, stringIndexInfo, undefined);
43351         }
43352         function getLowerBoundOfKeyType(type) {
43353             if (type.flags & 4194304) {
43354                 var t = getApparentType(type.type);
43355                 return isGenericTupleType(t) ? getKnownKeysOfTupleType(t) : getIndexType(t);
43356             }
43357             if (type.flags & 16777216) {
43358                 if (type.root.isDistributive) {
43359                     var checkType = type.checkType;
43360                     var constraint = getLowerBoundOfKeyType(checkType);
43361                     if (constraint !== checkType) {
43362                         return getConditionalTypeInstantiation(type, prependTypeMapping(type.root.checkType, constraint, type.mapper));
43363                     }
43364                 }
43365                 return type;
43366             }
43367             if (type.flags & 1048576) {
43368                 return getUnionType(ts.sameMap(type.types, getLowerBoundOfKeyType));
43369             }
43370             if (type.flags & 2097152) {
43371                 return getIntersectionType(ts.sameMap(type.types, getLowerBoundOfKeyType));
43372             }
43373             return type;
43374         }
43375         function resolveMappedTypeMembers(type) {
43376             var members = ts.createSymbolTable();
43377             var stringIndexInfo;
43378             var numberIndexInfo;
43379             setStructuredTypeMembers(type, emptySymbols, ts.emptyArray, ts.emptyArray, undefined, undefined);
43380             var typeParameter = getTypeParameterFromMappedType(type);
43381             var constraintType = getConstraintTypeFromMappedType(type);
43382             var nameType = getNameTypeFromMappedType(type.target || type);
43383             var templateType = getTemplateTypeFromMappedType(type.target || type);
43384             var modifiersType = getApparentType(getModifiersTypeFromMappedType(type));
43385             var templateModifiers = getMappedTypeModifiers(type);
43386             var include = keyofStringsOnly ? 128 : 8576;
43387             if (isMappedTypeWithKeyofConstraintDeclaration(type)) {
43388                 for (var _i = 0, _a = getPropertiesOfType(modifiersType); _i < _a.length; _i++) {
43389                     var prop = _a[_i];
43390                     addMemberForKeyType(getLiteralTypeFromProperty(prop, include));
43391                 }
43392                 if (modifiersType.flags & 1 || getIndexInfoOfType(modifiersType, 0)) {
43393                     addMemberForKeyType(stringType);
43394                 }
43395                 if (!keyofStringsOnly && getIndexInfoOfType(modifiersType, 1)) {
43396                     addMemberForKeyType(numberType);
43397                 }
43398             }
43399             else {
43400                 forEachType(getLowerBoundOfKeyType(constraintType), addMemberForKeyType);
43401             }
43402             setStructuredTypeMembers(type, members, ts.emptyArray, ts.emptyArray, stringIndexInfo, numberIndexInfo);
43403             function addMemberForKeyType(keyType) {
43404                 var propNameType = nameType ? instantiateType(nameType, appendTypeMapping(type.mapper, typeParameter, keyType)) : keyType;
43405                 forEachType(propNameType, function (t) { return addMemberForKeyTypeWorker(keyType, t); });
43406             }
43407             function addMemberForKeyTypeWorker(keyType, propNameType) {
43408                 if (isTypeUsableAsPropertyName(propNameType)) {
43409                     var propName = getPropertyNameFromType(propNameType);
43410                     var existingProp = members.get(propName);
43411                     if (existingProp) {
43412                         existingProp.nameType = getUnionType([existingProp.nameType, propNameType]);
43413                         existingProp.keyType = getUnionType([existingProp.keyType, keyType]);
43414                     }
43415                     else {
43416                         var modifiersProp = isTypeUsableAsPropertyName(keyType) ? getPropertyOfType(modifiersType, getPropertyNameFromType(keyType)) : undefined;
43417                         var isOptional = !!(templateModifiers & 4 ||
43418                             !(templateModifiers & 8) && modifiersProp && modifiersProp.flags & 16777216);
43419                         var isReadonly = !!(templateModifiers & 1 ||
43420                             !(templateModifiers & 2) && modifiersProp && isReadonlySymbol(modifiersProp));
43421                         var stripOptional = strictNullChecks && !isOptional && modifiersProp && modifiersProp.flags & 16777216;
43422                         var prop = createSymbol(4 | (isOptional ? 16777216 : 0), propName, 262144 | (isReadonly ? 8 : 0) | (stripOptional ? 524288 : 0));
43423                         prop.mappedType = type;
43424                         prop.nameType = propNameType;
43425                         prop.keyType = keyType;
43426                         if (modifiersProp) {
43427                             prop.syntheticOrigin = modifiersProp;
43428                             prop.declarations = modifiersProp.declarations;
43429                         }
43430                         members.set(propName, prop);
43431                     }
43432                 }
43433                 else if (propNameType.flags & (1 | 4 | 8 | 32)) {
43434                     var propType = instantiateType(templateType, appendTypeMapping(type.mapper, typeParameter, keyType));
43435                     if (propNameType.flags & (1 | 4)) {
43436                         stringIndexInfo = createIndexInfo(stringIndexInfo ? getUnionType([stringIndexInfo.type, propType]) : propType, !!(templateModifiers & 1));
43437                     }
43438                     else {
43439                         numberIndexInfo = createIndexInfo(numberIndexInfo ? getUnionType([numberIndexInfo.type, propType]) : propType, !!(templateModifiers & 1));
43440                     }
43441                 }
43442             }
43443         }
43444         function getTypeOfMappedSymbol(symbol) {
43445             if (!symbol.type) {
43446                 var mappedType = symbol.mappedType;
43447                 if (!pushTypeResolution(symbol, 0)) {
43448                     mappedType.containsError = true;
43449                     return errorType;
43450                 }
43451                 var templateType = getTemplateTypeFromMappedType(mappedType.target || mappedType);
43452                 var mapper = appendTypeMapping(mappedType.mapper, getTypeParameterFromMappedType(mappedType), symbol.keyType);
43453                 var propType = instantiateType(templateType, mapper);
43454                 var type = strictNullChecks && symbol.flags & 16777216 && !maybeTypeOfKind(propType, 32768 | 16384) ? getOptionalType(propType) :
43455                     symbol.checkFlags & 524288 ? getTypeWithFacts(propType, 524288) :
43456                         propType;
43457                 if (!popTypeResolution()) {
43458                     error(currentNode, ts.Diagnostics.Type_of_property_0_circularly_references_itself_in_mapped_type_1, symbolToString(symbol), typeToString(mappedType));
43459                     type = errorType;
43460                 }
43461                 symbol.type = type;
43462             }
43463             return symbol.type;
43464         }
43465         function getTypeParameterFromMappedType(type) {
43466             return type.typeParameter ||
43467                 (type.typeParameter = getDeclaredTypeOfTypeParameter(getSymbolOfNode(type.declaration.typeParameter)));
43468         }
43469         function getConstraintTypeFromMappedType(type) {
43470             return type.constraintType ||
43471                 (type.constraintType = getConstraintOfTypeParameter(getTypeParameterFromMappedType(type)) || errorType);
43472         }
43473         function getNameTypeFromMappedType(type) {
43474             return type.declaration.nameType ?
43475                 type.nameType || (type.nameType = instantiateType(getTypeFromTypeNode(type.declaration.nameType), type.mapper)) :
43476                 undefined;
43477         }
43478         function getTemplateTypeFromMappedType(type) {
43479             return type.templateType ||
43480                 (type.templateType = type.declaration.type ?
43481                     instantiateType(addOptionality(getTypeFromTypeNode(type.declaration.type), !!(getMappedTypeModifiers(type) & 4)), type.mapper) :
43482                     errorType);
43483         }
43484         function getConstraintDeclarationForMappedType(type) {
43485             return ts.getEffectiveConstraintOfTypeParameter(type.declaration.typeParameter);
43486         }
43487         function isMappedTypeWithKeyofConstraintDeclaration(type) {
43488             var constraintDeclaration = getConstraintDeclarationForMappedType(type);
43489             return constraintDeclaration.kind === 188 &&
43490                 constraintDeclaration.operator === 138;
43491         }
43492         function getModifiersTypeFromMappedType(type) {
43493             if (!type.modifiersType) {
43494                 if (isMappedTypeWithKeyofConstraintDeclaration(type)) {
43495                     type.modifiersType = instantiateType(getTypeFromTypeNode(getConstraintDeclarationForMappedType(type).type), type.mapper);
43496                 }
43497                 else {
43498                     var declaredType = getTypeFromMappedTypeNode(type.declaration);
43499                     var constraint = getConstraintTypeFromMappedType(declaredType);
43500                     var extendedConstraint = constraint && constraint.flags & 262144 ? getConstraintOfTypeParameter(constraint) : constraint;
43501                     type.modifiersType = extendedConstraint && extendedConstraint.flags & 4194304 ? instantiateType(extendedConstraint.type, type.mapper) : unknownType;
43502                 }
43503             }
43504             return type.modifiersType;
43505         }
43506         function getMappedTypeModifiers(type) {
43507             var declaration = type.declaration;
43508             return (declaration.readonlyToken ? declaration.readonlyToken.kind === 40 ? 2 : 1 : 0) |
43509                 (declaration.questionToken ? declaration.questionToken.kind === 40 ? 8 : 4 : 0);
43510         }
43511         function getMappedTypeOptionality(type) {
43512             var modifiers = getMappedTypeModifiers(type);
43513             return modifiers & 8 ? -1 : modifiers & 4 ? 1 : 0;
43514         }
43515         function getCombinedMappedTypeOptionality(type) {
43516             var optionality = getMappedTypeOptionality(type);
43517             var modifiersType = getModifiersTypeFromMappedType(type);
43518             return optionality || (isGenericMappedType(modifiersType) ? getMappedTypeOptionality(modifiersType) : 0);
43519         }
43520         function isPartialMappedType(type) {
43521             return !!(ts.getObjectFlags(type) & 32 && getMappedTypeModifiers(type) & 4);
43522         }
43523         function isGenericMappedType(type) {
43524             return !!(ts.getObjectFlags(type) & 32) && isGenericIndexType(getConstraintTypeFromMappedType(type));
43525         }
43526         function resolveStructuredTypeMembers(type) {
43527             if (!type.members) {
43528                 if (type.flags & 524288) {
43529                     if (type.objectFlags & 4) {
43530                         resolveTypeReferenceMembers(type);
43531                     }
43532                     else if (type.objectFlags & 3) {
43533                         resolveClassOrInterfaceMembers(type);
43534                     }
43535                     else if (type.objectFlags & 2048) {
43536                         resolveReverseMappedTypeMembers(type);
43537                     }
43538                     else if (type.objectFlags & 16) {
43539                         resolveAnonymousTypeMembers(type);
43540                     }
43541                     else if (type.objectFlags & 32) {
43542                         resolveMappedTypeMembers(type);
43543                     }
43544                 }
43545                 else if (type.flags & 1048576) {
43546                     resolveUnionTypeMembers(type);
43547                 }
43548                 else if (type.flags & 2097152) {
43549                     resolveIntersectionTypeMembers(type);
43550                 }
43551             }
43552             return type;
43553         }
43554         function getPropertiesOfObjectType(type) {
43555             if (type.flags & 524288) {
43556                 return resolveStructuredTypeMembers(type).properties;
43557             }
43558             return ts.emptyArray;
43559         }
43560         function getPropertyOfObjectType(type, name) {
43561             if (type.flags & 524288) {
43562                 var resolved = resolveStructuredTypeMembers(type);
43563                 var symbol = resolved.members.get(name);
43564                 if (symbol && symbolIsValue(symbol)) {
43565                     return symbol;
43566                 }
43567             }
43568         }
43569         function getPropertiesOfUnionOrIntersectionType(type) {
43570             if (!type.resolvedProperties) {
43571                 var members = ts.createSymbolTable();
43572                 for (var _i = 0, _a = type.types; _i < _a.length; _i++) {
43573                     var current = _a[_i];
43574                     for (var _b = 0, _c = getPropertiesOfType(current); _b < _c.length; _b++) {
43575                         var prop = _c[_b];
43576                         if (!members.has(prop.escapedName)) {
43577                             var combinedProp = getPropertyOfUnionOrIntersectionType(type, prop.escapedName);
43578                             if (combinedProp) {
43579                                 members.set(prop.escapedName, combinedProp);
43580                             }
43581                         }
43582                     }
43583                     if (type.flags & 1048576 && !getIndexInfoOfType(current, 0) && !getIndexInfoOfType(current, 1)) {
43584                         break;
43585                     }
43586                 }
43587                 type.resolvedProperties = getNamedMembers(members);
43588             }
43589             return type.resolvedProperties;
43590         }
43591         function getPropertiesOfType(type) {
43592             type = getReducedApparentType(type);
43593             return type.flags & 3145728 ?
43594                 getPropertiesOfUnionOrIntersectionType(type) :
43595                 getPropertiesOfObjectType(type);
43596         }
43597         function isTypeInvalidDueToUnionDiscriminant(contextualType, obj) {
43598             var list = obj.properties;
43599             return list.some(function (property) {
43600                 var nameType = property.name && getLiteralTypeFromPropertyName(property.name);
43601                 var name = nameType && isTypeUsableAsPropertyName(nameType) ? getPropertyNameFromType(nameType) : undefined;
43602                 var expected = name === undefined ? undefined : getTypeOfPropertyOfType(contextualType, name);
43603                 return !!expected && isLiteralType(expected) && !isTypeAssignableTo(getTypeOfNode(property), expected);
43604             });
43605         }
43606         function getAllPossiblePropertiesOfTypes(types) {
43607             var unionType = getUnionType(types);
43608             if (!(unionType.flags & 1048576)) {
43609                 return getAugmentedPropertiesOfType(unionType);
43610             }
43611             var props = ts.createSymbolTable();
43612             for (var _i = 0, types_5 = types; _i < types_5.length; _i++) {
43613                 var memberType = types_5[_i];
43614                 for (var _a = 0, _b = getAugmentedPropertiesOfType(memberType); _a < _b.length; _a++) {
43615                     var escapedName = _b[_a].escapedName;
43616                     if (!props.has(escapedName)) {
43617                         var prop = createUnionOrIntersectionProperty(unionType, escapedName);
43618                         if (prop)
43619                             props.set(escapedName, prop);
43620                     }
43621                 }
43622             }
43623             return ts.arrayFrom(props.values());
43624         }
43625         function getConstraintOfType(type) {
43626             return type.flags & 262144 ? getConstraintOfTypeParameter(type) :
43627                 type.flags & 8388608 ? getConstraintOfIndexedAccess(type) :
43628                     type.flags & 16777216 ? getConstraintOfConditionalType(type) :
43629                         getBaseConstraintOfType(type);
43630         }
43631         function getConstraintOfTypeParameter(typeParameter) {
43632             return hasNonCircularBaseConstraint(typeParameter) ? getConstraintFromTypeParameter(typeParameter) : undefined;
43633         }
43634         function getConstraintOfIndexedAccess(type) {
43635             return hasNonCircularBaseConstraint(type) ? getConstraintFromIndexedAccess(type) : undefined;
43636         }
43637         function getSimplifiedTypeOrConstraint(type) {
43638             var simplified = getSimplifiedType(type, false);
43639             return simplified !== type ? simplified : getConstraintOfType(type);
43640         }
43641         function getConstraintFromIndexedAccess(type) {
43642             var indexConstraint = getSimplifiedTypeOrConstraint(type.indexType);
43643             if (indexConstraint && indexConstraint !== type.indexType) {
43644                 var indexedAccess = getIndexedAccessTypeOrUndefined(type.objectType, indexConstraint, type.noUncheckedIndexedAccessCandidate);
43645                 if (indexedAccess) {
43646                     return indexedAccess;
43647                 }
43648             }
43649             var objectConstraint = getSimplifiedTypeOrConstraint(type.objectType);
43650             if (objectConstraint && objectConstraint !== type.objectType) {
43651                 return getIndexedAccessTypeOrUndefined(objectConstraint, type.indexType, type.noUncheckedIndexedAccessCandidate);
43652             }
43653             return undefined;
43654         }
43655         function getDefaultConstraintOfConditionalType(type) {
43656             if (!type.resolvedDefaultConstraint) {
43657                 var trueConstraint = getInferredTrueTypeFromConditionalType(type);
43658                 var falseConstraint = getFalseTypeFromConditionalType(type);
43659                 type.resolvedDefaultConstraint = isTypeAny(trueConstraint) ? falseConstraint : isTypeAny(falseConstraint) ? trueConstraint : getUnionType([trueConstraint, falseConstraint]);
43660             }
43661             return type.resolvedDefaultConstraint;
43662         }
43663         function getConstraintOfDistributiveConditionalType(type) {
43664             if (type.root.isDistributive && type.restrictiveInstantiation !== type) {
43665                 var simplified = getSimplifiedType(type.checkType, false);
43666                 var constraint = simplified === type.checkType ? getConstraintOfType(simplified) : simplified;
43667                 if (constraint && constraint !== type.checkType) {
43668                     var instantiated = getConditionalTypeInstantiation(type, prependTypeMapping(type.root.checkType, constraint, type.mapper));
43669                     if (!(instantiated.flags & 131072)) {
43670                         return instantiated;
43671                     }
43672                 }
43673             }
43674             return undefined;
43675         }
43676         function getConstraintFromConditionalType(type) {
43677             return getConstraintOfDistributiveConditionalType(type) || getDefaultConstraintOfConditionalType(type);
43678         }
43679         function getConstraintOfConditionalType(type) {
43680             return hasNonCircularBaseConstraint(type) ? getConstraintFromConditionalType(type) : undefined;
43681         }
43682         function getEffectiveConstraintOfIntersection(types, targetIsUnion) {
43683             var constraints;
43684             var hasDisjointDomainType = false;
43685             for (var _i = 0, types_6 = types; _i < types_6.length; _i++) {
43686                 var t = types_6[_i];
43687                 if (t.flags & 465829888) {
43688                     var constraint = getConstraintOfType(t);
43689                     while (constraint && constraint.flags & (262144 | 4194304 | 16777216)) {
43690                         constraint = getConstraintOfType(constraint);
43691                     }
43692                     if (constraint) {
43693                         constraints = ts.append(constraints, constraint);
43694                         if (targetIsUnion) {
43695                             constraints = ts.append(constraints, t);
43696                         }
43697                     }
43698                 }
43699                 else if (t.flags & 469892092) {
43700                     hasDisjointDomainType = true;
43701                 }
43702             }
43703             if (constraints && (targetIsUnion || hasDisjointDomainType)) {
43704                 if (hasDisjointDomainType) {
43705                     for (var _a = 0, types_7 = types; _a < types_7.length; _a++) {
43706                         var t = types_7[_a];
43707                         if (t.flags & 469892092) {
43708                             constraints = ts.append(constraints, t);
43709                         }
43710                     }
43711                 }
43712                 return getIntersectionType(constraints);
43713             }
43714             return undefined;
43715         }
43716         function getBaseConstraintOfType(type) {
43717             if (type.flags & (58982400 | 3145728 | 134217728 | 268435456)) {
43718                 var constraint = getResolvedBaseConstraint(type);
43719                 return constraint !== noConstraintType && constraint !== circularConstraintType ? constraint : undefined;
43720             }
43721             return type.flags & 4194304 ? keyofConstraintType : undefined;
43722         }
43723         function getBaseConstraintOrType(type) {
43724             return getBaseConstraintOfType(type) || type;
43725         }
43726         function hasNonCircularBaseConstraint(type) {
43727             return getResolvedBaseConstraint(type) !== circularConstraintType;
43728         }
43729         function getResolvedBaseConstraint(type) {
43730             if (type.resolvedBaseConstraint) {
43731                 return type.resolvedBaseConstraint;
43732             }
43733             var nonTerminating = false;
43734             var stack = [];
43735             return type.resolvedBaseConstraint = getTypeWithThisArgument(getImmediateBaseConstraint(type), type);
43736             function getImmediateBaseConstraint(t) {
43737                 if (!t.immediateBaseConstraint) {
43738                     if (!pushTypeResolution(t, 4)) {
43739                         return circularConstraintType;
43740                     }
43741                     if (constraintDepth >= 50) {
43742                         ts.tracing.instant("check", "getImmediateBaseConstraint_DepthLimit", { typeId: t.id, originalTypeId: type.id, depth: constraintDepth });
43743                         error(currentNode, ts.Diagnostics.Type_instantiation_is_excessively_deep_and_possibly_infinite);
43744                         nonTerminating = true;
43745                         return t.immediateBaseConstraint = noConstraintType;
43746                     }
43747                     var result = void 0;
43748                     if (!isDeeplyNestedType(t, stack, stack.length)) {
43749                         stack.push(t);
43750                         constraintDepth++;
43751                         result = computeBaseConstraint(getSimplifiedType(t, false));
43752                         constraintDepth--;
43753                         stack.pop();
43754                     }
43755                     if (!popTypeResolution()) {
43756                         if (t.flags & 262144) {
43757                             var errorNode = getConstraintDeclaration(t);
43758                             if (errorNode) {
43759                                 var diagnostic = error(errorNode, ts.Diagnostics.Type_parameter_0_has_a_circular_constraint, typeToString(t));
43760                                 if (currentNode && !ts.isNodeDescendantOf(errorNode, currentNode) && !ts.isNodeDescendantOf(currentNode, errorNode)) {
43761                                     ts.addRelatedInfo(diagnostic, ts.createDiagnosticForNode(currentNode, ts.Diagnostics.Circularity_originates_in_type_at_this_location));
43762                                 }
43763                             }
43764                         }
43765                         result = circularConstraintType;
43766                     }
43767                     if (nonTerminating) {
43768                         result = circularConstraintType;
43769                     }
43770                     t.immediateBaseConstraint = result || noConstraintType;
43771                 }
43772                 return t.immediateBaseConstraint;
43773             }
43774             function getBaseConstraint(t) {
43775                 var c = getImmediateBaseConstraint(t);
43776                 return c !== noConstraintType && c !== circularConstraintType ? c : undefined;
43777             }
43778             function computeBaseConstraint(t) {
43779                 if (t.flags & 262144) {
43780                     var constraint = getConstraintFromTypeParameter(t);
43781                     return t.isThisType || !constraint ?
43782                         constraint :
43783                         getBaseConstraint(constraint);
43784                 }
43785                 if (t.flags & 3145728) {
43786                     var types = t.types;
43787                     var baseTypes = [];
43788                     for (var _i = 0, types_8 = types; _i < types_8.length; _i++) {
43789                         var type_3 = types_8[_i];
43790                         var baseType = getBaseConstraint(type_3);
43791                         if (baseType) {
43792                             baseTypes.push(baseType);
43793                         }
43794                     }
43795                     return t.flags & 1048576 && baseTypes.length === types.length ? getUnionType(baseTypes) :
43796                         t.flags & 2097152 && baseTypes.length ? getIntersectionType(baseTypes) :
43797                             undefined;
43798                 }
43799                 if (t.flags & 4194304) {
43800                     return keyofConstraintType;
43801                 }
43802                 if (t.flags & 134217728) {
43803                     var types = t.types;
43804                     var constraints = ts.mapDefined(types, getBaseConstraint);
43805                     return constraints.length === types.length ? getTemplateLiteralType(t.texts, constraints) : stringType;
43806                 }
43807                 if (t.flags & 268435456) {
43808                     var constraint = getBaseConstraint(t.type);
43809                     return constraint ? getStringMappingType(t.symbol, constraint) : stringType;
43810                 }
43811                 if (t.flags & 8388608) {
43812                     var baseObjectType = getBaseConstraint(t.objectType);
43813                     var baseIndexType = getBaseConstraint(t.indexType);
43814                     var baseIndexedAccess = baseObjectType && baseIndexType && getIndexedAccessTypeOrUndefined(baseObjectType, baseIndexType, t.noUncheckedIndexedAccessCandidate);
43815                     return baseIndexedAccess && getBaseConstraint(baseIndexedAccess);
43816                 }
43817                 if (t.flags & 16777216) {
43818                     var constraint = getConstraintFromConditionalType(t);
43819                     constraintDepth++;
43820                     var result = constraint && getBaseConstraint(constraint);
43821                     constraintDepth--;
43822                     return result;
43823                 }
43824                 if (t.flags & 33554432) {
43825                     return getBaseConstraint(t.substitute);
43826                 }
43827                 return t;
43828             }
43829         }
43830         function getApparentTypeOfIntersectionType(type) {
43831             return type.resolvedApparentType || (type.resolvedApparentType = getTypeWithThisArgument(type, type, true));
43832         }
43833         function getResolvedTypeParameterDefault(typeParameter) {
43834             if (!typeParameter.default) {
43835                 if (typeParameter.target) {
43836                     var targetDefault = getResolvedTypeParameterDefault(typeParameter.target);
43837                     typeParameter.default = targetDefault ? instantiateType(targetDefault, typeParameter.mapper) : noConstraintType;
43838                 }
43839                 else {
43840                     typeParameter.default = resolvingDefaultType;
43841                     var defaultDeclaration = typeParameter.symbol && ts.forEach(typeParameter.symbol.declarations, function (decl) { return ts.isTypeParameterDeclaration(decl) && decl.default; });
43842                     var defaultType = defaultDeclaration ? getTypeFromTypeNode(defaultDeclaration) : noConstraintType;
43843                     if (typeParameter.default === resolvingDefaultType) {
43844                         typeParameter.default = defaultType;
43845                     }
43846                 }
43847             }
43848             else if (typeParameter.default === resolvingDefaultType) {
43849                 typeParameter.default = circularConstraintType;
43850             }
43851             return typeParameter.default;
43852         }
43853         function getDefaultFromTypeParameter(typeParameter) {
43854             var defaultType = getResolvedTypeParameterDefault(typeParameter);
43855             return defaultType !== noConstraintType && defaultType !== circularConstraintType ? defaultType : undefined;
43856         }
43857         function hasNonCircularTypeParameterDefault(typeParameter) {
43858             return getResolvedTypeParameterDefault(typeParameter) !== circularConstraintType;
43859         }
43860         function hasTypeParameterDefault(typeParameter) {
43861             return !!(typeParameter.symbol && ts.forEach(typeParameter.symbol.declarations, function (decl) { return ts.isTypeParameterDeclaration(decl) && decl.default; }));
43862         }
43863         function getApparentTypeOfMappedType(type) {
43864             return type.resolvedApparentType || (type.resolvedApparentType = getResolvedApparentTypeOfMappedType(type));
43865         }
43866         function getResolvedApparentTypeOfMappedType(type) {
43867             var typeVariable = getHomomorphicTypeVariable(type);
43868             if (typeVariable && !type.declaration.nameType) {
43869                 var constraint = getConstraintOfTypeParameter(typeVariable);
43870                 if (constraint && (isArrayType(constraint) || isTupleType(constraint))) {
43871                     return instantiateType(type, prependTypeMapping(typeVariable, constraint, type.mapper));
43872                 }
43873             }
43874             return type;
43875         }
43876         function getApparentType(type) {
43877             var t = type.flags & 465829888 ? getBaseConstraintOfType(type) || unknownType : type;
43878             return ts.getObjectFlags(t) & 32 ? getApparentTypeOfMappedType(t) :
43879                 t.flags & 2097152 ? getApparentTypeOfIntersectionType(t) :
43880                     t.flags & 402653316 ? globalStringType :
43881                         t.flags & 296 ? globalNumberType :
43882                             t.flags & 2112 ? getGlobalBigIntType(languageVersion >= 7) :
43883                                 t.flags & 528 ? globalBooleanType :
43884                                     t.flags & 12288 ? getGlobalESSymbolType(languageVersion >= 2) :
43885                                         t.flags & 67108864 ? emptyObjectType :
43886                                             t.flags & 4194304 ? keyofConstraintType :
43887                                                 t.flags & 2 && !strictNullChecks ? emptyObjectType :
43888                                                     t;
43889         }
43890         function getReducedApparentType(type) {
43891             return getReducedType(getApparentType(getReducedType(type)));
43892         }
43893         function createUnionOrIntersectionProperty(containingType, name) {
43894             var singleProp;
43895             var propSet;
43896             var indexTypes;
43897             var isUnion = containingType.flags & 1048576;
43898             var optionalFlag = isUnion ? 0 : 16777216;
43899             var syntheticFlag = 4;
43900             var checkFlags = 0;
43901             for (var _i = 0, _a = containingType.types; _i < _a.length; _i++) {
43902                 var current = _a[_i];
43903                 var type = getApparentType(current);
43904                 if (!(type === errorType || type.flags & 131072)) {
43905                     var prop = getPropertyOfType(type, name);
43906                     var modifiers = prop ? ts.getDeclarationModifierFlagsFromSymbol(prop) : 0;
43907                     if (prop) {
43908                         if (isUnion) {
43909                             optionalFlag |= (prop.flags & 16777216);
43910                         }
43911                         else {
43912                             optionalFlag &= prop.flags;
43913                         }
43914                         if (!singleProp) {
43915                             singleProp = prop;
43916                         }
43917                         else if (prop !== singleProp) {
43918                             if (!propSet) {
43919                                 propSet = new ts.Map();
43920                                 propSet.set(getSymbolId(singleProp), singleProp);
43921                             }
43922                             var id = getSymbolId(prop);
43923                             if (!propSet.has(id)) {
43924                                 propSet.set(id, prop);
43925                             }
43926                         }
43927                         checkFlags |= (isReadonlySymbol(prop) ? 8 : 0) |
43928                             (!(modifiers & 24) ? 256 : 0) |
43929                             (modifiers & 16 ? 512 : 0) |
43930                             (modifiers & 8 ? 1024 : 0) |
43931                             (modifiers & 32 ? 2048 : 0);
43932                         if (!isPrototypeProperty(prop)) {
43933                             syntheticFlag = 2;
43934                         }
43935                     }
43936                     else if (isUnion) {
43937                         var indexInfo = !isLateBoundName(name) && (isNumericLiteralName(name) && getIndexInfoOfType(type, 1) || getIndexInfoOfType(type, 0));
43938                         if (indexInfo) {
43939                             checkFlags |= 32 | (indexInfo.isReadonly ? 8 : 0);
43940                             indexTypes = ts.append(indexTypes, isTupleType(type) ? getRestTypeOfTupleType(type) || undefinedType : indexInfo.type);
43941                         }
43942                         else if (isObjectLiteralType(type)) {
43943                             checkFlags |= 32;
43944                             indexTypes = ts.append(indexTypes, undefinedType);
43945                         }
43946                         else {
43947                             checkFlags |= 16;
43948                         }
43949                     }
43950                 }
43951             }
43952             if (!singleProp || isUnion && (propSet || checkFlags & 48) && checkFlags & (1024 | 512)) {
43953                 return undefined;
43954             }
43955             if (!propSet && !(checkFlags & 16) && !indexTypes) {
43956                 return singleProp;
43957             }
43958             var props = propSet ? ts.arrayFrom(propSet.values()) : [singleProp];
43959             var declarations;
43960             var firstType;
43961             var nameType;
43962             var propTypes = [];
43963             var firstValueDeclaration;
43964             var hasNonUniformValueDeclaration = false;
43965             for (var _b = 0, props_1 = props; _b < props_1.length; _b++) {
43966                 var prop = props_1[_b];
43967                 if (!firstValueDeclaration) {
43968                     firstValueDeclaration = prop.valueDeclaration;
43969                 }
43970                 else if (prop.valueDeclaration && prop.valueDeclaration !== firstValueDeclaration) {
43971                     hasNonUniformValueDeclaration = true;
43972                 }
43973                 declarations = ts.addRange(declarations, prop.declarations);
43974                 var type = getTypeOfSymbol(prop);
43975                 if (!firstType) {
43976                     firstType = type;
43977                     nameType = getSymbolLinks(prop).nameType;
43978                 }
43979                 else if (type !== firstType) {
43980                     checkFlags |= 64;
43981                 }
43982                 if (isLiteralType(type)) {
43983                     checkFlags |= 128;
43984                 }
43985                 if (type.flags & 131072) {
43986                     checkFlags |= 131072;
43987                 }
43988                 propTypes.push(type);
43989             }
43990             ts.addRange(propTypes, indexTypes);
43991             var result = createSymbol(4 | optionalFlag, name, syntheticFlag | checkFlags);
43992             result.containingType = containingType;
43993             if (!hasNonUniformValueDeclaration && firstValueDeclaration) {
43994                 result.valueDeclaration = firstValueDeclaration;
43995                 if (firstValueDeclaration.symbol.parent) {
43996                     result.parent = firstValueDeclaration.symbol.parent;
43997                 }
43998             }
43999             result.declarations = declarations;
44000             result.nameType = nameType;
44001             if (propTypes.length > 2) {
44002                 result.checkFlags |= 65536;
44003                 result.deferralParent = containingType;
44004                 result.deferralConstituents = propTypes;
44005             }
44006             else {
44007                 result.type = isUnion ? getUnionType(propTypes) : getIntersectionType(propTypes);
44008             }
44009             return result;
44010         }
44011         function getUnionOrIntersectionProperty(type, name) {
44012             var properties = type.propertyCache || (type.propertyCache = ts.createSymbolTable());
44013             var property = properties.get(name);
44014             if (!property) {
44015                 property = createUnionOrIntersectionProperty(type, name);
44016                 if (property) {
44017                     properties.set(name, property);
44018                 }
44019             }
44020             return property;
44021         }
44022         function getPropertyOfUnionOrIntersectionType(type, name) {
44023             var property = getUnionOrIntersectionProperty(type, name);
44024             return property && !(ts.getCheckFlags(property) & 16) ? property : undefined;
44025         }
44026         function getReducedType(type) {
44027             if (type.flags & 1048576 && type.objectFlags & 268435456) {
44028                 return type.resolvedReducedType || (type.resolvedReducedType = getReducedUnionType(type));
44029             }
44030             else if (type.flags & 2097152) {
44031                 if (!(type.objectFlags & 268435456)) {
44032                     type.objectFlags |= 268435456 |
44033                         (ts.some(getPropertiesOfUnionOrIntersectionType(type), isNeverReducedProperty) ? 536870912 : 0);
44034                 }
44035                 return type.objectFlags & 536870912 ? neverType : type;
44036             }
44037             return type;
44038         }
44039         function getReducedUnionType(unionType) {
44040             var reducedTypes = ts.sameMap(unionType.types, getReducedType);
44041             if (reducedTypes === unionType.types) {
44042                 return unionType;
44043             }
44044             var reduced = getUnionType(reducedTypes);
44045             if (reduced.flags & 1048576) {
44046                 reduced.resolvedReducedType = reduced;
44047             }
44048             return reduced;
44049         }
44050         function isNeverReducedProperty(prop) {
44051             return isDiscriminantWithNeverType(prop) || isConflictingPrivateProperty(prop);
44052         }
44053         function isDiscriminantWithNeverType(prop) {
44054             return !(prop.flags & 16777216) &&
44055                 (ts.getCheckFlags(prop) & (192 | 131072)) === 192 &&
44056                 !!(getTypeOfSymbol(prop).flags & 131072);
44057         }
44058         function isConflictingPrivateProperty(prop) {
44059             return !prop.valueDeclaration && !!(ts.getCheckFlags(prop) & 1024);
44060         }
44061         function elaborateNeverIntersection(errorInfo, type) {
44062             if (ts.getObjectFlags(type) & 536870912) {
44063                 var neverProp = ts.find(getPropertiesOfUnionOrIntersectionType(type), isDiscriminantWithNeverType);
44064                 if (neverProp) {
44065                     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));
44066                 }
44067                 var privateProp = ts.find(getPropertiesOfUnionOrIntersectionType(type), isConflictingPrivateProperty);
44068                 if (privateProp) {
44069                     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));
44070                 }
44071             }
44072             return errorInfo;
44073         }
44074         function getPropertyOfType(type, name) {
44075             type = getReducedApparentType(type);
44076             if (type.flags & 524288) {
44077                 var resolved = resolveStructuredTypeMembers(type);
44078                 var symbol = resolved.members.get(name);
44079                 if (symbol && symbolIsValue(symbol)) {
44080                     return symbol;
44081                 }
44082                 var functionType = resolved === anyFunctionType ? globalFunctionType :
44083                     resolved.callSignatures.length ? globalCallableFunctionType :
44084                         resolved.constructSignatures.length ? globalNewableFunctionType :
44085                             undefined;
44086                 if (functionType) {
44087                     var symbol_1 = getPropertyOfObjectType(functionType, name);
44088                     if (symbol_1) {
44089                         return symbol_1;
44090                     }
44091                 }
44092                 return getPropertyOfObjectType(globalObjectType, name);
44093             }
44094             if (type.flags & 3145728) {
44095                 return getPropertyOfUnionOrIntersectionType(type, name);
44096             }
44097             return undefined;
44098         }
44099         function getSignaturesOfStructuredType(type, kind) {
44100             if (type.flags & 3670016) {
44101                 var resolved = resolveStructuredTypeMembers(type);
44102                 return kind === 0 ? resolved.callSignatures : resolved.constructSignatures;
44103             }
44104             return ts.emptyArray;
44105         }
44106         function getSignaturesOfType(type, kind) {
44107             return getSignaturesOfStructuredType(getReducedApparentType(type), kind);
44108         }
44109         function getIndexInfoOfStructuredType(type, kind) {
44110             if (type.flags & 3670016) {
44111                 var resolved = resolveStructuredTypeMembers(type);
44112                 return kind === 0 ? resolved.stringIndexInfo : resolved.numberIndexInfo;
44113             }
44114         }
44115         function getIndexTypeOfStructuredType(type, kind) {
44116             var info = getIndexInfoOfStructuredType(type, kind);
44117             return info && info.type;
44118         }
44119         function getIndexInfoOfType(type, kind) {
44120             return getIndexInfoOfStructuredType(getReducedApparentType(type), kind);
44121         }
44122         function getIndexTypeOfType(type, kind) {
44123             return getIndexTypeOfStructuredType(getReducedApparentType(type), kind);
44124         }
44125         function getImplicitIndexTypeOfType(type, kind) {
44126             if (isObjectTypeWithInferableIndex(type)) {
44127                 var propTypes = [];
44128                 for (var _i = 0, _a = getPropertiesOfType(type); _i < _a.length; _i++) {
44129                     var prop = _a[_i];
44130                     if (kind === 0 || isNumericLiteralName(prop.escapedName)) {
44131                         propTypes.push(getTypeOfSymbol(prop));
44132                     }
44133                 }
44134                 if (kind === 0) {
44135                     ts.append(propTypes, getIndexTypeOfType(type, 1));
44136                 }
44137                 if (propTypes.length) {
44138                     return getUnionType(propTypes);
44139                 }
44140             }
44141             return undefined;
44142         }
44143         function getTypeParametersFromDeclaration(declaration) {
44144             var result;
44145             for (var _i = 0, _a = ts.getEffectiveTypeParameterDeclarations(declaration); _i < _a.length; _i++) {
44146                 var node = _a[_i];
44147                 result = ts.appendIfUnique(result, getDeclaredTypeOfTypeParameter(node.symbol));
44148             }
44149             return result;
44150         }
44151         function symbolsToArray(symbols) {
44152             var result = [];
44153             symbols.forEach(function (symbol, id) {
44154                 if (!isReservedMemberName(id)) {
44155                     result.push(symbol);
44156                 }
44157             });
44158             return result;
44159         }
44160         function isJSDocOptionalParameter(node) {
44161             return ts.isInJSFile(node) && (node.type && node.type.kind === 307
44162                 || ts.getJSDocParameterTags(node).some(function (_a) {
44163                     var isBracketed = _a.isBracketed, typeExpression = _a.typeExpression;
44164                     return isBracketed || !!typeExpression && typeExpression.type.kind === 307;
44165                 }));
44166         }
44167         function tryFindAmbientModule(moduleName, withAugmentations) {
44168             if (ts.isExternalModuleNameRelative(moduleName)) {
44169                 return undefined;
44170             }
44171             var symbol = getSymbol(globals, '"' + moduleName + '"', 512);
44172             return symbol && withAugmentations ? getMergedSymbol(symbol) : symbol;
44173         }
44174         function isOptionalParameter(node) {
44175             if (ts.hasQuestionToken(node) || isOptionalJSDocPropertyLikeTag(node) || isJSDocOptionalParameter(node)) {
44176                 return true;
44177             }
44178             if (node.initializer) {
44179                 var signature = getSignatureFromDeclaration(node.parent);
44180                 var parameterIndex = node.parent.parameters.indexOf(node);
44181                 ts.Debug.assert(parameterIndex >= 0);
44182                 return parameterIndex >= getMinArgumentCount(signature, 1 | 2);
44183             }
44184             var iife = ts.getImmediatelyInvokedFunctionExpression(node.parent);
44185             if (iife) {
44186                 return !node.type &&
44187                     !node.dotDotDotToken &&
44188                     node.parent.parameters.indexOf(node) >= iife.arguments.length;
44189             }
44190             return false;
44191         }
44192         function isOptionalJSDocPropertyLikeTag(node) {
44193             if (!ts.isJSDocPropertyLikeTag(node)) {
44194                 return false;
44195             }
44196             var isBracketed = node.isBracketed, typeExpression = node.typeExpression;
44197             return isBracketed || !!typeExpression && typeExpression.type.kind === 307;
44198         }
44199         function createTypePredicate(kind, parameterName, parameterIndex, type) {
44200             return { kind: kind, parameterName: parameterName, parameterIndex: parameterIndex, type: type };
44201         }
44202         function getMinTypeArgumentCount(typeParameters) {
44203             var minTypeArgumentCount = 0;
44204             if (typeParameters) {
44205                 for (var i = 0; i < typeParameters.length; i++) {
44206                     if (!hasTypeParameterDefault(typeParameters[i])) {
44207                         minTypeArgumentCount = i + 1;
44208                     }
44209                 }
44210             }
44211             return minTypeArgumentCount;
44212         }
44213         function fillMissingTypeArguments(typeArguments, typeParameters, minTypeArgumentCount, isJavaScriptImplicitAny) {
44214             var numTypeParameters = ts.length(typeParameters);
44215             if (!numTypeParameters) {
44216                 return [];
44217             }
44218             var numTypeArguments = ts.length(typeArguments);
44219             if (isJavaScriptImplicitAny || (numTypeArguments >= minTypeArgumentCount && numTypeArguments <= numTypeParameters)) {
44220                 var result = typeArguments ? typeArguments.slice() : [];
44221                 for (var i = numTypeArguments; i < numTypeParameters; i++) {
44222                     result[i] = errorType;
44223                 }
44224                 var baseDefaultType = getDefaultTypeArgumentType(isJavaScriptImplicitAny);
44225                 for (var i = numTypeArguments; i < numTypeParameters; i++) {
44226                     var defaultType = getDefaultFromTypeParameter(typeParameters[i]);
44227                     if (isJavaScriptImplicitAny && defaultType && (isTypeIdenticalTo(defaultType, unknownType) || isTypeIdenticalTo(defaultType, emptyObjectType))) {
44228                         defaultType = anyType;
44229                     }
44230                     result[i] = defaultType ? instantiateType(defaultType, createTypeMapper(typeParameters, result)) : baseDefaultType;
44231                 }
44232                 result.length = typeParameters.length;
44233                 return result;
44234             }
44235             return typeArguments && typeArguments.slice();
44236         }
44237         function getSignatureFromDeclaration(declaration) {
44238             var links = getNodeLinks(declaration);
44239             if (!links.resolvedSignature) {
44240                 var parameters = [];
44241                 var flags = 0;
44242                 var minArgumentCount = 0;
44243                 var thisParameter = void 0;
44244                 var hasThisParameter = false;
44245                 var iife = ts.getImmediatelyInvokedFunctionExpression(declaration);
44246                 var isJSConstructSignature = ts.isJSDocConstructSignature(declaration);
44247                 var isUntypedSignatureInJSFile = !iife &&
44248                     ts.isInJSFile(declaration) &&
44249                     ts.isValueSignatureDeclaration(declaration) &&
44250                     !ts.hasJSDocParameterTags(declaration) &&
44251                     !ts.getJSDocType(declaration);
44252                 if (isUntypedSignatureInJSFile) {
44253                     flags |= 16;
44254                 }
44255                 for (var i = isJSConstructSignature ? 1 : 0; i < declaration.parameters.length; i++) {
44256                     var param = declaration.parameters[i];
44257                     var paramSymbol = param.symbol;
44258                     var type = ts.isJSDocParameterTag(param) ? (param.typeExpression && param.typeExpression.type) : param.type;
44259                     if (paramSymbol && !!(paramSymbol.flags & 4) && !ts.isBindingPattern(param.name)) {
44260                         var resolvedSymbol = resolveName(param, paramSymbol.escapedName, 111551, undefined, undefined, false);
44261                         paramSymbol = resolvedSymbol;
44262                     }
44263                     if (i === 0 && paramSymbol.escapedName === "this") {
44264                         hasThisParameter = true;
44265                         thisParameter = param.symbol;
44266                     }
44267                     else {
44268                         parameters.push(paramSymbol);
44269                     }
44270                     if (type && type.kind === 191) {
44271                         flags |= 2;
44272                     }
44273                     var isOptionalParameter_1 = isOptionalJSDocPropertyLikeTag(param) ||
44274                         param.initializer || param.questionToken || param.dotDotDotToken ||
44275                         iife && parameters.length > iife.arguments.length && !type ||
44276                         isJSDocOptionalParameter(param);
44277                     if (!isOptionalParameter_1) {
44278                         minArgumentCount = parameters.length;
44279                     }
44280                 }
44281                 if ((declaration.kind === 167 || declaration.kind === 168) &&
44282                     !hasNonBindableDynamicName(declaration) &&
44283                     (!hasThisParameter || !thisParameter)) {
44284                     var otherKind = declaration.kind === 167 ? 168 : 167;
44285                     var other = ts.getDeclarationOfKind(getSymbolOfNode(declaration), otherKind);
44286                     if (other) {
44287                         thisParameter = getAnnotatedAccessorThisParameter(other);
44288                     }
44289                 }
44290                 var classType = declaration.kind === 166 ?
44291                     getDeclaredTypeOfClassOrInterface(getMergedSymbol(declaration.parent.symbol))
44292                     : undefined;
44293                 var typeParameters = classType ? classType.localTypeParameters : getTypeParametersFromDeclaration(declaration);
44294                 if (ts.hasRestParameter(declaration) || ts.isInJSFile(declaration) && maybeAddJsSyntheticRestParameter(declaration, parameters)) {
44295                     flags |= 1;
44296                 }
44297                 links.resolvedSignature = createSignature(declaration, typeParameters, thisParameter, parameters, undefined, undefined, minArgumentCount, flags);
44298             }
44299             return links.resolvedSignature;
44300         }
44301         function maybeAddJsSyntheticRestParameter(declaration, parameters) {
44302             if (ts.isJSDocSignature(declaration) || !containsArgumentsReference(declaration)) {
44303                 return false;
44304             }
44305             var lastParam = ts.lastOrUndefined(declaration.parameters);
44306             var lastParamTags = lastParam ? ts.getJSDocParameterTags(lastParam) : ts.getJSDocTags(declaration).filter(ts.isJSDocParameterTag);
44307             var lastParamVariadicType = ts.firstDefined(lastParamTags, function (p) {
44308                 return p.typeExpression && ts.isJSDocVariadicType(p.typeExpression.type) ? p.typeExpression.type : undefined;
44309             });
44310             var syntheticArgsSymbol = createSymbol(3, "args", 32768);
44311             syntheticArgsSymbol.type = lastParamVariadicType ? createArrayType(getTypeFromTypeNode(lastParamVariadicType.type)) : anyArrayType;
44312             if (lastParamVariadicType) {
44313                 parameters.pop();
44314             }
44315             parameters.push(syntheticArgsSymbol);
44316             return true;
44317         }
44318         function getSignatureOfTypeTag(node) {
44319             if (!(ts.isInJSFile(node) && ts.isFunctionLikeDeclaration(node)))
44320                 return undefined;
44321             var typeTag = ts.getJSDocTypeTag(node);
44322             var signature = typeTag && typeTag.typeExpression && getSingleCallSignature(getTypeFromTypeNode(typeTag.typeExpression));
44323             return signature && getErasedSignature(signature);
44324         }
44325         function getReturnTypeOfTypeTag(node) {
44326             var signature = getSignatureOfTypeTag(node);
44327             return signature && getReturnTypeOfSignature(signature);
44328         }
44329         function containsArgumentsReference(declaration) {
44330             var links = getNodeLinks(declaration);
44331             if (links.containsArgumentsReference === undefined) {
44332                 if (links.flags & 8192) {
44333                     links.containsArgumentsReference = true;
44334                 }
44335                 else {
44336                     links.containsArgumentsReference = traverse(declaration.body);
44337                 }
44338             }
44339             return links.containsArgumentsReference;
44340             function traverse(node) {
44341                 if (!node)
44342                     return false;
44343                 switch (node.kind) {
44344                     case 78:
44345                         return node.escapedText === "arguments" && ts.isExpressionNode(node);
44346                     case 163:
44347                     case 165:
44348                     case 167:
44349                     case 168:
44350                         return node.name.kind === 158
44351                             && traverse(node.name);
44352                     default:
44353                         return !ts.nodeStartsNewLexicalEnvironment(node) && !ts.isPartOfTypeNode(node) && !!ts.forEachChild(node, traverse);
44354                 }
44355             }
44356         }
44357         function getSignaturesOfSymbol(symbol) {
44358             if (!symbol)
44359                 return ts.emptyArray;
44360             var result = [];
44361             for (var i = 0; i < symbol.declarations.length; i++) {
44362                 var decl = symbol.declarations[i];
44363                 if (!ts.isFunctionLike(decl))
44364                     continue;
44365                 if (i > 0 && decl.body) {
44366                     var previous = symbol.declarations[i - 1];
44367                     if (decl.parent === previous.parent && decl.kind === previous.kind && decl.pos === previous.end) {
44368                         continue;
44369                     }
44370                 }
44371                 result.push(getSignatureFromDeclaration(decl));
44372             }
44373             return result;
44374         }
44375         function resolveExternalModuleTypeByLiteral(name) {
44376             var moduleSym = resolveExternalModuleName(name, name);
44377             if (moduleSym) {
44378                 var resolvedModuleSymbol = resolveExternalModuleSymbol(moduleSym);
44379                 if (resolvedModuleSymbol) {
44380                     return getTypeOfSymbol(resolvedModuleSymbol);
44381                 }
44382             }
44383             return anyType;
44384         }
44385         function getThisTypeOfSignature(signature) {
44386             if (signature.thisParameter) {
44387                 return getTypeOfSymbol(signature.thisParameter);
44388             }
44389         }
44390         function getTypePredicateOfSignature(signature) {
44391             if (!signature.resolvedTypePredicate) {
44392                 if (signature.target) {
44393                     var targetTypePredicate = getTypePredicateOfSignature(signature.target);
44394                     signature.resolvedTypePredicate = targetTypePredicate ? instantiateTypePredicate(targetTypePredicate, signature.mapper) : noTypePredicate;
44395                 }
44396                 else if (signature.unionSignatures) {
44397                     signature.resolvedTypePredicate = getUnionTypePredicate(signature.unionSignatures) || noTypePredicate;
44398                 }
44399                 else {
44400                     var type = signature.declaration && ts.getEffectiveReturnTypeNode(signature.declaration);
44401                     var jsdocPredicate = void 0;
44402                     if (!type && ts.isInJSFile(signature.declaration)) {
44403                         var jsdocSignature = getSignatureOfTypeTag(signature.declaration);
44404                         if (jsdocSignature && signature !== jsdocSignature) {
44405                             jsdocPredicate = getTypePredicateOfSignature(jsdocSignature);
44406                         }
44407                     }
44408                     signature.resolvedTypePredicate = type && ts.isTypePredicateNode(type) ?
44409                         createTypePredicateFromTypePredicateNode(type, signature) :
44410                         jsdocPredicate || noTypePredicate;
44411                 }
44412                 ts.Debug.assert(!!signature.resolvedTypePredicate);
44413             }
44414             return signature.resolvedTypePredicate === noTypePredicate ? undefined : signature.resolvedTypePredicate;
44415         }
44416         function createTypePredicateFromTypePredicateNode(node, signature) {
44417             var parameterName = node.parameterName;
44418             var type = node.type && getTypeFromTypeNode(node.type);
44419             return parameterName.kind === 187 ?
44420                 createTypePredicate(node.assertsModifier ? 2 : 0, undefined, undefined, type) :
44421                 createTypePredicate(node.assertsModifier ? 3 : 1, parameterName.escapedText, ts.findIndex(signature.parameters, function (p) { return p.escapedName === parameterName.escapedText; }), type);
44422         }
44423         function getReturnTypeOfSignature(signature) {
44424             if (!signature.resolvedReturnType) {
44425                 if (!pushTypeResolution(signature, 3)) {
44426                     return errorType;
44427                 }
44428                 var type = signature.target ? instantiateType(getReturnTypeOfSignature(signature.target), signature.mapper) :
44429                     signature.unionSignatures ? getUnionType(ts.map(signature.unionSignatures, getReturnTypeOfSignature), 2) :
44430                         getReturnTypeFromAnnotation(signature.declaration) ||
44431                             (ts.nodeIsMissing(signature.declaration.body) ? anyType : getReturnTypeFromBody(signature.declaration));
44432                 if (signature.flags & 4) {
44433                     type = addOptionalTypeMarker(type);
44434                 }
44435                 else if (signature.flags & 8) {
44436                     type = getOptionalType(type);
44437                 }
44438                 if (!popTypeResolution()) {
44439                     if (signature.declaration) {
44440                         var typeNode = ts.getEffectiveReturnTypeNode(signature.declaration);
44441                         if (typeNode) {
44442                             error(typeNode, ts.Diagnostics.Return_type_annotation_circularly_references_itself);
44443                         }
44444                         else if (noImplicitAny) {
44445                             var declaration = signature.declaration;
44446                             var name = ts.getNameOfDeclaration(declaration);
44447                             if (name) {
44448                                 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));
44449                             }
44450                             else {
44451                                 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);
44452                             }
44453                         }
44454                     }
44455                     type = anyType;
44456                 }
44457                 signature.resolvedReturnType = type;
44458             }
44459             return signature.resolvedReturnType;
44460         }
44461         function getReturnTypeFromAnnotation(declaration) {
44462             if (declaration.kind === 166) {
44463                 return getDeclaredTypeOfClassOrInterface(getMergedSymbol(declaration.parent.symbol));
44464             }
44465             if (ts.isJSDocConstructSignature(declaration)) {
44466                 return getTypeFromTypeNode(declaration.parameters[0].type);
44467             }
44468             var typeNode = ts.getEffectiveReturnTypeNode(declaration);
44469             if (typeNode) {
44470                 return getTypeFromTypeNode(typeNode);
44471             }
44472             if (declaration.kind === 167 && !hasNonBindableDynamicName(declaration)) {
44473                 var jsDocType = ts.isInJSFile(declaration) && getTypeForDeclarationFromJSDocComment(declaration);
44474                 if (jsDocType) {
44475                     return jsDocType;
44476                 }
44477                 var setter = ts.getDeclarationOfKind(getSymbolOfNode(declaration), 168);
44478                 var setterType = getAnnotatedAccessorType(setter);
44479                 if (setterType) {
44480                     return setterType;
44481                 }
44482             }
44483             return getReturnTypeOfTypeTag(declaration);
44484         }
44485         function isResolvingReturnTypeOfSignature(signature) {
44486             return !signature.resolvedReturnType && findResolutionCycleStartIndex(signature, 3) >= 0;
44487         }
44488         function getRestTypeOfSignature(signature) {
44489             return tryGetRestTypeOfSignature(signature) || anyType;
44490         }
44491         function tryGetRestTypeOfSignature(signature) {
44492             if (signatureHasRestParameter(signature)) {
44493                 var sigRestType = getTypeOfSymbol(signature.parameters[signature.parameters.length - 1]);
44494                 var restType = isTupleType(sigRestType) ? getRestTypeOfTupleType(sigRestType) : sigRestType;
44495                 return restType && getIndexTypeOfType(restType, 1);
44496             }
44497             return undefined;
44498         }
44499         function getSignatureInstantiation(signature, typeArguments, isJavascript, inferredTypeParameters) {
44500             var instantiatedSignature = getSignatureInstantiationWithoutFillingInTypeArguments(signature, fillMissingTypeArguments(typeArguments, signature.typeParameters, getMinTypeArgumentCount(signature.typeParameters), isJavascript));
44501             if (inferredTypeParameters) {
44502                 var returnSignature = getSingleCallOrConstructSignature(getReturnTypeOfSignature(instantiatedSignature));
44503                 if (returnSignature) {
44504                     var newReturnSignature = cloneSignature(returnSignature);
44505                     newReturnSignature.typeParameters = inferredTypeParameters;
44506                     var newInstantiatedSignature = cloneSignature(instantiatedSignature);
44507                     newInstantiatedSignature.resolvedReturnType = getOrCreateTypeFromSignature(newReturnSignature);
44508                     return newInstantiatedSignature;
44509                 }
44510             }
44511             return instantiatedSignature;
44512         }
44513         function getSignatureInstantiationWithoutFillingInTypeArguments(signature, typeArguments) {
44514             var instantiations = signature.instantiations || (signature.instantiations = new ts.Map());
44515             var id = getTypeListId(typeArguments);
44516             var instantiation = instantiations.get(id);
44517             if (!instantiation) {
44518                 instantiations.set(id, instantiation = createSignatureInstantiation(signature, typeArguments));
44519             }
44520             return instantiation;
44521         }
44522         function createSignatureInstantiation(signature, typeArguments) {
44523             return instantiateSignature(signature, createSignatureTypeMapper(signature, typeArguments), true);
44524         }
44525         function createSignatureTypeMapper(signature, typeArguments) {
44526             return createTypeMapper(signature.typeParameters, typeArguments);
44527         }
44528         function getErasedSignature(signature) {
44529             return signature.typeParameters ?
44530                 signature.erasedSignatureCache || (signature.erasedSignatureCache = createErasedSignature(signature)) :
44531                 signature;
44532         }
44533         function createErasedSignature(signature) {
44534             return instantiateSignature(signature, createTypeEraser(signature.typeParameters), true);
44535         }
44536         function getCanonicalSignature(signature) {
44537             return signature.typeParameters ?
44538                 signature.canonicalSignatureCache || (signature.canonicalSignatureCache = createCanonicalSignature(signature)) :
44539                 signature;
44540         }
44541         function createCanonicalSignature(signature) {
44542             return getSignatureInstantiation(signature, ts.map(signature.typeParameters, function (tp) { return tp.target && !getConstraintOfTypeParameter(tp.target) ? tp.target : tp; }), ts.isInJSFile(signature.declaration));
44543         }
44544         function getBaseSignature(signature) {
44545             var typeParameters = signature.typeParameters;
44546             if (typeParameters) {
44547                 var typeEraser_1 = createTypeEraser(typeParameters);
44548                 var baseConstraints = ts.map(typeParameters, function (tp) { return instantiateType(getBaseConstraintOfType(tp), typeEraser_1) || unknownType; });
44549                 return instantiateSignature(signature, createTypeMapper(typeParameters, baseConstraints), true);
44550             }
44551             return signature;
44552         }
44553         function getOrCreateTypeFromSignature(signature) {
44554             if (!signature.isolatedSignatureType) {
44555                 var kind = signature.declaration ? signature.declaration.kind : 0;
44556                 var isConstructor = kind === 166 || kind === 170 || kind === 175;
44557                 var type = createObjectType(16);
44558                 type.members = emptySymbols;
44559                 type.properties = ts.emptyArray;
44560                 type.callSignatures = !isConstructor ? [signature] : ts.emptyArray;
44561                 type.constructSignatures = isConstructor ? [signature] : ts.emptyArray;
44562                 signature.isolatedSignatureType = type;
44563             }
44564             return signature.isolatedSignatureType;
44565         }
44566         function getIndexSymbol(symbol) {
44567             return symbol.members.get("__index");
44568         }
44569         function getIndexDeclarationOfSymbol(symbol, kind) {
44570             var syntaxKind = kind === 1 ? 144 : 147;
44571             var indexSymbol = getIndexSymbol(symbol);
44572             if (indexSymbol) {
44573                 for (var _i = 0, _a = indexSymbol.declarations; _i < _a.length; _i++) {
44574                     var decl = _a[_i];
44575                     var node = ts.cast(decl, ts.isIndexSignatureDeclaration);
44576                     if (node.parameters.length === 1) {
44577                         var parameter = node.parameters[0];
44578                         if (parameter.type && parameter.type.kind === syntaxKind) {
44579                             return node;
44580                         }
44581                     }
44582                 }
44583             }
44584             return undefined;
44585         }
44586         function createIndexInfo(type, isReadonly, declaration) {
44587             return { type: type, isReadonly: isReadonly, declaration: declaration };
44588         }
44589         function getIndexInfoOfSymbol(symbol, kind) {
44590             var declaration = getIndexDeclarationOfSymbol(symbol, kind);
44591             if (declaration) {
44592                 return createIndexInfo(declaration.type ? getTypeFromTypeNode(declaration.type) : anyType, ts.hasEffectiveModifier(declaration, 64), declaration);
44593             }
44594             return undefined;
44595         }
44596         function getConstraintDeclaration(type) {
44597             return ts.mapDefined(ts.filter(type.symbol && type.symbol.declarations, ts.isTypeParameterDeclaration), ts.getEffectiveConstraintOfTypeParameter)[0];
44598         }
44599         function getInferredTypeParameterConstraint(typeParameter) {
44600             var inferences;
44601             if (typeParameter.symbol) {
44602                 for (var _i = 0, _a = typeParameter.symbol.declarations; _i < _a.length; _i++) {
44603                     var declaration = _a[_i];
44604                     if (declaration.parent.kind === 185) {
44605                         var _b = ts.walkUpParenthesizedTypesAndGetParentAndChild(declaration.parent.parent), _c = _b[0], childTypeParameter = _c === void 0 ? declaration.parent : _c, grandParent = _b[1];
44606                         if (grandParent.kind === 173) {
44607                             var typeReference = grandParent;
44608                             var typeParameters = getTypeParametersForTypeReference(typeReference);
44609                             if (typeParameters) {
44610                                 var index = typeReference.typeArguments.indexOf(childTypeParameter);
44611                                 if (index < typeParameters.length) {
44612                                     var declaredConstraint = getConstraintOfTypeParameter(typeParameters[index]);
44613                                     if (declaredConstraint) {
44614                                         var mapper = createTypeMapper(typeParameters, getEffectiveTypeArguments(typeReference, typeParameters));
44615                                         var constraint = instantiateType(declaredConstraint, mapper);
44616                                         if (constraint !== typeParameter) {
44617                                             inferences = ts.append(inferences, constraint);
44618                                         }
44619                                     }
44620                                 }
44621                             }
44622                         }
44623                         else if (grandParent.kind === 160 && grandParent.dotDotDotToken ||
44624                             grandParent.kind === 181 ||
44625                             grandParent.kind === 192 && grandParent.dotDotDotToken) {
44626                             inferences = ts.append(inferences, createArrayType(unknownType));
44627                         }
44628                         else if (grandParent.kind === 194) {
44629                             inferences = ts.append(inferences, stringType);
44630                         }
44631                     }
44632                 }
44633             }
44634             return inferences && getIntersectionType(inferences);
44635         }
44636         function getConstraintFromTypeParameter(typeParameter) {
44637             if (!typeParameter.constraint) {
44638                 if (typeParameter.target) {
44639                     var targetConstraint = getConstraintOfTypeParameter(typeParameter.target);
44640                     typeParameter.constraint = targetConstraint ? instantiateType(targetConstraint, typeParameter.mapper) : noConstraintType;
44641                 }
44642                 else {
44643                     var constraintDeclaration = getConstraintDeclaration(typeParameter);
44644                     if (!constraintDeclaration) {
44645                         typeParameter.constraint = getInferredTypeParameterConstraint(typeParameter) || noConstraintType;
44646                     }
44647                     else {
44648                         var type = getTypeFromTypeNode(constraintDeclaration);
44649                         if (type.flags & 1 && type !== errorType) {
44650                             type = constraintDeclaration.parent.parent.kind === 190 ? keyofConstraintType : unknownType;
44651                         }
44652                         typeParameter.constraint = type;
44653                     }
44654                 }
44655             }
44656             return typeParameter.constraint === noConstraintType ? undefined : typeParameter.constraint;
44657         }
44658         function getParentSymbolOfTypeParameter(typeParameter) {
44659             var tp = ts.getDeclarationOfKind(typeParameter.symbol, 159);
44660             var host = ts.isJSDocTemplateTag(tp.parent) ? ts.getHostSignatureFromJSDoc(tp.parent) : tp.parent;
44661             return host && getSymbolOfNode(host);
44662         }
44663         function getTypeListId(types) {
44664             var result = "";
44665             if (types) {
44666                 var length_4 = types.length;
44667                 var i = 0;
44668                 while (i < length_4) {
44669                     var startId = types[i].id;
44670                     var count = 1;
44671                     while (i + count < length_4 && types[i + count].id === startId + count) {
44672                         count++;
44673                     }
44674                     if (result.length) {
44675                         result += ",";
44676                     }
44677                     result += startId;
44678                     if (count > 1) {
44679                         result += ":" + count;
44680                     }
44681                     i += count;
44682                 }
44683             }
44684             return result;
44685         }
44686         function getPropagatingFlagsOfTypes(types, excludeKinds) {
44687             var result = 0;
44688             for (var _i = 0, types_9 = types; _i < types_9.length; _i++) {
44689                 var type = types_9[_i];
44690                 if (!(type.flags & excludeKinds)) {
44691                     result |= ts.getObjectFlags(type);
44692                 }
44693             }
44694             return result & 3670016;
44695         }
44696         function createTypeReference(target, typeArguments) {
44697             var id = getTypeListId(typeArguments);
44698             var type = target.instantiations.get(id);
44699             if (!type) {
44700                 type = createObjectType(4, target.symbol);
44701                 target.instantiations.set(id, type);
44702                 type.objectFlags |= typeArguments ? getPropagatingFlagsOfTypes(typeArguments, 0) : 0;
44703                 type.target = target;
44704                 type.resolvedTypeArguments = typeArguments;
44705             }
44706             return type;
44707         }
44708         function cloneTypeReference(source) {
44709             var type = createType(source.flags);
44710             type.symbol = source.symbol;
44711             type.objectFlags = source.objectFlags;
44712             type.target = source.target;
44713             type.resolvedTypeArguments = source.resolvedTypeArguments;
44714             return type;
44715         }
44716         function createDeferredTypeReference(target, node, mapper) {
44717             var aliasSymbol = getAliasSymbolForTypeNode(node);
44718             var aliasTypeArguments = getTypeArgumentsForAliasSymbol(aliasSymbol);
44719             var type = createObjectType(4, target.symbol);
44720             type.target = target;
44721             type.node = node;
44722             type.mapper = mapper;
44723             type.aliasSymbol = aliasSymbol;
44724             type.aliasTypeArguments = mapper ? instantiateTypes(aliasTypeArguments, mapper) : aliasTypeArguments;
44725             return type;
44726         }
44727         function getTypeArguments(type) {
44728             var _a, _b;
44729             if (!type.resolvedTypeArguments) {
44730                 if (!pushTypeResolution(type, 6)) {
44731                     return ((_a = type.target.localTypeParameters) === null || _a === void 0 ? void 0 : _a.map(function () { return errorType; })) || ts.emptyArray;
44732                 }
44733                 var node = type.node;
44734                 var typeArguments = !node ? ts.emptyArray :
44735                     node.kind === 173 ? ts.concatenate(type.target.outerTypeParameters, getEffectiveTypeArguments(node, type.target.localTypeParameters)) :
44736                         node.kind === 178 ? [getTypeFromTypeNode(node.elementType)] :
44737                             ts.map(node.elements, getTypeFromTypeNode);
44738                 if (popTypeResolution()) {
44739                     type.resolvedTypeArguments = type.mapper ? instantiateTypes(typeArguments, type.mapper) : typeArguments;
44740                 }
44741                 else {
44742                     type.resolvedTypeArguments = ((_b = type.target.localTypeParameters) === null || _b === void 0 ? void 0 : _b.map(function () { return errorType; })) || ts.emptyArray;
44743                     error(type.node || currentNode, type.target.symbol ? ts.Diagnostics.Type_arguments_for_0_circularly_reference_themselves : ts.Diagnostics.Tuple_type_arguments_circularly_reference_themselves, type.target.symbol && symbolToString(type.target.symbol));
44744                 }
44745             }
44746             return type.resolvedTypeArguments;
44747         }
44748         function getTypeReferenceArity(type) {
44749             return ts.length(type.target.typeParameters);
44750         }
44751         function getTypeFromClassOrInterfaceReference(node, symbol) {
44752             var type = getDeclaredTypeOfSymbol(getMergedSymbol(symbol));
44753             var typeParameters = type.localTypeParameters;
44754             if (typeParameters) {
44755                 var numTypeArguments = ts.length(node.typeArguments);
44756                 var minTypeArgumentCount = getMinTypeArgumentCount(typeParameters);
44757                 var isJs = ts.isInJSFile(node);
44758                 var isJsImplicitAny = !noImplicitAny && isJs;
44759                 if (!isJsImplicitAny && (numTypeArguments < minTypeArgumentCount || numTypeArguments > typeParameters.length)) {
44760                     var missingAugmentsTag = isJs && ts.isExpressionWithTypeArguments(node) && !ts.isJSDocAugmentsTag(node.parent);
44761                     var diag = minTypeArgumentCount === typeParameters.length ?
44762                         missingAugmentsTag ?
44763                             ts.Diagnostics.Expected_0_type_arguments_provide_these_with_an_extends_tag :
44764                             ts.Diagnostics.Generic_type_0_requires_1_type_argument_s :
44765                         missingAugmentsTag ?
44766                             ts.Diagnostics.Expected_0_1_type_arguments_provide_these_with_an_extends_tag :
44767                             ts.Diagnostics.Generic_type_0_requires_between_1_and_2_type_arguments;
44768                     var typeStr = typeToString(type, undefined, 2);
44769                     error(node, diag, typeStr, minTypeArgumentCount, typeParameters.length);
44770                     if (!isJs) {
44771                         return errorType;
44772                     }
44773                 }
44774                 if (node.kind === 173 && isDeferredTypeReferenceNode(node, ts.length(node.typeArguments) !== typeParameters.length)) {
44775                     return createDeferredTypeReference(type, node, undefined);
44776                 }
44777                 var typeArguments = ts.concatenate(type.outerTypeParameters, fillMissingTypeArguments(typeArgumentsFromTypeReferenceNode(node), typeParameters, minTypeArgumentCount, isJs));
44778                 return createTypeReference(type, typeArguments);
44779             }
44780             return checkNoTypeArguments(node, symbol) ? type : errorType;
44781         }
44782         function getTypeAliasInstantiation(symbol, typeArguments) {
44783             var type = getDeclaredTypeOfSymbol(symbol);
44784             if (type === intrinsicMarkerType && intrinsicTypeKinds.has(symbol.escapedName) && typeArguments && typeArguments.length === 1) {
44785                 return getStringMappingType(symbol, typeArguments[0]);
44786             }
44787             var links = getSymbolLinks(symbol);
44788             var typeParameters = links.typeParameters;
44789             var id = getTypeListId(typeArguments);
44790             var instantiation = links.instantiations.get(id);
44791             if (!instantiation) {
44792                 links.instantiations.set(id, instantiation = instantiateType(type, createTypeMapper(typeParameters, fillMissingTypeArguments(typeArguments, typeParameters, getMinTypeArgumentCount(typeParameters), ts.isInJSFile(symbol.valueDeclaration)))));
44793             }
44794             return instantiation;
44795         }
44796         function getTypeFromTypeAliasReference(node, symbol) {
44797             var type = getDeclaredTypeOfSymbol(symbol);
44798             var typeParameters = getSymbolLinks(symbol).typeParameters;
44799             if (typeParameters) {
44800                 var numTypeArguments = ts.length(node.typeArguments);
44801                 var minTypeArgumentCount = getMinTypeArgumentCount(typeParameters);
44802                 if (numTypeArguments < minTypeArgumentCount || numTypeArguments > typeParameters.length) {
44803                     error(node, minTypeArgumentCount === typeParameters.length ?
44804                         ts.Diagnostics.Generic_type_0_requires_1_type_argument_s :
44805                         ts.Diagnostics.Generic_type_0_requires_between_1_and_2_type_arguments, symbolToString(symbol), minTypeArgumentCount, typeParameters.length);
44806                     return errorType;
44807                 }
44808                 return getTypeAliasInstantiation(symbol, typeArgumentsFromTypeReferenceNode(node));
44809             }
44810             return checkNoTypeArguments(node, symbol) ? type : errorType;
44811         }
44812         function getTypeReferenceName(node) {
44813             switch (node.kind) {
44814                 case 173:
44815                     return node.typeName;
44816                 case 223:
44817                     var expr = node.expression;
44818                     if (ts.isEntityNameExpression(expr)) {
44819                         return expr;
44820                     }
44821             }
44822             return undefined;
44823         }
44824         function resolveTypeReferenceName(typeReferenceName, meaning, ignoreErrors) {
44825             if (!typeReferenceName) {
44826                 return unknownSymbol;
44827             }
44828             return resolveEntityName(typeReferenceName, meaning, ignoreErrors) || unknownSymbol;
44829         }
44830         function getTypeReferenceType(node, symbol) {
44831             if (symbol === unknownSymbol) {
44832                 return errorType;
44833             }
44834             symbol = getExpandoSymbol(symbol) || symbol;
44835             if (symbol.flags & (32 | 64)) {
44836                 return getTypeFromClassOrInterfaceReference(node, symbol);
44837             }
44838             if (symbol.flags & 524288) {
44839                 return getTypeFromTypeAliasReference(node, symbol);
44840             }
44841             var res = tryGetDeclaredTypeOfSymbol(symbol);
44842             if (res) {
44843                 return checkNoTypeArguments(node, symbol) ? getRegularTypeOfLiteralType(res) : errorType;
44844             }
44845             if (symbol.flags & 111551 && isJSDocTypeReference(node)) {
44846                 var jsdocType = getTypeFromJSDocValueReference(node, symbol);
44847                 if (jsdocType) {
44848                     return jsdocType;
44849                 }
44850                 else {
44851                     resolveTypeReferenceName(getTypeReferenceName(node), 788968);
44852                     return getTypeOfSymbol(symbol);
44853                 }
44854             }
44855             return errorType;
44856         }
44857         function getTypeFromJSDocValueReference(node, symbol) {
44858             var links = getNodeLinks(node);
44859             if (!links.resolvedJSDocType) {
44860                 var valueType = getTypeOfSymbol(symbol);
44861                 var typeType = valueType;
44862                 if (symbol.valueDeclaration) {
44863                     var isImportTypeWithQualifier = node.kind === 195 && node.qualifier;
44864                     if (valueType.symbol && valueType.symbol !== symbol && isImportTypeWithQualifier) {
44865                         typeType = getTypeReferenceType(node, valueType.symbol);
44866                     }
44867                 }
44868                 links.resolvedJSDocType = typeType;
44869             }
44870             return links.resolvedJSDocType;
44871         }
44872         function getSubstitutionType(baseType, substitute) {
44873             if (substitute.flags & 3 || substitute === baseType) {
44874                 return baseType;
44875             }
44876             var id = getTypeId(baseType) + ">" + getTypeId(substitute);
44877             var cached = substitutionTypes.get(id);
44878             if (cached) {
44879                 return cached;
44880             }
44881             var result = createType(33554432);
44882             result.baseType = baseType;
44883             result.substitute = substitute;
44884             substitutionTypes.set(id, result);
44885             return result;
44886         }
44887         function isUnaryTupleTypeNode(node) {
44888             return node.kind === 179 && node.elements.length === 1;
44889         }
44890         function getImpliedConstraint(type, checkNode, extendsNode) {
44891             return isUnaryTupleTypeNode(checkNode) && isUnaryTupleTypeNode(extendsNode) ? getImpliedConstraint(type, checkNode.elements[0], extendsNode.elements[0]) :
44892                 getActualTypeVariable(getTypeFromTypeNode(checkNode)) === type ? getTypeFromTypeNode(extendsNode) :
44893                     undefined;
44894         }
44895         function getConditionalFlowTypeOfType(type, node) {
44896             var constraints;
44897             while (node && !ts.isStatement(node) && node.kind !== 311) {
44898                 var parent = node.parent;
44899                 if (parent.kind === 184 && node === parent.trueType) {
44900                     var constraint = getImpliedConstraint(type, parent.checkType, parent.extendsType);
44901                     if (constraint) {
44902                         constraints = ts.append(constraints, constraint);
44903                     }
44904                 }
44905                 node = parent;
44906             }
44907             return constraints ? getSubstitutionType(type, getIntersectionType(ts.append(constraints, type))) : type;
44908         }
44909         function isJSDocTypeReference(node) {
44910             return !!(node.flags & 4194304) && (node.kind === 173 || node.kind === 195);
44911         }
44912         function checkNoTypeArguments(node, symbol) {
44913             if (node.typeArguments) {
44914                 error(node, ts.Diagnostics.Type_0_is_not_generic, symbol ? symbolToString(symbol) : node.typeName ? ts.declarationNameToString(node.typeName) : anon);
44915                 return false;
44916             }
44917             return true;
44918         }
44919         function getIntendedTypeFromJSDocTypeReference(node) {
44920             if (ts.isIdentifier(node.typeName)) {
44921                 var typeArgs = node.typeArguments;
44922                 switch (node.typeName.escapedText) {
44923                     case "String":
44924                         checkNoTypeArguments(node);
44925                         return stringType;
44926                     case "Number":
44927                         checkNoTypeArguments(node);
44928                         return numberType;
44929                     case "Boolean":
44930                         checkNoTypeArguments(node);
44931                         return booleanType;
44932                     case "Void":
44933                         checkNoTypeArguments(node);
44934                         return voidType;
44935                     case "Undefined":
44936                         checkNoTypeArguments(node);
44937                         return undefinedType;
44938                     case "Null":
44939                         checkNoTypeArguments(node);
44940                         return nullType;
44941                     case "Function":
44942                     case "function":
44943                         checkNoTypeArguments(node);
44944                         return globalFunctionType;
44945                     case "array":
44946                         return (!typeArgs || !typeArgs.length) && !noImplicitAny ? anyArrayType : undefined;
44947                     case "promise":
44948                         return (!typeArgs || !typeArgs.length) && !noImplicitAny ? createPromiseType(anyType) : undefined;
44949                     case "Object":
44950                         if (typeArgs && typeArgs.length === 2) {
44951                             if (ts.isJSDocIndexSignature(node)) {
44952                                 var indexed = getTypeFromTypeNode(typeArgs[0]);
44953                                 var target = getTypeFromTypeNode(typeArgs[1]);
44954                                 var index = createIndexInfo(target, false);
44955                                 return createAnonymousType(undefined, emptySymbols, ts.emptyArray, ts.emptyArray, indexed === stringType ? index : undefined, indexed === numberType ? index : undefined);
44956                             }
44957                             return anyType;
44958                         }
44959                         checkNoTypeArguments(node);
44960                         return !noImplicitAny ? anyType : undefined;
44961                 }
44962             }
44963         }
44964         function getTypeFromJSDocNullableTypeNode(node) {
44965             var type = getTypeFromTypeNode(node.type);
44966             return strictNullChecks ? getNullableType(type, 65536) : type;
44967         }
44968         function getTypeFromTypeReference(node) {
44969             var links = getNodeLinks(node);
44970             if (!links.resolvedType) {
44971                 if (ts.isConstTypeReference(node) && ts.isAssertionExpression(node.parent)) {
44972                     links.resolvedSymbol = unknownSymbol;
44973                     return links.resolvedType = checkExpressionCached(node.parent.expression);
44974                 }
44975                 var symbol = void 0;
44976                 var type = void 0;
44977                 var meaning = 788968;
44978                 if (isJSDocTypeReference(node)) {
44979                     type = getIntendedTypeFromJSDocTypeReference(node);
44980                     if (!type) {
44981                         symbol = resolveTypeReferenceName(getTypeReferenceName(node), meaning, true);
44982                         if (symbol === unknownSymbol) {
44983                             symbol = resolveTypeReferenceName(getTypeReferenceName(node), meaning | 111551);
44984                         }
44985                         else {
44986                             resolveTypeReferenceName(getTypeReferenceName(node), meaning);
44987                         }
44988                         type = getTypeReferenceType(node, symbol);
44989                     }
44990                 }
44991                 if (!type) {
44992                     symbol = resolveTypeReferenceName(getTypeReferenceName(node), meaning);
44993                     type = getTypeReferenceType(node, symbol);
44994                 }
44995                 links.resolvedSymbol = symbol;
44996                 links.resolvedType = type;
44997             }
44998             return links.resolvedType;
44999         }
45000         function typeArgumentsFromTypeReferenceNode(node) {
45001             return ts.map(node.typeArguments, getTypeFromTypeNode);
45002         }
45003         function getTypeFromTypeQueryNode(node) {
45004             var links = getNodeLinks(node);
45005             if (!links.resolvedType) {
45006                 links.resolvedType = getRegularTypeOfLiteralType(getWidenedType(checkExpression(node.exprName)));
45007             }
45008             return links.resolvedType;
45009         }
45010         function getTypeOfGlobalSymbol(symbol, arity) {
45011             function getTypeDeclaration(symbol) {
45012                 var declarations = symbol.declarations;
45013                 for (var _i = 0, declarations_3 = declarations; _i < declarations_3.length; _i++) {
45014                     var declaration = declarations_3[_i];
45015                     switch (declaration.kind) {
45016                         case 252:
45017                         case 253:
45018                         case 255:
45019                             return declaration;
45020                     }
45021                 }
45022             }
45023             if (!symbol) {
45024                 return arity ? emptyGenericType : emptyObjectType;
45025             }
45026             var type = getDeclaredTypeOfSymbol(symbol);
45027             if (!(type.flags & 524288)) {
45028                 error(getTypeDeclaration(symbol), ts.Diagnostics.Global_type_0_must_be_a_class_or_interface_type, ts.symbolName(symbol));
45029                 return arity ? emptyGenericType : emptyObjectType;
45030             }
45031             if (ts.length(type.typeParameters) !== arity) {
45032                 error(getTypeDeclaration(symbol), ts.Diagnostics.Global_type_0_must_have_1_type_parameter_s, ts.symbolName(symbol), arity);
45033                 return arity ? emptyGenericType : emptyObjectType;
45034             }
45035             return type;
45036         }
45037         function getGlobalValueSymbol(name, reportErrors) {
45038             return getGlobalSymbol(name, 111551, reportErrors ? ts.Diagnostics.Cannot_find_global_value_0 : undefined);
45039         }
45040         function getGlobalTypeSymbol(name, reportErrors) {
45041             return getGlobalSymbol(name, 788968, reportErrors ? ts.Diagnostics.Cannot_find_global_type_0 : undefined);
45042         }
45043         function getGlobalSymbol(name, meaning, diagnostic) {
45044             return resolveName(undefined, name, meaning, diagnostic, name, false);
45045         }
45046         function getGlobalType(name, arity, reportErrors) {
45047             var symbol = getGlobalTypeSymbol(name, reportErrors);
45048             return symbol || reportErrors ? getTypeOfGlobalSymbol(symbol, arity) : undefined;
45049         }
45050         function getGlobalTypedPropertyDescriptorType() {
45051             return deferredGlobalTypedPropertyDescriptorType || (deferredGlobalTypedPropertyDescriptorType = getGlobalType("TypedPropertyDescriptor", 1, true)) || emptyGenericType;
45052         }
45053         function getGlobalTemplateStringsArrayType() {
45054             return deferredGlobalTemplateStringsArrayType || (deferredGlobalTemplateStringsArrayType = getGlobalType("TemplateStringsArray", 0, true)) || emptyObjectType;
45055         }
45056         function getGlobalImportMetaType() {
45057             return deferredGlobalImportMetaType || (deferredGlobalImportMetaType = getGlobalType("ImportMeta", 0, true)) || emptyObjectType;
45058         }
45059         function getGlobalESSymbolConstructorSymbol(reportErrors) {
45060             return deferredGlobalESSymbolConstructorSymbol || (deferredGlobalESSymbolConstructorSymbol = getGlobalValueSymbol("Symbol", reportErrors));
45061         }
45062         function getGlobalESSymbolType(reportErrors) {
45063             return deferredGlobalESSymbolType || (deferredGlobalESSymbolType = getGlobalType("Symbol", 0, reportErrors)) || emptyObjectType;
45064         }
45065         function getGlobalPromiseType(reportErrors) {
45066             return deferredGlobalPromiseType || (deferredGlobalPromiseType = getGlobalType("Promise", 1, reportErrors)) || emptyGenericType;
45067         }
45068         function getGlobalPromiseLikeType(reportErrors) {
45069             return deferredGlobalPromiseLikeType || (deferredGlobalPromiseLikeType = getGlobalType("PromiseLike", 1, reportErrors)) || emptyGenericType;
45070         }
45071         function getGlobalPromiseConstructorSymbol(reportErrors) {
45072             return deferredGlobalPromiseConstructorSymbol || (deferredGlobalPromiseConstructorSymbol = getGlobalValueSymbol("Promise", reportErrors));
45073         }
45074         function getGlobalPromiseConstructorLikeType(reportErrors) {
45075             return deferredGlobalPromiseConstructorLikeType || (deferredGlobalPromiseConstructorLikeType = getGlobalType("PromiseConstructorLike", 0, reportErrors)) || emptyObjectType;
45076         }
45077         function getGlobalAsyncIterableType(reportErrors) {
45078             return deferredGlobalAsyncIterableType || (deferredGlobalAsyncIterableType = getGlobalType("AsyncIterable", 1, reportErrors)) || emptyGenericType;
45079         }
45080         function getGlobalAsyncIteratorType(reportErrors) {
45081             return deferredGlobalAsyncIteratorType || (deferredGlobalAsyncIteratorType = getGlobalType("AsyncIterator", 3, reportErrors)) || emptyGenericType;
45082         }
45083         function getGlobalAsyncIterableIteratorType(reportErrors) {
45084             return deferredGlobalAsyncIterableIteratorType || (deferredGlobalAsyncIterableIteratorType = getGlobalType("AsyncIterableIterator", 1, reportErrors)) || emptyGenericType;
45085         }
45086         function getGlobalAsyncGeneratorType(reportErrors) {
45087             return deferredGlobalAsyncGeneratorType || (deferredGlobalAsyncGeneratorType = getGlobalType("AsyncGenerator", 3, reportErrors)) || emptyGenericType;
45088         }
45089         function getGlobalIterableType(reportErrors) {
45090             return deferredGlobalIterableType || (deferredGlobalIterableType = getGlobalType("Iterable", 1, reportErrors)) || emptyGenericType;
45091         }
45092         function getGlobalIteratorType(reportErrors) {
45093             return deferredGlobalIteratorType || (deferredGlobalIteratorType = getGlobalType("Iterator", 3, reportErrors)) || emptyGenericType;
45094         }
45095         function getGlobalIterableIteratorType(reportErrors) {
45096             return deferredGlobalIterableIteratorType || (deferredGlobalIterableIteratorType = getGlobalType("IterableIterator", 1, reportErrors)) || emptyGenericType;
45097         }
45098         function getGlobalGeneratorType(reportErrors) {
45099             return deferredGlobalGeneratorType || (deferredGlobalGeneratorType = getGlobalType("Generator", 3, reportErrors)) || emptyGenericType;
45100         }
45101         function getGlobalIteratorYieldResultType(reportErrors) {
45102             return deferredGlobalIteratorYieldResultType || (deferredGlobalIteratorYieldResultType = getGlobalType("IteratorYieldResult", 1, reportErrors)) || emptyGenericType;
45103         }
45104         function getGlobalIteratorReturnResultType(reportErrors) {
45105             return deferredGlobalIteratorReturnResultType || (deferredGlobalIteratorReturnResultType = getGlobalType("IteratorReturnResult", 1, reportErrors)) || emptyGenericType;
45106         }
45107         function getGlobalTypeOrUndefined(name, arity) {
45108             if (arity === void 0) { arity = 0; }
45109             var symbol = getGlobalSymbol(name, 788968, undefined);
45110             return symbol && getTypeOfGlobalSymbol(symbol, arity);
45111         }
45112         function getGlobalExtractSymbol() {
45113             return deferredGlobalExtractSymbol || (deferredGlobalExtractSymbol = getGlobalSymbol("Extract", 524288, ts.Diagnostics.Cannot_find_global_type_0));
45114         }
45115         function getGlobalOmitSymbol() {
45116             return deferredGlobalOmitSymbol || (deferredGlobalOmitSymbol = getGlobalSymbol("Omit", 524288, ts.Diagnostics.Cannot_find_global_type_0));
45117         }
45118         function getGlobalBigIntType(reportErrors) {
45119             return deferredGlobalBigIntType || (deferredGlobalBigIntType = getGlobalType("BigInt", 0, reportErrors)) || emptyObjectType;
45120         }
45121         function createTypeFromGenericGlobalType(genericGlobalType, typeArguments) {
45122             return genericGlobalType !== emptyGenericType ? createTypeReference(genericGlobalType, typeArguments) : emptyObjectType;
45123         }
45124         function createTypedPropertyDescriptorType(propertyType) {
45125             return createTypeFromGenericGlobalType(getGlobalTypedPropertyDescriptorType(), [propertyType]);
45126         }
45127         function createIterableType(iteratedType) {
45128             return createTypeFromGenericGlobalType(getGlobalIterableType(true), [iteratedType]);
45129         }
45130         function createArrayType(elementType, readonly) {
45131             return createTypeFromGenericGlobalType(readonly ? globalReadonlyArrayType : globalArrayType, [elementType]);
45132         }
45133         function getTupleElementFlags(node) {
45134             switch (node.kind) {
45135                 case 180:
45136                     return 2;
45137                 case 181:
45138                     return getRestTypeElementFlags(node);
45139                 case 192:
45140                     return node.questionToken ? 2 :
45141                         node.dotDotDotToken ? getRestTypeElementFlags(node) :
45142                             1;
45143                 default:
45144                     return 1;
45145             }
45146         }
45147         function getRestTypeElementFlags(node) {
45148             return getArrayElementTypeNode(node.type) ? 4 : 8;
45149         }
45150         function getArrayOrTupleTargetType(node) {
45151             var readonly = isReadonlyTypeOperator(node.parent);
45152             var elementType = getArrayElementTypeNode(node);
45153             if (elementType) {
45154                 return readonly ? globalReadonlyArrayType : globalArrayType;
45155             }
45156             var elementFlags = ts.map(node.elements, getTupleElementFlags);
45157             var missingName = ts.some(node.elements, function (e) { return e.kind !== 192; });
45158             return getTupleTargetType(elementFlags, readonly, missingName ? undefined : node.elements);
45159         }
45160         function isDeferredTypeReferenceNode(node, hasDefaultTypeArguments) {
45161             return !!getAliasSymbolForTypeNode(node) || isResolvedByTypeAlias(node) && (node.kind === 178 ? mayResolveTypeAlias(node.elementType) :
45162                 node.kind === 179 ? ts.some(node.elements, mayResolveTypeAlias) :
45163                     hasDefaultTypeArguments || ts.some(node.typeArguments, mayResolveTypeAlias));
45164         }
45165         function isResolvedByTypeAlias(node) {
45166             var parent = node.parent;
45167             switch (parent.kind) {
45168                 case 186:
45169                 case 192:
45170                 case 173:
45171                 case 182:
45172                 case 183:
45173                 case 189:
45174                 case 184:
45175                 case 188:
45176                 case 178:
45177                 case 179:
45178                     return isResolvedByTypeAlias(parent);
45179                 case 254:
45180                     return true;
45181             }
45182             return false;
45183         }
45184         function mayResolveTypeAlias(node) {
45185             switch (node.kind) {
45186                 case 173:
45187                     return isJSDocTypeReference(node) || !!(resolveTypeReferenceName(node.typeName, 788968).flags & 524288);
45188                 case 176:
45189                     return true;
45190                 case 188:
45191                     return node.operator !== 151 && mayResolveTypeAlias(node.type);
45192                 case 186:
45193                 case 180:
45194                 case 192:
45195                 case 307:
45196                 case 305:
45197                 case 306:
45198                 case 301:
45199                     return mayResolveTypeAlias(node.type);
45200                 case 181:
45201                     return node.type.kind !== 178 || mayResolveTypeAlias(node.type.elementType);
45202                 case 182:
45203                 case 183:
45204                     return ts.some(node.types, mayResolveTypeAlias);
45205                 case 189:
45206                     return mayResolveTypeAlias(node.objectType) || mayResolveTypeAlias(node.indexType);
45207                 case 184:
45208                     return mayResolveTypeAlias(node.checkType) || mayResolveTypeAlias(node.extendsType) ||
45209                         mayResolveTypeAlias(node.trueType) || mayResolveTypeAlias(node.falseType);
45210             }
45211             return false;
45212         }
45213         function getTypeFromArrayOrTupleTypeNode(node) {
45214             var links = getNodeLinks(node);
45215             if (!links.resolvedType) {
45216                 var target = getArrayOrTupleTargetType(node);
45217                 if (target === emptyGenericType) {
45218                     links.resolvedType = emptyObjectType;
45219                 }
45220                 else if (!(node.kind === 179 && ts.some(node.elements, function (e) { return !!(getTupleElementFlags(e) & 8); })) && isDeferredTypeReferenceNode(node)) {
45221                     links.resolvedType = node.kind === 179 && node.elements.length === 0 ? target :
45222                         createDeferredTypeReference(target, node, undefined);
45223                 }
45224                 else {
45225                     var elementTypes = node.kind === 178 ? [getTypeFromTypeNode(node.elementType)] : ts.map(node.elements, getTypeFromTypeNode);
45226                     links.resolvedType = createNormalizedTypeReference(target, elementTypes);
45227                 }
45228             }
45229             return links.resolvedType;
45230         }
45231         function isReadonlyTypeOperator(node) {
45232             return ts.isTypeOperatorNode(node) && node.operator === 142;
45233         }
45234         function createTupleType(elementTypes, elementFlags, readonly, namedMemberDeclarations) {
45235             if (readonly === void 0) { readonly = false; }
45236             var tupleTarget = getTupleTargetType(elementFlags || ts.map(elementTypes, function (_) { return 1; }), readonly, namedMemberDeclarations);
45237             return tupleTarget === emptyGenericType ? emptyObjectType :
45238                 elementTypes.length ? createNormalizedTypeReference(tupleTarget, elementTypes) :
45239                     tupleTarget;
45240         }
45241         function getTupleTargetType(elementFlags, readonly, namedMemberDeclarations) {
45242             if (elementFlags.length === 1 && elementFlags[0] & 4) {
45243                 return readonly ? globalReadonlyArrayType : globalArrayType;
45244             }
45245             var key = ts.map(elementFlags, function (f) { return f & 1 ? "#" : f & 2 ? "?" : f & 4 ? "." : "*"; }).join() +
45246                 (readonly ? "R" : "") +
45247                 (namedMemberDeclarations && namedMemberDeclarations.length ? "," + ts.map(namedMemberDeclarations, getNodeId).join(",") : "");
45248             var type = tupleTypes.get(key);
45249             if (!type) {
45250                 tupleTypes.set(key, type = createTupleTargetType(elementFlags, readonly, namedMemberDeclarations));
45251             }
45252             return type;
45253         }
45254         function createTupleTargetType(elementFlags, readonly, namedMemberDeclarations) {
45255             var arity = elementFlags.length;
45256             var minLength = ts.findLastIndex(elementFlags, function (f) { return !!(f & (1 | 8)); }) + 1;
45257             var typeParameters;
45258             var properties = [];
45259             var combinedFlags = 0;
45260             if (arity) {
45261                 typeParameters = new Array(arity);
45262                 for (var i = 0; i < arity; i++) {
45263                     var typeParameter = typeParameters[i] = createTypeParameter();
45264                     var flags = elementFlags[i];
45265                     combinedFlags |= flags;
45266                     if (!(combinedFlags & 12)) {
45267                         var property = createSymbol(4 | (flags & 2 ? 16777216 : 0), "" + i, readonly ? 8 : 0);
45268                         property.tupleLabelDeclaration = namedMemberDeclarations === null || namedMemberDeclarations === void 0 ? void 0 : namedMemberDeclarations[i];
45269                         property.type = typeParameter;
45270                         properties.push(property);
45271                     }
45272                 }
45273             }
45274             var fixedLength = properties.length;
45275             var lengthSymbol = createSymbol(4, "length");
45276             if (combinedFlags & 12) {
45277                 lengthSymbol.type = numberType;
45278             }
45279             else {
45280                 var literalTypes_1 = [];
45281                 for (var i = minLength; i <= arity; i++)
45282                     literalTypes_1.push(getLiteralType(i));
45283                 lengthSymbol.type = getUnionType(literalTypes_1);
45284             }
45285             properties.push(lengthSymbol);
45286             var type = createObjectType(8 | 4);
45287             type.typeParameters = typeParameters;
45288             type.outerTypeParameters = undefined;
45289             type.localTypeParameters = typeParameters;
45290             type.instantiations = new ts.Map();
45291             type.instantiations.set(getTypeListId(type.typeParameters), type);
45292             type.target = type;
45293             type.resolvedTypeArguments = type.typeParameters;
45294             type.thisType = createTypeParameter();
45295             type.thisType.isThisType = true;
45296             type.thisType.constraint = type;
45297             type.declaredProperties = properties;
45298             type.declaredCallSignatures = ts.emptyArray;
45299             type.declaredConstructSignatures = ts.emptyArray;
45300             type.declaredStringIndexInfo = undefined;
45301             type.declaredNumberIndexInfo = undefined;
45302             type.elementFlags = elementFlags;
45303             type.minLength = minLength;
45304             type.fixedLength = fixedLength;
45305             type.hasRestElement = !!(combinedFlags & 12);
45306             type.combinedFlags = combinedFlags;
45307             type.readonly = readonly;
45308             type.labeledElementDeclarations = namedMemberDeclarations;
45309             return type;
45310         }
45311         function createNormalizedTypeReference(target, typeArguments) {
45312             return target.objectFlags & 8 && target.combinedFlags & 8 ?
45313                 createNormalizedTupleType(target, typeArguments) :
45314                 createTypeReference(target, typeArguments);
45315         }
45316         function createNormalizedTupleType(target, elementTypes) {
45317             var _a, _b, _c;
45318             var unionIndex = ts.findIndex(elementTypes, function (t, i) { return !!(target.elementFlags[i] & 8 && t.flags & (131072 | 1048576)); });
45319             if (unionIndex >= 0) {
45320                 return checkCrossProductUnion(ts.map(elementTypes, function (t, i) { return target.elementFlags[i] & 8 ? t : unknownType; })) ?
45321                     mapType(elementTypes[unionIndex], function (t) { return createNormalizedTupleType(target, ts.replaceElement(elementTypes, unionIndex, t)); }) :
45322                     errorType;
45323             }
45324             var spreadIndex = ts.findIndex(elementTypes, function (t, i) { return !!(target.elementFlags[i] & 8) && !(t.flags & 58982400) && !isGenericMappedType(t); });
45325             if (spreadIndex < 0) {
45326                 return createTypeReference(target, elementTypes);
45327             }
45328             var expandedTypes = [];
45329             var expandedFlags = [];
45330             var expandedDeclarations = [];
45331             var optionalIndex = -1;
45332             var restTypes;
45333             var _loop_13 = function (i) {
45334                 var type = elementTypes[i];
45335                 var flags = target.elementFlags[i];
45336                 if (flags & 8) {
45337                     if (type.flags & 58982400 || isGenericMappedType(type)) {
45338                         addElementOrRest(type, 8, (_a = target.labeledElementDeclarations) === null || _a === void 0 ? void 0 : _a[i]);
45339                     }
45340                     else if (isTupleType(type)) {
45341                         ts.forEach(getTypeArguments(type), function (t, n) { var _a; return addElementOrRest(t, type.target.elementFlags[n], (_a = type.target.labeledElementDeclarations) === null || _a === void 0 ? void 0 : _a[n]); });
45342                     }
45343                     else {
45344                         addElementOrRest(isArrayLikeType(type) && getIndexTypeOfType(type, 1) || errorType, 4, (_b = target.labeledElementDeclarations) === null || _b === void 0 ? void 0 : _b[i]);
45345                     }
45346                 }
45347                 else {
45348                     addElementOrRest(type, flags, (_c = target.labeledElementDeclarations) === null || _c === void 0 ? void 0 : _c[i]);
45349                 }
45350             };
45351             for (var i = 0; i < elementTypes.length; i++) {
45352                 _loop_13(i);
45353             }
45354             if (restTypes) {
45355                 expandedTypes[expandedTypes.length - 1] = getUnionType(restTypes);
45356             }
45357             var tupleTarget = getTupleTargetType(expandedFlags, target.readonly, expandedDeclarations);
45358             return tupleTarget === emptyGenericType ? emptyObjectType :
45359                 expandedFlags.length ? createTypeReference(tupleTarget, expandedTypes) :
45360                     tupleTarget;
45361             function addElementOrRest(type, flags, declaration) {
45362                 if (restTypes) {
45363                     restTypes.push(flags & 8 ? getIndexedAccessType(type, numberType) : type);
45364                 }
45365                 else {
45366                     if (flags & 1 && optionalIndex >= 0) {
45367                         for (var i = optionalIndex; i < expandedFlags.length; i++) {
45368                             if (expandedFlags[i] & 2)
45369                                 expandedFlags[i] = 1;
45370                         }
45371                         optionalIndex = -1;
45372                     }
45373                     else if (flags & 2 && optionalIndex < 0) {
45374                         optionalIndex = expandedFlags.length;
45375                     }
45376                     else if (flags & 4) {
45377                         restTypes = [type];
45378                     }
45379                     expandedTypes.push(type);
45380                     expandedFlags.push(flags);
45381                     if (expandedDeclarations && declaration) {
45382                         expandedDeclarations.push(declaration);
45383                     }
45384                     else {
45385                         expandedDeclarations = undefined;
45386                     }
45387                 }
45388             }
45389         }
45390         function sliceTupleType(type, index, endSkipCount) {
45391             if (endSkipCount === void 0) { endSkipCount = 0; }
45392             var target = type.target;
45393             var endIndex = getTypeReferenceArity(type) - endSkipCount;
45394             return index > target.fixedLength ? getRestArrayTypeOfTupleType(type) || createTupleType(ts.emptyArray) :
45395                 createTupleType(getTypeArguments(type).slice(index, endIndex), target.elementFlags.slice(index, endIndex), false, target.labeledElementDeclarations && target.labeledElementDeclarations.slice(index, endIndex));
45396         }
45397         function getKnownKeysOfTupleType(type) {
45398             return getUnionType(ts.append(ts.arrayOf(type.target.fixedLength, function (i) { return getLiteralType("" + i); }), getIndexType(type.target.readonly ? globalReadonlyArrayType : globalArrayType)));
45399         }
45400         function getTypeFromOptionalTypeNode(node) {
45401             var type = getTypeFromTypeNode(node.type);
45402             return strictNullChecks ? getOptionalType(type) : type;
45403         }
45404         function getTypeId(type) {
45405             return type.id;
45406         }
45407         function containsType(types, type) {
45408             return ts.binarySearch(types, type, getTypeId, ts.compareValues) >= 0;
45409         }
45410         function insertType(types, type) {
45411             var index = ts.binarySearch(types, type, getTypeId, ts.compareValues);
45412             if (index < 0) {
45413                 types.splice(~index, 0, type);
45414                 return true;
45415             }
45416             return false;
45417         }
45418         function addTypeToUnion(typeSet, includes, type) {
45419             var flags = type.flags;
45420             if (flags & 1048576) {
45421                 return addTypesToUnion(typeSet, includes, type.types);
45422             }
45423             if (!(flags & 131072)) {
45424                 includes |= flags & 205258751;
45425                 if (flags & 469499904)
45426                     includes |= 262144;
45427                 if (type === wildcardType)
45428                     includes |= 8388608;
45429                 if (!strictNullChecks && flags & 98304) {
45430                     if (!(ts.getObjectFlags(type) & 524288))
45431                         includes |= 4194304;
45432                 }
45433                 else {
45434                     var len = typeSet.length;
45435                     var index = len && type.id > typeSet[len - 1].id ? ~len : ts.binarySearch(typeSet, type, getTypeId, ts.compareValues);
45436                     if (index < 0) {
45437                         typeSet.splice(~index, 0, type);
45438                     }
45439                 }
45440             }
45441             return includes;
45442         }
45443         function addTypesToUnion(typeSet, includes, types) {
45444             for (var _i = 0, types_10 = types; _i < types_10.length; _i++) {
45445                 var type = types_10[_i];
45446                 includes = addTypeToUnion(typeSet, includes, type);
45447             }
45448             return includes;
45449         }
45450         function isSetOfLiteralsFromSameEnum(types) {
45451             var first = types[0];
45452             if (first.flags & 1024) {
45453                 var firstEnum = getParentOfSymbol(first.symbol);
45454                 for (var i = 1; i < types.length; i++) {
45455                     var other = types[i];
45456                     if (!(other.flags & 1024) || (firstEnum !== getParentOfSymbol(other.symbol))) {
45457                         return false;
45458                     }
45459                 }
45460                 return true;
45461             }
45462             return false;
45463         }
45464         function removeSubtypes(types, primitivesOnly) {
45465             var len = types.length;
45466             if (len === 0 || isSetOfLiteralsFromSameEnum(types)) {
45467                 return true;
45468             }
45469             var i = len;
45470             var count = 0;
45471             while (i > 0) {
45472                 i--;
45473                 var source = types[i];
45474                 for (var _i = 0, types_11 = types; _i < types_11.length; _i++) {
45475                     var target = types_11[_i];
45476                     if (source !== target) {
45477                         if (count === 100000) {
45478                             var estimatedCount = (count / (len - i)) * len;
45479                             if (estimatedCount > (primitivesOnly ? 25000000 : 1000000)) {
45480                                 ts.tracing.instant("check", "removeSubtypes_DepthLimit", { typeIds: types.map(function (t) { return t.id; }) });
45481                                 error(currentNode, ts.Diagnostics.Expression_produces_a_union_type_that_is_too_complex_to_represent);
45482                                 return false;
45483                             }
45484                         }
45485                         count++;
45486                         if (isTypeRelatedTo(source, target, strictSubtypeRelation) && (!(ts.getObjectFlags(getTargetType(source)) & 1) ||
45487                             !(ts.getObjectFlags(getTargetType(target)) & 1) ||
45488                             isTypeDerivedFrom(source, target))) {
45489                             ts.orderedRemoveItemAt(types, i);
45490                             break;
45491                         }
45492                     }
45493                 }
45494             }
45495             return true;
45496         }
45497         function removeRedundantLiteralTypes(types, includes) {
45498             var i = types.length;
45499             while (i > 0) {
45500                 i--;
45501                 var t = types[i];
45502                 var remove = t.flags & 128 && includes & 4 ||
45503                     t.flags & 256 && includes & 8 ||
45504                     t.flags & 2048 && includes & 64 ||
45505                     t.flags & 8192 && includes & 4096 ||
45506                     isFreshLiteralType(t) && containsType(types, t.regularType);
45507                 if (remove) {
45508                     ts.orderedRemoveItemAt(types, i);
45509                 }
45510             }
45511         }
45512         function removeStringLiteralsMatchedByTemplateLiterals(types) {
45513             var templates = ts.filter(types, isPatternLiteralType);
45514             if (templates.length) {
45515                 var i = types.length;
45516                 var _loop_14 = function () {
45517                     i--;
45518                     var t = types[i];
45519                     if (t.flags & 128 && ts.some(templates, function (template) { return isTypeSubtypeOf(t, template); })) {
45520                         ts.orderedRemoveItemAt(types, i);
45521                     }
45522                 };
45523                 while (i > 0) {
45524                     _loop_14();
45525                 }
45526             }
45527         }
45528         function getUnionType(types, unionReduction, aliasSymbol, aliasTypeArguments) {
45529             if (unionReduction === void 0) { unionReduction = 1; }
45530             if (types.length === 0) {
45531                 return neverType;
45532             }
45533             if (types.length === 1) {
45534                 return types[0];
45535             }
45536             var typeSet = [];
45537             var includes = addTypesToUnion(typeSet, 0, types);
45538             if (unionReduction !== 0) {
45539                 if (includes & 3) {
45540                     return includes & 1 ? includes & 8388608 ? wildcardType : anyType : unknownType;
45541                 }
45542                 switch (unionReduction) {
45543                     case 1:
45544                         if (includes & (2944 | 8192)) {
45545                             removeRedundantLiteralTypes(typeSet, includes);
45546                         }
45547                         if (includes & 128 && includes & 134217728) {
45548                             removeStringLiteralsMatchedByTemplateLiterals(typeSet);
45549                         }
45550                         break;
45551                     case 2:
45552                         if (!removeSubtypes(typeSet, !(includes & 262144))) {
45553                             return errorType;
45554                         }
45555                         break;
45556                 }
45557                 if (typeSet.length === 0) {
45558                     return includes & 65536 ? includes & 4194304 ? nullType : nullWideningType :
45559                         includes & 32768 ? includes & 4194304 ? undefinedType : undefinedWideningType :
45560                             neverType;
45561                 }
45562             }
45563             var objectFlags = (includes & 469647395 ? 0 : 262144) |
45564                 (includes & 2097152 ? 268435456 : 0);
45565             return getUnionTypeFromSortedList(typeSet, objectFlags, aliasSymbol, aliasTypeArguments);
45566         }
45567         function getUnionTypePredicate(signatures) {
45568             var first;
45569             var types = [];
45570             for (var _i = 0, signatures_6 = signatures; _i < signatures_6.length; _i++) {
45571                 var sig = signatures_6[_i];
45572                 var pred = getTypePredicateOfSignature(sig);
45573                 if (!pred || pred.kind === 2 || pred.kind === 3) {
45574                     continue;
45575                 }
45576                 if (first) {
45577                     if (!typePredicateKindsMatch(first, pred)) {
45578                         return undefined;
45579                     }
45580                 }
45581                 else {
45582                     first = pred;
45583                 }
45584                 types.push(pred.type);
45585             }
45586             if (!first) {
45587                 return undefined;
45588             }
45589             var unionType = getUnionType(types);
45590             return createTypePredicate(first.kind, first.parameterName, first.parameterIndex, unionType);
45591         }
45592         function typePredicateKindsMatch(a, b) {
45593             return a.kind === b.kind && a.parameterIndex === b.parameterIndex;
45594         }
45595         function getUnionTypeFromSortedList(types, objectFlags, aliasSymbol, aliasTypeArguments) {
45596             if (types.length === 0) {
45597                 return neverType;
45598             }
45599             if (types.length === 1) {
45600                 return types[0];
45601             }
45602             var id = getTypeListId(types);
45603             var type = unionTypes.get(id);
45604             if (!type) {
45605                 type = createType(1048576);
45606                 unionTypes.set(id, type);
45607                 type.objectFlags = objectFlags | getPropagatingFlagsOfTypes(types, 98304);
45608                 type.types = types;
45609                 type.aliasSymbol = aliasSymbol;
45610                 type.aliasTypeArguments = aliasTypeArguments;
45611             }
45612             return type;
45613         }
45614         function getTypeFromUnionTypeNode(node) {
45615             var links = getNodeLinks(node);
45616             if (!links.resolvedType) {
45617                 var aliasSymbol = getAliasSymbolForTypeNode(node);
45618                 links.resolvedType = getUnionType(ts.map(node.types, getTypeFromTypeNode), 1, aliasSymbol, getTypeArgumentsForAliasSymbol(aliasSymbol));
45619             }
45620             return links.resolvedType;
45621         }
45622         function addTypeToIntersection(typeSet, includes, type) {
45623             var flags = type.flags;
45624             if (flags & 2097152) {
45625                 return addTypesToIntersection(typeSet, includes, type.types);
45626             }
45627             if (isEmptyAnonymousObjectType(type)) {
45628                 if (!(includes & 16777216)) {
45629                     includes |= 16777216;
45630                     typeSet.set(type.id.toString(), type);
45631                 }
45632             }
45633             else {
45634                 if (flags & 3) {
45635                     if (type === wildcardType)
45636                         includes |= 8388608;
45637                 }
45638                 else if ((strictNullChecks || !(flags & 98304)) && !typeSet.has(type.id.toString())) {
45639                     if (type.flags & 109440 && includes & 109440) {
45640                         includes |= 67108864;
45641                     }
45642                     typeSet.set(type.id.toString(), type);
45643                 }
45644                 includes |= flags & 205258751;
45645             }
45646             return includes;
45647         }
45648         function addTypesToIntersection(typeSet, includes, types) {
45649             for (var _i = 0, types_12 = types; _i < types_12.length; _i++) {
45650                 var type = types_12[_i];
45651                 includes = addTypeToIntersection(typeSet, includes, getRegularTypeOfLiteralType(type));
45652             }
45653             return includes;
45654         }
45655         function removeRedundantPrimitiveTypes(types, includes) {
45656             var i = types.length;
45657             while (i > 0) {
45658                 i--;
45659                 var t = types[i];
45660                 var remove = t.flags & 4 && includes & 128 ||
45661                     t.flags & 8 && includes & 256 ||
45662                     t.flags & 64 && includes & 2048 ||
45663                     t.flags & 4096 && includes & 8192;
45664                 if (remove) {
45665                     ts.orderedRemoveItemAt(types, i);
45666                 }
45667             }
45668         }
45669         function eachUnionContains(unionTypes, type) {
45670             for (var _i = 0, unionTypes_1 = unionTypes; _i < unionTypes_1.length; _i++) {
45671                 var u = unionTypes_1[_i];
45672                 if (!containsType(u.types, type)) {
45673                     var primitive = type.flags & 128 ? stringType :
45674                         type.flags & 256 ? numberType :
45675                             type.flags & 2048 ? bigintType :
45676                                 type.flags & 8192 ? esSymbolType :
45677                                     undefined;
45678                     if (!primitive || !containsType(u.types, primitive)) {
45679                         return false;
45680                     }
45681                 }
45682             }
45683             return true;
45684         }
45685         function extractRedundantTemplateLiterals(types) {
45686             var i = types.length;
45687             var literals = ts.filter(types, function (t) { return !!(t.flags & 128); });
45688             while (i > 0) {
45689                 i--;
45690                 var t = types[i];
45691                 if (!(t.flags & 134217728))
45692                     continue;
45693                 for (var _i = 0, literals_1 = literals; _i < literals_1.length; _i++) {
45694                     var t2 = literals_1[_i];
45695                     if (isTypeSubtypeOf(t2, t)) {
45696                         ts.orderedRemoveItemAt(types, i);
45697                         break;
45698                     }
45699                     else if (isPatternLiteralType(t)) {
45700                         return true;
45701                     }
45702                 }
45703             }
45704             return false;
45705         }
45706         function extractIrreducible(types, flag) {
45707             if (ts.every(types, function (t) { return !!(t.flags & 1048576) && ts.some(t.types, function (tt) { return !!(tt.flags & flag); }); })) {
45708                 for (var i = 0; i < types.length; i++) {
45709                     types[i] = filterType(types[i], function (t) { return !(t.flags & flag); });
45710                 }
45711                 return true;
45712             }
45713             return false;
45714         }
45715         function intersectUnionsOfPrimitiveTypes(types) {
45716             var unionTypes;
45717             var index = ts.findIndex(types, function (t) { return !!(ts.getObjectFlags(t) & 262144); });
45718             if (index < 0) {
45719                 return false;
45720             }
45721             var i = index + 1;
45722             while (i < types.length) {
45723                 var t = types[i];
45724                 if (ts.getObjectFlags(t) & 262144) {
45725                     (unionTypes || (unionTypes = [types[index]])).push(t);
45726                     ts.orderedRemoveItemAt(types, i);
45727                 }
45728                 else {
45729                     i++;
45730                 }
45731             }
45732             if (!unionTypes) {
45733                 return false;
45734             }
45735             var checked = [];
45736             var result = [];
45737             for (var _i = 0, unionTypes_2 = unionTypes; _i < unionTypes_2.length; _i++) {
45738                 var u = unionTypes_2[_i];
45739                 for (var _a = 0, _b = u.types; _a < _b.length; _a++) {
45740                     var t = _b[_a];
45741                     if (insertType(checked, t)) {
45742                         if (eachUnionContains(unionTypes, t)) {
45743                             insertType(result, t);
45744                         }
45745                     }
45746                 }
45747             }
45748             types[index] = getUnionTypeFromSortedList(result, 262144);
45749             return true;
45750         }
45751         function createIntersectionType(types, aliasSymbol, aliasTypeArguments) {
45752             var result = createType(2097152);
45753             result.objectFlags = getPropagatingFlagsOfTypes(types, 98304);
45754             result.types = types;
45755             result.aliasSymbol = aliasSymbol;
45756             result.aliasTypeArguments = aliasTypeArguments;
45757             return result;
45758         }
45759         function getIntersectionType(types, aliasSymbol, aliasTypeArguments) {
45760             var typeMembershipMap = new ts.Map();
45761             var includes = addTypesToIntersection(typeMembershipMap, 0, types);
45762             var typeSet = ts.arrayFrom(typeMembershipMap.values());
45763             if (includes & 131072 ||
45764                 strictNullChecks && includes & 98304 && includes & (524288 | 67108864 | 16777216) ||
45765                 includes & 67108864 && includes & (469892092 & ~67108864) ||
45766                 includes & 402653316 && includes & (469892092 & ~402653316) ||
45767                 includes & 296 && includes & (469892092 & ~296) ||
45768                 includes & 2112 && includes & (469892092 & ~2112) ||
45769                 includes & 12288 && includes & (469892092 & ~12288) ||
45770                 includes & 49152 && includes & (469892092 & ~49152)) {
45771                 return neverType;
45772             }
45773             if (includes & 134217728 && includes & 128 && extractRedundantTemplateLiterals(typeSet)) {
45774                 return neverType;
45775             }
45776             if (includes & 1) {
45777                 return includes & 8388608 ? wildcardType : anyType;
45778             }
45779             if (!strictNullChecks && includes & 98304) {
45780                 return includes & 32768 ? undefinedType : nullType;
45781             }
45782             if (includes & 4 && includes & 128 ||
45783                 includes & 8 && includes & 256 ||
45784                 includes & 64 && includes & 2048 ||
45785                 includes & 4096 && includes & 8192) {
45786                 removeRedundantPrimitiveTypes(typeSet, includes);
45787             }
45788             if (includes & 16777216 && includes & 524288) {
45789                 ts.orderedRemoveItemAt(typeSet, ts.findIndex(typeSet, isEmptyAnonymousObjectType));
45790             }
45791             if (typeSet.length === 0) {
45792                 return unknownType;
45793             }
45794             if (typeSet.length === 1) {
45795                 return typeSet[0];
45796             }
45797             var id = getTypeListId(typeSet);
45798             var result = intersectionTypes.get(id);
45799             if (!result) {
45800                 if (includes & 1048576) {
45801                     if (intersectUnionsOfPrimitiveTypes(typeSet)) {
45802                         result = getIntersectionType(typeSet, aliasSymbol, aliasTypeArguments);
45803                     }
45804                     else if (extractIrreducible(typeSet, 32768)) {
45805                         result = getUnionType([getIntersectionType(typeSet), undefinedType], 1, aliasSymbol, aliasTypeArguments);
45806                     }
45807                     else if (extractIrreducible(typeSet, 65536)) {
45808                         result = getUnionType([getIntersectionType(typeSet), nullType], 1, aliasSymbol, aliasTypeArguments);
45809                     }
45810                     else {
45811                         if (!checkCrossProductUnion(typeSet)) {
45812                             return errorType;
45813                         }
45814                         var unionIndex_1 = ts.findIndex(typeSet, function (t) { return (t.flags & 1048576) !== 0; });
45815                         var unionType = typeSet[unionIndex_1];
45816                         result = getUnionType(ts.map(unionType.types, function (t) { return getIntersectionType(ts.replaceElement(typeSet, unionIndex_1, t)); }), 1, aliasSymbol, aliasTypeArguments);
45817                     }
45818                 }
45819                 else {
45820                     result = createIntersectionType(typeSet, aliasSymbol, aliasTypeArguments);
45821                 }
45822                 intersectionTypes.set(id, result);
45823             }
45824             return result;
45825         }
45826         function checkCrossProductUnion(types) {
45827             var size = ts.reduceLeft(types, function (n, t) { return n * (t.flags & 1048576 ? t.types.length : t.flags & 131072 ? 0 : 1); }, 1);
45828             if (size >= 100000) {
45829                 ts.tracing.instant("check", "checkCrossProductUnion_DepthLimit", { typeIds: types.map(function (t) { return t.id; }), size: size });
45830                 error(currentNode, ts.Diagnostics.Expression_produces_a_union_type_that_is_too_complex_to_represent);
45831                 return false;
45832             }
45833             return true;
45834         }
45835         function getTypeFromIntersectionTypeNode(node) {
45836             var links = getNodeLinks(node);
45837             if (!links.resolvedType) {
45838                 var aliasSymbol = getAliasSymbolForTypeNode(node);
45839                 links.resolvedType = getIntersectionType(ts.map(node.types, getTypeFromTypeNode), aliasSymbol, getTypeArgumentsForAliasSymbol(aliasSymbol));
45840             }
45841             return links.resolvedType;
45842         }
45843         function createIndexType(type, stringsOnly) {
45844             var result = createType(4194304);
45845             result.type = type;
45846             result.stringsOnly = stringsOnly;
45847             return result;
45848         }
45849         function getIndexTypeForGenericType(type, stringsOnly) {
45850             return stringsOnly ?
45851                 type.resolvedStringIndexType || (type.resolvedStringIndexType = createIndexType(type, true)) :
45852                 type.resolvedIndexType || (type.resolvedIndexType = createIndexType(type, false));
45853         }
45854         function getIndexTypeForMappedType(type, noIndexSignatures) {
45855             var constraint = filterType(getConstraintTypeFromMappedType(type), function (t) { return !(noIndexSignatures && t.flags & (1 | 4)); });
45856             var nameType = type.declaration.nameType && getTypeFromTypeNode(type.declaration.nameType);
45857             return nameType ?
45858                 mapType(constraint, function (t) { return instantiateType(nameType, appendTypeMapping(type.mapper, getTypeParameterFromMappedType(type), t)); }) :
45859                 constraint;
45860         }
45861         function isNonDistributiveNameType(type) {
45862             return !!(type && (type.flags & 16777216 && !type.root.isDistributive ||
45863                 type.flags & (3145728 | 134217728) && ts.some(type.types, isNonDistributiveNameType) ||
45864                 type.flags & (4194304 | 268435456) && isNonDistributiveNameType(type.type) ||
45865                 type.flags & 8388608 && isNonDistributiveNameType(type.indexType) ||
45866                 type.flags & 33554432 && isNonDistributiveNameType(type.substitute)));
45867         }
45868         function getLiteralTypeFromPropertyName(name) {
45869             if (ts.isPrivateIdentifier(name)) {
45870                 return neverType;
45871             }
45872             return ts.isIdentifier(name) ? getLiteralType(ts.unescapeLeadingUnderscores(name.escapedText)) :
45873                 getRegularTypeOfLiteralType(ts.isComputedPropertyName(name) ? checkComputedPropertyName(name) : checkExpression(name));
45874         }
45875         function getBigIntLiteralType(node) {
45876             return getLiteralType({
45877                 negative: false,
45878                 base10Value: ts.parsePseudoBigInt(node.text)
45879             });
45880         }
45881         function getLiteralTypeFromProperty(prop, include) {
45882             if (!(ts.getDeclarationModifierFlagsFromSymbol(prop) & 24)) {
45883                 var type = getSymbolLinks(getLateBoundSymbol(prop)).nameType;
45884                 if (!type && !ts.isKnownSymbol(prop)) {
45885                     if (prop.escapedName === "default") {
45886                         type = getLiteralType("default");
45887                     }
45888                     else {
45889                         var name = prop.valueDeclaration && ts.getNameOfDeclaration(prop.valueDeclaration);
45890                         type = name && getLiteralTypeFromPropertyName(name) || getLiteralType(ts.symbolName(prop));
45891                     }
45892                 }
45893                 if (type && type.flags & include) {
45894                     return type;
45895                 }
45896             }
45897             return neverType;
45898         }
45899         function getLiteralTypeFromProperties(type, include) {
45900             return getUnionType(ts.map(getPropertiesOfType(type), function (p) { return getLiteralTypeFromProperty(p, include); }));
45901         }
45902         function getNonEnumNumberIndexInfo(type) {
45903             var numberIndexInfo = getIndexInfoOfType(type, 1);
45904             return numberIndexInfo !== enumNumberIndexInfo ? numberIndexInfo : undefined;
45905         }
45906         function getIndexType(type, stringsOnly, noIndexSignatures) {
45907             if (stringsOnly === void 0) { stringsOnly = keyofStringsOnly; }
45908             type = getReducedType(type);
45909             return type.flags & 1048576 ? getIntersectionType(ts.map(type.types, function (t) { return getIndexType(t, stringsOnly, noIndexSignatures); })) :
45910                 type.flags & 2097152 ? getUnionType(ts.map(type.types, function (t) { return getIndexType(t, stringsOnly, noIndexSignatures); })) :
45911                     type.flags & 58982400 || isGenericTupleType(type) || isGenericMappedType(type) && isNonDistributiveNameType(getNameTypeFromMappedType(type)) ? getIndexTypeForGenericType(type, stringsOnly) :
45912                         ts.getObjectFlags(type) & 32 ? getIndexTypeForMappedType(type, noIndexSignatures) :
45913                             type === wildcardType ? wildcardType :
45914                                 type.flags & 2 ? neverType :
45915                                     type.flags & (1 | 131072) ? keyofConstraintType :
45916                                         stringsOnly ? !noIndexSignatures && getIndexInfoOfType(type, 0) ? stringType : getLiteralTypeFromProperties(type, 128) :
45917                                             !noIndexSignatures && getIndexInfoOfType(type, 0) ? getUnionType([stringType, numberType, getLiteralTypeFromProperties(type, 8192)]) :
45918                                                 getNonEnumNumberIndexInfo(type) ? getUnionType([numberType, getLiteralTypeFromProperties(type, 128 | 8192)]) :
45919                                                     getLiteralTypeFromProperties(type, 8576);
45920         }
45921         function getExtractStringType(type) {
45922             if (keyofStringsOnly) {
45923                 return type;
45924             }
45925             var extractTypeAlias = getGlobalExtractSymbol();
45926             return extractTypeAlias ? getTypeAliasInstantiation(extractTypeAlias, [type, stringType]) : stringType;
45927         }
45928         function getIndexTypeOrString(type) {
45929             var indexType = getExtractStringType(getIndexType(type));
45930             return indexType.flags & 131072 ? stringType : indexType;
45931         }
45932         function getTypeFromTypeOperatorNode(node) {
45933             var links = getNodeLinks(node);
45934             if (!links.resolvedType) {
45935                 switch (node.operator) {
45936                     case 138:
45937                         links.resolvedType = getIndexType(getTypeFromTypeNode(node.type));
45938                         break;
45939                     case 151:
45940                         links.resolvedType = node.type.kind === 148
45941                             ? getESSymbolLikeTypeForNode(ts.walkUpParenthesizedTypes(node.parent))
45942                             : errorType;
45943                         break;
45944                     case 142:
45945                         links.resolvedType = getTypeFromTypeNode(node.type);
45946                         break;
45947                     default:
45948                         throw ts.Debug.assertNever(node.operator);
45949                 }
45950             }
45951             return links.resolvedType;
45952         }
45953         function getTypeFromTemplateTypeNode(node) {
45954             var links = getNodeLinks(node);
45955             if (!links.resolvedType) {
45956                 links.resolvedType = getTemplateLiteralType(__spreadArrays([node.head.text], ts.map(node.templateSpans, function (span) { return span.literal.text; })), ts.map(node.templateSpans, function (span) { return getTypeFromTypeNode(span.type); }));
45957             }
45958             return links.resolvedType;
45959         }
45960         function getTemplateLiteralType(texts, types) {
45961             var unionIndex = ts.findIndex(types, function (t) { return !!(t.flags & (131072 | 1048576)); });
45962             if (unionIndex >= 0) {
45963                 return checkCrossProductUnion(types) ?
45964                     mapType(types[unionIndex], function (t) { return getTemplateLiteralType(texts, ts.replaceElement(types, unionIndex, t)); }) :
45965                     errorType;
45966             }
45967             if (ts.contains(types, wildcardType)) {
45968                 return wildcardType;
45969             }
45970             var newTypes = [];
45971             var newTexts = [];
45972             var text = texts[0];
45973             if (!addSpans(texts, types)) {
45974                 return stringType;
45975             }
45976             if (newTypes.length === 0) {
45977                 return getLiteralType(text);
45978             }
45979             newTexts.push(text);
45980             var id = getTypeListId(newTypes) + "|" + ts.map(newTexts, function (t) { return t.length; }).join(",") + "|" + newTexts.join("");
45981             var type = templateLiteralTypes.get(id);
45982             if (!type) {
45983                 templateLiteralTypes.set(id, type = createTemplateLiteralType(newTexts, newTypes));
45984             }
45985             return type;
45986             function addSpans(texts, types) {
45987                 for (var i = 0; i < types.length; i++) {
45988                     var t = types[i];
45989                     if (t.flags & (2944 | 65536 | 32768)) {
45990                         text += getTemplateStringForType(t) || "";
45991                         text += texts[i + 1];
45992                     }
45993                     else if (t.flags & 134217728) {
45994                         text += t.texts[0];
45995                         if (!addSpans(t.texts, t.types))
45996                             return false;
45997                         text += texts[i + 1];
45998                     }
45999                     else if (isGenericIndexType(t) || isPatternLiteralPlaceholderType(t)) {
46000                         newTypes.push(t);
46001                         newTexts.push(text);
46002                         text = texts[i + 1];
46003                     }
46004                     else {
46005                         return false;
46006                     }
46007                 }
46008                 return true;
46009             }
46010         }
46011         function getTemplateStringForType(type) {
46012             return type.flags & 128 ? type.value :
46013                 type.flags & 256 ? "" + type.value :
46014                     type.flags & 2048 ? ts.pseudoBigIntToString(type.value) :
46015                         type.flags & 512 ? type.intrinsicName :
46016                             type.flags & 65536 ? "null" :
46017                                 type.flags & 32768 ? "undefined" :
46018                                     undefined;
46019         }
46020         function createTemplateLiteralType(texts, types) {
46021             var type = createType(134217728);
46022             type.texts = texts;
46023             type.types = types;
46024             return type;
46025         }
46026         function getStringMappingType(symbol, type) {
46027             return type.flags & (1048576 | 131072) ? mapType(type, function (t) { return getStringMappingType(symbol, t); }) :
46028                 isGenericIndexType(type) ? getStringMappingTypeForGenericType(symbol, type) :
46029                     type.flags & 128 ? getLiteralType(applyStringMapping(symbol, type.value)) :
46030                         type;
46031         }
46032         function applyStringMapping(symbol, str) {
46033             switch (intrinsicTypeKinds.get(symbol.escapedName)) {
46034                 case 0: return str.toUpperCase();
46035                 case 1: return str.toLowerCase();
46036                 case 2: return str.charAt(0).toUpperCase() + str.slice(1);
46037                 case 3: return str.charAt(0).toLowerCase() + str.slice(1);
46038             }
46039             return str;
46040         }
46041         function getStringMappingTypeForGenericType(symbol, type) {
46042             var id = getSymbolId(symbol) + "," + getTypeId(type);
46043             var result = stringMappingTypes.get(id);
46044             if (!result) {
46045                 stringMappingTypes.set(id, result = createStringMappingType(symbol, type));
46046             }
46047             return result;
46048         }
46049         function createStringMappingType(symbol, type) {
46050             var result = createType(268435456);
46051             result.symbol = symbol;
46052             result.type = type;
46053             return result;
46054         }
46055         function createIndexedAccessType(objectType, indexType, aliasSymbol, aliasTypeArguments, shouldIncludeUndefined) {
46056             var type = createType(8388608);
46057             type.objectType = objectType;
46058             type.indexType = indexType;
46059             type.aliasSymbol = aliasSymbol;
46060             type.aliasTypeArguments = aliasTypeArguments;
46061             type.noUncheckedIndexedAccessCandidate = shouldIncludeUndefined;
46062             return type;
46063         }
46064         function isJSLiteralType(type) {
46065             if (noImplicitAny) {
46066                 return false;
46067             }
46068             if (ts.getObjectFlags(type) & 16384) {
46069                 return true;
46070             }
46071             if (type.flags & 1048576) {
46072                 return ts.every(type.types, isJSLiteralType);
46073             }
46074             if (type.flags & 2097152) {
46075                 return ts.some(type.types, isJSLiteralType);
46076             }
46077             if (type.flags & 465829888) {
46078                 return isJSLiteralType(getResolvedBaseConstraint(type));
46079             }
46080             return false;
46081         }
46082         function getPropertyNameFromIndex(indexType, accessNode) {
46083             var accessExpression = accessNode && accessNode.kind === 202 ? accessNode : undefined;
46084             return isTypeUsableAsPropertyName(indexType) ?
46085                 getPropertyNameFromType(indexType) :
46086                 accessExpression && checkThatExpressionIsProperSymbolReference(accessExpression.argumentExpression, indexType, false) ?
46087                     ts.getPropertyNameForKnownSymbolName(ts.idText(accessExpression.argumentExpression.name)) :
46088                     accessNode && ts.isPropertyName(accessNode) ?
46089                         ts.getPropertyNameForPropertyNameNode(accessNode) :
46090                         undefined;
46091         }
46092         function isUncalledFunctionReference(node, symbol) {
46093             return !(symbol.flags & (16 | 8192))
46094                 || !ts.isCallLikeExpression(ts.findAncestor(node, function (n) { return !ts.isAccessExpression(n); }) || node.parent)
46095                     && ts.every(symbol.declarations, function (d) { return !ts.isFunctionLike(d) || !!(ts.getCombinedNodeFlags(d) & 134217728); });
46096         }
46097         function getPropertyTypeForIndexType(originalObjectType, objectType, indexType, fullIndexType, suppressNoImplicitAnyError, accessNode, accessFlags, noUncheckedIndexedAccessCandidate, reportDeprecated) {
46098             var _a;
46099             var accessExpression = accessNode && accessNode.kind === 202 ? accessNode : undefined;
46100             var propName = accessNode && ts.isPrivateIdentifier(accessNode) ? undefined : getPropertyNameFromIndex(indexType, accessNode);
46101             if (propName !== undefined) {
46102                 var prop = getPropertyOfType(objectType, propName);
46103                 if (prop) {
46104                     if (reportDeprecated && accessNode && getDeclarationNodeFlagsFromSymbol(prop) & 134217728 && isUncalledFunctionReference(accessNode, prop)) {
46105                         var deprecatedNode = (_a = accessExpression === null || accessExpression === void 0 ? void 0 : accessExpression.argumentExpression) !== null && _a !== void 0 ? _a : (ts.isIndexedAccessTypeNode(accessNode) ? accessNode.indexType : accessNode);
46106                         errorOrSuggestion(false, deprecatedNode, ts.Diagnostics._0_is_deprecated, propName);
46107                     }
46108                     if (accessExpression) {
46109                         markPropertyAsReferenced(prop, accessExpression, accessExpression.expression.kind === 107);
46110                         if (isAssignmentToReadonlyEntity(accessExpression, prop, ts.getAssignmentTargetKind(accessExpression))) {
46111                             error(accessExpression.argumentExpression, ts.Diagnostics.Cannot_assign_to_0_because_it_is_a_read_only_property, symbolToString(prop));
46112                             return undefined;
46113                         }
46114                         if (accessFlags & 4) {
46115                             getNodeLinks(accessNode).resolvedSymbol = prop;
46116                         }
46117                         if (isThisPropertyAccessInConstructor(accessExpression, prop)) {
46118                             return autoType;
46119                         }
46120                     }
46121                     var propType = getTypeOfSymbol(prop);
46122                     return accessExpression && ts.getAssignmentTargetKind(accessExpression) !== 1 ?
46123                         getFlowTypeOfReference(accessExpression, propType) :
46124                         propType;
46125                 }
46126                 if (everyType(objectType, isTupleType) && isNumericLiteralName(propName) && +propName >= 0) {
46127                     if (accessNode && everyType(objectType, function (t) { return !t.target.hasRestElement; }) && !(accessFlags & 8)) {
46128                         var indexNode = getIndexNodeForAccessExpression(accessNode);
46129                         if (isTupleType(objectType)) {
46130                             error(indexNode, ts.Diagnostics.Tuple_type_0_of_length_1_has_no_element_at_index_2, typeToString(objectType), getTypeReferenceArity(objectType), ts.unescapeLeadingUnderscores(propName));
46131                         }
46132                         else {
46133                             error(indexNode, ts.Diagnostics.Property_0_does_not_exist_on_type_1, ts.unescapeLeadingUnderscores(propName), typeToString(objectType));
46134                         }
46135                     }
46136                     errorIfWritingToReadonlyIndex(getIndexInfoOfType(objectType, 1));
46137                     return mapType(objectType, function (t) {
46138                         var restType = getRestTypeOfTupleType(t) || undefinedType;
46139                         return noUncheckedIndexedAccessCandidate ? getUnionType([restType, undefinedType]) : restType;
46140                     });
46141                 }
46142             }
46143             if (!(indexType.flags & 98304) && isTypeAssignableToKind(indexType, 402653316 | 296 | 12288)) {
46144                 if (objectType.flags & (1 | 131072)) {
46145                     return objectType;
46146                 }
46147                 var stringIndexInfo = getIndexInfoOfType(objectType, 0);
46148                 var indexInfo = isTypeAssignableToKind(indexType, 296) && getIndexInfoOfType(objectType, 1) || stringIndexInfo;
46149                 if (indexInfo) {
46150                     if (accessFlags & 1 && indexInfo === stringIndexInfo) {
46151                         if (accessExpression) {
46152                             error(accessExpression, ts.Diagnostics.Type_0_cannot_be_used_to_index_type_1, typeToString(indexType), typeToString(originalObjectType));
46153                         }
46154                         return undefined;
46155                     }
46156                     if (accessNode && !isTypeAssignableToKind(indexType, 4 | 8)) {
46157                         var indexNode = getIndexNodeForAccessExpression(accessNode);
46158                         error(indexNode, ts.Diagnostics.Type_0_cannot_be_used_as_an_index_type, typeToString(indexType));
46159                         return noUncheckedIndexedAccessCandidate ? getUnionType([indexInfo.type, undefinedType]) : indexInfo.type;
46160                     }
46161                     errorIfWritingToReadonlyIndex(indexInfo);
46162                     return noUncheckedIndexedAccessCandidate ? getUnionType([indexInfo.type, undefinedType]) : indexInfo.type;
46163                 }
46164                 if (indexType.flags & 131072) {
46165                     return neverType;
46166                 }
46167                 if (isJSLiteralType(objectType)) {
46168                     return anyType;
46169                 }
46170                 if (accessExpression && !isConstEnumObjectType(objectType)) {
46171                     if (objectType.symbol === globalThisSymbol && propName !== undefined && globalThisSymbol.exports.has(propName) && (globalThisSymbol.exports.get(propName).flags & 418)) {
46172                         error(accessExpression, ts.Diagnostics.Property_0_does_not_exist_on_type_1, ts.unescapeLeadingUnderscores(propName), typeToString(objectType));
46173                     }
46174                     else if (noImplicitAny && !compilerOptions.suppressImplicitAnyIndexErrors && !suppressNoImplicitAnyError) {
46175                         if (propName !== undefined && typeHasStaticProperty(propName, objectType)) {
46176                             error(accessExpression, ts.Diagnostics.Property_0_is_a_static_member_of_type_1, propName, typeToString(objectType));
46177                         }
46178                         else if (getIndexTypeOfType(objectType, 1)) {
46179                             error(accessExpression.argumentExpression, ts.Diagnostics.Element_implicitly_has_an_any_type_because_index_expression_is_not_of_type_number);
46180                         }
46181                         else {
46182                             var suggestion = void 0;
46183                             if (propName !== undefined && (suggestion = getSuggestionForNonexistentProperty(propName, objectType))) {
46184                                 if (suggestion !== undefined) {
46185                                     error(accessExpression.argumentExpression, ts.Diagnostics.Property_0_does_not_exist_on_type_1_Did_you_mean_2, propName, typeToString(objectType), suggestion);
46186                                 }
46187                             }
46188                             else {
46189                                 var suggestion_1 = getSuggestionForNonexistentIndexSignature(objectType, accessExpression, indexType);
46190                                 if (suggestion_1 !== undefined) {
46191                                     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);
46192                                 }
46193                                 else {
46194                                     var errorInfo = void 0;
46195                                     if (indexType.flags & 1024) {
46196                                         errorInfo = ts.chainDiagnosticMessages(undefined, ts.Diagnostics.Property_0_does_not_exist_on_type_1, "[" + typeToString(indexType) + "]", typeToString(objectType));
46197                                     }
46198                                     else if (indexType.flags & 8192) {
46199                                         var symbolName_2 = getFullyQualifiedName(indexType.symbol, accessExpression);
46200                                         errorInfo = ts.chainDiagnosticMessages(undefined, ts.Diagnostics.Property_0_does_not_exist_on_type_1, "[" + symbolName_2 + "]", typeToString(objectType));
46201                                     }
46202                                     else if (indexType.flags & 128) {
46203                                         errorInfo = ts.chainDiagnosticMessages(undefined, ts.Diagnostics.Property_0_does_not_exist_on_type_1, indexType.value, typeToString(objectType));
46204                                     }
46205                                     else if (indexType.flags & 256) {
46206                                         errorInfo = ts.chainDiagnosticMessages(undefined, ts.Diagnostics.Property_0_does_not_exist_on_type_1, indexType.value, typeToString(objectType));
46207                                     }
46208                                     else if (indexType.flags & (8 | 4)) {
46209                                         errorInfo = ts.chainDiagnosticMessages(undefined, ts.Diagnostics.No_index_signature_with_a_parameter_of_type_0_was_found_on_type_1, typeToString(indexType), typeToString(objectType));
46210                                     }
46211                                     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));
46212                                     diagnostics.add(ts.createDiagnosticForNodeFromMessageChain(accessExpression, errorInfo));
46213                                 }
46214                             }
46215                         }
46216                     }
46217                     return undefined;
46218                 }
46219             }
46220             if (isJSLiteralType(objectType)) {
46221                 return anyType;
46222             }
46223             if (accessNode) {
46224                 var indexNode = getIndexNodeForAccessExpression(accessNode);
46225                 if (indexType.flags & (128 | 256)) {
46226                     error(indexNode, ts.Diagnostics.Property_0_does_not_exist_on_type_1, "" + indexType.value, typeToString(objectType));
46227                 }
46228                 else if (indexType.flags & (4 | 8)) {
46229                     error(indexNode, ts.Diagnostics.Type_0_has_no_matching_index_signature_for_type_1, typeToString(objectType), typeToString(indexType));
46230                 }
46231                 else {
46232                     error(indexNode, ts.Diagnostics.Type_0_cannot_be_used_as_an_index_type, typeToString(indexType));
46233                 }
46234             }
46235             if (isTypeAny(indexType)) {
46236                 return indexType;
46237             }
46238             return undefined;
46239             function errorIfWritingToReadonlyIndex(indexInfo) {
46240                 if (indexInfo && indexInfo.isReadonly && accessExpression && (ts.isAssignmentTarget(accessExpression) || ts.isDeleteTarget(accessExpression))) {
46241                     error(accessExpression, ts.Diagnostics.Index_signature_in_type_0_only_permits_reading, typeToString(objectType));
46242                 }
46243             }
46244         }
46245         function getIndexNodeForAccessExpression(accessNode) {
46246             return accessNode.kind === 202 ? accessNode.argumentExpression :
46247                 accessNode.kind === 189 ? accessNode.indexType :
46248                     accessNode.kind === 158 ? accessNode.expression :
46249                         accessNode;
46250         }
46251         function isPatternLiteralPlaceholderType(type) {
46252             return templateConstraintType.types.indexOf(type) !== -1 || !!(type.flags & 1);
46253         }
46254         function isPatternLiteralType(type) {
46255             return !!(type.flags & 134217728) && ts.every(type.types, isPatternLiteralPlaceholderType);
46256         }
46257         function isGenericObjectType(type) {
46258             if (type.flags & 3145728) {
46259                 if (!(type.objectFlags & 4194304)) {
46260                     type.objectFlags |= 4194304 |
46261                         (ts.some(type.types, isGenericObjectType) ? 8388608 : 0);
46262                 }
46263                 return !!(type.objectFlags & 8388608);
46264             }
46265             return !!(type.flags & 58982400) || isGenericMappedType(type) || isGenericTupleType(type);
46266         }
46267         function isGenericIndexType(type) {
46268             if (type.flags & 3145728) {
46269                 if (!(type.objectFlags & 16777216)) {
46270                     type.objectFlags |= 16777216 |
46271                         (ts.some(type.types, isGenericIndexType) ? 33554432 : 0);
46272                 }
46273                 return !!(type.objectFlags & 33554432);
46274             }
46275             return !!(type.flags & (58982400 | 4194304 | 134217728 | 268435456)) && !isPatternLiteralType(type);
46276         }
46277         function isThisTypeParameter(type) {
46278             return !!(type.flags & 262144 && type.isThisType);
46279         }
46280         function getSimplifiedType(type, writing) {
46281             return type.flags & 8388608 ? getSimplifiedIndexedAccessType(type, writing) :
46282                 type.flags & 16777216 ? getSimplifiedConditionalType(type, writing) :
46283                     type;
46284         }
46285         function distributeIndexOverObjectType(objectType, indexType, writing) {
46286             if (objectType.flags & 3145728) {
46287                 var types = ts.map(objectType.types, function (t) { return getSimplifiedType(getIndexedAccessType(t, indexType), writing); });
46288                 return objectType.flags & 2097152 || writing ? getIntersectionType(types) : getUnionType(types);
46289             }
46290         }
46291         function distributeObjectOverIndexType(objectType, indexType, writing) {
46292             if (indexType.flags & 1048576) {
46293                 var types = ts.map(indexType.types, function (t) { return getSimplifiedType(getIndexedAccessType(objectType, t), writing); });
46294                 return writing ? getIntersectionType(types) : getUnionType(types);
46295             }
46296         }
46297         function unwrapSubstitution(type) {
46298             if (type.flags & 33554432) {
46299                 return type.substitute;
46300             }
46301             return type;
46302         }
46303         function getSimplifiedIndexedAccessType(type, writing) {
46304             var cache = writing ? "simplifiedForWriting" : "simplifiedForReading";
46305             if (type[cache]) {
46306                 return type[cache] === circularConstraintType ? type : type[cache];
46307             }
46308             type[cache] = circularConstraintType;
46309             var objectType = unwrapSubstitution(getSimplifiedType(type.objectType, writing));
46310             var indexType = getSimplifiedType(type.indexType, writing);
46311             var distributedOverIndex = distributeObjectOverIndexType(objectType, indexType, writing);
46312             if (distributedOverIndex) {
46313                 return type[cache] = distributedOverIndex;
46314             }
46315             if (!(indexType.flags & 465829888)) {
46316                 var distributedOverObject = distributeIndexOverObjectType(objectType, indexType, writing);
46317                 if (distributedOverObject) {
46318                     return type[cache] = distributedOverObject;
46319                 }
46320             }
46321             if (isGenericTupleType(objectType) && indexType.flags & 296) {
46322                 var elementType = getElementTypeOfSliceOfTupleType(objectType, indexType.flags & 8 ? 0 : objectType.target.fixedLength, 0, writing);
46323                 if (elementType) {
46324                     return type[cache] = elementType;
46325                 }
46326             }
46327             if (isGenericMappedType(objectType)) {
46328                 return type[cache] = mapType(substituteIndexedMappedType(objectType, type.indexType), function (t) { return getSimplifiedType(t, writing); });
46329             }
46330             return type[cache] = type;
46331         }
46332         function getSimplifiedConditionalType(type, writing) {
46333             var checkType = type.checkType;
46334             var extendsType = type.extendsType;
46335             var trueType = getTrueTypeFromConditionalType(type);
46336             var falseType = getFalseTypeFromConditionalType(type);
46337             if (falseType.flags & 131072 && getActualTypeVariable(trueType) === getActualTypeVariable(checkType)) {
46338                 if (checkType.flags & 1 || isTypeAssignableTo(getRestrictiveInstantiation(checkType), getRestrictiveInstantiation(extendsType))) {
46339                     return getSimplifiedType(trueType, writing);
46340                 }
46341                 else if (isIntersectionEmpty(checkType, extendsType)) {
46342                     return neverType;
46343                 }
46344             }
46345             else if (trueType.flags & 131072 && getActualTypeVariable(falseType) === getActualTypeVariable(checkType)) {
46346                 if (!(checkType.flags & 1) && isTypeAssignableTo(getRestrictiveInstantiation(checkType), getRestrictiveInstantiation(extendsType))) {
46347                     return neverType;
46348                 }
46349                 else if (checkType.flags & 1 || isIntersectionEmpty(checkType, extendsType)) {
46350                     return getSimplifiedType(falseType, writing);
46351                 }
46352             }
46353             return type;
46354         }
46355         function isIntersectionEmpty(type1, type2) {
46356             return !!(getUnionType([intersectTypes(type1, type2), neverType]).flags & 131072);
46357         }
46358         function substituteIndexedMappedType(objectType, index) {
46359             var mapper = createTypeMapper([getTypeParameterFromMappedType(objectType)], [index]);
46360             var templateMapper = combineTypeMappers(objectType.mapper, mapper);
46361             return instantiateType(getTemplateTypeFromMappedType(objectType), templateMapper);
46362         }
46363         function getIndexedAccessType(objectType, indexType, noUncheckedIndexedAccessCandidate, accessNode, aliasSymbol, aliasTypeArguments, accessFlags) {
46364             if (accessFlags === void 0) { accessFlags = 0; }
46365             return getIndexedAccessTypeOrUndefined(objectType, indexType, noUncheckedIndexedAccessCandidate, accessNode, accessFlags, aliasSymbol, aliasTypeArguments) || (accessNode ? errorType : unknownType);
46366         }
46367         function indexTypeLessThan(indexType, limit) {
46368             return everyType(indexType, function (t) {
46369                 if (t.flags & 384) {
46370                     var propName = getPropertyNameFromType(t);
46371                     if (isNumericLiteralName(propName)) {
46372                         var index = +propName;
46373                         return index >= 0 && index < limit;
46374                     }
46375                 }
46376                 return false;
46377             });
46378         }
46379         function getIndexedAccessTypeOrUndefined(objectType, indexType, noUncheckedIndexedAccessCandidate, accessNode, accessFlags, aliasSymbol, aliasTypeArguments) {
46380             if (accessFlags === void 0) { accessFlags = 0; }
46381             if (objectType === wildcardType || indexType === wildcardType) {
46382                 return wildcardType;
46383             }
46384             var shouldIncludeUndefined = noUncheckedIndexedAccessCandidate ||
46385                 (!!compilerOptions.noUncheckedIndexedAccess &&
46386                     (accessFlags & (2 | 16)) === 16);
46387             if (isStringIndexSignatureOnlyType(objectType) && !(indexType.flags & 98304) && isTypeAssignableToKind(indexType, 4 | 8)) {
46388                 indexType = stringType;
46389             }
46390             if (isGenericIndexType(indexType) || (accessNode && accessNode.kind !== 189 ?
46391                 isGenericTupleType(objectType) && !indexTypeLessThan(indexType, objectType.target.fixedLength) :
46392                 isGenericObjectType(objectType) && !(isTupleType(objectType) && indexTypeLessThan(indexType, objectType.target.fixedLength)))) {
46393                 if (objectType.flags & 3) {
46394                     return objectType;
46395                 }
46396                 var id = objectType.id + "," + indexType.id + (shouldIncludeUndefined ? "?" : "");
46397                 var type = indexedAccessTypes.get(id);
46398                 if (!type) {
46399                     indexedAccessTypes.set(id, type = createIndexedAccessType(objectType, indexType, aliasSymbol, aliasTypeArguments, shouldIncludeUndefined));
46400                 }
46401                 return type;
46402             }
46403             var apparentObjectType = getReducedApparentType(objectType);
46404             if (indexType.flags & 1048576 && !(indexType.flags & 16)) {
46405                 var propTypes = [];
46406                 var wasMissingProp = false;
46407                 for (var _i = 0, _a = indexType.types; _i < _a.length; _i++) {
46408                     var t = _a[_i];
46409                     var propType = getPropertyTypeForIndexType(objectType, apparentObjectType, t, indexType, wasMissingProp, accessNode, accessFlags, shouldIncludeUndefined);
46410                     if (propType) {
46411                         propTypes.push(propType);
46412                     }
46413                     else if (!accessNode) {
46414                         return undefined;
46415                     }
46416                     else {
46417                         wasMissingProp = true;
46418                     }
46419                 }
46420                 if (wasMissingProp) {
46421                     return undefined;
46422                 }
46423                 return accessFlags & 2
46424                     ? getIntersectionType(propTypes, aliasSymbol, aliasTypeArguments)
46425                     : getUnionType(propTypes, 1, aliasSymbol, aliasTypeArguments);
46426             }
46427             return getPropertyTypeForIndexType(objectType, apparentObjectType, indexType, indexType, false, accessNode, accessFlags | 4, shouldIncludeUndefined, true);
46428         }
46429         function getTypeFromIndexedAccessTypeNode(node) {
46430             var links = getNodeLinks(node);
46431             if (!links.resolvedType) {
46432                 var objectType = getTypeFromTypeNode(node.objectType);
46433                 var indexType = getTypeFromTypeNode(node.indexType);
46434                 var potentialAlias = getAliasSymbolForTypeNode(node);
46435                 var resolved = getIndexedAccessType(objectType, indexType, undefined, node, potentialAlias, getTypeArgumentsForAliasSymbol(potentialAlias));
46436                 links.resolvedType = resolved.flags & 8388608 &&
46437                     resolved.objectType === objectType &&
46438                     resolved.indexType === indexType ?
46439                     getConditionalFlowTypeOfType(resolved, node) : resolved;
46440             }
46441             return links.resolvedType;
46442         }
46443         function getTypeFromMappedTypeNode(node) {
46444             var links = getNodeLinks(node);
46445             if (!links.resolvedType) {
46446                 var type = createObjectType(32, node.symbol);
46447                 type.declaration = node;
46448                 type.aliasSymbol = getAliasSymbolForTypeNode(node);
46449                 type.aliasTypeArguments = getTypeArgumentsForAliasSymbol(type.aliasSymbol);
46450                 links.resolvedType = type;
46451                 getConstraintTypeFromMappedType(type);
46452             }
46453             return links.resolvedType;
46454         }
46455         function getActualTypeVariable(type) {
46456             if (type.flags & 33554432) {
46457                 return type.baseType;
46458             }
46459             if (type.flags & 8388608 && (type.objectType.flags & 33554432 ||
46460                 type.indexType.flags & 33554432)) {
46461                 return getIndexedAccessType(getActualTypeVariable(type.objectType), getActualTypeVariable(type.indexType));
46462             }
46463             return type;
46464         }
46465         function getConditionalType(root, mapper) {
46466             var result;
46467             var extraTypes;
46468             var _loop_15 = function () {
46469                 var checkType = instantiateType(root.checkType, mapper);
46470                 var checkTypeInstantiable = isGenericObjectType(checkType) || isGenericIndexType(checkType);
46471                 var extendsType = instantiateType(root.extendsType, mapper);
46472                 if (checkType === wildcardType || extendsType === wildcardType) {
46473                     return { value: wildcardType };
46474                 }
46475                 var combinedMapper = void 0;
46476                 if (root.inferTypeParameters) {
46477                     var context = createInferenceContext(root.inferTypeParameters, undefined, 0);
46478                     if (!checkTypeInstantiable || !ts.some(root.inferTypeParameters, function (t) { return t === extendsType; })) {
46479                         inferTypes(context.inferences, checkType, extendsType, 256 | 512);
46480                     }
46481                     combinedMapper = mergeTypeMappers(mapper, context.mapper);
46482                 }
46483                 var inferredExtendsType = combinedMapper ? instantiateType(root.extendsType, combinedMapper) : extendsType;
46484                 if (!checkTypeInstantiable && !isGenericObjectType(inferredExtendsType) && !isGenericIndexType(inferredExtendsType)) {
46485                     if (!(inferredExtendsType.flags & 3) && (checkType.flags & 1 || !isTypeAssignableTo(getPermissiveInstantiation(checkType), getPermissiveInstantiation(inferredExtendsType)))) {
46486                         if (checkType.flags & 1) {
46487                             (extraTypes || (extraTypes = [])).push(instantiateType(getTypeFromTypeNode(root.node.trueType), combinedMapper || mapper));
46488                         }
46489                         var falseType_1 = getTypeFromTypeNode(root.node.falseType);
46490                         if (falseType_1.flags & 16777216) {
46491                             var newRoot = falseType_1.root;
46492                             if (newRoot.node.parent === root.node && (!newRoot.isDistributive || newRoot.checkType === root.checkType)) {
46493                                 root = newRoot;
46494                                 return "continue";
46495                             }
46496                         }
46497                         result = instantiateType(falseType_1, mapper);
46498                         return "break";
46499                     }
46500                     if (inferredExtendsType.flags & 3 || isTypeAssignableTo(getRestrictiveInstantiation(checkType), getRestrictiveInstantiation(inferredExtendsType))) {
46501                         result = instantiateType(getTypeFromTypeNode(root.node.trueType), combinedMapper || mapper);
46502                         return "break";
46503                     }
46504                 }
46505                 var erasedCheckType = getActualTypeVariable(checkType);
46506                 result = createType(16777216);
46507                 result.root = root;
46508                 result.checkType = erasedCheckType;
46509                 result.extendsType = extendsType;
46510                 result.mapper = mapper;
46511                 result.combinedMapper = combinedMapper;
46512                 result.aliasSymbol = root.aliasSymbol;
46513                 result.aliasTypeArguments = instantiateTypes(root.aliasTypeArguments, mapper);
46514                 return "break";
46515             };
46516             while (true) {
46517                 var state_4 = _loop_15();
46518                 if (typeof state_4 === "object")
46519                     return state_4.value;
46520                 if (state_4 === "break")
46521                     break;
46522             }
46523             return extraTypes ? getUnionType(ts.append(extraTypes, result)) : result;
46524         }
46525         function getTrueTypeFromConditionalType(type) {
46526             return type.resolvedTrueType || (type.resolvedTrueType = instantiateType(getTypeFromTypeNode(type.root.node.trueType), type.mapper));
46527         }
46528         function getFalseTypeFromConditionalType(type) {
46529             return type.resolvedFalseType || (type.resolvedFalseType = instantiateType(getTypeFromTypeNode(type.root.node.falseType), type.mapper));
46530         }
46531         function getInferredTrueTypeFromConditionalType(type) {
46532             return type.resolvedInferredTrueType || (type.resolvedInferredTrueType = type.combinedMapper ? instantiateType(getTypeFromTypeNode(type.root.node.trueType), type.combinedMapper) : getTrueTypeFromConditionalType(type));
46533         }
46534         function getInferTypeParameters(node) {
46535             var result;
46536             if (node.locals) {
46537                 node.locals.forEach(function (symbol) {
46538                     if (symbol.flags & 262144) {
46539                         result = ts.append(result, getDeclaredTypeOfSymbol(symbol));
46540                     }
46541                 });
46542             }
46543             return result;
46544         }
46545         function getTypeFromConditionalTypeNode(node) {
46546             var links = getNodeLinks(node);
46547             if (!links.resolvedType) {
46548                 var checkType = getTypeFromTypeNode(node.checkType);
46549                 var aliasSymbol = getAliasSymbolForTypeNode(node);
46550                 var aliasTypeArguments = getTypeArgumentsForAliasSymbol(aliasSymbol);
46551                 var allOuterTypeParameters = getOuterTypeParameters(node, true);
46552                 var outerTypeParameters = aliasTypeArguments ? allOuterTypeParameters : ts.filter(allOuterTypeParameters, function (tp) { return isTypeParameterPossiblyReferenced(tp, node); });
46553                 var root = {
46554                     node: node,
46555                     checkType: checkType,
46556                     extendsType: getTypeFromTypeNode(node.extendsType),
46557                     isDistributive: !!(checkType.flags & 262144),
46558                     inferTypeParameters: getInferTypeParameters(node),
46559                     outerTypeParameters: outerTypeParameters,
46560                     instantiations: undefined,
46561                     aliasSymbol: aliasSymbol,
46562                     aliasTypeArguments: aliasTypeArguments
46563                 };
46564                 links.resolvedType = getConditionalType(root, undefined);
46565                 if (outerTypeParameters) {
46566                     root.instantiations = new ts.Map();
46567                     root.instantiations.set(getTypeListId(outerTypeParameters), links.resolvedType);
46568                 }
46569             }
46570             return links.resolvedType;
46571         }
46572         function getTypeFromInferTypeNode(node) {
46573             var links = getNodeLinks(node);
46574             if (!links.resolvedType) {
46575                 links.resolvedType = getDeclaredTypeOfTypeParameter(getSymbolOfNode(node.typeParameter));
46576             }
46577             return links.resolvedType;
46578         }
46579         function getIdentifierChain(node) {
46580             if (ts.isIdentifier(node)) {
46581                 return [node];
46582             }
46583             else {
46584                 return ts.append(getIdentifierChain(node.left), node.right);
46585             }
46586         }
46587         function getTypeFromImportTypeNode(node) {
46588             var links = getNodeLinks(node);
46589             if (!links.resolvedType) {
46590                 if (node.isTypeOf && node.typeArguments) {
46591                     error(node, ts.Diagnostics.Type_arguments_cannot_be_used_here);
46592                     links.resolvedSymbol = unknownSymbol;
46593                     return links.resolvedType = errorType;
46594                 }
46595                 if (!ts.isLiteralImportTypeNode(node)) {
46596                     error(node.argument, ts.Diagnostics.String_literal_expected);
46597                     links.resolvedSymbol = unknownSymbol;
46598                     return links.resolvedType = errorType;
46599                 }
46600                 var targetMeaning = node.isTypeOf ? 111551 : node.flags & 4194304 ? 111551 | 788968 : 788968;
46601                 var innerModuleSymbol = resolveExternalModuleName(node, node.argument.literal);
46602                 if (!innerModuleSymbol) {
46603                     links.resolvedSymbol = unknownSymbol;
46604                     return links.resolvedType = errorType;
46605                 }
46606                 var moduleSymbol = resolveExternalModuleSymbol(innerModuleSymbol, false);
46607                 if (!ts.nodeIsMissing(node.qualifier)) {
46608                     var nameStack = getIdentifierChain(node.qualifier);
46609                     var currentNamespace = moduleSymbol;
46610                     var current = void 0;
46611                     while (current = nameStack.shift()) {
46612                         var meaning = nameStack.length ? 1920 : targetMeaning;
46613                         var mergedResolvedSymbol = getMergedSymbol(resolveSymbol(currentNamespace));
46614                         var next = node.isTypeOf
46615                             ? getPropertyOfType(getTypeOfSymbol(mergedResolvedSymbol), current.escapedText)
46616                             : getSymbol(getExportsOfSymbol(mergedResolvedSymbol), current.escapedText, meaning);
46617                         if (!next) {
46618                             error(current, ts.Diagnostics.Namespace_0_has_no_exported_member_1, getFullyQualifiedName(currentNamespace), ts.declarationNameToString(current));
46619                             return links.resolvedType = errorType;
46620                         }
46621                         getNodeLinks(current).resolvedSymbol = next;
46622                         getNodeLinks(current.parent).resolvedSymbol = next;
46623                         currentNamespace = next;
46624                     }
46625                     links.resolvedType = resolveImportSymbolType(node, links, currentNamespace, targetMeaning);
46626                 }
46627                 else {
46628                     if (moduleSymbol.flags & targetMeaning) {
46629                         links.resolvedType = resolveImportSymbolType(node, links, moduleSymbol, targetMeaning);
46630                     }
46631                     else {
46632                         var errorMessage = targetMeaning === 111551
46633                             ? ts.Diagnostics.Module_0_does_not_refer_to_a_value_but_is_used_as_a_value_here
46634                             : ts.Diagnostics.Module_0_does_not_refer_to_a_type_but_is_used_as_a_type_here_Did_you_mean_typeof_import_0;
46635                         error(node, errorMessage, node.argument.literal.text);
46636                         links.resolvedSymbol = unknownSymbol;
46637                         links.resolvedType = errorType;
46638                     }
46639                 }
46640             }
46641             return links.resolvedType;
46642         }
46643         function resolveImportSymbolType(node, links, symbol, meaning) {
46644             var resolvedSymbol = resolveSymbol(symbol);
46645             links.resolvedSymbol = resolvedSymbol;
46646             if (meaning === 111551) {
46647                 return getTypeOfSymbol(symbol);
46648             }
46649             else {
46650                 return getTypeReferenceType(node, resolvedSymbol);
46651             }
46652         }
46653         function getTypeFromTypeLiteralOrFunctionOrConstructorTypeNode(node) {
46654             var links = getNodeLinks(node);
46655             if (!links.resolvedType) {
46656                 var aliasSymbol = getAliasSymbolForTypeNode(node);
46657                 if (getMembersOfSymbol(node.symbol).size === 0 && !aliasSymbol) {
46658                     links.resolvedType = emptyTypeLiteralType;
46659                 }
46660                 else {
46661                     var type = createObjectType(16, node.symbol);
46662                     type.aliasSymbol = aliasSymbol;
46663                     type.aliasTypeArguments = getTypeArgumentsForAliasSymbol(aliasSymbol);
46664                     if (ts.isJSDocTypeLiteral(node) && node.isArrayType) {
46665                         type = createArrayType(type);
46666                     }
46667                     links.resolvedType = type;
46668                 }
46669             }
46670             return links.resolvedType;
46671         }
46672         function getAliasSymbolForTypeNode(node) {
46673             var host = node.parent;
46674             while (ts.isParenthesizedTypeNode(host) || ts.isJSDocTypeExpression(host) || ts.isTypeOperatorNode(host) && host.operator === 142) {
46675                 host = host.parent;
46676             }
46677             return ts.isTypeAlias(host) ? getSymbolOfNode(host) : undefined;
46678         }
46679         function getTypeArgumentsForAliasSymbol(symbol) {
46680             return symbol ? getLocalTypeParametersOfClassOrInterfaceOrTypeAlias(symbol) : undefined;
46681         }
46682         function isNonGenericObjectType(type) {
46683             return !!(type.flags & 524288) && !isGenericMappedType(type);
46684         }
46685         function isEmptyObjectTypeOrSpreadsIntoEmptyObject(type) {
46686             return isEmptyObjectType(type) || !!(type.flags & (65536 | 32768 | 528 | 296 | 2112 | 402653316 | 1056 | 67108864 | 4194304));
46687         }
46688         function tryMergeUnionOfObjectTypeAndEmptyObject(type, readonly) {
46689             if (type.types.length === 2) {
46690                 var firstType = type.types[0];
46691                 var secondType = type.types[1];
46692                 if (ts.every(type.types, isEmptyObjectTypeOrSpreadsIntoEmptyObject)) {
46693                     return isEmptyObjectType(firstType) ? firstType : isEmptyObjectType(secondType) ? secondType : emptyObjectType;
46694                 }
46695                 if (isEmptyObjectTypeOrSpreadsIntoEmptyObject(firstType)) {
46696                     return getAnonymousPartialType(secondType);
46697                 }
46698                 if (isEmptyObjectTypeOrSpreadsIntoEmptyObject(secondType)) {
46699                     return getAnonymousPartialType(firstType);
46700                 }
46701             }
46702             function getAnonymousPartialType(type) {
46703                 var members = ts.createSymbolTable();
46704                 for (var _i = 0, _a = getPropertiesOfType(type); _i < _a.length; _i++) {
46705                     var prop = _a[_i];
46706                     if (ts.getDeclarationModifierFlagsFromSymbol(prop) & (8 | 16)) {
46707                     }
46708                     else if (isSpreadableProperty(prop)) {
46709                         var isSetonlyAccessor = prop.flags & 65536 && !(prop.flags & 32768);
46710                         var flags = 4 | 16777216;
46711                         var result = createSymbol(flags, prop.escapedName, readonly ? 8 : 0);
46712                         result.type = isSetonlyAccessor ? undefinedType : getTypeOfSymbol(prop);
46713                         result.declarations = prop.declarations;
46714                         result.nameType = getSymbolLinks(prop).nameType;
46715                         result.syntheticOrigin = prop;
46716                         members.set(prop.escapedName, result);
46717                     }
46718                 }
46719                 var spread = createAnonymousType(type.symbol, members, ts.emptyArray, ts.emptyArray, getIndexInfoOfType(type, 0), getIndexInfoOfType(type, 1));
46720                 spread.objectFlags |= 128 | 1048576;
46721                 return spread;
46722             }
46723         }
46724         function getSpreadType(left, right, symbol, objectFlags, readonly) {
46725             if (left.flags & 1 || right.flags & 1) {
46726                 return anyType;
46727             }
46728             if (left.flags & 2 || right.flags & 2) {
46729                 return unknownType;
46730             }
46731             if (left.flags & 131072) {
46732                 return right;
46733             }
46734             if (right.flags & 131072) {
46735                 return left;
46736             }
46737             if (left.flags & 1048576) {
46738                 var merged = tryMergeUnionOfObjectTypeAndEmptyObject(left, readonly);
46739                 if (merged) {
46740                     return getSpreadType(merged, right, symbol, objectFlags, readonly);
46741                 }
46742                 return checkCrossProductUnion([left, right])
46743                     ? mapType(left, function (t) { return getSpreadType(t, right, symbol, objectFlags, readonly); })
46744                     : errorType;
46745             }
46746             if (right.flags & 1048576) {
46747                 var merged = tryMergeUnionOfObjectTypeAndEmptyObject(right, readonly);
46748                 if (merged) {
46749                     return getSpreadType(left, merged, symbol, objectFlags, readonly);
46750                 }
46751                 return checkCrossProductUnion([left, right])
46752                     ? mapType(right, function (t) { return getSpreadType(left, t, symbol, objectFlags, readonly); })
46753                     : errorType;
46754             }
46755             if (right.flags & (528 | 296 | 2112 | 402653316 | 1056 | 67108864 | 4194304)) {
46756                 return left;
46757             }
46758             if (isGenericObjectType(left) || isGenericObjectType(right)) {
46759                 if (isEmptyObjectType(left)) {
46760                     return right;
46761                 }
46762                 if (left.flags & 2097152) {
46763                     var types = left.types;
46764                     var lastLeft = types[types.length - 1];
46765                     if (isNonGenericObjectType(lastLeft) && isNonGenericObjectType(right)) {
46766                         return getIntersectionType(ts.concatenate(types.slice(0, types.length - 1), [getSpreadType(lastLeft, right, symbol, objectFlags, readonly)]));
46767                     }
46768                 }
46769                 return getIntersectionType([left, right]);
46770             }
46771             var members = ts.createSymbolTable();
46772             var skippedPrivateMembers = new ts.Set();
46773             var stringIndexInfo;
46774             var numberIndexInfo;
46775             if (left === emptyObjectType) {
46776                 stringIndexInfo = getIndexInfoOfType(right, 0);
46777                 numberIndexInfo = getIndexInfoOfType(right, 1);
46778             }
46779             else {
46780                 stringIndexInfo = unionSpreadIndexInfos(getIndexInfoOfType(left, 0), getIndexInfoOfType(right, 0));
46781                 numberIndexInfo = unionSpreadIndexInfos(getIndexInfoOfType(left, 1), getIndexInfoOfType(right, 1));
46782             }
46783             for (var _i = 0, _a = getPropertiesOfType(right); _i < _a.length; _i++) {
46784                 var rightProp = _a[_i];
46785                 if (ts.getDeclarationModifierFlagsFromSymbol(rightProp) & (8 | 16)) {
46786                     skippedPrivateMembers.add(rightProp.escapedName);
46787                 }
46788                 else if (isSpreadableProperty(rightProp)) {
46789                     members.set(rightProp.escapedName, getSpreadSymbol(rightProp, readonly));
46790                 }
46791             }
46792             for (var _b = 0, _c = getPropertiesOfType(left); _b < _c.length; _b++) {
46793                 var leftProp = _c[_b];
46794                 if (skippedPrivateMembers.has(leftProp.escapedName) || !isSpreadableProperty(leftProp)) {
46795                     continue;
46796                 }
46797                 if (members.has(leftProp.escapedName)) {
46798                     var rightProp = members.get(leftProp.escapedName);
46799                     var rightType = getTypeOfSymbol(rightProp);
46800                     if (rightProp.flags & 16777216) {
46801                         var declarations = ts.concatenate(leftProp.declarations, rightProp.declarations);
46802                         var flags = 4 | (leftProp.flags & 16777216);
46803                         var result = createSymbol(flags, leftProp.escapedName);
46804                         result.type = getUnionType([getTypeOfSymbol(leftProp), getTypeWithFacts(rightType, 524288)]);
46805                         result.leftSpread = leftProp;
46806                         result.rightSpread = rightProp;
46807                         result.declarations = declarations;
46808                         result.nameType = getSymbolLinks(leftProp).nameType;
46809                         members.set(leftProp.escapedName, result);
46810                     }
46811                 }
46812                 else {
46813                     members.set(leftProp.escapedName, getSpreadSymbol(leftProp, readonly));
46814                 }
46815             }
46816             var spread = createAnonymousType(symbol, members, ts.emptyArray, ts.emptyArray, getIndexInfoWithReadonly(stringIndexInfo, readonly), getIndexInfoWithReadonly(numberIndexInfo, readonly));
46817             spread.objectFlags |= 128 | 1048576 | 1024 | objectFlags;
46818             return spread;
46819         }
46820         function isSpreadableProperty(prop) {
46821             return !ts.some(prop.declarations, ts.isPrivateIdentifierPropertyDeclaration) &&
46822                 (!(prop.flags & (8192 | 32768 | 65536)) ||
46823                     !prop.declarations.some(function (decl) { return ts.isClassLike(decl.parent); }));
46824         }
46825         function getSpreadSymbol(prop, readonly) {
46826             var isSetonlyAccessor = prop.flags & 65536 && !(prop.flags & 32768);
46827             if (!isSetonlyAccessor && readonly === isReadonlySymbol(prop)) {
46828                 return prop;
46829             }
46830             var flags = 4 | (prop.flags & 16777216);
46831             var result = createSymbol(flags, prop.escapedName, readonly ? 8 : 0);
46832             result.type = isSetonlyAccessor ? undefinedType : getTypeOfSymbol(prop);
46833             result.declarations = prop.declarations;
46834             result.nameType = getSymbolLinks(prop).nameType;
46835             result.syntheticOrigin = prop;
46836             return result;
46837         }
46838         function getIndexInfoWithReadonly(info, readonly) {
46839             return info && info.isReadonly !== readonly ? createIndexInfo(info.type, readonly, info.declaration) : info;
46840         }
46841         function createLiteralType(flags, value, symbol) {
46842             var type = createType(flags);
46843             type.symbol = symbol;
46844             type.value = value;
46845             return type;
46846         }
46847         function getFreshTypeOfLiteralType(type) {
46848             if (type.flags & 2944) {
46849                 if (!type.freshType) {
46850                     var freshType = createLiteralType(type.flags, type.value, type.symbol);
46851                     freshType.regularType = type;
46852                     freshType.freshType = freshType;
46853                     type.freshType = freshType;
46854                 }
46855                 return type.freshType;
46856             }
46857             return type;
46858         }
46859         function getRegularTypeOfLiteralType(type) {
46860             return type.flags & 2944 ? type.regularType :
46861                 type.flags & 1048576 ? (type.regularType || (type.regularType = getUnionType(ts.sameMap(type.types, getRegularTypeOfLiteralType)))) :
46862                     type;
46863         }
46864         function isFreshLiteralType(type) {
46865             return !!(type.flags & 2944) && type.freshType === type;
46866         }
46867         function getLiteralType(value, enumId, symbol) {
46868             var qualifier = typeof value === "number" ? "#" : typeof value === "string" ? "@" : "n";
46869             var key = (enumId ? enumId : "") + qualifier + (typeof value === "object" ? ts.pseudoBigIntToString(value) : value);
46870             var type = literalTypes.get(key);
46871             if (!type) {
46872                 var flags = (typeof value === "number" ? 256 :
46873                     typeof value === "string" ? 128 : 2048) |
46874                     (enumId ? 1024 : 0);
46875                 literalTypes.set(key, type = createLiteralType(flags, value, symbol));
46876                 type.regularType = type;
46877             }
46878             return type;
46879         }
46880         function getTypeFromLiteralTypeNode(node) {
46881             if (node.literal.kind === 103) {
46882                 return nullType;
46883             }
46884             var links = getNodeLinks(node);
46885             if (!links.resolvedType) {
46886                 links.resolvedType = getRegularTypeOfLiteralType(checkExpression(node.literal));
46887             }
46888             return links.resolvedType;
46889         }
46890         function createUniqueESSymbolType(symbol) {
46891             var type = createType(8192);
46892             type.symbol = symbol;
46893             type.escapedName = "__@" + type.symbol.escapedName + "@" + getSymbolId(type.symbol);
46894             return type;
46895         }
46896         function getESSymbolLikeTypeForNode(node) {
46897             if (ts.isValidESSymbolDeclaration(node)) {
46898                 var symbol = getSymbolOfNode(node);
46899                 var links = getSymbolLinks(symbol);
46900                 return links.uniqueESSymbolType || (links.uniqueESSymbolType = createUniqueESSymbolType(symbol));
46901             }
46902             return esSymbolType;
46903         }
46904         function getThisType(node) {
46905             var container = ts.getThisContainer(node, false);
46906             var parent = container && container.parent;
46907             if (parent && (ts.isClassLike(parent) || parent.kind === 253)) {
46908                 if (!ts.hasSyntacticModifier(container, 32) &&
46909                     (!ts.isConstructorDeclaration(container) || ts.isNodeDescendantOf(node, container.body))) {
46910                     return getDeclaredTypeOfClassOrInterface(getSymbolOfNode(parent)).thisType;
46911                 }
46912             }
46913             if (parent && ts.isObjectLiteralExpression(parent) && ts.isBinaryExpression(parent.parent) && ts.getAssignmentDeclarationKind(parent.parent) === 6) {
46914                 return getDeclaredTypeOfClassOrInterface(getSymbolOfNode(parent.parent.left).parent).thisType;
46915             }
46916             var host = node.flags & 4194304 ? ts.getHostSignatureFromJSDoc(node) : undefined;
46917             if (host && ts.isFunctionExpression(host) && ts.isBinaryExpression(host.parent) && ts.getAssignmentDeclarationKind(host.parent) === 3) {
46918                 return getDeclaredTypeOfClassOrInterface(getSymbolOfNode(host.parent.left).parent).thisType;
46919             }
46920             if (isJSConstructor(container) && ts.isNodeDescendantOf(node, container.body)) {
46921                 return getDeclaredTypeOfClassOrInterface(getSymbolOfNode(container)).thisType;
46922             }
46923             error(node, ts.Diagnostics.A_this_type_is_available_only_in_a_non_static_member_of_a_class_or_interface);
46924             return errorType;
46925         }
46926         function getTypeFromThisTypeNode(node) {
46927             var links = getNodeLinks(node);
46928             if (!links.resolvedType) {
46929                 links.resolvedType = getThisType(node);
46930             }
46931             return links.resolvedType;
46932         }
46933         function getTypeFromRestTypeNode(node) {
46934             return getTypeFromTypeNode(getArrayElementTypeNode(node.type) || node.type);
46935         }
46936         function getArrayElementTypeNode(node) {
46937             switch (node.kind) {
46938                 case 186:
46939                     return getArrayElementTypeNode(node.type);
46940                 case 179:
46941                     if (node.elements.length === 1) {
46942                         node = node.elements[0];
46943                         if (node.kind === 181 || node.kind === 192 && node.dotDotDotToken) {
46944                             return getArrayElementTypeNode(node.type);
46945                         }
46946                     }
46947                     break;
46948                 case 178:
46949                     return node.elementType;
46950             }
46951             return undefined;
46952         }
46953         function getTypeFromNamedTupleTypeNode(node) {
46954             var links = getNodeLinks(node);
46955             return links.resolvedType || (links.resolvedType =
46956                 node.dotDotDotToken ? getTypeFromRestTypeNode(node) :
46957                     node.questionToken && strictNullChecks ? getOptionalType(getTypeFromTypeNode(node.type)) :
46958                         getTypeFromTypeNode(node.type));
46959         }
46960         function getTypeFromTypeNode(node) {
46961             return getConditionalFlowTypeOfType(getTypeFromTypeNodeWorker(node), node);
46962         }
46963         function getTypeFromTypeNodeWorker(node) {
46964             switch (node.kind) {
46965                 case 128:
46966                 case 303:
46967                 case 304:
46968                     return anyType;
46969                 case 152:
46970                     return unknownType;
46971                 case 147:
46972                     return stringType;
46973                 case 144:
46974                     return numberType;
46975                 case 155:
46976                     return bigintType;
46977                 case 131:
46978                     return booleanType;
46979                 case 148:
46980                     return esSymbolType;
46981                 case 113:
46982                     return voidType;
46983                 case 150:
46984                     return undefinedType;
46985                 case 103:
46986                     return nullType;
46987                 case 141:
46988                     return neverType;
46989                 case 145:
46990                     return node.flags & 131072 && !noImplicitAny ? anyType : nonPrimitiveType;
46991                 case 136:
46992                     return intrinsicMarkerType;
46993                 case 187:
46994                 case 107:
46995                     return getTypeFromThisTypeNode(node);
46996                 case 191:
46997                     return getTypeFromLiteralTypeNode(node);
46998                 case 173:
46999                     return getTypeFromTypeReference(node);
47000                 case 172:
47001                     return node.assertsModifier ? voidType : booleanType;
47002                 case 223:
47003                     return getTypeFromTypeReference(node);
47004                 case 176:
47005                     return getTypeFromTypeQueryNode(node);
47006                 case 178:
47007                 case 179:
47008                     return getTypeFromArrayOrTupleTypeNode(node);
47009                 case 180:
47010                     return getTypeFromOptionalTypeNode(node);
47011                 case 182:
47012                     return getTypeFromUnionTypeNode(node);
47013                 case 183:
47014                     return getTypeFromIntersectionTypeNode(node);
47015                 case 305:
47016                     return getTypeFromJSDocNullableTypeNode(node);
47017                 case 307:
47018                     return addOptionality(getTypeFromTypeNode(node.type));
47019                 case 192:
47020                     return getTypeFromNamedTupleTypeNode(node);
47021                 case 186:
47022                 case 306:
47023                 case 301:
47024                     return getTypeFromTypeNode(node.type);
47025                 case 181:
47026                     return getTypeFromRestTypeNode(node);
47027                 case 309:
47028                     return getTypeFromJSDocVariadicType(node);
47029                 case 174:
47030                 case 175:
47031                 case 177:
47032                 case 312:
47033                 case 308:
47034                 case 313:
47035                     return getTypeFromTypeLiteralOrFunctionOrConstructorTypeNode(node);
47036                 case 188:
47037                     return getTypeFromTypeOperatorNode(node);
47038                 case 189:
47039                     return getTypeFromIndexedAccessTypeNode(node);
47040                 case 190:
47041                     return getTypeFromMappedTypeNode(node);
47042                 case 184:
47043                     return getTypeFromConditionalTypeNode(node);
47044                 case 185:
47045                     return getTypeFromInferTypeNode(node);
47046                 case 193:
47047                     return getTypeFromTemplateTypeNode(node);
47048                 case 195:
47049                     return getTypeFromImportTypeNode(node);
47050                 case 78:
47051                 case 157:
47052                 case 201:
47053                     var symbol = getSymbolAtLocation(node);
47054                     return symbol ? getDeclaredTypeOfSymbol(symbol) : errorType;
47055                 default:
47056                     return errorType;
47057             }
47058         }
47059         function instantiateList(items, mapper, instantiator) {
47060             if (items && items.length) {
47061                 for (var i = 0; i < items.length; i++) {
47062                     var item = items[i];
47063                     var mapped = instantiator(item, mapper);
47064                     if (item !== mapped) {
47065                         var result = i === 0 ? [] : items.slice(0, i);
47066                         result.push(mapped);
47067                         for (i++; i < items.length; i++) {
47068                             result.push(instantiator(items[i], mapper));
47069                         }
47070                         return result;
47071                     }
47072                 }
47073             }
47074             return items;
47075         }
47076         function instantiateTypes(types, mapper) {
47077             return instantiateList(types, mapper, instantiateType);
47078         }
47079         function instantiateSignatures(signatures, mapper) {
47080             return instantiateList(signatures, mapper, instantiateSignature);
47081         }
47082         function createTypeMapper(sources, targets) {
47083             return sources.length === 1 ? makeUnaryTypeMapper(sources[0], targets ? targets[0] : anyType) : makeArrayTypeMapper(sources, targets);
47084         }
47085         function getMappedType(type, mapper) {
47086             switch (mapper.kind) {
47087                 case 0:
47088                     return type === mapper.source ? mapper.target : type;
47089                 case 1:
47090                     var sources = mapper.sources;
47091                     var targets = mapper.targets;
47092                     for (var i = 0; i < sources.length; i++) {
47093                         if (type === sources[i]) {
47094                             return targets ? targets[i] : anyType;
47095                         }
47096                     }
47097                     return type;
47098                 case 2:
47099                     return mapper.func(type);
47100                 case 3:
47101                 case 4:
47102                     var t1 = getMappedType(type, mapper.mapper1);
47103                     return t1 !== type && mapper.kind === 3 ? instantiateType(t1, mapper.mapper2) : getMappedType(t1, mapper.mapper2);
47104             }
47105         }
47106         function makeUnaryTypeMapper(source, target) {
47107             return { kind: 0, source: source, target: target };
47108         }
47109         function makeArrayTypeMapper(sources, targets) {
47110             return { kind: 1, sources: sources, targets: targets };
47111         }
47112         function makeFunctionTypeMapper(func) {
47113             return { kind: 2, func: func };
47114         }
47115         function makeCompositeTypeMapper(kind, mapper1, mapper2) {
47116             return { kind: kind, mapper1: mapper1, mapper2: mapper2 };
47117         }
47118         function createTypeEraser(sources) {
47119             return createTypeMapper(sources, undefined);
47120         }
47121         function createBackreferenceMapper(context, index) {
47122             return makeFunctionTypeMapper(function (t) { return ts.findIndex(context.inferences, function (info) { return info.typeParameter === t; }) >= index ? unknownType : t; });
47123         }
47124         function combineTypeMappers(mapper1, mapper2) {
47125             return mapper1 ? makeCompositeTypeMapper(3, mapper1, mapper2) : mapper2;
47126         }
47127         function mergeTypeMappers(mapper1, mapper2) {
47128             return mapper1 ? makeCompositeTypeMapper(4, mapper1, mapper2) : mapper2;
47129         }
47130         function prependTypeMapping(source, target, mapper) {
47131             return !mapper ? makeUnaryTypeMapper(source, target) : makeCompositeTypeMapper(4, makeUnaryTypeMapper(source, target), mapper);
47132         }
47133         function appendTypeMapping(mapper, source, target) {
47134             return !mapper ? makeUnaryTypeMapper(source, target) : makeCompositeTypeMapper(4, mapper, makeUnaryTypeMapper(source, target));
47135         }
47136         function getRestrictiveTypeParameter(tp) {
47137             return tp.constraint === unknownType ? tp : tp.restrictiveInstantiation || (tp.restrictiveInstantiation = createTypeParameter(tp.symbol),
47138                 tp.restrictiveInstantiation.constraint = unknownType,
47139                 tp.restrictiveInstantiation);
47140         }
47141         function cloneTypeParameter(typeParameter) {
47142             var result = createTypeParameter(typeParameter.symbol);
47143             result.target = typeParameter;
47144             return result;
47145         }
47146         function instantiateTypePredicate(predicate, mapper) {
47147             return createTypePredicate(predicate.kind, predicate.parameterName, predicate.parameterIndex, instantiateType(predicate.type, mapper));
47148         }
47149         function instantiateSignature(signature, mapper, eraseTypeParameters) {
47150             var freshTypeParameters;
47151             if (signature.typeParameters && !eraseTypeParameters) {
47152                 freshTypeParameters = ts.map(signature.typeParameters, cloneTypeParameter);
47153                 mapper = combineTypeMappers(createTypeMapper(signature.typeParameters, freshTypeParameters), mapper);
47154                 for (var _i = 0, freshTypeParameters_1 = freshTypeParameters; _i < freshTypeParameters_1.length; _i++) {
47155                     var tp = freshTypeParameters_1[_i];
47156                     tp.mapper = mapper;
47157                 }
47158             }
47159             var result = createSignature(signature.declaration, freshTypeParameters, signature.thisParameter && instantiateSymbol(signature.thisParameter, mapper), instantiateList(signature.parameters, mapper, instantiateSymbol), undefined, undefined, signature.minArgumentCount, signature.flags & 19);
47160             result.target = signature;
47161             result.mapper = mapper;
47162             return result;
47163         }
47164         function instantiateSymbol(symbol, mapper) {
47165             var links = getSymbolLinks(symbol);
47166             if (links.type && !couldContainTypeVariables(links.type)) {
47167                 return symbol;
47168             }
47169             if (ts.getCheckFlags(symbol) & 1) {
47170                 symbol = links.target;
47171                 mapper = combineTypeMappers(links.mapper, mapper);
47172             }
47173             var result = createSymbol(symbol.flags, symbol.escapedName, 1 | ts.getCheckFlags(symbol) & (8 | 4096 | 16384 | 32768));
47174             result.declarations = symbol.declarations;
47175             result.parent = symbol.parent;
47176             result.target = symbol;
47177             result.mapper = mapper;
47178             if (symbol.valueDeclaration) {
47179                 result.valueDeclaration = symbol.valueDeclaration;
47180             }
47181             if (links.nameType) {
47182                 result.nameType = links.nameType;
47183             }
47184             return result;
47185         }
47186         function getObjectTypeInstantiation(type, mapper) {
47187             var declaration = type.objectFlags & 4 ? type.node : type.symbol.declarations[0];
47188             var links = getNodeLinks(declaration);
47189             var target = type.objectFlags & 4 ? links.resolvedType :
47190                 type.objectFlags & 64 ? type.target : type;
47191             var typeParameters = links.outerTypeParameters;
47192             if (!typeParameters) {
47193                 var outerTypeParameters = getOuterTypeParameters(declaration, true);
47194                 if (isJSConstructor(declaration)) {
47195                     var templateTagParameters = getTypeParametersFromDeclaration(declaration);
47196                     outerTypeParameters = ts.addRange(outerTypeParameters, templateTagParameters);
47197                 }
47198                 typeParameters = outerTypeParameters || ts.emptyArray;
47199                 typeParameters = (target.objectFlags & 4 || target.symbol.flags & 2048) && !target.aliasTypeArguments ?
47200                     ts.filter(typeParameters, function (tp) { return isTypeParameterPossiblyReferenced(tp, declaration); }) :
47201                     typeParameters;
47202                 links.outerTypeParameters = typeParameters;
47203             }
47204             if (typeParameters.length) {
47205                 var combinedMapper_1 = combineTypeMappers(type.mapper, mapper);
47206                 var typeArguments = ts.map(typeParameters, function (t) { return getMappedType(t, combinedMapper_1); });
47207                 var id = getTypeListId(typeArguments);
47208                 if (!target.instantiations) {
47209                     target.instantiations = new ts.Map();
47210                     target.instantiations.set(getTypeListId(typeParameters), target);
47211                 }
47212                 var result = target.instantiations.get(id);
47213                 if (!result) {
47214                     var newMapper = createTypeMapper(typeParameters, typeArguments);
47215                     result = target.objectFlags & 4 ? createDeferredTypeReference(type.target, type.node, newMapper) :
47216                         target.objectFlags & 32 ? instantiateMappedType(target, newMapper) :
47217                             instantiateAnonymousType(target, newMapper);
47218                     target.instantiations.set(id, result);
47219                 }
47220                 return result;
47221             }
47222             return type;
47223         }
47224         function maybeTypeParameterReference(node) {
47225             return !(node.kind === 157 ||
47226                 node.parent.kind === 173 && node.parent.typeArguments && node === node.parent.typeName ||
47227                 node.parent.kind === 195 && node.parent.typeArguments && node === node.parent.qualifier);
47228         }
47229         function isTypeParameterPossiblyReferenced(tp, node) {
47230             if (tp.symbol && tp.symbol.declarations && tp.symbol.declarations.length === 1) {
47231                 var container = tp.symbol.declarations[0].parent;
47232                 for (var n = node; n !== container; n = n.parent) {
47233                     if (!n || n.kind === 230 || n.kind === 184 && ts.forEachChild(n.extendsType, containsReference)) {
47234                         return true;
47235                     }
47236                 }
47237                 return !!ts.forEachChild(node, containsReference);
47238             }
47239             return true;
47240             function containsReference(node) {
47241                 switch (node.kind) {
47242                     case 187:
47243                         return !!tp.isThisType;
47244                     case 78:
47245                         return !tp.isThisType && ts.isPartOfTypeNode(node) && maybeTypeParameterReference(node) &&
47246                             getTypeFromTypeNodeWorker(node) === tp;
47247                     case 176:
47248                         return true;
47249                 }
47250                 return !!ts.forEachChild(node, containsReference);
47251             }
47252         }
47253         function getHomomorphicTypeVariable(type) {
47254             var constraintType = getConstraintTypeFromMappedType(type);
47255             if (constraintType.flags & 4194304) {
47256                 var typeVariable = getActualTypeVariable(constraintType.type);
47257                 if (typeVariable.flags & 262144) {
47258                     return typeVariable;
47259                 }
47260             }
47261             return undefined;
47262         }
47263         function instantiateMappedType(type, mapper) {
47264             var typeVariable = getHomomorphicTypeVariable(type);
47265             if (typeVariable) {
47266                 var mappedTypeVariable = instantiateType(typeVariable, mapper);
47267                 if (typeVariable !== mappedTypeVariable) {
47268                     return mapType(getReducedType(mappedTypeVariable), function (t) {
47269                         if (t.flags & (3 | 58982400 | 524288 | 2097152) && t !== wildcardType && t !== errorType) {
47270                             if (!type.declaration.nameType) {
47271                                 if (isArrayType(t)) {
47272                                     return instantiateMappedArrayType(t, type, prependTypeMapping(typeVariable, t, mapper));
47273                                 }
47274                                 if (isGenericTupleType(t)) {
47275                                     return instantiateMappedGenericTupleType(t, type, typeVariable, mapper);
47276                                 }
47277                                 if (isTupleType(t)) {
47278                                     return instantiateMappedTupleType(t, type, prependTypeMapping(typeVariable, t, mapper));
47279                                 }
47280                             }
47281                             return instantiateAnonymousType(type, prependTypeMapping(typeVariable, t, mapper));
47282                         }
47283                         return t;
47284                     });
47285                 }
47286             }
47287             return instantiateAnonymousType(type, mapper);
47288         }
47289         function getModifiedReadonlyState(state, modifiers) {
47290             return modifiers & 1 ? true : modifiers & 2 ? false : state;
47291         }
47292         function instantiateMappedGenericTupleType(tupleType, mappedType, typeVariable, mapper) {
47293             var elementFlags = tupleType.target.elementFlags;
47294             var elementTypes = ts.map(getTypeArguments(tupleType), function (t, i) {
47295                 var singleton = elementFlags[i] & 8 ? t :
47296                     elementFlags[i] & 4 ? createArrayType(t) :
47297                         createTupleType([t], [elementFlags[i]]);
47298                 return instantiateMappedType(mappedType, prependTypeMapping(typeVariable, singleton, mapper));
47299             });
47300             var newReadonly = getModifiedReadonlyState(tupleType.target.readonly, getMappedTypeModifiers(mappedType));
47301             return createTupleType(elementTypes, ts.map(elementTypes, function (_) { return 8; }), newReadonly);
47302         }
47303         function instantiateMappedArrayType(arrayType, mappedType, mapper) {
47304             var elementType = instantiateMappedTypeTemplate(mappedType, numberType, true, mapper);
47305             return elementType === errorType ? errorType :
47306                 createArrayType(elementType, getModifiedReadonlyState(isReadonlyArrayType(arrayType), getMappedTypeModifiers(mappedType)));
47307         }
47308         function instantiateMappedTupleType(tupleType, mappedType, mapper) {
47309             var elementFlags = tupleType.target.elementFlags;
47310             var elementTypes = ts.map(getTypeArguments(tupleType), function (_, i) {
47311                 return instantiateMappedTypeTemplate(mappedType, getLiteralType("" + i), !!(elementFlags[i] & 2), mapper);
47312             });
47313             var modifiers = getMappedTypeModifiers(mappedType);
47314             var newTupleModifiers = modifiers & 4 ? ts.map(elementFlags, function (f) { return f & 1 ? 2 : f; }) :
47315                 modifiers & 8 ? ts.map(elementFlags, function (f) { return f & 2 ? 1 : f; }) :
47316                     elementFlags;
47317             var newReadonly = getModifiedReadonlyState(tupleType.target.readonly, modifiers);
47318             return ts.contains(elementTypes, errorType) ? errorType :
47319                 createTupleType(elementTypes, newTupleModifiers, newReadonly, tupleType.target.labeledElementDeclarations);
47320         }
47321         function instantiateMappedTypeTemplate(type, key, isOptional, mapper) {
47322             var templateMapper = appendTypeMapping(mapper, getTypeParameterFromMappedType(type), key);
47323             var propType = instantiateType(getTemplateTypeFromMappedType(type.target || type), templateMapper);
47324             var modifiers = getMappedTypeModifiers(type);
47325             return strictNullChecks && modifiers & 4 && !maybeTypeOfKind(propType, 32768 | 16384) ? getOptionalType(propType) :
47326                 strictNullChecks && modifiers & 8 && isOptional ? getTypeWithFacts(propType, 524288) :
47327                     propType;
47328         }
47329         function instantiateAnonymousType(type, mapper) {
47330             var result = createObjectType(type.objectFlags | 64, type.symbol);
47331             if (type.objectFlags & 32) {
47332                 result.declaration = type.declaration;
47333                 var origTypeParameter = getTypeParameterFromMappedType(type);
47334                 var freshTypeParameter = cloneTypeParameter(origTypeParameter);
47335                 result.typeParameter = freshTypeParameter;
47336                 mapper = combineTypeMappers(makeUnaryTypeMapper(origTypeParameter, freshTypeParameter), mapper);
47337                 freshTypeParameter.mapper = mapper;
47338             }
47339             result.target = type;
47340             result.mapper = mapper;
47341             result.aliasSymbol = type.aliasSymbol;
47342             result.aliasTypeArguments = instantiateTypes(type.aliasTypeArguments, mapper);
47343             return result;
47344         }
47345         function getConditionalTypeInstantiation(type, mapper) {
47346             var root = type.root;
47347             if (root.outerTypeParameters) {
47348                 var typeArguments = ts.map(root.outerTypeParameters, function (t) { return getMappedType(t, mapper); });
47349                 var id = getTypeListId(typeArguments);
47350                 var result = root.instantiations.get(id);
47351                 if (!result) {
47352                     var newMapper = createTypeMapper(root.outerTypeParameters, typeArguments);
47353                     result = instantiateConditionalType(root, newMapper);
47354                     root.instantiations.set(id, result);
47355                 }
47356                 return result;
47357             }
47358             return type;
47359         }
47360         function instantiateConditionalType(root, mapper) {
47361             if (root.isDistributive) {
47362                 var checkType_1 = root.checkType;
47363                 var instantiatedType = getMappedType(checkType_1, mapper);
47364                 if (checkType_1 !== instantiatedType && instantiatedType.flags & (1048576 | 131072)) {
47365                     return mapType(instantiatedType, function (t) { return getConditionalType(root, prependTypeMapping(checkType_1, t, mapper)); });
47366                 }
47367             }
47368             return getConditionalType(root, mapper);
47369         }
47370         function instantiateType(type, mapper) {
47371             if (!(type && mapper && couldContainTypeVariables(type))) {
47372                 return type;
47373             }
47374             if (instantiationDepth === 50 || instantiationCount >= 5000000) {
47375                 ts.tracing.instant("check", "instantiateType_DepthLimit", { typeId: type.id, instantiationDepth: instantiationDepth, instantiationCount: instantiationCount });
47376                 error(currentNode, ts.Diagnostics.Type_instantiation_is_excessively_deep_and_possibly_infinite);
47377                 return errorType;
47378             }
47379             totalInstantiationCount++;
47380             instantiationCount++;
47381             instantiationDepth++;
47382             var result = instantiateTypeWorker(type, mapper);
47383             instantiationDepth--;
47384             return result;
47385         }
47386         function instantiateTypeWorker(type, mapper) {
47387             var flags = type.flags;
47388             if (flags & 262144) {
47389                 return getMappedType(type, mapper);
47390             }
47391             if (flags & 524288) {
47392                 var objectFlags = type.objectFlags;
47393                 if (objectFlags & (4 | 16 | 32)) {
47394                     if (objectFlags & 4 && !(type.node)) {
47395                         var resolvedTypeArguments = type.resolvedTypeArguments;
47396                         var newTypeArguments = instantiateTypes(resolvedTypeArguments, mapper);
47397                         return newTypeArguments !== resolvedTypeArguments ? createNormalizedTypeReference(type.target, newTypeArguments) : type;
47398                     }
47399                     return getObjectTypeInstantiation(type, mapper);
47400                 }
47401                 return type;
47402             }
47403             if (flags & 3145728) {
47404                 var types = type.types;
47405                 var newTypes = instantiateTypes(types, mapper);
47406                 return newTypes === types ? type :
47407                     flags & 2097152 ?
47408                         getIntersectionType(newTypes, type.aliasSymbol, instantiateTypes(type.aliasTypeArguments, mapper)) :
47409                         getUnionType(newTypes, 1, type.aliasSymbol, instantiateTypes(type.aliasTypeArguments, mapper));
47410             }
47411             if (flags & 4194304) {
47412                 return getIndexType(instantiateType(type.type, mapper));
47413             }
47414             if (flags & 134217728) {
47415                 return getTemplateLiteralType(type.texts, instantiateTypes(type.types, mapper));
47416             }
47417             if (flags & 268435456) {
47418                 return getStringMappingType(type.symbol, instantiateType(type.type, mapper));
47419             }
47420             if (flags & 8388608) {
47421                 return getIndexedAccessType(instantiateType(type.objectType, mapper), instantiateType(type.indexType, mapper), type.noUncheckedIndexedAccessCandidate, undefined, type.aliasSymbol, instantiateTypes(type.aliasTypeArguments, mapper));
47422             }
47423             if (flags & 16777216) {
47424                 return getConditionalTypeInstantiation(type, combineTypeMappers(type.mapper, mapper));
47425             }
47426             if (flags & 33554432) {
47427                 var maybeVariable = instantiateType(type.baseType, mapper);
47428                 if (maybeVariable.flags & 8650752) {
47429                     return getSubstitutionType(maybeVariable, instantiateType(type.substitute, mapper));
47430                 }
47431                 else {
47432                     var sub = instantiateType(type.substitute, mapper);
47433                     if (sub.flags & 3 || isTypeAssignableTo(getRestrictiveInstantiation(maybeVariable), getRestrictiveInstantiation(sub))) {
47434                         return maybeVariable;
47435                     }
47436                     return sub;
47437                 }
47438             }
47439             return type;
47440         }
47441         function getPermissiveInstantiation(type) {
47442             return type.flags & (131068 | 3 | 131072) ? type :
47443                 type.permissiveInstantiation || (type.permissiveInstantiation = instantiateType(type, permissiveMapper));
47444         }
47445         function getRestrictiveInstantiation(type) {
47446             if (type.flags & (131068 | 3 | 131072)) {
47447                 return type;
47448             }
47449             if (type.restrictiveInstantiation) {
47450                 return type.restrictiveInstantiation;
47451             }
47452             type.restrictiveInstantiation = instantiateType(type, restrictiveMapper);
47453             type.restrictiveInstantiation.restrictiveInstantiation = type.restrictiveInstantiation;
47454             return type.restrictiveInstantiation;
47455         }
47456         function instantiateIndexInfo(info, mapper) {
47457             return info && createIndexInfo(instantiateType(info.type, mapper), info.isReadonly, info.declaration);
47458         }
47459         function isContextSensitive(node) {
47460             ts.Debug.assert(node.kind !== 165 || ts.isObjectLiteralMethod(node));
47461             switch (node.kind) {
47462                 case 208:
47463                 case 209:
47464                 case 165:
47465                 case 251:
47466                     return isContextSensitiveFunctionLikeDeclaration(node);
47467                 case 200:
47468                     return ts.some(node.properties, isContextSensitive);
47469                 case 199:
47470                     return ts.some(node.elements, isContextSensitive);
47471                 case 217:
47472                     return isContextSensitive(node.whenTrue) ||
47473                         isContextSensitive(node.whenFalse);
47474                 case 216:
47475                     return (node.operatorToken.kind === 56 || node.operatorToken.kind === 60) &&
47476                         (isContextSensitive(node.left) || isContextSensitive(node.right));
47477                 case 288:
47478                     return isContextSensitive(node.initializer);
47479                 case 207:
47480                     return isContextSensitive(node.expression);
47481                 case 281:
47482                     return ts.some(node.properties, isContextSensitive) || ts.isJsxOpeningElement(node.parent) && ts.some(node.parent.parent.children, isContextSensitive);
47483                 case 280: {
47484                     var initializer = node.initializer;
47485                     return !!initializer && isContextSensitive(initializer);
47486                 }
47487                 case 283: {
47488                     var expression = node.expression;
47489                     return !!expression && isContextSensitive(expression);
47490                 }
47491             }
47492             return false;
47493         }
47494         function isContextSensitiveFunctionLikeDeclaration(node) {
47495             return (!ts.isFunctionDeclaration(node) || ts.isInJSFile(node) && !!getTypeForDeclarationFromJSDocComment(node)) &&
47496                 (hasContextSensitiveParameters(node) || hasContextSensitiveReturnExpression(node));
47497         }
47498         function hasContextSensitiveParameters(node) {
47499             if (!node.typeParameters) {
47500                 if (ts.some(node.parameters, function (p) { return !ts.getEffectiveTypeAnnotationNode(p); })) {
47501                     return true;
47502                 }
47503                 if (node.kind !== 209) {
47504                     var parameter = ts.firstOrUndefined(node.parameters);
47505                     if (!(parameter && ts.parameterIsThisKeyword(parameter))) {
47506                         return true;
47507                     }
47508                 }
47509             }
47510             return false;
47511         }
47512         function hasContextSensitiveReturnExpression(node) {
47513             return !node.typeParameters && !ts.getEffectiveReturnTypeNode(node) && !!node.body && node.body.kind !== 230 && isContextSensitive(node.body);
47514         }
47515         function isContextSensitiveFunctionOrObjectLiteralMethod(func) {
47516             return (ts.isInJSFile(func) && ts.isFunctionDeclaration(func) || isFunctionExpressionOrArrowFunction(func) || ts.isObjectLiteralMethod(func)) &&
47517                 isContextSensitiveFunctionLikeDeclaration(func);
47518         }
47519         function getTypeWithoutSignatures(type) {
47520             if (type.flags & 524288) {
47521                 var resolved = resolveStructuredTypeMembers(type);
47522                 if (resolved.constructSignatures.length || resolved.callSignatures.length) {
47523                     var result = createObjectType(16, type.symbol);
47524                     result.members = resolved.members;
47525                     result.properties = resolved.properties;
47526                     result.callSignatures = ts.emptyArray;
47527                     result.constructSignatures = ts.emptyArray;
47528                     return result;
47529                 }
47530             }
47531             else if (type.flags & 2097152) {
47532                 return getIntersectionType(ts.map(type.types, getTypeWithoutSignatures));
47533             }
47534             return type;
47535         }
47536         function isTypeIdenticalTo(source, target) {
47537             return isTypeRelatedTo(source, target, identityRelation);
47538         }
47539         function compareTypesIdentical(source, target) {
47540             return isTypeRelatedTo(source, target, identityRelation) ? -1 : 0;
47541         }
47542         function compareTypesAssignable(source, target) {
47543             return isTypeRelatedTo(source, target, assignableRelation) ? -1 : 0;
47544         }
47545         function compareTypesSubtypeOf(source, target) {
47546             return isTypeRelatedTo(source, target, subtypeRelation) ? -1 : 0;
47547         }
47548         function isTypeSubtypeOf(source, target) {
47549             return isTypeRelatedTo(source, target, subtypeRelation);
47550         }
47551         function isTypeAssignableTo(source, target) {
47552             return isTypeRelatedTo(source, target, assignableRelation);
47553         }
47554         function isTypeDerivedFrom(source, target) {
47555             return source.flags & 1048576 ? ts.every(source.types, function (t) { return isTypeDerivedFrom(t, target); }) :
47556                 target.flags & 1048576 ? ts.some(target.types, function (t) { return isTypeDerivedFrom(source, t); }) :
47557                     source.flags & 58982400 ? isTypeDerivedFrom(getBaseConstraintOfType(source) || unknownType, target) :
47558                         target === globalObjectType ? !!(source.flags & (524288 | 67108864)) :
47559                             target === globalFunctionType ? !!(source.flags & 524288) && isFunctionObjectType(source) :
47560                                 hasBaseType(source, getTargetType(target)) || (isArrayType(target) && !isReadonlyArrayType(target) && isTypeDerivedFrom(source, globalReadonlyArrayType));
47561         }
47562         function isTypeComparableTo(source, target) {
47563             return isTypeRelatedTo(source, target, comparableRelation);
47564         }
47565         function areTypesComparable(type1, type2) {
47566             return isTypeComparableTo(type1, type2) || isTypeComparableTo(type2, type1);
47567         }
47568         function checkTypeAssignableTo(source, target, errorNode, headMessage, containingMessageChain, errorOutputObject) {
47569             return checkTypeRelatedTo(source, target, assignableRelation, errorNode, headMessage, containingMessageChain, errorOutputObject);
47570         }
47571         function checkTypeAssignableToAndOptionallyElaborate(source, target, errorNode, expr, headMessage, containingMessageChain) {
47572             return checkTypeRelatedToAndOptionallyElaborate(source, target, assignableRelation, errorNode, expr, headMessage, containingMessageChain, undefined);
47573         }
47574         function checkTypeRelatedToAndOptionallyElaborate(source, target, relation, errorNode, expr, headMessage, containingMessageChain, errorOutputContainer) {
47575             if (isTypeRelatedTo(source, target, relation))
47576                 return true;
47577             if (!errorNode || !elaborateError(expr, source, target, relation, headMessage, containingMessageChain, errorOutputContainer)) {
47578                 return checkTypeRelatedTo(source, target, relation, errorNode, headMessage, containingMessageChain, errorOutputContainer);
47579             }
47580             return false;
47581         }
47582         function isOrHasGenericConditional(type) {
47583             return !!(type.flags & 16777216 || (type.flags & 2097152 && ts.some(type.types, isOrHasGenericConditional)));
47584         }
47585         function elaborateError(node, source, target, relation, headMessage, containingMessageChain, errorOutputContainer) {
47586             if (!node || isOrHasGenericConditional(target))
47587                 return false;
47588             if (!checkTypeRelatedTo(source, target, relation, undefined)
47589                 && elaborateDidYouMeanToCallOrConstruct(node, source, target, relation, headMessage, containingMessageChain, errorOutputContainer)) {
47590                 return true;
47591             }
47592             switch (node.kind) {
47593                 case 283:
47594                 case 207:
47595                     return elaborateError(node.expression, source, target, relation, headMessage, containingMessageChain, errorOutputContainer);
47596                 case 216:
47597                     switch (node.operatorToken.kind) {
47598                         case 62:
47599                         case 27:
47600                             return elaborateError(node.right, source, target, relation, headMessage, containingMessageChain, errorOutputContainer);
47601                     }
47602                     break;
47603                 case 200:
47604                     return elaborateObjectLiteral(node, source, target, relation, containingMessageChain, errorOutputContainer);
47605                 case 199:
47606                     return elaborateArrayLiteral(node, source, target, relation, containingMessageChain, errorOutputContainer);
47607                 case 281:
47608                     return elaborateJsxComponents(node, source, target, relation, containingMessageChain, errorOutputContainer);
47609                 case 209:
47610                     return elaborateArrowFunction(node, source, target, relation, containingMessageChain, errorOutputContainer);
47611             }
47612             return false;
47613         }
47614         function elaborateDidYouMeanToCallOrConstruct(node, source, target, relation, headMessage, containingMessageChain, errorOutputContainer) {
47615             var callSignatures = getSignaturesOfType(source, 0);
47616             var constructSignatures = getSignaturesOfType(source, 1);
47617             for (var _i = 0, _a = [constructSignatures, callSignatures]; _i < _a.length; _i++) {
47618                 var signatures = _a[_i];
47619                 if (ts.some(signatures, function (s) {
47620                     var returnType = getReturnTypeOfSignature(s);
47621                     return !(returnType.flags & (1 | 131072)) && checkTypeRelatedTo(returnType, target, relation, undefined);
47622                 })) {
47623                     var resultObj = errorOutputContainer || {};
47624                     checkTypeAssignableTo(source, target, node, headMessage, containingMessageChain, resultObj);
47625                     var diagnostic = resultObj.errors[resultObj.errors.length - 1];
47626                     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));
47627                     return true;
47628                 }
47629             }
47630             return false;
47631         }
47632         function elaborateArrowFunction(node, source, target, relation, containingMessageChain, errorOutputContainer) {
47633             if (ts.isBlock(node.body)) {
47634                 return false;
47635             }
47636             if (ts.some(node.parameters, ts.hasType)) {
47637                 return false;
47638             }
47639             var sourceSig = getSingleCallSignature(source);
47640             if (!sourceSig) {
47641                 return false;
47642             }
47643             var targetSignatures = getSignaturesOfType(target, 0);
47644             if (!ts.length(targetSignatures)) {
47645                 return false;
47646             }
47647             var returnExpression = node.body;
47648             var sourceReturn = getReturnTypeOfSignature(sourceSig);
47649             var targetReturn = getUnionType(ts.map(targetSignatures, getReturnTypeOfSignature));
47650             if (!checkTypeRelatedTo(sourceReturn, targetReturn, relation, undefined)) {
47651                 var elaborated = returnExpression && elaborateError(returnExpression, sourceReturn, targetReturn, relation, undefined, containingMessageChain, errorOutputContainer);
47652                 if (elaborated) {
47653                     return elaborated;
47654                 }
47655                 var resultObj = errorOutputContainer || {};
47656                 checkTypeRelatedTo(sourceReturn, targetReturn, relation, returnExpression, undefined, containingMessageChain, resultObj);
47657                 if (resultObj.errors) {
47658                     if (target.symbol && ts.length(target.symbol.declarations)) {
47659                         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));
47660                     }
47661                     if ((ts.getFunctionFlags(node) & 2) === 0
47662                         && !getTypeOfPropertyOfType(sourceReturn, "then")
47663                         && checkTypeRelatedTo(createPromiseType(sourceReturn), targetReturn, relation, undefined)) {
47664                         ts.addRelatedInfo(resultObj.errors[resultObj.errors.length - 1], ts.createDiagnosticForNode(node, ts.Diagnostics.Did_you_mean_to_mark_this_function_as_async));
47665                     }
47666                     return true;
47667                 }
47668             }
47669             return false;
47670         }
47671         function getBestMatchIndexedAccessTypeOrUndefined(source, target, nameType) {
47672             var idx = getIndexedAccessTypeOrUndefined(target, nameType);
47673             if (idx) {
47674                 return idx;
47675             }
47676             if (target.flags & 1048576) {
47677                 var best = getBestMatchingType(source, target);
47678                 if (best) {
47679                     return getIndexedAccessTypeOrUndefined(best, nameType);
47680                 }
47681             }
47682         }
47683         function checkExpressionForMutableLocationWithContextualType(next, sourcePropType) {
47684             next.contextualType = sourcePropType;
47685             try {
47686                 return checkExpressionForMutableLocation(next, 1, sourcePropType);
47687             }
47688             finally {
47689                 next.contextualType = undefined;
47690             }
47691         }
47692         function elaborateElementwise(iterator, source, target, relation, containingMessageChain, errorOutputContainer) {
47693             var reportedError = false;
47694             for (var status = iterator.next(); !status.done; status = iterator.next()) {
47695                 var _a = status.value, prop = _a.errorNode, next = _a.innerExpression, nameType = _a.nameType, errorMessage = _a.errorMessage;
47696                 var targetPropType = getBestMatchIndexedAccessTypeOrUndefined(source, target, nameType);
47697                 if (!targetPropType || targetPropType.flags & 8388608)
47698                     continue;
47699                 var sourcePropType = getIndexedAccessTypeOrUndefined(source, nameType);
47700                 if (sourcePropType && !checkTypeRelatedTo(sourcePropType, targetPropType, relation, undefined)) {
47701                     var elaborated = next && elaborateError(next, sourcePropType, targetPropType, relation, undefined, containingMessageChain, errorOutputContainer);
47702                     if (elaborated) {
47703                         reportedError = true;
47704                     }
47705                     else {
47706                         var resultObj = errorOutputContainer || {};
47707                         var specificSource = next ? checkExpressionForMutableLocationWithContextualType(next, sourcePropType) : sourcePropType;
47708                         var result = checkTypeRelatedTo(specificSource, targetPropType, relation, prop, errorMessage, containingMessageChain, resultObj);
47709                         if (result && specificSource !== sourcePropType) {
47710                             checkTypeRelatedTo(sourcePropType, targetPropType, relation, prop, errorMessage, containingMessageChain, resultObj);
47711                         }
47712                         if (resultObj.errors) {
47713                             var reportedDiag = resultObj.errors[resultObj.errors.length - 1];
47714                             var propertyName = isTypeUsableAsPropertyName(nameType) ? getPropertyNameFromType(nameType) : undefined;
47715                             var targetProp = propertyName !== undefined ? getPropertyOfType(target, propertyName) : undefined;
47716                             var issuedElaboration = false;
47717                             if (!targetProp) {
47718                                 var indexInfo = isTypeAssignableToKind(nameType, 296) && getIndexInfoOfType(target, 1) ||
47719                                     getIndexInfoOfType(target, 0) ||
47720                                     undefined;
47721                                 if (indexInfo && indexInfo.declaration && !ts.getSourceFileOfNode(indexInfo.declaration).hasNoDefaultLib) {
47722                                     issuedElaboration = true;
47723                                     ts.addRelatedInfo(reportedDiag, ts.createDiagnosticForNode(indexInfo.declaration, ts.Diagnostics.The_expected_type_comes_from_this_index_signature));
47724                                 }
47725                             }
47726                             if (!issuedElaboration && (targetProp && ts.length(targetProp.declarations) || target.symbol && ts.length(target.symbol.declarations))) {
47727                                 var targetNode = targetProp && ts.length(targetProp.declarations) ? targetProp.declarations[0] : target.symbol.declarations[0];
47728                                 if (!ts.getSourceFileOfNode(targetNode).hasNoDefaultLib) {
47729                                     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)));
47730                                 }
47731                             }
47732                         }
47733                         reportedError = true;
47734                     }
47735                 }
47736             }
47737             return reportedError;
47738         }
47739         function generateJsxAttributes(node) {
47740             var _i, _a, prop;
47741             return __generator(this, function (_b) {
47742                 switch (_b.label) {
47743                     case 0:
47744                         if (!ts.length(node.properties))
47745                             return [2];
47746                         _i = 0, _a = node.properties;
47747                         _b.label = 1;
47748                     case 1:
47749                         if (!(_i < _a.length)) return [3, 4];
47750                         prop = _a[_i];
47751                         if (ts.isJsxSpreadAttribute(prop))
47752                             return [3, 3];
47753                         return [4, { errorNode: prop.name, innerExpression: prop.initializer, nameType: getLiteralType(ts.idText(prop.name)) }];
47754                     case 2:
47755                         _b.sent();
47756                         _b.label = 3;
47757                     case 3:
47758                         _i++;
47759                         return [3, 1];
47760                     case 4: return [2];
47761                 }
47762             });
47763         }
47764         function generateJsxChildren(node, getInvalidTextDiagnostic) {
47765             var memberOffset, i, child, nameType, elem;
47766             return __generator(this, function (_a) {
47767                 switch (_a.label) {
47768                     case 0:
47769                         if (!ts.length(node.children))
47770                             return [2];
47771                         memberOffset = 0;
47772                         i = 0;
47773                         _a.label = 1;
47774                     case 1:
47775                         if (!(i < node.children.length)) return [3, 5];
47776                         child = node.children[i];
47777                         nameType = getLiteralType(i - memberOffset);
47778                         elem = getElaborationElementForJsxChild(child, nameType, getInvalidTextDiagnostic);
47779                         if (!elem) return [3, 3];
47780                         return [4, elem];
47781                     case 2:
47782                         _a.sent();
47783                         return [3, 4];
47784                     case 3:
47785                         memberOffset++;
47786                         _a.label = 4;
47787                     case 4:
47788                         i++;
47789                         return [3, 1];
47790                     case 5: return [2];
47791                 }
47792             });
47793         }
47794         function getElaborationElementForJsxChild(child, nameType, getInvalidTextDiagnostic) {
47795             switch (child.kind) {
47796                 case 283:
47797                     return { errorNode: child, innerExpression: child.expression, nameType: nameType };
47798                 case 11:
47799                     if (child.containsOnlyTriviaWhiteSpaces) {
47800                         break;
47801                     }
47802                     return { errorNode: child, innerExpression: undefined, nameType: nameType, errorMessage: getInvalidTextDiagnostic() };
47803                 case 273:
47804                 case 274:
47805                 case 277:
47806                     return { errorNode: child, innerExpression: child, nameType: nameType };
47807                 default:
47808                     return ts.Debug.assertNever(child, "Found invalid jsx child");
47809             }
47810         }
47811         function elaborateJsxComponents(node, source, target, relation, containingMessageChain, errorOutputContainer) {
47812             var result = elaborateElementwise(generateJsxAttributes(node), source, target, relation, containingMessageChain, errorOutputContainer);
47813             var invalidTextDiagnostic;
47814             if (ts.isJsxOpeningElement(node.parent) && ts.isJsxElement(node.parent.parent)) {
47815                 var containingElement = node.parent.parent;
47816                 var childPropName = getJsxElementChildrenPropertyName(getJsxNamespaceAt(node));
47817                 var childrenPropName = childPropName === undefined ? "children" : ts.unescapeLeadingUnderscores(childPropName);
47818                 var childrenNameType = getLiteralType(childrenPropName);
47819                 var childrenTargetType = getIndexedAccessType(target, childrenNameType);
47820                 var validChildren = ts.getSemanticJsxChildren(containingElement.children);
47821                 if (!ts.length(validChildren)) {
47822                     return result;
47823                 }
47824                 var moreThanOneRealChildren = ts.length(validChildren) > 1;
47825                 var arrayLikeTargetParts = filterType(childrenTargetType, isArrayOrTupleLikeType);
47826                 var nonArrayLikeTargetParts = filterType(childrenTargetType, function (t) { return !isArrayOrTupleLikeType(t); });
47827                 if (moreThanOneRealChildren) {
47828                     if (arrayLikeTargetParts !== neverType) {
47829                         var realSource = createTupleType(checkJsxChildren(containingElement, 0));
47830                         var children = generateJsxChildren(containingElement, getInvalidTextualChildDiagnostic);
47831                         result = elaborateElementwise(children, realSource, arrayLikeTargetParts, relation, containingMessageChain, errorOutputContainer) || result;
47832                     }
47833                     else if (!isTypeRelatedTo(getIndexedAccessType(source, childrenNameType), childrenTargetType, relation)) {
47834                         result = true;
47835                         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));
47836                         if (errorOutputContainer && errorOutputContainer.skipLogging) {
47837                             (errorOutputContainer.errors || (errorOutputContainer.errors = [])).push(diag);
47838                         }
47839                     }
47840                 }
47841                 else {
47842                     if (nonArrayLikeTargetParts !== neverType) {
47843                         var child = validChildren[0];
47844                         var elem_1 = getElaborationElementForJsxChild(child, childrenNameType, getInvalidTextualChildDiagnostic);
47845                         if (elem_1) {
47846                             result = elaborateElementwise((function () { return __generator(this, function (_a) {
47847                                 switch (_a.label) {
47848                                     case 0: return [4, elem_1];
47849                                     case 1:
47850                                         _a.sent();
47851                                         return [2];
47852                                 }
47853                             }); })(), source, target, relation, containingMessageChain, errorOutputContainer) || result;
47854                         }
47855                     }
47856                     else if (!isTypeRelatedTo(getIndexedAccessType(source, childrenNameType), childrenTargetType, relation)) {
47857                         result = true;
47858                         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));
47859                         if (errorOutputContainer && errorOutputContainer.skipLogging) {
47860                             (errorOutputContainer.errors || (errorOutputContainer.errors = [])).push(diag);
47861                         }
47862                     }
47863                 }
47864             }
47865             return result;
47866             function getInvalidTextualChildDiagnostic() {
47867                 if (!invalidTextDiagnostic) {
47868                     var tagNameText = ts.getTextOfNode(node.parent.tagName);
47869                     var childPropName = getJsxElementChildrenPropertyName(getJsxNamespaceAt(node));
47870                     var childrenPropName = childPropName === undefined ? "children" : ts.unescapeLeadingUnderscores(childPropName);
47871                     var childrenTargetType = getIndexedAccessType(target, getLiteralType(childrenPropName));
47872                     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;
47873                     invalidTextDiagnostic = __assign(__assign({}, diagnostic), { key: "!!ALREADY FORMATTED!!", message: ts.formatMessage(undefined, diagnostic, tagNameText, childrenPropName, typeToString(childrenTargetType)) });
47874                 }
47875                 return invalidTextDiagnostic;
47876             }
47877         }
47878         function generateLimitedTupleElements(node, target) {
47879             var len, i, elem, nameType;
47880             return __generator(this, function (_a) {
47881                 switch (_a.label) {
47882                     case 0:
47883                         len = ts.length(node.elements);
47884                         if (!len)
47885                             return [2];
47886                         i = 0;
47887                         _a.label = 1;
47888                     case 1:
47889                         if (!(i < len)) return [3, 4];
47890                         if (isTupleLikeType(target) && !getPropertyOfType(target, ("" + i)))
47891                             return [3, 3];
47892                         elem = node.elements[i];
47893                         if (ts.isOmittedExpression(elem))
47894                             return [3, 3];
47895                         nameType = getLiteralType(i);
47896                         return [4, { errorNode: elem, innerExpression: elem, nameType: nameType }];
47897                     case 2:
47898                         _a.sent();
47899                         _a.label = 3;
47900                     case 3:
47901                         i++;
47902                         return [3, 1];
47903                     case 4: return [2];
47904                 }
47905             });
47906         }
47907         function elaborateArrayLiteral(node, source, target, relation, containingMessageChain, errorOutputContainer) {
47908             if (target.flags & 131068)
47909                 return false;
47910             if (isTupleLikeType(source)) {
47911                 return elaborateElementwise(generateLimitedTupleElements(node, target), source, target, relation, containingMessageChain, errorOutputContainer);
47912             }
47913             var oldContext = node.contextualType;
47914             node.contextualType = target;
47915             try {
47916                 var tupleizedType = checkArrayLiteral(node, 1, true);
47917                 node.contextualType = oldContext;
47918                 if (isTupleLikeType(tupleizedType)) {
47919                     return elaborateElementwise(generateLimitedTupleElements(node, target), tupleizedType, target, relation, containingMessageChain, errorOutputContainer);
47920                 }
47921                 return false;
47922             }
47923             finally {
47924                 node.contextualType = oldContext;
47925             }
47926         }
47927         function generateObjectLiteralElements(node) {
47928             var _i, _a, prop, type, _b;
47929             return __generator(this, function (_c) {
47930                 switch (_c.label) {
47931                     case 0:
47932                         if (!ts.length(node.properties))
47933                             return [2];
47934                         _i = 0, _a = node.properties;
47935                         _c.label = 1;
47936                     case 1:
47937                         if (!(_i < _a.length)) return [3, 8];
47938                         prop = _a[_i];
47939                         if (ts.isSpreadAssignment(prop))
47940                             return [3, 7];
47941                         type = getLiteralTypeFromProperty(getSymbolOfNode(prop), 8576);
47942                         if (!type || (type.flags & 131072)) {
47943                             return [3, 7];
47944                         }
47945                         _b = prop.kind;
47946                         switch (_b) {
47947                             case 168: return [3, 2];
47948                             case 167: return [3, 2];
47949                             case 165: return [3, 2];
47950                             case 289: return [3, 2];
47951                             case 288: return [3, 4];
47952                         }
47953                         return [3, 6];
47954                     case 2: return [4, { errorNode: prop.name, innerExpression: undefined, nameType: type }];
47955                     case 3:
47956                         _c.sent();
47957                         return [3, 7];
47958                     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 }];
47959                     case 5:
47960                         _c.sent();
47961                         return [3, 7];
47962                     case 6:
47963                         ts.Debug.assertNever(prop);
47964                         _c.label = 7;
47965                     case 7:
47966                         _i++;
47967                         return [3, 1];
47968                     case 8: return [2];
47969                 }
47970             });
47971         }
47972         function elaborateObjectLiteral(node, source, target, relation, containingMessageChain, errorOutputContainer) {
47973             if (target.flags & 131068)
47974                 return false;
47975             return elaborateElementwise(generateObjectLiteralElements(node), source, target, relation, containingMessageChain, errorOutputContainer);
47976         }
47977         function checkTypeComparableTo(source, target, errorNode, headMessage, containingMessageChain) {
47978             return checkTypeRelatedTo(source, target, comparableRelation, errorNode, headMessage, containingMessageChain);
47979         }
47980         function isSignatureAssignableTo(source, target, ignoreReturnTypes) {
47981             return compareSignaturesRelated(source, target, ignoreReturnTypes ? 4 : 0, false, undefined, undefined, compareTypesAssignable, undefined) !== 0;
47982         }
47983         function isAnySignature(s) {
47984             return !s.typeParameters && (!s.thisParameter || isTypeAny(getTypeOfParameter(s.thisParameter))) && s.parameters.length === 1 &&
47985                 signatureHasRestParameter(s) && (getTypeOfParameter(s.parameters[0]) === anyArrayType || isTypeAny(getTypeOfParameter(s.parameters[0]))) &&
47986                 isTypeAny(getReturnTypeOfSignature(s));
47987         }
47988         function compareSignaturesRelated(source, target, checkMode, reportErrors, errorReporter, incompatibleErrorReporter, compareTypes, reportUnreliableMarkers) {
47989             if (source === target) {
47990                 return -1;
47991             }
47992             if (isAnySignature(target)) {
47993                 return -1;
47994             }
47995             var targetCount = getParameterCount(target);
47996             var sourceHasMoreParameters = !hasEffectiveRestParameter(target) &&
47997                 (checkMode & 8 ? hasEffectiveRestParameter(source) || getParameterCount(source) > targetCount : getMinArgumentCount(source) > targetCount);
47998             if (sourceHasMoreParameters) {
47999                 return 0;
48000             }
48001             if (source.typeParameters && source.typeParameters !== target.typeParameters) {
48002                 target = getCanonicalSignature(target);
48003                 source = instantiateSignatureInContextOf(source, target, undefined, compareTypes);
48004             }
48005             var sourceCount = getParameterCount(source);
48006             var sourceRestType = getNonArrayRestType(source);
48007             var targetRestType = getNonArrayRestType(target);
48008             if (sourceRestType || targetRestType) {
48009                 void instantiateType(sourceRestType || targetRestType, reportUnreliableMarkers);
48010             }
48011             if (sourceRestType && targetRestType && sourceCount !== targetCount) {
48012                 return 0;
48013             }
48014             var kind = target.declaration ? target.declaration.kind : 0;
48015             var strictVariance = !(checkMode & 3) && strictFunctionTypes && kind !== 165 &&
48016                 kind !== 164 && kind !== 166;
48017             var result = -1;
48018             var sourceThisType = getThisTypeOfSignature(source);
48019             if (sourceThisType && sourceThisType !== voidType) {
48020                 var targetThisType = getThisTypeOfSignature(target);
48021                 if (targetThisType) {
48022                     var related = !strictVariance && compareTypes(sourceThisType, targetThisType, false)
48023                         || compareTypes(targetThisType, sourceThisType, reportErrors);
48024                     if (!related) {
48025                         if (reportErrors) {
48026                             errorReporter(ts.Diagnostics.The_this_types_of_each_signature_are_incompatible);
48027                         }
48028                         return 0;
48029                     }
48030                     result &= related;
48031                 }
48032             }
48033             var paramCount = sourceRestType || targetRestType ? Math.min(sourceCount, targetCount) : Math.max(sourceCount, targetCount);
48034             var restIndex = sourceRestType || targetRestType ? paramCount - 1 : -1;
48035             for (var i = 0; i < paramCount; i++) {
48036                 var sourceType = i === restIndex ? getRestTypeAtPosition(source, i) : tryGetTypeAtPosition(source, i);
48037                 var targetType = i === restIndex ? getRestTypeAtPosition(target, i) : tryGetTypeAtPosition(target, i);
48038                 if (sourceType && targetType) {
48039                     var sourceSig = checkMode & 3 ? undefined : getSingleCallSignature(getNonNullableType(sourceType));
48040                     var targetSig = checkMode & 3 ? undefined : getSingleCallSignature(getNonNullableType(targetType));
48041                     var callbacks = sourceSig && targetSig && !getTypePredicateOfSignature(sourceSig) && !getTypePredicateOfSignature(targetSig) &&
48042                         (getFalsyFlags(sourceType) & 98304) === (getFalsyFlags(targetType) & 98304);
48043                     var related = callbacks ?
48044                         compareSignaturesRelated(targetSig, sourceSig, (checkMode & 8) | (strictVariance ? 2 : 1), reportErrors, errorReporter, incompatibleErrorReporter, compareTypes, reportUnreliableMarkers) :
48045                         !(checkMode & 3) && !strictVariance && compareTypes(sourceType, targetType, false) || compareTypes(targetType, sourceType, reportErrors);
48046                     if (related && checkMode & 8 && i >= getMinArgumentCount(source) && i < getMinArgumentCount(target) && compareTypes(sourceType, targetType, false)) {
48047                         related = 0;
48048                     }
48049                     if (!related) {
48050                         if (reportErrors) {
48051                             errorReporter(ts.Diagnostics.Types_of_parameters_0_and_1_are_incompatible, ts.unescapeLeadingUnderscores(getParameterNameAtPosition(source, i)), ts.unescapeLeadingUnderscores(getParameterNameAtPosition(target, i)));
48052                         }
48053                         return 0;
48054                     }
48055                     result &= related;
48056                 }
48057             }
48058             if (!(checkMode & 4)) {
48059                 var targetReturnType = isResolvingReturnTypeOfSignature(target) ? anyType
48060                     : target.declaration && isJSConstructor(target.declaration) ? getDeclaredTypeOfClassOrInterface(getMergedSymbol(target.declaration.symbol))
48061                         : getReturnTypeOfSignature(target);
48062                 if (targetReturnType === voidType) {
48063                     return result;
48064                 }
48065                 var sourceReturnType = isResolvingReturnTypeOfSignature(source) ? anyType
48066                     : source.declaration && isJSConstructor(source.declaration) ? getDeclaredTypeOfClassOrInterface(getMergedSymbol(source.declaration.symbol))
48067                         : getReturnTypeOfSignature(source);
48068                 var targetTypePredicate = getTypePredicateOfSignature(target);
48069                 if (targetTypePredicate) {
48070                     var sourceTypePredicate = getTypePredicateOfSignature(source);
48071                     if (sourceTypePredicate) {
48072                         result &= compareTypePredicateRelatedTo(sourceTypePredicate, targetTypePredicate, reportErrors, errorReporter, compareTypes);
48073                     }
48074                     else if (ts.isIdentifierTypePredicate(targetTypePredicate)) {
48075                         if (reportErrors) {
48076                             errorReporter(ts.Diagnostics.Signature_0_must_be_a_type_predicate, signatureToString(source));
48077                         }
48078                         return 0;
48079                     }
48080                 }
48081                 else {
48082                     result &= checkMode & 1 && compareTypes(targetReturnType, sourceReturnType, false) ||
48083                         compareTypes(sourceReturnType, targetReturnType, reportErrors);
48084                     if (!result && reportErrors && incompatibleErrorReporter) {
48085                         incompatibleErrorReporter(sourceReturnType, targetReturnType);
48086                     }
48087                 }
48088             }
48089             return result;
48090         }
48091         function compareTypePredicateRelatedTo(source, target, reportErrors, errorReporter, compareTypes) {
48092             if (source.kind !== target.kind) {
48093                 if (reportErrors) {
48094                     errorReporter(ts.Diagnostics.A_this_based_type_guard_is_not_compatible_with_a_parameter_based_type_guard);
48095                     errorReporter(ts.Diagnostics.Type_predicate_0_is_not_assignable_to_1, typePredicateToString(source), typePredicateToString(target));
48096                 }
48097                 return 0;
48098             }
48099             if (source.kind === 1 || source.kind === 3) {
48100                 if (source.parameterIndex !== target.parameterIndex) {
48101                     if (reportErrors) {
48102                         errorReporter(ts.Diagnostics.Parameter_0_is_not_in_the_same_position_as_parameter_1, source.parameterName, target.parameterName);
48103                         errorReporter(ts.Diagnostics.Type_predicate_0_is_not_assignable_to_1, typePredicateToString(source), typePredicateToString(target));
48104                     }
48105                     return 0;
48106                 }
48107             }
48108             var related = source.type === target.type ? -1 :
48109                 source.type && target.type ? compareTypes(source.type, target.type, reportErrors) :
48110                     0;
48111             if (related === 0 && reportErrors) {
48112                 errorReporter(ts.Diagnostics.Type_predicate_0_is_not_assignable_to_1, typePredicateToString(source), typePredicateToString(target));
48113             }
48114             return related;
48115         }
48116         function isImplementationCompatibleWithOverload(implementation, overload) {
48117             var erasedSource = getErasedSignature(implementation);
48118             var erasedTarget = getErasedSignature(overload);
48119             var sourceReturnType = getReturnTypeOfSignature(erasedSource);
48120             var targetReturnType = getReturnTypeOfSignature(erasedTarget);
48121             if (targetReturnType === voidType
48122                 || isTypeRelatedTo(targetReturnType, sourceReturnType, assignableRelation)
48123                 || isTypeRelatedTo(sourceReturnType, targetReturnType, assignableRelation)) {
48124                 return isSignatureAssignableTo(erasedSource, erasedTarget, true);
48125             }
48126             return false;
48127         }
48128         function isEmptyResolvedType(t) {
48129             return t !== anyFunctionType &&
48130                 t.properties.length === 0 &&
48131                 t.callSignatures.length === 0 &&
48132                 t.constructSignatures.length === 0 &&
48133                 !t.stringIndexInfo &&
48134                 !t.numberIndexInfo;
48135         }
48136         function isEmptyObjectType(type) {
48137             return type.flags & 524288 ? !isGenericMappedType(type) && isEmptyResolvedType(resolveStructuredTypeMembers(type)) :
48138                 type.flags & 67108864 ? true :
48139                     type.flags & 1048576 ? ts.some(type.types, isEmptyObjectType) :
48140                         type.flags & 2097152 ? ts.every(type.types, isEmptyObjectType) :
48141                             false;
48142         }
48143         function isEmptyAnonymousObjectType(type) {
48144             return !!(ts.getObjectFlags(type) & 16 && (type.members && isEmptyResolvedType(type) ||
48145                 type.symbol && type.symbol.flags & 2048 && getMembersOfSymbol(type.symbol).size === 0));
48146         }
48147         function isStringIndexSignatureOnlyType(type) {
48148             return type.flags & 524288 && !isGenericMappedType(type) && getPropertiesOfType(type).length === 0 && getIndexInfoOfType(type, 0) && !getIndexInfoOfType(type, 1) ||
48149                 type.flags & 3145728 && ts.every(type.types, isStringIndexSignatureOnlyType) ||
48150                 false;
48151         }
48152         function isEnumTypeRelatedTo(sourceSymbol, targetSymbol, errorReporter) {
48153             if (sourceSymbol === targetSymbol) {
48154                 return true;
48155             }
48156             var id = getSymbolId(sourceSymbol) + "," + getSymbolId(targetSymbol);
48157             var entry = enumRelation.get(id);
48158             if (entry !== undefined && !(!(entry & 4) && entry & 2 && errorReporter)) {
48159                 return !!(entry & 1);
48160             }
48161             if (sourceSymbol.escapedName !== targetSymbol.escapedName || !(sourceSymbol.flags & 256) || !(targetSymbol.flags & 256)) {
48162                 enumRelation.set(id, 2 | 4);
48163                 return false;
48164             }
48165             var targetEnumType = getTypeOfSymbol(targetSymbol);
48166             for (var _i = 0, _a = getPropertiesOfType(getTypeOfSymbol(sourceSymbol)); _i < _a.length; _i++) {
48167                 var property = _a[_i];
48168                 if (property.flags & 8) {
48169                     var targetProperty = getPropertyOfType(targetEnumType, property.escapedName);
48170                     if (!targetProperty || !(targetProperty.flags & 8)) {
48171                         if (errorReporter) {
48172                             errorReporter(ts.Diagnostics.Property_0_is_missing_in_type_1, ts.symbolName(property), typeToString(getDeclaredTypeOfSymbol(targetSymbol), undefined, 64));
48173                             enumRelation.set(id, 2 | 4);
48174                         }
48175                         else {
48176                             enumRelation.set(id, 2);
48177                         }
48178                         return false;
48179                     }
48180                 }
48181             }
48182             enumRelation.set(id, 1);
48183             return true;
48184         }
48185         function isSimpleTypeRelatedTo(source, target, relation, errorReporter) {
48186             var s = source.flags;
48187             var t = target.flags;
48188             if (t & 3 || s & 131072 || source === wildcardType)
48189                 return true;
48190             if (t & 131072)
48191                 return false;
48192             if (s & 402653316 && t & 4)
48193                 return true;
48194             if (s & 128 && s & 1024 &&
48195                 t & 128 && !(t & 1024) &&
48196                 source.value === target.value)
48197                 return true;
48198             if (s & 296 && t & 8)
48199                 return true;
48200             if (s & 256 && s & 1024 &&
48201                 t & 256 && !(t & 1024) &&
48202                 source.value === target.value)
48203                 return true;
48204             if (s & 2112 && t & 64)
48205                 return true;
48206             if (s & 528 && t & 16)
48207                 return true;
48208             if (s & 12288 && t & 4096)
48209                 return true;
48210             if (s & 32 && t & 32 && isEnumTypeRelatedTo(source.symbol, target.symbol, errorReporter))
48211                 return true;
48212             if (s & 1024 && t & 1024) {
48213                 if (s & 1048576 && t & 1048576 && isEnumTypeRelatedTo(source.symbol, target.symbol, errorReporter))
48214                     return true;
48215                 if (s & 2944 && t & 2944 &&
48216                     source.value === target.value &&
48217                     isEnumTypeRelatedTo(getParentOfSymbol(source.symbol), getParentOfSymbol(target.symbol), errorReporter))
48218                     return true;
48219             }
48220             if (s & 32768 && (!strictNullChecks || t & (32768 | 16384)))
48221                 return true;
48222             if (s & 65536 && (!strictNullChecks || t & 65536))
48223                 return true;
48224             if (s & 524288 && t & 67108864)
48225                 return true;
48226             if (relation === assignableRelation || relation === comparableRelation) {
48227                 if (s & 1)
48228                     return true;
48229                 if (s & (8 | 256) && !(s & 1024) && (t & 32 || t & 256 && t & 1024))
48230                     return true;
48231             }
48232             return false;
48233         }
48234         function isTypeRelatedTo(source, target, relation) {
48235             if (isFreshLiteralType(source)) {
48236                 source = source.regularType;
48237             }
48238             if (isFreshLiteralType(target)) {
48239                 target = target.regularType;
48240             }
48241             if (source === target) {
48242                 return true;
48243             }
48244             if (relation !== identityRelation) {
48245                 if (relation === comparableRelation && !(target.flags & 131072) && isSimpleTypeRelatedTo(target, source, relation) || isSimpleTypeRelatedTo(source, target, relation)) {
48246                     return true;
48247                 }
48248             }
48249             else {
48250                 if (!(source.flags & 3145728) && !(target.flags & 3145728) &&
48251                     source.flags !== target.flags && !(source.flags & 469237760))
48252                     return false;
48253             }
48254             if (source.flags & 524288 && target.flags & 524288) {
48255                 var related = relation.get(getRelationKey(source, target, 0, relation));
48256                 if (related !== undefined) {
48257                     return !!(related & 1);
48258                 }
48259             }
48260             if (source.flags & 469499904 || target.flags & 469499904) {
48261                 return checkTypeRelatedTo(source, target, relation, undefined);
48262             }
48263             return false;
48264         }
48265         function isIgnoredJsxProperty(source, sourceProp) {
48266             return ts.getObjectFlags(source) & 4096 && !isUnhyphenatedJsxName(sourceProp.escapedName);
48267         }
48268         function getNormalizedType(type, writing) {
48269             while (true) {
48270                 var t = isFreshLiteralType(type) ? type.regularType :
48271                     ts.getObjectFlags(type) & 4 && type.node ? createTypeReference(type.target, getTypeArguments(type)) :
48272                         type.flags & 3145728 ? getReducedType(type) :
48273                             type.flags & 33554432 ? writing ? type.baseType : type.substitute :
48274                                 type.flags & 25165824 ? getSimplifiedType(type, writing) :
48275                                     type;
48276                 if (t === type)
48277                     break;
48278                 type = t;
48279             }
48280             return type;
48281         }
48282         function checkTypeRelatedTo(source, target, relation, errorNode, headMessage, containingMessageChain, errorOutputContainer) {
48283             var errorInfo;
48284             var relatedInfo;
48285             var maybeKeys;
48286             var sourceStack;
48287             var targetStack;
48288             var maybeCount = 0;
48289             var depth = 0;
48290             var expandingFlags = 0;
48291             var overflow = false;
48292             var overrideNextErrorInfo = 0;
48293             var lastSkippedInfo;
48294             var incompatibleStack = [];
48295             var inPropertyCheck = false;
48296             ts.Debug.assert(relation !== identityRelation || !errorNode, "no error reporting in identity checking");
48297             var result = isRelatedTo(source, target, !!errorNode, headMessage);
48298             if (incompatibleStack.length) {
48299                 reportIncompatibleStack();
48300             }
48301             if (overflow) {
48302                 ts.tracing.instant("check", "checkTypeRelatedTo_DepthLimit", { sourceId: source.id, targetId: target.id, depth: depth });
48303                 var diag = error(errorNode || currentNode, ts.Diagnostics.Excessive_stack_depth_comparing_types_0_and_1, typeToString(source), typeToString(target));
48304                 if (errorOutputContainer) {
48305                     (errorOutputContainer.errors || (errorOutputContainer.errors = [])).push(diag);
48306                 }
48307             }
48308             else if (errorInfo) {
48309                 if (containingMessageChain) {
48310                     var chain = containingMessageChain();
48311                     if (chain) {
48312                         ts.concatenateDiagnosticMessageChains(chain, errorInfo);
48313                         errorInfo = chain;
48314                     }
48315                 }
48316                 var relatedInformation = void 0;
48317                 if (headMessage && errorNode && !result && source.symbol) {
48318                     var links = getSymbolLinks(source.symbol);
48319                     if (links.originatingImport && !ts.isImportCall(links.originatingImport)) {
48320                         var helpfulRetry = checkTypeRelatedTo(getTypeOfSymbol(links.target), target, relation, undefined);
48321                         if (helpfulRetry) {
48322                             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);
48323                             relatedInformation = ts.append(relatedInformation, diag_1);
48324                         }
48325                     }
48326                 }
48327                 var diag = ts.createDiagnosticForNodeFromMessageChain(errorNode, errorInfo, relatedInformation);
48328                 if (relatedInfo) {
48329                     ts.addRelatedInfo.apply(void 0, __spreadArrays([diag], relatedInfo));
48330                 }
48331                 if (errorOutputContainer) {
48332                     (errorOutputContainer.errors || (errorOutputContainer.errors = [])).push(diag);
48333                 }
48334                 if (!errorOutputContainer || !errorOutputContainer.skipLogging) {
48335                     diagnostics.add(diag);
48336                 }
48337             }
48338             if (errorNode && errorOutputContainer && errorOutputContainer.skipLogging && result === 0) {
48339                 ts.Debug.assert(!!errorOutputContainer.errors, "missed opportunity to interact with error.");
48340             }
48341             return result !== 0;
48342             function resetErrorInfo(saved) {
48343                 errorInfo = saved.errorInfo;
48344                 lastSkippedInfo = saved.lastSkippedInfo;
48345                 incompatibleStack = saved.incompatibleStack;
48346                 overrideNextErrorInfo = saved.overrideNextErrorInfo;
48347                 relatedInfo = saved.relatedInfo;
48348             }
48349             function captureErrorCalculationState() {
48350                 return {
48351                     errorInfo: errorInfo,
48352                     lastSkippedInfo: lastSkippedInfo,
48353                     incompatibleStack: incompatibleStack.slice(),
48354                     overrideNextErrorInfo: overrideNextErrorInfo,
48355                     relatedInfo: !relatedInfo ? undefined : relatedInfo.slice()
48356                 };
48357             }
48358             function reportIncompatibleError(message, arg0, arg1, arg2, arg3) {
48359                 overrideNextErrorInfo++;
48360                 lastSkippedInfo = undefined;
48361                 incompatibleStack.push([message, arg0, arg1, arg2, arg3]);
48362             }
48363             function reportIncompatibleStack() {
48364                 var stack = incompatibleStack;
48365                 incompatibleStack = [];
48366                 var info = lastSkippedInfo;
48367                 lastSkippedInfo = undefined;
48368                 if (stack.length === 1) {
48369                     reportError.apply(void 0, stack[0]);
48370                     if (info) {
48371                         reportRelationError.apply(void 0, __spreadArrays([undefined], info));
48372                     }
48373                     return;
48374                 }
48375                 var path = "";
48376                 var secondaryRootErrors = [];
48377                 while (stack.length) {
48378                     var _a = stack.pop(), msg = _a[0], args = _a.slice(1);
48379                     switch (msg.code) {
48380                         case ts.Diagnostics.Types_of_property_0_are_incompatible.code: {
48381                             if (path.indexOf("new ") === 0) {
48382                                 path = "(" + path + ")";
48383                             }
48384                             var str = "" + args[0];
48385                             if (path.length === 0) {
48386                                 path = "" + str;
48387                             }
48388                             else if (ts.isIdentifierText(str, compilerOptions.target)) {
48389                                 path = path + "." + str;
48390                             }
48391                             else if (str[0] === "[" && str[str.length - 1] === "]") {
48392                                 path = "" + path + str;
48393                             }
48394                             else {
48395                                 path = path + "[" + str + "]";
48396                             }
48397                             break;
48398                         }
48399                         case ts.Diagnostics.Call_signature_return_types_0_and_1_are_incompatible.code:
48400                         case ts.Diagnostics.Construct_signature_return_types_0_and_1_are_incompatible.code:
48401                         case ts.Diagnostics.Call_signatures_with_no_arguments_have_incompatible_return_types_0_and_1.code:
48402                         case ts.Diagnostics.Construct_signatures_with_no_arguments_have_incompatible_return_types_0_and_1.code: {
48403                             if (path.length === 0) {
48404                                 var mappedMsg = msg;
48405                                 if (msg.code === ts.Diagnostics.Call_signatures_with_no_arguments_have_incompatible_return_types_0_and_1.code) {
48406                                     mappedMsg = ts.Diagnostics.Call_signature_return_types_0_and_1_are_incompatible;
48407                                 }
48408                                 else if (msg.code === ts.Diagnostics.Construct_signatures_with_no_arguments_have_incompatible_return_types_0_and_1.code) {
48409                                     mappedMsg = ts.Diagnostics.Construct_signature_return_types_0_and_1_are_incompatible;
48410                                 }
48411                                 secondaryRootErrors.unshift([mappedMsg, args[0], args[1]]);
48412                             }
48413                             else {
48414                                 var prefix = (msg.code === ts.Diagnostics.Construct_signature_return_types_0_and_1_are_incompatible.code ||
48415                                     msg.code === ts.Diagnostics.Construct_signatures_with_no_arguments_have_incompatible_return_types_0_and_1.code)
48416                                     ? "new "
48417                                     : "";
48418                                 var params = (msg.code === ts.Diagnostics.Call_signatures_with_no_arguments_have_incompatible_return_types_0_and_1.code ||
48419                                     msg.code === ts.Diagnostics.Construct_signatures_with_no_arguments_have_incompatible_return_types_0_and_1.code)
48420                                     ? ""
48421                                     : "...";
48422                                 path = "" + prefix + path + "(" + params + ")";
48423                             }
48424                             break;
48425                         }
48426                         default:
48427                             return ts.Debug.fail("Unhandled Diagnostic: " + msg.code);
48428                     }
48429                 }
48430                 if (path) {
48431                     reportError(path[path.length - 1] === ")"
48432                         ? ts.Diagnostics.The_types_returned_by_0_are_incompatible_between_these_types
48433                         : ts.Diagnostics.The_types_of_0_are_incompatible_between_these_types, path);
48434                 }
48435                 else {
48436                     secondaryRootErrors.shift();
48437                 }
48438                 for (var _i = 0, secondaryRootErrors_1 = secondaryRootErrors; _i < secondaryRootErrors_1.length; _i++) {
48439                     var _b = secondaryRootErrors_1[_i], msg = _b[0], args = _b.slice(1);
48440                     var originalValue = msg.elidedInCompatabilityPyramid;
48441                     msg.elidedInCompatabilityPyramid = false;
48442                     reportError.apply(void 0, __spreadArrays([msg], args));
48443                     msg.elidedInCompatabilityPyramid = originalValue;
48444                 }
48445                 if (info) {
48446                     reportRelationError.apply(void 0, __spreadArrays([undefined], info));
48447                 }
48448             }
48449             function reportError(message, arg0, arg1, arg2, arg3) {
48450                 ts.Debug.assert(!!errorNode);
48451                 if (incompatibleStack.length)
48452                     reportIncompatibleStack();
48453                 if (message.elidedInCompatabilityPyramid)
48454                     return;
48455                 errorInfo = ts.chainDiagnosticMessages(errorInfo, message, arg0, arg1, arg2, arg3);
48456             }
48457             function associateRelatedInfo(info) {
48458                 ts.Debug.assert(!!errorInfo);
48459                 if (!relatedInfo) {
48460                     relatedInfo = [info];
48461                 }
48462                 else {
48463                     relatedInfo.push(info);
48464                 }
48465             }
48466             function reportRelationError(message, source, target) {
48467                 if (incompatibleStack.length)
48468                     reportIncompatibleStack();
48469                 var _a = getTypeNamesForErrorDisplay(source, target), sourceType = _a[0], targetType = _a[1];
48470                 var generalizedSource = source;
48471                 var generalizedSourceType = sourceType;
48472                 if (isLiteralType(source) && !typeCouldHaveTopLevelSingletonTypes(target)) {
48473                     generalizedSource = getBaseTypeOfLiteralType(source);
48474                     ts.Debug.assert(!isTypeAssignableTo(generalizedSource, target), "generalized source shouldn't be assignable");
48475                     generalizedSourceType = getTypeNameForErrorDisplay(generalizedSource);
48476                 }
48477                 if (target.flags & 262144) {
48478                     var constraint = getBaseConstraintOfType(target);
48479                     var needsOriginalSource = void 0;
48480                     if (constraint && (isTypeAssignableTo(generalizedSource, constraint) || (needsOriginalSource = isTypeAssignableTo(source, constraint)))) {
48481                         reportError(ts.Diagnostics._0_is_assignable_to_the_constraint_of_type_1_but_1_could_be_instantiated_with_a_different_subtype_of_constraint_2, needsOriginalSource ? sourceType : generalizedSourceType, targetType, typeToString(constraint));
48482                     }
48483                     else {
48484                         reportError(ts.Diagnostics._0_could_be_instantiated_with_an_arbitrary_type_which_could_be_unrelated_to_1, targetType, generalizedSourceType);
48485                     }
48486                 }
48487                 if (!message) {
48488                     if (relation === comparableRelation) {
48489                         message = ts.Diagnostics.Type_0_is_not_comparable_to_type_1;
48490                     }
48491                     else if (sourceType === targetType) {
48492                         message = ts.Diagnostics.Type_0_is_not_assignable_to_type_1_Two_different_types_with_this_name_exist_but_they_are_unrelated;
48493                     }
48494                     else {
48495                         message = ts.Diagnostics.Type_0_is_not_assignable_to_type_1;
48496                     }
48497                 }
48498                 reportError(message, generalizedSourceType, targetType);
48499             }
48500             function tryElaborateErrorsForPrimitivesAndObjects(source, target) {
48501                 var sourceType = symbolValueDeclarationIsContextSensitive(source.symbol) ? typeToString(source, source.symbol.valueDeclaration) : typeToString(source);
48502                 var targetType = symbolValueDeclarationIsContextSensitive(target.symbol) ? typeToString(target, target.symbol.valueDeclaration) : typeToString(target);
48503                 if ((globalStringType === source && stringType === target) ||
48504                     (globalNumberType === source && numberType === target) ||
48505                     (globalBooleanType === source && booleanType === target) ||
48506                     (getGlobalESSymbolType(false) === source && esSymbolType === target)) {
48507                     reportError(ts.Diagnostics._0_is_a_primitive_but_1_is_a_wrapper_object_Prefer_using_0_when_possible, targetType, sourceType);
48508                 }
48509             }
48510             function tryElaborateArrayLikeErrors(source, target, reportErrors) {
48511                 if (isTupleType(source)) {
48512                     if (source.target.readonly && isMutableArrayOrTuple(target)) {
48513                         if (reportErrors) {
48514                             reportError(ts.Diagnostics.The_type_0_is_readonly_and_cannot_be_assigned_to_the_mutable_type_1, typeToString(source), typeToString(target));
48515                         }
48516                         return false;
48517                     }
48518                     return isTupleType(target) || isArrayType(target);
48519                 }
48520                 if (isReadonlyArrayType(source) && isMutableArrayOrTuple(target)) {
48521                     if (reportErrors) {
48522                         reportError(ts.Diagnostics.The_type_0_is_readonly_and_cannot_be_assigned_to_the_mutable_type_1, typeToString(source), typeToString(target));
48523                     }
48524                     return false;
48525                 }
48526                 if (isTupleType(target)) {
48527                     return isArrayType(source);
48528                 }
48529                 return true;
48530             }
48531             function isRelatedTo(originalSource, originalTarget, reportErrors, headMessage, intersectionState) {
48532                 if (reportErrors === void 0) { reportErrors = false; }
48533                 if (intersectionState === void 0) { intersectionState = 0; }
48534                 if (originalSource.flags & 524288 && originalTarget.flags & 131068) {
48535                     if (isSimpleTypeRelatedTo(originalSource, originalTarget, relation, reportErrors ? reportError : undefined)) {
48536                         return -1;
48537                     }
48538                     reportErrorResults(originalSource, originalTarget, 0, !!(ts.getObjectFlags(originalSource) & 4096));
48539                     return 0;
48540                 }
48541                 var source = getNormalizedType(originalSource, false);
48542                 var target = getNormalizedType(originalTarget, true);
48543                 if (source === target)
48544                     return -1;
48545                 if (relation === identityRelation) {
48546                     return isIdenticalTo(source, target);
48547                 }
48548                 if (source.flags & 262144 && getConstraintOfType(source) === target) {
48549                     return -1;
48550                 }
48551                 if (target.flags & 1048576 && source.flags & 524288 &&
48552                     target.types.length <= 3 && maybeTypeOfKind(target, 98304)) {
48553                     var nullStrippedTarget = extractTypesOfKind(target, ~98304);
48554                     if (!(nullStrippedTarget.flags & (1048576 | 131072))) {
48555                         if (source === nullStrippedTarget)
48556                             return -1;
48557                         target = nullStrippedTarget;
48558                     }
48559                 }
48560                 if (relation === comparableRelation && !(target.flags & 131072) && isSimpleTypeRelatedTo(target, source, relation) ||
48561                     isSimpleTypeRelatedTo(source, target, relation, reportErrors ? reportError : undefined))
48562                     return -1;
48563                 var isComparingJsxAttributes = !!(ts.getObjectFlags(source) & 4096);
48564                 var isPerformingExcessPropertyChecks = !(intersectionState & 2) && (isObjectLiteralType(source) && ts.getObjectFlags(source) & 32768);
48565                 if (isPerformingExcessPropertyChecks) {
48566                     if (hasExcessProperties(source, target, reportErrors)) {
48567                         if (reportErrors) {
48568                             reportRelationError(headMessage, source, target);
48569                         }
48570                         return 0;
48571                     }
48572                 }
48573                 var isPerformingCommonPropertyChecks = relation !== comparableRelation && !(intersectionState & 2) &&
48574                     source.flags & (131068 | 524288 | 2097152) && source !== globalObjectType &&
48575                     target.flags & (524288 | 2097152) && isWeakType(target) &&
48576                     (getPropertiesOfType(source).length > 0 || typeHasCallOrConstructSignatures(source));
48577                 if (isPerformingCommonPropertyChecks && !hasCommonProperties(source, target, isComparingJsxAttributes)) {
48578                     if (reportErrors) {
48579                         var calls = getSignaturesOfType(source, 0);
48580                         var constructs = getSignaturesOfType(source, 1);
48581                         if (calls.length > 0 && isRelatedTo(getReturnTypeOfSignature(calls[0]), target, false) ||
48582                             constructs.length > 0 && isRelatedTo(getReturnTypeOfSignature(constructs[0]), target, false)) {
48583                             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));
48584                         }
48585                         else {
48586                             reportError(ts.Diagnostics.Type_0_has_no_properties_in_common_with_type_1, typeToString(source), typeToString(target));
48587                         }
48588                     }
48589                     return 0;
48590                 }
48591                 var result = 0;
48592                 var saveErrorInfo = captureErrorCalculationState();
48593                 if (source.flags & 1048576) {
48594                     result = relation === comparableRelation ?
48595                         someTypeRelatedToType(source, target, reportErrors && !(source.flags & 131068), intersectionState) :
48596                         eachTypeRelatedToType(source, target, reportErrors && !(source.flags & 131068), intersectionState);
48597                 }
48598                 else {
48599                     if (target.flags & 1048576) {
48600                         result = typeRelatedToSomeType(getRegularTypeOfObjectLiteral(source), target, reportErrors && !(source.flags & 131068) && !(target.flags & 131068));
48601                     }
48602                     else if (target.flags & 2097152) {
48603                         result = typeRelatedToEachType(getRegularTypeOfObjectLiteral(source), target, reportErrors, 2);
48604                     }
48605                     else if (source.flags & 2097152) {
48606                         result = someTypeRelatedToType(source, target, false, 1);
48607                     }
48608                     if (!result && (source.flags & 469499904 || target.flags & 469499904)) {
48609                         if (result = recursiveTypeRelatedTo(source, target, reportErrors, intersectionState)) {
48610                             resetErrorInfo(saveErrorInfo);
48611                         }
48612                     }
48613                 }
48614                 if (!result && source.flags & (2097152 | 262144)) {
48615                     var constraint = getEffectiveConstraintOfIntersection(source.flags & 2097152 ? source.types : [source], !!(target.flags & 1048576));
48616                     if (constraint && (source.flags & 2097152 || target.flags & 1048576)) {
48617                         if (everyType(constraint, function (c) { return c !== source; })) {
48618                             if (result = isRelatedTo(constraint, target, false, undefined, intersectionState)) {
48619                                 resetErrorInfo(saveErrorInfo);
48620                             }
48621                         }
48622                     }
48623                 }
48624                 if (result && !inPropertyCheck && (target.flags & 2097152 && (isPerformingExcessPropertyChecks || isPerformingCommonPropertyChecks) ||
48625                     isNonGenericObjectType(target) && !isArrayType(target) && !isTupleType(target) && source.flags & 2097152 && getApparentType(source).flags & 3670016 && !ts.some(source.types, function (t) { return !!(ts.getObjectFlags(t) & 2097152); }))) {
48626                     inPropertyCheck = true;
48627                     result &= recursiveTypeRelatedTo(source, target, reportErrors, 4);
48628                     inPropertyCheck = false;
48629                 }
48630                 reportErrorResults(source, target, result, isComparingJsxAttributes);
48631                 return result;
48632                 function reportErrorResults(source, target, result, isComparingJsxAttributes) {
48633                     if (!result && reportErrors) {
48634                         source = originalSource.aliasSymbol ? originalSource : source;
48635                         target = originalTarget.aliasSymbol ? originalTarget : target;
48636                         var maybeSuppress = overrideNextErrorInfo > 0;
48637                         if (maybeSuppress) {
48638                             overrideNextErrorInfo--;
48639                         }
48640                         if (source.flags & 524288 && target.flags & 524288) {
48641                             var currentError = errorInfo;
48642                             tryElaborateArrayLikeErrors(source, target, reportErrors);
48643                             if (errorInfo !== currentError) {
48644                                 maybeSuppress = !!errorInfo;
48645                             }
48646                         }
48647                         if (source.flags & 524288 && target.flags & 131068) {
48648                             tryElaborateErrorsForPrimitivesAndObjects(source, target);
48649                         }
48650                         else if (source.symbol && source.flags & 524288 && globalObjectType === source) {
48651                             reportError(ts.Diagnostics.The_Object_type_is_assignable_to_very_few_other_types_Did_you_mean_to_use_the_any_type_instead);
48652                         }
48653                         else if (isComparingJsxAttributes && target.flags & 2097152) {
48654                             var targetTypes = target.types;
48655                             var intrinsicAttributes = getJsxType(JsxNames.IntrinsicAttributes, errorNode);
48656                             var intrinsicClassAttributes = getJsxType(JsxNames.IntrinsicClassAttributes, errorNode);
48657                             if (intrinsicAttributes !== errorType && intrinsicClassAttributes !== errorType &&
48658                                 (ts.contains(targetTypes, intrinsicAttributes) || ts.contains(targetTypes, intrinsicClassAttributes))) {
48659                                 return result;
48660                             }
48661                         }
48662                         else {
48663                             errorInfo = elaborateNeverIntersection(errorInfo, originalTarget);
48664                         }
48665                         if (!headMessage && maybeSuppress) {
48666                             lastSkippedInfo = [source, target];
48667                             return result;
48668                         }
48669                         reportRelationError(headMessage, source, target);
48670                     }
48671                 }
48672             }
48673             function isIdenticalTo(source, target) {
48674                 var flags = source.flags & target.flags;
48675                 if (!(flags & 469237760)) {
48676                     return 0;
48677                 }
48678                 if (flags & 3145728) {
48679                     var result_6 = eachTypeRelatedToSomeType(source, target);
48680                     if (result_6) {
48681                         result_6 &= eachTypeRelatedToSomeType(target, source);
48682                     }
48683                     return result_6;
48684                 }
48685                 return recursiveTypeRelatedTo(source, target, false, 0);
48686             }
48687             function getTypeOfPropertyInTypes(types, name) {
48688                 var appendPropType = function (propTypes, type) {
48689                     type = getApparentType(type);
48690                     var prop = type.flags & 3145728 ? getPropertyOfUnionOrIntersectionType(type, name) : getPropertyOfObjectType(type, name);
48691                     var propType = prop && getTypeOfSymbol(prop) || isNumericLiteralName(name) && getIndexTypeOfType(type, 1) || getIndexTypeOfType(type, 0) || undefinedType;
48692                     return ts.append(propTypes, propType);
48693                 };
48694                 return getUnionType(ts.reduceLeft(types, appendPropType, undefined) || ts.emptyArray);
48695             }
48696             function hasExcessProperties(source, target, reportErrors) {
48697                 if (!isExcessPropertyCheckTarget(target) || !noImplicitAny && ts.getObjectFlags(target) & 16384) {
48698                     return false;
48699                 }
48700                 var isComparingJsxAttributes = !!(ts.getObjectFlags(source) & 4096);
48701                 if ((relation === assignableRelation || relation === comparableRelation) &&
48702                     (isTypeSubsetOf(globalObjectType, target) || (!isComparingJsxAttributes && isEmptyObjectType(target)))) {
48703                     return false;
48704                 }
48705                 var reducedTarget = target;
48706                 var checkTypes;
48707                 if (target.flags & 1048576) {
48708                     reducedTarget = findMatchingDiscriminantType(source, target, isRelatedTo) || filterPrimitivesIfContainsNonPrimitive(target);
48709                     checkTypes = reducedTarget.flags & 1048576 ? reducedTarget.types : [reducedTarget];
48710                 }
48711                 var _loop_16 = function (prop) {
48712                     if (shouldCheckAsExcessProperty(prop, source.symbol) && !isIgnoredJsxProperty(source, prop)) {
48713                         if (!isKnownProperty(reducedTarget, prop.escapedName, isComparingJsxAttributes)) {
48714                             if (reportErrors) {
48715                                 var errorTarget = filterType(reducedTarget, isExcessPropertyCheckTarget);
48716                                 if (!errorNode)
48717                                     return { value: ts.Debug.fail() };
48718                                 if (ts.isJsxAttributes(errorNode) || ts.isJsxOpeningLikeElement(errorNode) || ts.isJsxOpeningLikeElement(errorNode.parent)) {
48719                                     if (prop.valueDeclaration && ts.isJsxAttribute(prop.valueDeclaration) && ts.getSourceFileOfNode(errorNode) === ts.getSourceFileOfNode(prop.valueDeclaration.name)) {
48720                                         errorNode = prop.valueDeclaration.name;
48721                                     }
48722                                     var propName = symbolToString(prop);
48723                                     var suggestionSymbol = getSuggestedSymbolForNonexistentJSXAttribute(propName, errorTarget);
48724                                     var suggestion = suggestionSymbol ? symbolToString(suggestionSymbol) : undefined;
48725                                     if (suggestion) {
48726                                         reportError(ts.Diagnostics.Property_0_does_not_exist_on_type_1_Did_you_mean_2, propName, typeToString(errorTarget), suggestion);
48727                                     }
48728                                     else {
48729                                         reportError(ts.Diagnostics.Property_0_does_not_exist_on_type_1, propName, typeToString(errorTarget));
48730                                     }
48731                                 }
48732                                 else {
48733                                     var objectLiteralDeclaration_1 = source.symbol && ts.firstOrUndefined(source.symbol.declarations);
48734                                     var suggestion = void 0;
48735                                     if (prop.valueDeclaration && ts.findAncestor(prop.valueDeclaration, function (d) { return d === objectLiteralDeclaration_1; }) && ts.getSourceFileOfNode(objectLiteralDeclaration_1) === ts.getSourceFileOfNode(errorNode)) {
48736                                         var propDeclaration = prop.valueDeclaration;
48737                                         ts.Debug.assertNode(propDeclaration, ts.isObjectLiteralElementLike);
48738                                         errorNode = propDeclaration;
48739                                         var name = propDeclaration.name;
48740                                         if (ts.isIdentifier(name)) {
48741                                             suggestion = getSuggestionForNonexistentProperty(name, errorTarget);
48742                                         }
48743                                     }
48744                                     if (suggestion !== undefined) {
48745                                         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);
48746                                     }
48747                                     else {
48748                                         reportError(ts.Diagnostics.Object_literal_may_only_specify_known_properties_and_0_does_not_exist_in_type_1, symbolToString(prop), typeToString(errorTarget));
48749                                     }
48750                                 }
48751                             }
48752                             return { value: true };
48753                         }
48754                         if (checkTypes && !isRelatedTo(getTypeOfSymbol(prop), getTypeOfPropertyInTypes(checkTypes, prop.escapedName), reportErrors)) {
48755                             if (reportErrors) {
48756                                 reportIncompatibleError(ts.Diagnostics.Types_of_property_0_are_incompatible, symbolToString(prop));
48757                             }
48758                             return { value: true };
48759                         }
48760                     }
48761                 };
48762                 for (var _i = 0, _a = getPropertiesOfType(source); _i < _a.length; _i++) {
48763                     var prop = _a[_i];
48764                     var state_5 = _loop_16(prop);
48765                     if (typeof state_5 === "object")
48766                         return state_5.value;
48767                 }
48768                 return false;
48769             }
48770             function shouldCheckAsExcessProperty(prop, container) {
48771                 return prop.valueDeclaration && container.valueDeclaration && prop.valueDeclaration.parent === container.valueDeclaration;
48772             }
48773             function eachTypeRelatedToSomeType(source, target) {
48774                 var result = -1;
48775                 var sourceTypes = source.types;
48776                 for (var _i = 0, sourceTypes_1 = sourceTypes; _i < sourceTypes_1.length; _i++) {
48777                     var sourceType = sourceTypes_1[_i];
48778                     var related = typeRelatedToSomeType(sourceType, target, false);
48779                     if (!related) {
48780                         return 0;
48781                     }
48782                     result &= related;
48783                 }
48784                 return result;
48785             }
48786             function typeRelatedToSomeType(source, target, reportErrors) {
48787                 var targetTypes = target.types;
48788                 if (target.flags & 1048576 && containsType(targetTypes, source)) {
48789                     return -1;
48790                 }
48791                 for (var _i = 0, targetTypes_1 = targetTypes; _i < targetTypes_1.length; _i++) {
48792                     var type = targetTypes_1[_i];
48793                     var related = isRelatedTo(source, type, false);
48794                     if (related) {
48795                         return related;
48796                     }
48797                 }
48798                 if (reportErrors) {
48799                     var bestMatchingType = getBestMatchingType(source, target, isRelatedTo);
48800                     isRelatedTo(source, bestMatchingType || targetTypes[targetTypes.length - 1], true);
48801                 }
48802                 return 0;
48803             }
48804             function typeRelatedToEachType(source, target, reportErrors, intersectionState) {
48805                 var result = -1;
48806                 var targetTypes = target.types;
48807                 for (var _i = 0, targetTypes_2 = targetTypes; _i < targetTypes_2.length; _i++) {
48808                     var targetType = targetTypes_2[_i];
48809                     var related = isRelatedTo(source, targetType, reportErrors, undefined, intersectionState);
48810                     if (!related) {
48811                         return 0;
48812                     }
48813                     result &= related;
48814                 }
48815                 return result;
48816             }
48817             function someTypeRelatedToType(source, target, reportErrors, intersectionState) {
48818                 var sourceTypes = source.types;
48819                 if (source.flags & 1048576 && containsType(sourceTypes, target)) {
48820                     return -1;
48821                 }
48822                 var len = sourceTypes.length;
48823                 for (var i = 0; i < len; i++) {
48824                     var related = isRelatedTo(sourceTypes[i], target, reportErrors && i === len - 1, undefined, intersectionState);
48825                     if (related) {
48826                         return related;
48827                     }
48828                 }
48829                 return 0;
48830             }
48831             function eachTypeRelatedToType(source, target, reportErrors, intersectionState) {
48832                 var result = -1;
48833                 var sourceTypes = source.types;
48834                 for (var i = 0; i < sourceTypes.length; i++) {
48835                     var sourceType = sourceTypes[i];
48836                     if (target.flags & 1048576 && target.types.length === sourceTypes.length) {
48837                         var related_1 = isRelatedTo(sourceType, target.types[i], false, undefined, intersectionState);
48838                         if (related_1) {
48839                             result &= related_1;
48840                             continue;
48841                         }
48842                     }
48843                     var related = isRelatedTo(sourceType, target, reportErrors, undefined, intersectionState);
48844                     if (!related) {
48845                         return 0;
48846                     }
48847                     result &= related;
48848                 }
48849                 return result;
48850             }
48851             function typeArgumentsRelatedTo(sources, targets, variances, reportErrors, intersectionState) {
48852                 if (sources === void 0) { sources = ts.emptyArray; }
48853                 if (targets === void 0) { targets = ts.emptyArray; }
48854                 if (variances === void 0) { variances = ts.emptyArray; }
48855                 if (sources.length !== targets.length && relation === identityRelation) {
48856                     return 0;
48857                 }
48858                 var length = sources.length <= targets.length ? sources.length : targets.length;
48859                 var result = -1;
48860                 for (var i = 0; i < length; i++) {
48861                     var varianceFlags = i < variances.length ? variances[i] : 1;
48862                     var variance = varianceFlags & 7;
48863                     if (variance !== 4) {
48864                         var s = sources[i];
48865                         var t = targets[i];
48866                         var related = -1;
48867                         if (varianceFlags & 8) {
48868                             related = relation === identityRelation ? isRelatedTo(s, t, false) : compareTypesIdentical(s, t);
48869                         }
48870                         else if (variance === 1) {
48871                             related = isRelatedTo(s, t, reportErrors, undefined, intersectionState);
48872                         }
48873                         else if (variance === 2) {
48874                             related = isRelatedTo(t, s, reportErrors, undefined, intersectionState);
48875                         }
48876                         else if (variance === 3) {
48877                             related = isRelatedTo(t, s, false);
48878                             if (!related) {
48879                                 related = isRelatedTo(s, t, reportErrors, undefined, intersectionState);
48880                             }
48881                         }
48882                         else {
48883                             related = isRelatedTo(s, t, reportErrors, undefined, intersectionState);
48884                             if (related) {
48885                                 related &= isRelatedTo(t, s, reportErrors, undefined, intersectionState);
48886                             }
48887                         }
48888                         if (!related) {
48889                             return 0;
48890                         }
48891                         result &= related;
48892                     }
48893                 }
48894                 return result;
48895             }
48896             function recursiveTypeRelatedTo(source, target, reportErrors, intersectionState) {
48897                 if (overflow) {
48898                     return 0;
48899                 }
48900                 var id = getRelationKey(source, target, intersectionState | (inPropertyCheck ? 8 : 0), relation);
48901                 var entry = relation.get(id);
48902                 if (entry !== undefined) {
48903                     if (reportErrors && entry & 2 && !(entry & 4)) {
48904                     }
48905                     else {
48906                         if (outofbandVarianceMarkerHandler) {
48907                             var saved = entry & 24;
48908                             if (saved & 8) {
48909                                 instantiateType(source, makeFunctionTypeMapper(reportUnmeasurableMarkers));
48910                             }
48911                             if (saved & 16) {
48912                                 instantiateType(source, makeFunctionTypeMapper(reportUnreliableMarkers));
48913                             }
48914                         }
48915                         return entry & 1 ? -1 : 0;
48916                     }
48917                 }
48918                 if (!maybeKeys) {
48919                     maybeKeys = [];
48920                     sourceStack = [];
48921                     targetStack = [];
48922                 }
48923                 else {
48924                     for (var i = 0; i < maybeCount; i++) {
48925                         if (id === maybeKeys[i]) {
48926                             return 3;
48927                         }
48928                     }
48929                     if (depth === 100) {
48930                         overflow = true;
48931                         return 0;
48932                     }
48933                 }
48934                 var maybeStart = maybeCount;
48935                 maybeKeys[maybeCount] = id;
48936                 maybeCount++;
48937                 sourceStack[depth] = source;
48938                 targetStack[depth] = target;
48939                 depth++;
48940                 var saveExpandingFlags = expandingFlags;
48941                 if (!(expandingFlags & 1) && isDeeplyNestedType(source, sourceStack, depth))
48942                     expandingFlags |= 1;
48943                 if (!(expandingFlags & 2) && isDeeplyNestedType(target, targetStack, depth))
48944                     expandingFlags |= 2;
48945                 var originalHandler;
48946                 var propagatingVarianceFlags = 0;
48947                 if (outofbandVarianceMarkerHandler) {
48948                     originalHandler = outofbandVarianceMarkerHandler;
48949                     outofbandVarianceMarkerHandler = function (onlyUnreliable) {
48950                         propagatingVarianceFlags |= onlyUnreliable ? 16 : 8;
48951                         return originalHandler(onlyUnreliable);
48952                     };
48953                 }
48954                 if (expandingFlags === 3) {
48955                     ts.tracing.instant("check", "recursiveTypeRelatedTo_DepthLimit", {
48956                         sourceId: source.id,
48957                         sourceIdStack: sourceStack.map(function (t) { return t.id; }),
48958                         targetId: target.id,
48959                         targetIdStack: targetStack.map(function (t) { return t.id; }),
48960                         depth: depth,
48961                     });
48962                 }
48963                 var result = expandingFlags !== 3 ? structuredTypeRelatedTo(source, target, reportErrors, intersectionState) : 3;
48964                 if (outofbandVarianceMarkerHandler) {
48965                     outofbandVarianceMarkerHandler = originalHandler;
48966                 }
48967                 expandingFlags = saveExpandingFlags;
48968                 depth--;
48969                 if (result) {
48970                     if (result === -1 || depth === 0) {
48971                         if (result === -1 || result === 3) {
48972                             for (var i = maybeStart; i < maybeCount; i++) {
48973                                 relation.set(maybeKeys[i], 1 | propagatingVarianceFlags);
48974                             }
48975                         }
48976                         maybeCount = maybeStart;
48977                     }
48978                 }
48979                 else {
48980                     relation.set(id, (reportErrors ? 4 : 0) | 2 | propagatingVarianceFlags);
48981                     maybeCount = maybeStart;
48982                 }
48983                 return result;
48984             }
48985             function structuredTypeRelatedTo(source, target, reportErrors, intersectionState) {
48986                 ts.tracing.push("check", "structuredTypeRelatedTo", { sourceId: source.id, targetId: target.id });
48987                 var result = structuredTypeRelatedToWorker(source, target, reportErrors, intersectionState);
48988                 ts.tracing.pop();
48989                 return result;
48990             }
48991             function structuredTypeRelatedToWorker(source, target, reportErrors, intersectionState) {
48992                 if (intersectionState & 4) {
48993                     return propertiesRelatedTo(source, target, reportErrors, undefined, 0);
48994                 }
48995                 var flags = source.flags & target.flags;
48996                 if (relation === identityRelation && !(flags & 524288)) {
48997                     if (flags & 4194304) {
48998                         return isRelatedTo(source.type, target.type, false);
48999                     }
49000                     var result_7 = 0;
49001                     if (flags & 8388608) {
49002                         if (result_7 = isRelatedTo(source.objectType, target.objectType, false)) {
49003                             if (result_7 &= isRelatedTo(source.indexType, target.indexType, false)) {
49004                                 return result_7;
49005                             }
49006                         }
49007                     }
49008                     if (flags & 16777216) {
49009                         if (source.root.isDistributive === target.root.isDistributive) {
49010                             if (result_7 = isRelatedTo(source.checkType, target.checkType, false)) {
49011                                 if (result_7 &= isRelatedTo(source.extendsType, target.extendsType, false)) {
49012                                     if (result_7 &= isRelatedTo(getTrueTypeFromConditionalType(source), getTrueTypeFromConditionalType(target), false)) {
49013                                         if (result_7 &= isRelatedTo(getFalseTypeFromConditionalType(source), getFalseTypeFromConditionalType(target), false)) {
49014                                             return result_7;
49015                                         }
49016                                     }
49017                                 }
49018                             }
49019                         }
49020                     }
49021                     if (flags & 33554432) {
49022                         return isRelatedTo(source.substitute, target.substitute, false);
49023                     }
49024                     return 0;
49025                 }
49026                 var result;
49027                 var originalErrorInfo;
49028                 var varianceCheckFailed = false;
49029                 var saveErrorInfo = captureErrorCalculationState();
49030                 if (source.flags & (524288 | 16777216) && source.aliasSymbol &&
49031                     source.aliasTypeArguments && source.aliasSymbol === target.aliasSymbol &&
49032                     !(source.aliasTypeArgumentsContainsMarker || target.aliasTypeArgumentsContainsMarker)) {
49033                     var variances = getAliasVariances(source.aliasSymbol);
49034                     if (variances === ts.emptyArray) {
49035                         return 1;
49036                     }
49037                     var varianceResult = relateVariances(source.aliasTypeArguments, target.aliasTypeArguments, variances, intersectionState);
49038                     if (varianceResult !== undefined) {
49039                         return varianceResult;
49040                     }
49041                 }
49042                 if (isSingleElementGenericTupleType(source) && !source.target.readonly && (result = isRelatedTo(getTypeArguments(source)[0], target)) ||
49043                     isSingleElementGenericTupleType(target) && (target.target.readonly || isMutableArrayOrTuple(getBaseConstraintOfType(source) || source)) && (result = isRelatedTo(source, getTypeArguments(target)[0]))) {
49044                     return result;
49045                 }
49046                 if (target.flags & 262144) {
49047                     if (ts.getObjectFlags(source) & 32 && !source.declaration.nameType && isRelatedTo(getIndexType(target), getConstraintTypeFromMappedType(source))) {
49048                         if (!(getMappedTypeModifiers(source) & 4)) {
49049                             var templateType = getTemplateTypeFromMappedType(source);
49050                             var indexedAccessType = getIndexedAccessType(target, getTypeParameterFromMappedType(source));
49051                             if (result = isRelatedTo(templateType, indexedAccessType, reportErrors)) {
49052                                 return result;
49053                             }
49054                         }
49055                     }
49056                 }
49057                 else if (target.flags & 4194304) {
49058                     var targetType = target.type;
49059                     if (source.flags & 4194304) {
49060                         if (result = isRelatedTo(targetType, source.type, false)) {
49061                             return result;
49062                         }
49063                     }
49064                     if (isTupleType(targetType)) {
49065                         if (result = isRelatedTo(source, getKnownKeysOfTupleType(targetType), reportErrors)) {
49066                             return result;
49067                         }
49068                     }
49069                     else {
49070                         var constraint = getSimplifiedTypeOrConstraint(targetType);
49071                         if (constraint) {
49072                             if (isRelatedTo(source, getIndexType(constraint, target.stringsOnly), reportErrors) === -1) {
49073                                 return -1;
49074                             }
49075                         }
49076                     }
49077                 }
49078                 else if (target.flags & 8388608) {
49079                     if (relation === assignableRelation || relation === comparableRelation) {
49080                         var objectType = target.objectType;
49081                         var indexType = target.indexType;
49082                         var baseObjectType = getBaseConstraintOfType(objectType) || objectType;
49083                         var baseIndexType = getBaseConstraintOfType(indexType) || indexType;
49084                         if (!isGenericObjectType(baseObjectType) && !isGenericIndexType(baseIndexType)) {
49085                             var accessFlags = 2 | (baseObjectType !== objectType ? 1 : 0);
49086                             var constraint = getIndexedAccessTypeOrUndefined(baseObjectType, baseIndexType, target.noUncheckedIndexedAccessCandidate, undefined, accessFlags);
49087                             if (constraint && (result = isRelatedTo(source, constraint, reportErrors))) {
49088                                 return result;
49089                             }
49090                         }
49091                     }
49092                 }
49093                 else if (isGenericMappedType(target) && !target.declaration.nameType) {
49094                     var template = getTemplateTypeFromMappedType(target);
49095                     var modifiers = getMappedTypeModifiers(target);
49096                     if (!(modifiers & 8)) {
49097                         if (template.flags & 8388608 && template.objectType === source &&
49098                             template.indexType === getTypeParameterFromMappedType(target)) {
49099                             return -1;
49100                         }
49101                         if (!isGenericMappedType(source)) {
49102                             var targetConstraint = getConstraintTypeFromMappedType(target);
49103                             var sourceKeys = getIndexType(source, undefined, true);
49104                             var includeOptional = modifiers & 4;
49105                             var filteredByApplicability = includeOptional ? intersectTypes(targetConstraint, sourceKeys) : undefined;
49106                             if (includeOptional
49107                                 ? !(filteredByApplicability.flags & 131072)
49108                                 : isRelatedTo(targetConstraint, sourceKeys)) {
49109                                 var templateType = getTemplateTypeFromMappedType(target);
49110                                 var typeParameter = getTypeParameterFromMappedType(target);
49111                                 var nonNullComponent = extractTypesOfKind(templateType, ~98304);
49112                                 if (nonNullComponent.flags & 8388608 && nonNullComponent.indexType === typeParameter) {
49113                                     if (result = isRelatedTo(source, nonNullComponent.objectType, reportErrors)) {
49114                                         return result;
49115                                     }
49116                                 }
49117                                 else {
49118                                     var indexingType = filteredByApplicability ? getIntersectionType([filteredByApplicability, typeParameter]) : typeParameter;
49119                                     var indexedAccessType = getIndexedAccessType(source, indexingType);
49120                                     if (result = isRelatedTo(indexedAccessType, templateType, reportErrors)) {
49121                                         return result;
49122                                     }
49123                                 }
49124                             }
49125                             originalErrorInfo = errorInfo;
49126                             resetErrorInfo(saveErrorInfo);
49127                         }
49128                     }
49129                 }
49130                 else if (target.flags & 134217728 && source.flags & 128) {
49131                     if (isPatternLiteralType(target)) {
49132                         var result_8 = inferLiteralsFromTemplateLiteralType(source, target);
49133                         if (result_8 && ts.every(result_8, function (r, i) { return isStringLiteralTypeValueParsableAsType(r, target.types[i]); })) {
49134                             return -1;
49135                         }
49136                     }
49137                 }
49138                 if (source.flags & 8650752) {
49139                     if (source.flags & 8388608 && target.flags & 8388608) {
49140                         if (result = isRelatedTo(source.objectType, target.objectType, reportErrors)) {
49141                             result &= isRelatedTo(source.indexType, target.indexType, reportErrors);
49142                         }
49143                         if (result) {
49144                             resetErrorInfo(saveErrorInfo);
49145                             return result;
49146                         }
49147                     }
49148                     else {
49149                         var constraint = getConstraintOfType(source);
49150                         if (!constraint || (source.flags & 262144 && constraint.flags & 1)) {
49151                             if (result = isRelatedTo(emptyObjectType, extractTypesOfKind(target, ~67108864))) {
49152                                 resetErrorInfo(saveErrorInfo);
49153                                 return result;
49154                             }
49155                         }
49156                         else if (result = isRelatedTo(constraint, target, false, undefined, intersectionState)) {
49157                             resetErrorInfo(saveErrorInfo);
49158                             return result;
49159                         }
49160                         else if (result = isRelatedTo(getTypeWithThisArgument(constraint, source), target, reportErrors, undefined, intersectionState)) {
49161                             resetErrorInfo(saveErrorInfo);
49162                             return result;
49163                         }
49164                     }
49165                 }
49166                 else if (source.flags & 4194304) {
49167                     if (result = isRelatedTo(keyofConstraintType, target, reportErrors)) {
49168                         resetErrorInfo(saveErrorInfo);
49169                         return result;
49170                     }
49171                 }
49172                 else if (source.flags & 134217728) {
49173                     if (target.flags & 134217728 &&
49174                         source.texts.length === target.texts.length &&
49175                         source.types.length === target.types.length &&
49176                         ts.every(source.texts, function (t, i) { return t === target.texts[i]; }) &&
49177                         ts.every(instantiateType(source, makeFunctionTypeMapper(reportUnreliableMarkers)).types, function (t, i) { return !!(target.types[i].flags & (1 | 4)) || !!isRelatedTo(t, target.types[i], false); })) {
49178                         return -1;
49179                     }
49180                     var constraint = getBaseConstraintOfType(source);
49181                     if (constraint && constraint !== source && (result = isRelatedTo(constraint, target, reportErrors))) {
49182                         resetErrorInfo(saveErrorInfo);
49183                         return result;
49184                     }
49185                 }
49186                 else if (source.flags & 268435456) {
49187                     if (target.flags & 268435456 && source.symbol === target.symbol) {
49188                         if (result = isRelatedTo(source.type, target.type, reportErrors)) {
49189                             resetErrorInfo(saveErrorInfo);
49190                             return result;
49191                         }
49192                     }
49193                     else {
49194                         var constraint = getBaseConstraintOfType(source);
49195                         if (constraint && (result = isRelatedTo(constraint, target, reportErrors))) {
49196                             resetErrorInfo(saveErrorInfo);
49197                             return result;
49198                         }
49199                     }
49200                 }
49201                 else if (source.flags & 16777216) {
49202                     if (target.flags & 16777216) {
49203                         var sourceParams = source.root.inferTypeParameters;
49204                         var sourceExtends = source.extendsType;
49205                         var mapper = void 0;
49206                         if (sourceParams) {
49207                             var ctx = createInferenceContext(sourceParams, undefined, 0, isRelatedTo);
49208                             inferTypes(ctx.inferences, target.extendsType, sourceExtends, 256 | 512);
49209                             sourceExtends = instantiateType(sourceExtends, ctx.mapper);
49210                             mapper = ctx.mapper;
49211                         }
49212                         if (isTypeIdenticalTo(sourceExtends, target.extendsType) &&
49213                             (isRelatedTo(source.checkType, target.checkType) || isRelatedTo(target.checkType, source.checkType))) {
49214                             if (result = isRelatedTo(instantiateType(getTrueTypeFromConditionalType(source), mapper), getTrueTypeFromConditionalType(target), reportErrors)) {
49215                                 result &= isRelatedTo(getFalseTypeFromConditionalType(source), getFalseTypeFromConditionalType(target), reportErrors);
49216                             }
49217                             if (result) {
49218                                 resetErrorInfo(saveErrorInfo);
49219                                 return result;
49220                             }
49221                         }
49222                     }
49223                     else {
49224                         var distributiveConstraint = getConstraintOfDistributiveConditionalType(source);
49225                         if (distributiveConstraint) {
49226                             if (result = isRelatedTo(distributiveConstraint, target, reportErrors)) {
49227                                 resetErrorInfo(saveErrorInfo);
49228                                 return result;
49229                             }
49230                         }
49231                     }
49232                     var defaultConstraint = getDefaultConstraintOfConditionalType(source);
49233                     if (defaultConstraint) {
49234                         if (result = isRelatedTo(defaultConstraint, target, reportErrors)) {
49235                             resetErrorInfo(saveErrorInfo);
49236                             return result;
49237                         }
49238                     }
49239                 }
49240                 else {
49241                     if (relation !== subtypeRelation && relation !== strictSubtypeRelation && isPartialMappedType(target) && isEmptyObjectType(source)) {
49242                         return -1;
49243                     }
49244                     if (isGenericMappedType(target)) {
49245                         if (isGenericMappedType(source)) {
49246                             if (result = mappedTypeRelatedTo(source, target, reportErrors)) {
49247                                 resetErrorInfo(saveErrorInfo);
49248                                 return result;
49249                             }
49250                         }
49251                         return 0;
49252                     }
49253                     var sourceIsPrimitive = !!(source.flags & 131068);
49254                     if (relation !== identityRelation) {
49255                         source = getApparentType(source);
49256                     }
49257                     else if (isGenericMappedType(source)) {
49258                         return 0;
49259                     }
49260                     if (ts.getObjectFlags(source) & 4 && ts.getObjectFlags(target) & 4 && source.target === target.target &&
49261                         !(ts.getObjectFlags(source) & 8192 || ts.getObjectFlags(target) & 8192)) {
49262                         var variances = getVariances(source.target);
49263                         if (variances === ts.emptyArray) {
49264                             return 1;
49265                         }
49266                         var varianceResult = relateVariances(getTypeArguments(source), getTypeArguments(target), variances, intersectionState);
49267                         if (varianceResult !== undefined) {
49268                             return varianceResult;
49269                         }
49270                     }
49271                     else if (isReadonlyArrayType(target) ? isArrayType(source) || isTupleType(source) : isArrayType(target) && isTupleType(source) && !source.target.readonly) {
49272                         if (relation !== identityRelation) {
49273                             return isRelatedTo(getIndexTypeOfType(source, 1) || anyType, getIndexTypeOfType(target, 1) || anyType, reportErrors);
49274                         }
49275                         else {
49276                             return 0;
49277                         }
49278                     }
49279                     else if ((relation === subtypeRelation || relation === strictSubtypeRelation) && isEmptyObjectType(target) && ts.getObjectFlags(target) & 32768 && !isEmptyObjectType(source)) {
49280                         return 0;
49281                     }
49282                     if (source.flags & (524288 | 2097152) && target.flags & 524288) {
49283                         var reportStructuralErrors = reportErrors && errorInfo === saveErrorInfo.errorInfo && !sourceIsPrimitive;
49284                         result = propertiesRelatedTo(source, target, reportStructuralErrors, undefined, intersectionState);
49285                         if (result) {
49286                             result &= signaturesRelatedTo(source, target, 0, reportStructuralErrors);
49287                             if (result) {
49288                                 result &= signaturesRelatedTo(source, target, 1, reportStructuralErrors);
49289                                 if (result) {
49290                                     result &= indexTypesRelatedTo(source, target, 0, sourceIsPrimitive, reportStructuralErrors, intersectionState);
49291                                     if (result) {
49292                                         result &= indexTypesRelatedTo(source, target, 1, sourceIsPrimitive, reportStructuralErrors, intersectionState);
49293                                     }
49294                                 }
49295                             }
49296                         }
49297                         if (varianceCheckFailed && result) {
49298                             errorInfo = originalErrorInfo || errorInfo || saveErrorInfo.errorInfo;
49299                         }
49300                         else if (result) {
49301                             return result;
49302                         }
49303                     }
49304                     if (source.flags & (524288 | 2097152) && target.flags & 1048576) {
49305                         var objectOnlyTarget = extractTypesOfKind(target, 524288 | 2097152 | 33554432);
49306                         if (objectOnlyTarget.flags & 1048576) {
49307                             var result_9 = typeRelatedToDiscriminatedType(source, objectOnlyTarget);
49308                             if (result_9) {
49309                                 return result_9;
49310                             }
49311                         }
49312                     }
49313                 }
49314                 return 0;
49315                 function relateVariances(sourceTypeArguments, targetTypeArguments, variances, intersectionState) {
49316                     if (result = typeArgumentsRelatedTo(sourceTypeArguments, targetTypeArguments, variances, reportErrors, intersectionState)) {
49317                         return result;
49318                     }
49319                     if (ts.some(variances, function (v) { return !!(v & 24); })) {
49320                         originalErrorInfo = undefined;
49321                         resetErrorInfo(saveErrorInfo);
49322                         return undefined;
49323                     }
49324                     var allowStructuralFallback = targetTypeArguments && hasCovariantVoidArgument(targetTypeArguments, variances);
49325                     varianceCheckFailed = !allowStructuralFallback;
49326                     if (variances !== ts.emptyArray && !allowStructuralFallback) {
49327                         if (varianceCheckFailed && !(reportErrors && ts.some(variances, function (v) { return (v & 7) === 0; }))) {
49328                             return 0;
49329                         }
49330                         originalErrorInfo = errorInfo;
49331                         resetErrorInfo(saveErrorInfo);
49332                     }
49333                 }
49334             }
49335             function reportUnmeasurableMarkers(p) {
49336                 if (outofbandVarianceMarkerHandler && (p === markerSuperType || p === markerSubType || p === markerOtherType)) {
49337                     outofbandVarianceMarkerHandler(false);
49338                 }
49339                 return p;
49340             }
49341             function reportUnreliableMarkers(p) {
49342                 if (outofbandVarianceMarkerHandler && (p === markerSuperType || p === markerSubType || p === markerOtherType)) {
49343                     outofbandVarianceMarkerHandler(true);
49344                 }
49345                 return p;
49346             }
49347             function mappedTypeRelatedTo(source, target, reportErrors) {
49348                 var modifiersRelated = relation === comparableRelation || (relation === identityRelation ? getMappedTypeModifiers(source) === getMappedTypeModifiers(target) :
49349                     getCombinedMappedTypeOptionality(source) <= getCombinedMappedTypeOptionality(target));
49350                 if (modifiersRelated) {
49351                     var result_10;
49352                     var targetConstraint = getConstraintTypeFromMappedType(target);
49353                     var sourceConstraint = instantiateType(getConstraintTypeFromMappedType(source), makeFunctionTypeMapper(getCombinedMappedTypeOptionality(source) < 0 ? reportUnmeasurableMarkers : reportUnreliableMarkers));
49354                     if (result_10 = isRelatedTo(targetConstraint, sourceConstraint, reportErrors)) {
49355                         var mapper = createTypeMapper([getTypeParameterFromMappedType(source)], [getTypeParameterFromMappedType(target)]);
49356                         if (instantiateType(getNameTypeFromMappedType(source), mapper) === instantiateType(getNameTypeFromMappedType(target), mapper)) {
49357                             return result_10 & isRelatedTo(instantiateType(getTemplateTypeFromMappedType(source), mapper), getTemplateTypeFromMappedType(target), reportErrors);
49358                         }
49359                     }
49360                 }
49361                 return 0;
49362             }
49363             function typeRelatedToDiscriminatedType(source, target) {
49364                 var sourceProperties = getPropertiesOfType(source);
49365                 var sourcePropertiesFiltered = findDiscriminantProperties(sourceProperties, target);
49366                 if (!sourcePropertiesFiltered)
49367                     return 0;
49368                 var numCombinations = 1;
49369                 for (var _i = 0, sourcePropertiesFiltered_1 = sourcePropertiesFiltered; _i < sourcePropertiesFiltered_1.length; _i++) {
49370                     var sourceProperty = sourcePropertiesFiltered_1[_i];
49371                     numCombinations *= countTypes(getTypeOfSymbol(sourceProperty));
49372                     if (numCombinations > 25) {
49373                         ts.tracing.instant("check", "typeRelatedToDiscriminatedType_DepthLimit", { sourceId: source.id, targetId: target.id, numCombinations: numCombinations });
49374                         return 0;
49375                     }
49376                 }
49377                 var sourceDiscriminantTypes = new Array(sourcePropertiesFiltered.length);
49378                 var excludedProperties = new ts.Set();
49379                 for (var i = 0; i < sourcePropertiesFiltered.length; i++) {
49380                     var sourceProperty = sourcePropertiesFiltered[i];
49381                     var sourcePropertyType = getTypeOfSymbol(sourceProperty);
49382                     sourceDiscriminantTypes[i] = sourcePropertyType.flags & 1048576
49383                         ? sourcePropertyType.types
49384                         : [sourcePropertyType];
49385                     excludedProperties.add(sourceProperty.escapedName);
49386                 }
49387                 var discriminantCombinations = ts.cartesianProduct(sourceDiscriminantTypes);
49388                 var matchingTypes = [];
49389                 var _loop_17 = function (combination) {
49390                     var hasMatch = false;
49391                     outer: for (var _i = 0, _a = target.types; _i < _a.length; _i++) {
49392                         var type = _a[_i];
49393                         var _loop_18 = function (i) {
49394                             var sourceProperty = sourcePropertiesFiltered[i];
49395                             var targetProperty = getPropertyOfType(type, sourceProperty.escapedName);
49396                             if (!targetProperty)
49397                                 return "continue-outer";
49398                             if (sourceProperty === targetProperty)
49399                                 return "continue";
49400                             var related = propertyRelatedTo(source, target, sourceProperty, targetProperty, function (_) { return combination[i]; }, false, 0, strictNullChecks || relation === comparableRelation);
49401                             if (!related) {
49402                                 return "continue-outer";
49403                             }
49404                         };
49405                         for (var i = 0; i < sourcePropertiesFiltered.length; i++) {
49406                             var state_7 = _loop_18(i);
49407                             switch (state_7) {
49408                                 case "continue-outer": continue outer;
49409                             }
49410                         }
49411                         ts.pushIfUnique(matchingTypes, type, ts.equateValues);
49412                         hasMatch = true;
49413                     }
49414                     if (!hasMatch) {
49415                         return { value: 0 };
49416                     }
49417                 };
49418                 for (var _a = 0, discriminantCombinations_1 = discriminantCombinations; _a < discriminantCombinations_1.length; _a++) {
49419                     var combination = discriminantCombinations_1[_a];
49420                     var state_6 = _loop_17(combination);
49421                     if (typeof state_6 === "object")
49422                         return state_6.value;
49423                 }
49424                 var result = -1;
49425                 for (var _b = 0, matchingTypes_1 = matchingTypes; _b < matchingTypes_1.length; _b++) {
49426                     var type = matchingTypes_1[_b];
49427                     result &= propertiesRelatedTo(source, type, false, excludedProperties, 0);
49428                     if (result) {
49429                         result &= signaturesRelatedTo(source, type, 0, false);
49430                         if (result) {
49431                             result &= signaturesRelatedTo(source, type, 1, false);
49432                             if (result) {
49433                                 result &= indexTypesRelatedTo(source, type, 0, false, false, 0);
49434                                 if (result && !(isTupleType(source) && isTupleType(type))) {
49435                                     result &= indexTypesRelatedTo(source, type, 1, false, false, 0);
49436                                 }
49437                             }
49438                         }
49439                     }
49440                     if (!result) {
49441                         return result;
49442                     }
49443                 }
49444                 return result;
49445             }
49446             function excludeProperties(properties, excludedProperties) {
49447                 if (!excludedProperties || properties.length === 0)
49448                     return properties;
49449                 var result;
49450                 for (var i = 0; i < properties.length; i++) {
49451                     if (!excludedProperties.has(properties[i].escapedName)) {
49452                         if (result) {
49453                             result.push(properties[i]);
49454                         }
49455                     }
49456                     else if (!result) {
49457                         result = properties.slice(0, i);
49458                     }
49459                 }
49460                 return result || properties;
49461             }
49462             function isPropertySymbolTypeRelated(sourceProp, targetProp, getTypeOfSourceProperty, reportErrors, intersectionState) {
49463                 var targetIsOptional = strictNullChecks && !!(ts.getCheckFlags(targetProp) & 48);
49464                 var source = getTypeOfSourceProperty(sourceProp);
49465                 if (ts.getCheckFlags(targetProp) & 65536 && !getSymbolLinks(targetProp).type) {
49466                     var links = getSymbolLinks(targetProp);
49467                     ts.Debug.assertIsDefined(links.deferralParent);
49468                     ts.Debug.assertIsDefined(links.deferralConstituents);
49469                     var unionParent = !!(links.deferralParent.flags & 1048576);
49470                     var result_11 = unionParent ? 0 : -1;
49471                     var targetTypes = links.deferralConstituents;
49472                     for (var _i = 0, targetTypes_3 = targetTypes; _i < targetTypes_3.length; _i++) {
49473                         var targetType = targetTypes_3[_i];
49474                         var related = isRelatedTo(source, targetType, false, undefined, unionParent ? 0 : 2);
49475                         if (!unionParent) {
49476                             if (!related) {
49477                                 return isRelatedTo(source, addOptionality(getTypeOfSymbol(targetProp), targetIsOptional), reportErrors);
49478                             }
49479                             result_11 &= related;
49480                         }
49481                         else {
49482                             if (related) {
49483                                 return related;
49484                             }
49485                         }
49486                     }
49487                     if (unionParent && !result_11 && targetIsOptional) {
49488                         result_11 = isRelatedTo(source, undefinedType);
49489                     }
49490                     if (unionParent && !result_11 && reportErrors) {
49491                         return isRelatedTo(source, addOptionality(getTypeOfSymbol(targetProp), targetIsOptional), reportErrors);
49492                     }
49493                     return result_11;
49494                 }
49495                 else {
49496                     return isRelatedTo(source, addOptionality(getTypeOfSymbol(targetProp), targetIsOptional), reportErrors, undefined, intersectionState);
49497                 }
49498             }
49499             function propertyRelatedTo(source, target, sourceProp, targetProp, getTypeOfSourceProperty, reportErrors, intersectionState, skipOptional) {
49500                 var sourcePropFlags = ts.getDeclarationModifierFlagsFromSymbol(sourceProp);
49501                 var targetPropFlags = ts.getDeclarationModifierFlagsFromSymbol(targetProp);
49502                 if (sourcePropFlags & 8 || targetPropFlags & 8) {
49503                     if (sourceProp.valueDeclaration !== targetProp.valueDeclaration) {
49504                         if (reportErrors) {
49505                             if (sourcePropFlags & 8 && targetPropFlags & 8) {
49506                                 reportError(ts.Diagnostics.Types_have_separate_declarations_of_a_private_property_0, symbolToString(targetProp));
49507                             }
49508                             else {
49509                                 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));
49510                             }
49511                         }
49512                         return 0;
49513                     }
49514                 }
49515                 else if (targetPropFlags & 16) {
49516                     if (!isValidOverrideOf(sourceProp, targetProp)) {
49517                         if (reportErrors) {
49518                             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));
49519                         }
49520                         return 0;
49521                     }
49522                 }
49523                 else if (sourcePropFlags & 16) {
49524                     if (reportErrors) {
49525                         reportError(ts.Diagnostics.Property_0_is_protected_in_type_1_but_public_in_type_2, symbolToString(targetProp), typeToString(source), typeToString(target));
49526                     }
49527                     return 0;
49528                 }
49529                 var related = isPropertySymbolTypeRelated(sourceProp, targetProp, getTypeOfSourceProperty, reportErrors, intersectionState);
49530                 if (!related) {
49531                     if (reportErrors) {
49532                         reportIncompatibleError(ts.Diagnostics.Types_of_property_0_are_incompatible, symbolToString(targetProp));
49533                     }
49534                     return 0;
49535                 }
49536                 if (!skipOptional && sourceProp.flags & 16777216 && !(targetProp.flags & 16777216)) {
49537                     if (reportErrors) {
49538                         reportError(ts.Diagnostics.Property_0_is_optional_in_type_1_but_required_in_type_2, symbolToString(targetProp), typeToString(source), typeToString(target));
49539                     }
49540                     return 0;
49541                 }
49542                 return related;
49543             }
49544             function reportUnmatchedProperty(source, target, unmatchedProperty, requireOptionalProperties) {
49545                 var shouldSkipElaboration = false;
49546                 if (unmatchedProperty.valueDeclaration
49547                     && ts.isNamedDeclaration(unmatchedProperty.valueDeclaration)
49548                     && ts.isPrivateIdentifier(unmatchedProperty.valueDeclaration.name)
49549                     && source.symbol
49550                     && source.symbol.flags & 32) {
49551                     var privateIdentifierDescription = unmatchedProperty.valueDeclaration.name.escapedText;
49552                     var symbolTableKey = ts.getSymbolNameForPrivateIdentifier(source.symbol, privateIdentifierDescription);
49553                     if (symbolTableKey && getPropertyOfType(source, symbolTableKey)) {
49554                         var sourceName = ts.factory.getDeclarationName(source.symbol.valueDeclaration);
49555                         var targetName = ts.factory.getDeclarationName(target.symbol.valueDeclaration);
49556                         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));
49557                         return;
49558                     }
49559                 }
49560                 var props = ts.arrayFrom(getUnmatchedProperties(source, target, requireOptionalProperties, false));
49561                 if (!headMessage || (headMessage.code !== ts.Diagnostics.Class_0_incorrectly_implements_interface_1.code &&
49562                     headMessage.code !== ts.Diagnostics.Class_0_incorrectly_implements_class_1_Did_you_mean_to_extend_1_and_inherit_its_members_as_a_subclass.code)) {
49563                     shouldSkipElaboration = true;
49564                 }
49565                 if (props.length === 1) {
49566                     var propName = symbolToString(unmatchedProperty);
49567                     reportError.apply(void 0, __spreadArrays([ts.Diagnostics.Property_0_is_missing_in_type_1_but_required_in_type_2, propName], getTypeNamesForErrorDisplay(source, target)));
49568                     if (ts.length(unmatchedProperty.declarations)) {
49569                         associateRelatedInfo(ts.createDiagnosticForNode(unmatchedProperty.declarations[0], ts.Diagnostics._0_is_declared_here, propName));
49570                     }
49571                     if (shouldSkipElaboration && errorInfo) {
49572                         overrideNextErrorInfo++;
49573                     }
49574                 }
49575                 else if (tryElaborateArrayLikeErrors(source, target, false)) {
49576                     if (props.length > 5) {
49577                         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);
49578                     }
49579                     else {
49580                         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(", "));
49581                     }
49582                     if (shouldSkipElaboration && errorInfo) {
49583                         overrideNextErrorInfo++;
49584                     }
49585                 }
49586             }
49587             function propertiesRelatedTo(source, target, reportErrors, excludedProperties, intersectionState) {
49588                 if (relation === identityRelation) {
49589                     return propertiesIdenticalTo(source, target, excludedProperties);
49590                 }
49591                 var result = -1;
49592                 if (isTupleType(target)) {
49593                     if (isArrayType(source) || isTupleType(source)) {
49594                         if (!target.target.readonly && (isReadonlyArrayType(source) || isTupleType(source) && source.target.readonly)) {
49595                             return 0;
49596                         }
49597                         var sourceArity = getTypeReferenceArity(source);
49598                         var targetArity = getTypeReferenceArity(target);
49599                         var sourceRestFlag = isTupleType(source) ? source.target.combinedFlags & 4 : 4;
49600                         var targetRestFlag = target.target.combinedFlags & 4;
49601                         var sourceMinLength = isTupleType(source) ? source.target.minLength : 0;
49602                         var targetMinLength = target.target.minLength;
49603                         if (!sourceRestFlag && sourceArity < targetMinLength) {
49604                             if (reportErrors) {
49605                                 reportError(ts.Diagnostics.Source_has_0_element_s_but_target_requires_1, sourceArity, targetMinLength);
49606                             }
49607                             return 0;
49608                         }
49609                         if (!targetRestFlag && targetArity < sourceMinLength) {
49610                             if (reportErrors) {
49611                                 reportError(ts.Diagnostics.Source_has_0_element_s_but_target_allows_only_1, sourceMinLength, targetArity);
49612                             }
49613                             return 0;
49614                         }
49615                         if (!targetRestFlag && sourceRestFlag) {
49616                             if (reportErrors) {
49617                                 if (sourceMinLength < targetMinLength) {
49618                                     reportError(ts.Diagnostics.Target_requires_0_element_s_but_source_may_have_fewer, targetMinLength);
49619                                 }
49620                                 else {
49621                                     reportError(ts.Diagnostics.Target_allows_only_0_element_s_but_source_may_have_more, targetArity);
49622                                 }
49623                             }
49624                             return 0;
49625                         }
49626                         var maxArity = Math.max(sourceArity, targetArity);
49627                         for (var i = 0; i < maxArity; i++) {
49628                             var targetFlags = i < targetArity ? target.target.elementFlags[i] : targetRestFlag;
49629                             var sourceFlags = isTupleType(source) && i < sourceArity ? source.target.elementFlags[i] : sourceRestFlag;
49630                             var canExcludeDiscriminants = !!excludedProperties;
49631                             if (sourceFlags && targetFlags) {
49632                                 if (targetFlags & 8 && !(sourceFlags & 8) ||
49633                                     (sourceFlags & 8 && !(targetFlags & 12))) {
49634                                     if (reportErrors) {
49635                                         reportError(ts.Diagnostics.Element_at_index_0_is_variadic_in_one_type_but_not_in_the_other, i);
49636                                     }
49637                                     return 0;
49638                                 }
49639                                 if (targetFlags & 1) {
49640                                     if (!(sourceFlags & 1)) {
49641                                         if (reportErrors) {
49642                                             reportError(ts.Diagnostics.Property_0_is_optional_in_type_1_but_required_in_type_2, i, typeToString(source), typeToString(target));
49643                                         }
49644                                         return 0;
49645                                     }
49646                                 }
49647                                 if (canExcludeDiscriminants) {
49648                                     if (sourceFlags & 12 || targetFlags & 12) {
49649                                         canExcludeDiscriminants = false;
49650                                     }
49651                                     if (canExcludeDiscriminants && (excludedProperties === null || excludedProperties === void 0 ? void 0 : excludedProperties.has(("" + i)))) {
49652                                         continue;
49653                                     }
49654                                 }
49655                                 var sourceType = getTypeArguments(source)[Math.min(i, sourceArity - 1)];
49656                                 var targetType = getTypeArguments(target)[Math.min(i, targetArity - 1)];
49657                                 var targetCheckType = sourceFlags & 8 && targetFlags & 4 ? createArrayType(targetType) : targetType;
49658                                 var related = isRelatedTo(sourceType, targetCheckType, reportErrors, undefined, intersectionState);
49659                                 if (!related) {
49660                                     if (reportErrors) {
49661                                         reportIncompatibleError(ts.Diagnostics.Types_of_property_0_are_incompatible, i);
49662                                     }
49663                                     return 0;
49664                                 }
49665                                 result &= related;
49666                             }
49667                         }
49668                         return result;
49669                     }
49670                     if (target.target.combinedFlags & 12) {
49671                         return 0;
49672                     }
49673                 }
49674                 var requireOptionalProperties = (relation === subtypeRelation || relation === strictSubtypeRelation) && !isObjectLiteralType(source) && !isEmptyArrayLiteralType(source) && !isTupleType(source);
49675                 var unmatchedProperty = getUnmatchedProperty(source, target, requireOptionalProperties, false);
49676                 if (unmatchedProperty) {
49677                     if (reportErrors) {
49678                         reportUnmatchedProperty(source, target, unmatchedProperty, requireOptionalProperties);
49679                     }
49680                     return 0;
49681                 }
49682                 if (isObjectLiteralType(target)) {
49683                     for (var _i = 0, _a = excludeProperties(getPropertiesOfType(source), excludedProperties); _i < _a.length; _i++) {
49684                         var sourceProp = _a[_i];
49685                         if (!getPropertyOfObjectType(target, sourceProp.escapedName)) {
49686                             var sourceType = getTypeOfSymbol(sourceProp);
49687                             if (!(sourceType === undefinedType || sourceType === undefinedWideningType || sourceType === optionalType)) {
49688                                 if (reportErrors) {
49689                                     reportError(ts.Diagnostics.Property_0_does_not_exist_on_type_1, symbolToString(sourceProp), typeToString(target));
49690                                 }
49691                                 return 0;
49692                             }
49693                         }
49694                     }
49695                 }
49696                 var properties = getPropertiesOfType(target);
49697                 var numericNamesOnly = isTupleType(source) && isTupleType(target);
49698                 for (var _b = 0, _c = excludeProperties(properties, excludedProperties); _b < _c.length; _b++) {
49699                     var targetProp = _c[_b];
49700                     var name = targetProp.escapedName;
49701                     if (!(targetProp.flags & 4194304) && (!numericNamesOnly || isNumericLiteralName(name) || name === "length")) {
49702                         var sourceProp = getPropertyOfType(source, name);
49703                         if (sourceProp && sourceProp !== targetProp) {
49704                             var related = propertyRelatedTo(source, target, sourceProp, targetProp, getTypeOfSymbol, reportErrors, intersectionState, relation === comparableRelation);
49705                             if (!related) {
49706                                 return 0;
49707                             }
49708                             result &= related;
49709                         }
49710                     }
49711                 }
49712                 return result;
49713             }
49714             function propertiesIdenticalTo(source, target, excludedProperties) {
49715                 if (!(source.flags & 524288 && target.flags & 524288)) {
49716                     return 0;
49717                 }
49718                 var sourceProperties = excludeProperties(getPropertiesOfObjectType(source), excludedProperties);
49719                 var targetProperties = excludeProperties(getPropertiesOfObjectType(target), excludedProperties);
49720                 if (sourceProperties.length !== targetProperties.length) {
49721                     return 0;
49722                 }
49723                 var result = -1;
49724                 for (var _i = 0, sourceProperties_1 = sourceProperties; _i < sourceProperties_1.length; _i++) {
49725                     var sourceProp = sourceProperties_1[_i];
49726                     var targetProp = getPropertyOfObjectType(target, sourceProp.escapedName);
49727                     if (!targetProp) {
49728                         return 0;
49729                     }
49730                     var related = compareProperties(sourceProp, targetProp, isRelatedTo);
49731                     if (!related) {
49732                         return 0;
49733                     }
49734                     result &= related;
49735                 }
49736                 return result;
49737             }
49738             function signaturesRelatedTo(source, target, kind, reportErrors) {
49739                 var _a, _b;
49740                 if (relation === identityRelation) {
49741                     return signaturesIdenticalTo(source, target, kind);
49742                 }
49743                 if (target === anyFunctionType || source === anyFunctionType) {
49744                     return -1;
49745                 }
49746                 var sourceIsJSConstructor = source.symbol && isJSConstructor(source.symbol.valueDeclaration);
49747                 var targetIsJSConstructor = target.symbol && isJSConstructor(target.symbol.valueDeclaration);
49748                 var sourceSignatures = getSignaturesOfType(source, (sourceIsJSConstructor && kind === 1) ?
49749                     0 : kind);
49750                 var targetSignatures = getSignaturesOfType(target, (targetIsJSConstructor && kind === 1) ?
49751                     0 : kind);
49752                 if (kind === 1 && sourceSignatures.length && targetSignatures.length) {
49753                     if (ts.isAbstractConstructorType(source) && !ts.isAbstractConstructorType(target)) {
49754                         if (reportErrors) {
49755                             reportError(ts.Diagnostics.Cannot_assign_an_abstract_constructor_type_to_a_non_abstract_constructor_type);
49756                         }
49757                         return 0;
49758                     }
49759                     if (!constructorVisibilitiesAreCompatible(sourceSignatures[0], targetSignatures[0], reportErrors)) {
49760                         return 0;
49761                     }
49762                 }
49763                 var result = -1;
49764                 var saveErrorInfo = captureErrorCalculationState();
49765                 var incompatibleReporter = kind === 1 ? reportIncompatibleConstructSignatureReturn : reportIncompatibleCallSignatureReturn;
49766                 var sourceObjectFlags = ts.getObjectFlags(source);
49767                 var targetObjectFlags = ts.getObjectFlags(target);
49768                 if (sourceObjectFlags & 64 && targetObjectFlags & 64 && source.symbol === target.symbol) {
49769                     for (var i = 0; i < targetSignatures.length; i++) {
49770                         var related = signatureRelatedTo(sourceSignatures[i], targetSignatures[i], true, reportErrors, incompatibleReporter(sourceSignatures[i], targetSignatures[i]));
49771                         if (!related) {
49772                             return 0;
49773                         }
49774                         result &= related;
49775                     }
49776                 }
49777                 else if (sourceSignatures.length === 1 && targetSignatures.length === 1) {
49778                     var eraseGenerics = relation === comparableRelation || !!compilerOptions.noStrictGenericChecks;
49779                     var sourceSignature = ts.first(sourceSignatures);
49780                     var targetSignature = ts.first(targetSignatures);
49781                     result = signatureRelatedTo(sourceSignature, targetSignature, eraseGenerics, reportErrors, incompatibleReporter(sourceSignature, targetSignature));
49782                     if (!result && reportErrors && kind === 1 && (sourceObjectFlags & targetObjectFlags) &&
49783                         (((_a = targetSignature.declaration) === null || _a === void 0 ? void 0 : _a.kind) === 166 || ((_b = sourceSignature.declaration) === null || _b === void 0 ? void 0 : _b.kind) === 166)) {
49784                         var constructSignatureToString = function (signature) {
49785                             return signatureToString(signature, undefined, 262144, kind);
49786                         };
49787                         reportError(ts.Diagnostics.Type_0_is_not_assignable_to_type_1, constructSignatureToString(sourceSignature), constructSignatureToString(targetSignature));
49788                         reportError(ts.Diagnostics.Types_of_construct_signatures_are_incompatible);
49789                         return result;
49790                     }
49791                 }
49792                 else {
49793                     outer: for (var _i = 0, targetSignatures_1 = targetSignatures; _i < targetSignatures_1.length; _i++) {
49794                         var t = targetSignatures_1[_i];
49795                         var shouldElaborateErrors = reportErrors;
49796                         for (var _c = 0, sourceSignatures_1 = sourceSignatures; _c < sourceSignatures_1.length; _c++) {
49797                             var s = sourceSignatures_1[_c];
49798                             var related = signatureRelatedTo(s, t, true, shouldElaborateErrors, incompatibleReporter(s, t));
49799                             if (related) {
49800                                 result &= related;
49801                                 resetErrorInfo(saveErrorInfo);
49802                                 continue outer;
49803                             }
49804                             shouldElaborateErrors = false;
49805                         }
49806                         if (shouldElaborateErrors) {
49807                             reportError(ts.Diagnostics.Type_0_provides_no_match_for_the_signature_1, typeToString(source), signatureToString(t, undefined, undefined, kind));
49808                         }
49809                         return 0;
49810                     }
49811                 }
49812                 return result;
49813             }
49814             function reportIncompatibleCallSignatureReturn(siga, sigb) {
49815                 if (siga.parameters.length === 0 && sigb.parameters.length === 0) {
49816                     return function (source, target) { return reportIncompatibleError(ts.Diagnostics.Call_signatures_with_no_arguments_have_incompatible_return_types_0_and_1, typeToString(source), typeToString(target)); };
49817                 }
49818                 return function (source, target) { return reportIncompatibleError(ts.Diagnostics.Call_signature_return_types_0_and_1_are_incompatible, typeToString(source), typeToString(target)); };
49819             }
49820             function reportIncompatibleConstructSignatureReturn(siga, sigb) {
49821                 if (siga.parameters.length === 0 && sigb.parameters.length === 0) {
49822                     return function (source, target) { return reportIncompatibleError(ts.Diagnostics.Construct_signatures_with_no_arguments_have_incompatible_return_types_0_and_1, typeToString(source), typeToString(target)); };
49823                 }
49824                 return function (source, target) { return reportIncompatibleError(ts.Diagnostics.Construct_signature_return_types_0_and_1_are_incompatible, typeToString(source), typeToString(target)); };
49825             }
49826             function signatureRelatedTo(source, target, erase, reportErrors, incompatibleReporter) {
49827                 return compareSignaturesRelated(erase ? getErasedSignature(source) : source, erase ? getErasedSignature(target) : target, relation === strictSubtypeRelation ? 8 : 0, reportErrors, reportError, incompatibleReporter, isRelatedTo, makeFunctionTypeMapper(reportUnreliableMarkers));
49828             }
49829             function signaturesIdenticalTo(source, target, kind) {
49830                 var sourceSignatures = getSignaturesOfType(source, kind);
49831                 var targetSignatures = getSignaturesOfType(target, kind);
49832                 if (sourceSignatures.length !== targetSignatures.length) {
49833                     return 0;
49834                 }
49835                 var result = -1;
49836                 for (var i = 0; i < sourceSignatures.length; i++) {
49837                     var related = compareSignaturesIdentical(sourceSignatures[i], targetSignatures[i], false, false, false, isRelatedTo);
49838                     if (!related) {
49839                         return 0;
49840                     }
49841                     result &= related;
49842                 }
49843                 return result;
49844             }
49845             function eachPropertyRelatedTo(source, target, kind, reportErrors) {
49846                 var result = -1;
49847                 var props = source.flags & 2097152 ? getPropertiesOfUnionOrIntersectionType(source) : getPropertiesOfObjectType(source);
49848                 for (var _i = 0, props_2 = props; _i < props_2.length; _i++) {
49849                     var prop = props_2[_i];
49850                     if (isIgnoredJsxProperty(source, prop)) {
49851                         continue;
49852                     }
49853                     var nameType = getSymbolLinks(prop).nameType;
49854                     if (nameType && nameType.flags & 8192) {
49855                         continue;
49856                     }
49857                     if (kind === 0 || isNumericLiteralName(prop.escapedName)) {
49858                         var related = isRelatedTo(getTypeOfSymbol(prop), target, reportErrors);
49859                         if (!related) {
49860                             if (reportErrors) {
49861                                 reportError(ts.Diagnostics.Property_0_is_incompatible_with_index_signature, symbolToString(prop));
49862                             }
49863                             return 0;
49864                         }
49865                         result &= related;
49866                     }
49867                 }
49868                 return result;
49869             }
49870             function indexTypeRelatedTo(sourceType, targetType, reportErrors) {
49871                 var related = isRelatedTo(sourceType, targetType, reportErrors);
49872                 if (!related && reportErrors) {
49873                     reportError(ts.Diagnostics.Index_signatures_are_incompatible);
49874                 }
49875                 return related;
49876             }
49877             function indexTypesRelatedTo(source, target, kind, sourceIsPrimitive, reportErrors, intersectionState) {
49878                 if (relation === identityRelation) {
49879                     return indexTypesIdenticalTo(source, target, kind);
49880                 }
49881                 var targetType = getIndexTypeOfType(target, kind);
49882                 if (!targetType || targetType.flags & 1 && !sourceIsPrimitive) {
49883                     return -1;
49884                 }
49885                 if (isGenericMappedType(source)) {
49886                     return getIndexTypeOfType(target, 0) ? isRelatedTo(getTemplateTypeFromMappedType(source), targetType, reportErrors) : 0;
49887                 }
49888                 var indexType = getIndexTypeOfType(source, kind) || kind === 1 && getIndexTypeOfType(source, 0);
49889                 if (indexType) {
49890                     return indexTypeRelatedTo(indexType, targetType, reportErrors);
49891                 }
49892                 if (!(intersectionState & 1) && isObjectTypeWithInferableIndex(source)) {
49893                     var related = eachPropertyRelatedTo(source, targetType, kind, reportErrors);
49894                     if (related && kind === 0) {
49895                         var numberIndexType = getIndexTypeOfType(source, 1);
49896                         if (numberIndexType) {
49897                             related &= indexTypeRelatedTo(numberIndexType, targetType, reportErrors);
49898                         }
49899                     }
49900                     return related;
49901                 }
49902                 if (reportErrors) {
49903                     reportError(ts.Diagnostics.Index_signature_is_missing_in_type_0, typeToString(source));
49904                 }
49905                 return 0;
49906             }
49907             function indexTypesIdenticalTo(source, target, indexKind) {
49908                 var targetInfo = getIndexInfoOfType(target, indexKind);
49909                 var sourceInfo = getIndexInfoOfType(source, indexKind);
49910                 if (!sourceInfo && !targetInfo) {
49911                     return -1;
49912                 }
49913                 if (sourceInfo && targetInfo && sourceInfo.isReadonly === targetInfo.isReadonly) {
49914                     return isRelatedTo(sourceInfo.type, targetInfo.type);
49915                 }
49916                 return 0;
49917             }
49918             function constructorVisibilitiesAreCompatible(sourceSignature, targetSignature, reportErrors) {
49919                 if (!sourceSignature.declaration || !targetSignature.declaration) {
49920                     return true;
49921                 }
49922                 var sourceAccessibility = ts.getSelectedEffectiveModifierFlags(sourceSignature.declaration, 24);
49923                 var targetAccessibility = ts.getSelectedEffectiveModifierFlags(targetSignature.declaration, 24);
49924                 if (targetAccessibility === 8) {
49925                     return true;
49926                 }
49927                 if (targetAccessibility === 16 && sourceAccessibility !== 8) {
49928                     return true;
49929                 }
49930                 if (targetAccessibility !== 16 && !sourceAccessibility) {
49931                     return true;
49932                 }
49933                 if (reportErrors) {
49934                     reportError(ts.Diagnostics.Cannot_assign_a_0_constructor_type_to_a_1_constructor_type, visibilityToString(sourceAccessibility), visibilityToString(targetAccessibility));
49935                 }
49936                 return false;
49937             }
49938         }
49939         function typeCouldHaveTopLevelSingletonTypes(type) {
49940             if (type.flags & 16) {
49941                 return false;
49942             }
49943             if (type.flags & 3145728) {
49944                 return !!ts.forEach(type.types, typeCouldHaveTopLevelSingletonTypes);
49945             }
49946             if (type.flags & 465829888) {
49947                 var constraint = getConstraintOfType(type);
49948                 if (constraint && constraint !== type) {
49949                     return typeCouldHaveTopLevelSingletonTypes(constraint);
49950                 }
49951             }
49952             return isUnitType(type) || !!(type.flags & 134217728);
49953         }
49954         function getBestMatchingType(source, target, isRelatedTo) {
49955             if (isRelatedTo === void 0) { isRelatedTo = compareTypesAssignable; }
49956             return findMatchingDiscriminantType(source, target, isRelatedTo, true) ||
49957                 findMatchingTypeReferenceOrTypeAliasReference(source, target) ||
49958                 findBestTypeForObjectLiteral(source, target) ||
49959                 findBestTypeForInvokable(source, target) ||
49960                 findMostOverlappyType(source, target);
49961         }
49962         function discriminateTypeByDiscriminableItems(target, discriminators, related, defaultValue, skipPartial) {
49963             var discriminable = target.types.map(function (_) { return undefined; });
49964             for (var _i = 0, discriminators_1 = discriminators; _i < discriminators_1.length; _i++) {
49965                 var _a = discriminators_1[_i], getDiscriminatingType = _a[0], propertyName = _a[1];
49966                 var targetProp = getUnionOrIntersectionProperty(target, propertyName);
49967                 if (skipPartial && targetProp && ts.getCheckFlags(targetProp) & 16) {
49968                     continue;
49969                 }
49970                 var i = 0;
49971                 for (var _b = 0, _c = target.types; _b < _c.length; _b++) {
49972                     var type = _c[_b];
49973                     var targetType = getTypeOfPropertyOfType(type, propertyName);
49974                     if (targetType && related(getDiscriminatingType(), targetType)) {
49975                         discriminable[i] = discriminable[i] === undefined ? true : discriminable[i];
49976                     }
49977                     else {
49978                         discriminable[i] = false;
49979                     }
49980                     i++;
49981                 }
49982             }
49983             var match = discriminable.indexOf(true);
49984             if (match === -1) {
49985                 return defaultValue;
49986             }
49987             var nextMatch = discriminable.indexOf(true, match + 1);
49988             while (nextMatch !== -1) {
49989                 if (!isTypeIdenticalTo(target.types[match], target.types[nextMatch])) {
49990                     return defaultValue;
49991                 }
49992                 nextMatch = discriminable.indexOf(true, nextMatch + 1);
49993             }
49994             return target.types[match];
49995         }
49996         function isWeakType(type) {
49997             if (type.flags & 524288) {
49998                 var resolved = resolveStructuredTypeMembers(type);
49999                 return resolved.callSignatures.length === 0 && resolved.constructSignatures.length === 0 &&
50000                     !resolved.stringIndexInfo && !resolved.numberIndexInfo &&
50001                     resolved.properties.length > 0 &&
50002                     ts.every(resolved.properties, function (p) { return !!(p.flags & 16777216); });
50003             }
50004             if (type.flags & 2097152) {
50005                 return ts.every(type.types, isWeakType);
50006             }
50007             return false;
50008         }
50009         function hasCommonProperties(source, target, isComparingJsxAttributes) {
50010             for (var _i = 0, _a = getPropertiesOfType(source); _i < _a.length; _i++) {
50011                 var prop = _a[_i];
50012                 if (isKnownProperty(target, prop.escapedName, isComparingJsxAttributes)) {
50013                     return true;
50014                 }
50015             }
50016             return false;
50017         }
50018         function getMarkerTypeReference(type, source, target) {
50019             var result = createTypeReference(type, ts.map(type.typeParameters, function (t) { return t === source ? target : t; }));
50020             result.objectFlags |= 8192;
50021             return result;
50022         }
50023         function getAliasVariances(symbol) {
50024             var links = getSymbolLinks(symbol);
50025             return getVariancesWorker(links.typeParameters, links, function (_links, param, marker) {
50026                 var type = getTypeAliasInstantiation(symbol, instantiateTypes(links.typeParameters, makeUnaryTypeMapper(param, marker)));
50027                 type.aliasTypeArgumentsContainsMarker = true;
50028                 return type;
50029             });
50030         }
50031         function getVariancesWorker(typeParameters, cache, createMarkerType) {
50032             var _a, _b, _c;
50033             if (typeParameters === void 0) { typeParameters = ts.emptyArray; }
50034             var variances = cache.variances;
50035             if (!variances) {
50036                 ts.tracing.push("check", "getVariancesWorker", { arity: typeParameters.length, id: (_c = (_a = cache.id) !== null && _a !== void 0 ? _a : (_b = cache.declaredType) === null || _b === void 0 ? void 0 : _b.id) !== null && _c !== void 0 ? _c : -1 });
50037                 cache.variances = ts.emptyArray;
50038                 variances = [];
50039                 var _loop_19 = function (tp) {
50040                     var unmeasurable = false;
50041                     var unreliable = false;
50042                     var oldHandler = outofbandVarianceMarkerHandler;
50043                     outofbandVarianceMarkerHandler = function (onlyUnreliable) { return onlyUnreliable ? unreliable = true : unmeasurable = true; };
50044                     var typeWithSuper = createMarkerType(cache, tp, markerSuperType);
50045                     var typeWithSub = createMarkerType(cache, tp, markerSubType);
50046                     var variance = (isTypeAssignableTo(typeWithSub, typeWithSuper) ? 1 : 0) |
50047                         (isTypeAssignableTo(typeWithSuper, typeWithSub) ? 2 : 0);
50048                     if (variance === 3 && isTypeAssignableTo(createMarkerType(cache, tp, markerOtherType), typeWithSuper)) {
50049                         variance = 4;
50050                     }
50051                     outofbandVarianceMarkerHandler = oldHandler;
50052                     if (unmeasurable || unreliable) {
50053                         if (unmeasurable) {
50054                             variance |= 8;
50055                         }
50056                         if (unreliable) {
50057                             variance |= 16;
50058                         }
50059                     }
50060                     variances.push(variance);
50061                 };
50062                 for (var _i = 0, typeParameters_1 = typeParameters; _i < typeParameters_1.length; _i++) {
50063                     var tp = typeParameters_1[_i];
50064                     _loop_19(tp);
50065                 }
50066                 cache.variances = variances;
50067                 ts.tracing.pop();
50068             }
50069             return variances;
50070         }
50071         function getVariances(type) {
50072             if (type === globalArrayType || type === globalReadonlyArrayType || type.objectFlags & 8) {
50073                 return arrayVariances;
50074             }
50075             return getVariancesWorker(type.typeParameters, type, getMarkerTypeReference);
50076         }
50077         function hasCovariantVoidArgument(typeArguments, variances) {
50078             for (var i = 0; i < variances.length; i++) {
50079                 if ((variances[i] & 7) === 1 && typeArguments[i].flags & 16384) {
50080                     return true;
50081                 }
50082             }
50083             return false;
50084         }
50085         function isUnconstrainedTypeParameter(type) {
50086             return type.flags & 262144 && !getConstraintOfTypeParameter(type);
50087         }
50088         function isNonDeferredTypeReference(type) {
50089             return !!(ts.getObjectFlags(type) & 4) && !type.node;
50090         }
50091         function isTypeReferenceWithGenericArguments(type) {
50092             return isNonDeferredTypeReference(type) && ts.some(getTypeArguments(type), function (t) { return isUnconstrainedTypeParameter(t) || isTypeReferenceWithGenericArguments(t); });
50093         }
50094         function getTypeReferenceId(type, typeParameters, depth) {
50095             if (depth === void 0) { depth = 0; }
50096             var result = "" + type.target.id;
50097             for (var _i = 0, _a = getTypeArguments(type); _i < _a.length; _i++) {
50098                 var t = _a[_i];
50099                 if (isUnconstrainedTypeParameter(t)) {
50100                     var index = typeParameters.indexOf(t);
50101                     if (index < 0) {
50102                         index = typeParameters.length;
50103                         typeParameters.push(t);
50104                     }
50105                     result += "=" + index;
50106                 }
50107                 else if (depth < 4 && isTypeReferenceWithGenericArguments(t)) {
50108                     result += "<" + getTypeReferenceId(t, typeParameters, depth + 1) + ">";
50109                 }
50110                 else {
50111                     result += "-" + t.id;
50112                 }
50113             }
50114             return result;
50115         }
50116         function getRelationKey(source, target, intersectionState, relation) {
50117             if (relation === identityRelation && source.id > target.id) {
50118                 var temp = source;
50119                 source = target;
50120                 target = temp;
50121             }
50122             var postFix = intersectionState ? ":" + intersectionState : "";
50123             if (isTypeReferenceWithGenericArguments(source) && isTypeReferenceWithGenericArguments(target)) {
50124                 var typeParameters = [];
50125                 return getTypeReferenceId(source, typeParameters) + "," + getTypeReferenceId(target, typeParameters) + postFix;
50126             }
50127             return source.id + "," + target.id + postFix;
50128         }
50129         function forEachProperty(prop, callback) {
50130             if (ts.getCheckFlags(prop) & 6) {
50131                 for (var _i = 0, _a = prop.containingType.types; _i < _a.length; _i++) {
50132                     var t = _a[_i];
50133                     var p = getPropertyOfType(t, prop.escapedName);
50134                     var result = p && forEachProperty(p, callback);
50135                     if (result) {
50136                         return result;
50137                     }
50138                 }
50139                 return undefined;
50140             }
50141             return callback(prop);
50142         }
50143         function getDeclaringClass(prop) {
50144             return prop.parent && prop.parent.flags & 32 ? getDeclaredTypeOfSymbol(getParentOfSymbol(prop)) : undefined;
50145         }
50146         function getTypeOfPropertyInBaseClass(property) {
50147             var classType = getDeclaringClass(property);
50148             var baseClassType = classType && getBaseTypes(classType)[0];
50149             return baseClassType && getTypeOfPropertyOfType(baseClassType, property.escapedName);
50150         }
50151         function isPropertyInClassDerivedFrom(prop, baseClass) {
50152             return forEachProperty(prop, function (sp) {
50153                 var sourceClass = getDeclaringClass(sp);
50154                 return sourceClass ? hasBaseType(sourceClass, baseClass) : false;
50155             });
50156         }
50157         function isValidOverrideOf(sourceProp, targetProp) {
50158             return !forEachProperty(targetProp, function (tp) { return ts.getDeclarationModifierFlagsFromSymbol(tp) & 16 ?
50159                 !isPropertyInClassDerivedFrom(sourceProp, getDeclaringClass(tp)) : false; });
50160         }
50161         function isClassDerivedFromDeclaringClasses(checkClass, prop) {
50162             return forEachProperty(prop, function (p) { return ts.getDeclarationModifierFlagsFromSymbol(p) & 16 ?
50163                 !hasBaseType(checkClass, getDeclaringClass(p)) : false; }) ? undefined : checkClass;
50164         }
50165         function isDeeplyNestedType(type, stack, depth) {
50166             if (depth >= 5) {
50167                 var identity_1 = getRecursionIdentity(type);
50168                 if (identity_1) {
50169                     var count = 0;
50170                     for (var i = 0; i < depth; i++) {
50171                         if (getRecursionIdentity(stack[i]) === identity_1) {
50172                             count++;
50173                             if (count >= 5) {
50174                                 return true;
50175                             }
50176                         }
50177                     }
50178                 }
50179             }
50180             return false;
50181         }
50182         function getRecursionIdentity(type) {
50183             if (type.flags & 524288 && !isObjectOrArrayLiteralType(type)) {
50184                 if (ts.getObjectFlags(type) && 4 && type.node) {
50185                     return type.node;
50186                 }
50187                 if (type.symbol && !(ts.getObjectFlags(type) & 16 && type.symbol.flags & 32)) {
50188                     return type.symbol;
50189                 }
50190                 if (isTupleType(type)) {
50191                     return type.target;
50192                 }
50193             }
50194             if (type.flags & 8388608) {
50195                 do {
50196                     type = type.objectType;
50197                 } while (type.flags & 8388608);
50198                 return type;
50199             }
50200             if (type.flags & 16777216) {
50201                 return type.root;
50202             }
50203             return undefined;
50204         }
50205         function isPropertyIdenticalTo(sourceProp, targetProp) {
50206             return compareProperties(sourceProp, targetProp, compareTypesIdentical) !== 0;
50207         }
50208         function compareProperties(sourceProp, targetProp, compareTypes) {
50209             if (sourceProp === targetProp) {
50210                 return -1;
50211             }
50212             var sourcePropAccessibility = ts.getDeclarationModifierFlagsFromSymbol(sourceProp) & 24;
50213             var targetPropAccessibility = ts.getDeclarationModifierFlagsFromSymbol(targetProp) & 24;
50214             if (sourcePropAccessibility !== targetPropAccessibility) {
50215                 return 0;
50216             }
50217             if (sourcePropAccessibility) {
50218                 if (getTargetSymbol(sourceProp) !== getTargetSymbol(targetProp)) {
50219                     return 0;
50220                 }
50221             }
50222             else {
50223                 if ((sourceProp.flags & 16777216) !== (targetProp.flags & 16777216)) {
50224                     return 0;
50225                 }
50226             }
50227             if (isReadonlySymbol(sourceProp) !== isReadonlySymbol(targetProp)) {
50228                 return 0;
50229             }
50230             return compareTypes(getTypeOfSymbol(sourceProp), getTypeOfSymbol(targetProp));
50231         }
50232         function isMatchingSignature(source, target, partialMatch) {
50233             var sourceParameterCount = getParameterCount(source);
50234             var targetParameterCount = getParameterCount(target);
50235             var sourceMinArgumentCount = getMinArgumentCount(source);
50236             var targetMinArgumentCount = getMinArgumentCount(target);
50237             var sourceHasRestParameter = hasEffectiveRestParameter(source);
50238             var targetHasRestParameter = hasEffectiveRestParameter(target);
50239             if (sourceParameterCount === targetParameterCount &&
50240                 sourceMinArgumentCount === targetMinArgumentCount &&
50241                 sourceHasRestParameter === targetHasRestParameter) {
50242                 return true;
50243             }
50244             if (partialMatch && sourceMinArgumentCount <= targetMinArgumentCount) {
50245                 return true;
50246             }
50247             return false;
50248         }
50249         function compareSignaturesIdentical(source, target, partialMatch, ignoreThisTypes, ignoreReturnTypes, compareTypes) {
50250             if (source === target) {
50251                 return -1;
50252             }
50253             if (!(isMatchingSignature(source, target, partialMatch))) {
50254                 return 0;
50255             }
50256             if (ts.length(source.typeParameters) !== ts.length(target.typeParameters)) {
50257                 return 0;
50258             }
50259             if (target.typeParameters) {
50260                 var mapper = createTypeMapper(source.typeParameters, target.typeParameters);
50261                 for (var i = 0; i < target.typeParameters.length; i++) {
50262                     var s = source.typeParameters[i];
50263                     var t = target.typeParameters[i];
50264                     if (!(s === t || compareTypes(instantiateType(getConstraintFromTypeParameter(s), mapper) || unknownType, getConstraintFromTypeParameter(t) || unknownType) &&
50265                         compareTypes(instantiateType(getDefaultFromTypeParameter(s), mapper) || unknownType, getDefaultFromTypeParameter(t) || unknownType))) {
50266                         return 0;
50267                     }
50268                 }
50269                 source = instantiateSignature(source, mapper, true);
50270             }
50271             var result = -1;
50272             if (!ignoreThisTypes) {
50273                 var sourceThisType = getThisTypeOfSignature(source);
50274                 if (sourceThisType) {
50275                     var targetThisType = getThisTypeOfSignature(target);
50276                     if (targetThisType) {
50277                         var related = compareTypes(sourceThisType, targetThisType);
50278                         if (!related) {
50279                             return 0;
50280                         }
50281                         result &= related;
50282                     }
50283                 }
50284             }
50285             var targetLen = getParameterCount(target);
50286             for (var i = 0; i < targetLen; i++) {
50287                 var s = getTypeAtPosition(source, i);
50288                 var t = getTypeAtPosition(target, i);
50289                 var related = compareTypes(t, s);
50290                 if (!related) {
50291                     return 0;
50292                 }
50293                 result &= related;
50294             }
50295             if (!ignoreReturnTypes) {
50296                 var sourceTypePredicate = getTypePredicateOfSignature(source);
50297                 var targetTypePredicate = getTypePredicateOfSignature(target);
50298                 result &= sourceTypePredicate || targetTypePredicate ?
50299                     compareTypePredicatesIdentical(sourceTypePredicate, targetTypePredicate, compareTypes) :
50300                     compareTypes(getReturnTypeOfSignature(source), getReturnTypeOfSignature(target));
50301             }
50302             return result;
50303         }
50304         function compareTypePredicatesIdentical(source, target, compareTypes) {
50305             return !(source && target && typePredicateKindsMatch(source, target)) ? 0 :
50306                 source.type === target.type ? -1 :
50307                     source.type && target.type ? compareTypes(source.type, target.type) :
50308                         0;
50309         }
50310         function literalTypesWithSameBaseType(types) {
50311             var commonBaseType;
50312             for (var _i = 0, types_13 = types; _i < types_13.length; _i++) {
50313                 var t = types_13[_i];
50314                 var baseType = getBaseTypeOfLiteralType(t);
50315                 if (!commonBaseType) {
50316                     commonBaseType = baseType;
50317                 }
50318                 if (baseType === t || baseType !== commonBaseType) {
50319                     return false;
50320                 }
50321             }
50322             return true;
50323         }
50324         function getSupertypeOrUnion(types) {
50325             return literalTypesWithSameBaseType(types) ?
50326                 getUnionType(types) :
50327                 ts.reduceLeft(types, function (s, t) { return isTypeSubtypeOf(s, t) ? t : s; });
50328         }
50329         function getCommonSupertype(types) {
50330             if (!strictNullChecks) {
50331                 return getSupertypeOrUnion(types);
50332             }
50333             var primaryTypes = ts.filter(types, function (t) { return !(t.flags & 98304); });
50334             return primaryTypes.length ?
50335                 getNullableType(getSupertypeOrUnion(primaryTypes), getFalsyFlagsOfTypes(types) & 98304) :
50336                 getUnionType(types, 2);
50337         }
50338         function getCommonSubtype(types) {
50339             return ts.reduceLeft(types, function (s, t) { return isTypeSubtypeOf(t, s) ? t : s; });
50340         }
50341         function isArrayType(type) {
50342             return !!(ts.getObjectFlags(type) & 4) && (type.target === globalArrayType || type.target === globalReadonlyArrayType);
50343         }
50344         function isReadonlyArrayType(type) {
50345             return !!(ts.getObjectFlags(type) & 4) && type.target === globalReadonlyArrayType;
50346         }
50347         function isMutableArrayOrTuple(type) {
50348             return isArrayType(type) && !isReadonlyArrayType(type) || isTupleType(type) && !type.target.readonly;
50349         }
50350         function getElementTypeOfArrayType(type) {
50351             return isArrayType(type) ? getTypeArguments(type)[0] : undefined;
50352         }
50353         function isArrayLikeType(type) {
50354             return isArrayType(type) || !(type.flags & 98304) && isTypeAssignableTo(type, anyReadonlyArrayType);
50355         }
50356         function isEmptyArrayLiteralType(type) {
50357             var elementType = isArrayType(type) ? getTypeArguments(type)[0] : undefined;
50358             return elementType === undefinedWideningType || elementType === implicitNeverType;
50359         }
50360         function isTupleLikeType(type) {
50361             return isTupleType(type) || !!getPropertyOfType(type, "0");
50362         }
50363         function isArrayOrTupleLikeType(type) {
50364             return isArrayLikeType(type) || isTupleLikeType(type);
50365         }
50366         function getTupleElementType(type, index) {
50367             var propType = getTypeOfPropertyOfType(type, "" + index);
50368             if (propType) {
50369                 return propType;
50370             }
50371             if (everyType(type, isTupleType)) {
50372                 return mapType(type, function (t) { return getRestTypeOfTupleType(t) || undefinedType; });
50373             }
50374             return undefined;
50375         }
50376         function isNeitherUnitTypeNorNever(type) {
50377             return !(type.flags & (109440 | 131072));
50378         }
50379         function isUnitType(type) {
50380             return !!(type.flags & 109440);
50381         }
50382         function isLiteralType(type) {
50383             return type.flags & 16 ? true :
50384                 type.flags & 1048576 ? type.flags & 1024 ? true : ts.every(type.types, isUnitType) :
50385                     isUnitType(type);
50386         }
50387         function getBaseTypeOfLiteralType(type) {
50388             return type.flags & 1024 ? getBaseTypeOfEnumLiteralType(type) :
50389                 type.flags & 128 ? stringType :
50390                     type.flags & 256 ? numberType :
50391                         type.flags & 2048 ? bigintType :
50392                             type.flags & 512 ? booleanType :
50393                                 type.flags & 1048576 ? getUnionType(ts.sameMap(type.types, getBaseTypeOfLiteralType)) :
50394                                     type;
50395         }
50396         function getWidenedLiteralType(type) {
50397             return type.flags & 1024 && isFreshLiteralType(type) ? getBaseTypeOfEnumLiteralType(type) :
50398                 type.flags & 128 && isFreshLiteralType(type) ? stringType :
50399                     type.flags & 256 && isFreshLiteralType(type) ? numberType :
50400                         type.flags & 2048 && isFreshLiteralType(type) ? bigintType :
50401                             type.flags & 512 && isFreshLiteralType(type) ? booleanType :
50402                                 type.flags & 1048576 ? getUnionType(ts.sameMap(type.types, getWidenedLiteralType)) :
50403                                     type;
50404         }
50405         function getWidenedUniqueESSymbolType(type) {
50406             return type.flags & 8192 ? esSymbolType :
50407                 type.flags & 1048576 ? getUnionType(ts.sameMap(type.types, getWidenedUniqueESSymbolType)) :
50408                     type;
50409         }
50410         function getWidenedLiteralLikeTypeForContextualType(type, contextualType) {
50411             if (!isLiteralOfContextualType(type, contextualType)) {
50412                 type = getWidenedUniqueESSymbolType(getWidenedLiteralType(type));
50413             }
50414             return type;
50415         }
50416         function getWidenedLiteralLikeTypeForContextualReturnTypeIfNeeded(type, contextualSignatureReturnType, isAsync) {
50417             if (type && isUnitType(type)) {
50418                 var contextualType = !contextualSignatureReturnType ? undefined :
50419                     isAsync ? getPromisedTypeOfPromise(contextualSignatureReturnType) :
50420                         contextualSignatureReturnType;
50421                 type = getWidenedLiteralLikeTypeForContextualType(type, contextualType);
50422             }
50423             return type;
50424         }
50425         function getWidenedLiteralLikeTypeForContextualIterationTypeIfNeeded(type, contextualSignatureReturnType, kind, isAsyncGenerator) {
50426             if (type && isUnitType(type)) {
50427                 var contextualType = !contextualSignatureReturnType ? undefined :
50428                     getIterationTypeOfGeneratorFunctionReturnType(kind, contextualSignatureReturnType, isAsyncGenerator);
50429                 type = getWidenedLiteralLikeTypeForContextualType(type, contextualType);
50430             }
50431             return type;
50432         }
50433         function isTupleType(type) {
50434             return !!(ts.getObjectFlags(type) & 4 && type.target.objectFlags & 8);
50435         }
50436         function isGenericTupleType(type) {
50437             return isTupleType(type) && !!(type.target.combinedFlags & 8);
50438         }
50439         function isSingleElementGenericTupleType(type) {
50440             return isGenericTupleType(type) && type.target.elementFlags.length === 1;
50441         }
50442         function getRestTypeOfTupleType(type) {
50443             return getElementTypeOfSliceOfTupleType(type, type.target.fixedLength);
50444         }
50445         function getRestArrayTypeOfTupleType(type) {
50446             var restType = getRestTypeOfTupleType(type);
50447             return restType && createArrayType(restType);
50448         }
50449         function getEndLengthOfType(type) {
50450             return isTupleType(type) ? getTypeReferenceArity(type) - ts.findLastIndex(type.target.elementFlags, function (f) { return !(f & (1 | 2)); }) - 1 : 0;
50451         }
50452         function getElementTypeOfSliceOfTupleType(type, index, endSkipCount, writing) {
50453             if (endSkipCount === void 0) { endSkipCount = 0; }
50454             if (writing === void 0) { writing = false; }
50455             var length = getTypeReferenceArity(type) - endSkipCount;
50456             if (index < length) {
50457                 var typeArguments = getTypeArguments(type);
50458                 var elementTypes = [];
50459                 for (var i = index; i < length; i++) {
50460                     var t = typeArguments[i];
50461                     elementTypes.push(type.target.elementFlags[i] & 8 ? getIndexedAccessType(t, numberType) : t);
50462                 }
50463                 return writing ? getIntersectionType(elementTypes) : getUnionType(elementTypes);
50464             }
50465             return undefined;
50466         }
50467         function isTupleTypeStructureMatching(t1, t2) {
50468             return getTypeReferenceArity(t1) === getTypeReferenceArity(t2) &&
50469                 ts.every(t1.target.elementFlags, function (f, i) { return (f & 12) === (t2.target.elementFlags[i] & 12); });
50470         }
50471         function isZeroBigInt(_a) {
50472             var value = _a.value;
50473             return value.base10Value === "0";
50474         }
50475         function getFalsyFlagsOfTypes(types) {
50476             var result = 0;
50477             for (var _i = 0, types_14 = types; _i < types_14.length; _i++) {
50478                 var t = types_14[_i];
50479                 result |= getFalsyFlags(t);
50480             }
50481             return result;
50482         }
50483         function getFalsyFlags(type) {
50484             return type.flags & 1048576 ? getFalsyFlagsOfTypes(type.types) :
50485                 type.flags & 128 ? type.value === "" ? 128 : 0 :
50486                     type.flags & 256 ? type.value === 0 ? 256 : 0 :
50487                         type.flags & 2048 ? isZeroBigInt(type) ? 2048 : 0 :
50488                             type.flags & 512 ? (type === falseType || type === regularFalseType) ? 512 : 0 :
50489                                 type.flags & 117724;
50490         }
50491         function removeDefinitelyFalsyTypes(type) {
50492             return getFalsyFlags(type) & 117632 ?
50493                 filterType(type, function (t) { return !(getFalsyFlags(t) & 117632); }) :
50494                 type;
50495         }
50496         function extractDefinitelyFalsyTypes(type) {
50497             return mapType(type, getDefinitelyFalsyPartOfType);
50498         }
50499         function getDefinitelyFalsyPartOfType(type) {
50500             return type.flags & 4 ? emptyStringType :
50501                 type.flags & 8 ? zeroType :
50502                     type.flags & 64 ? zeroBigIntType :
50503                         type === regularFalseType ||
50504                             type === falseType ||
50505                             type.flags & (16384 | 32768 | 65536 | 3) ||
50506                             type.flags & 128 && type.value === "" ||
50507                             type.flags & 256 && type.value === 0 ||
50508                             type.flags & 2048 && isZeroBigInt(type) ? type :
50509                             neverType;
50510         }
50511         function getNullableType(type, flags) {
50512             var missing = (flags & ~type.flags) & (32768 | 65536);
50513             return missing === 0 ? type :
50514                 missing === 32768 ? getUnionType([type, undefinedType]) :
50515                     missing === 65536 ? getUnionType([type, nullType]) :
50516                         getUnionType([type, undefinedType, nullType]);
50517         }
50518         function getOptionalType(type) {
50519             ts.Debug.assert(strictNullChecks);
50520             return type.flags & 32768 ? type : getUnionType([type, undefinedType]);
50521         }
50522         function getGlobalNonNullableTypeInstantiation(type) {
50523             if (!deferredGlobalNonNullableTypeAlias) {
50524                 deferredGlobalNonNullableTypeAlias = getGlobalSymbol("NonNullable", 524288, undefined) || unknownSymbol;
50525             }
50526             if (deferredGlobalNonNullableTypeAlias !== unknownSymbol) {
50527                 return getTypeAliasInstantiation(deferredGlobalNonNullableTypeAlias, [type]);
50528             }
50529             return getTypeWithFacts(type, 2097152);
50530         }
50531         function getNonNullableType(type) {
50532             return strictNullChecks ? getGlobalNonNullableTypeInstantiation(type) : type;
50533         }
50534         function addOptionalTypeMarker(type) {
50535             return strictNullChecks ? getUnionType([type, optionalType]) : type;
50536         }
50537         function isNotOptionalTypeMarker(type) {
50538             return type !== optionalType;
50539         }
50540         function removeOptionalTypeMarker(type) {
50541             return strictNullChecks ? filterType(type, isNotOptionalTypeMarker) : type;
50542         }
50543         function propagateOptionalTypeMarker(type, node, wasOptional) {
50544             return wasOptional ? ts.isOutermostOptionalChain(node) ? getOptionalType(type) : addOptionalTypeMarker(type) : type;
50545         }
50546         function getOptionalExpressionType(exprType, expression) {
50547             return ts.isExpressionOfOptionalChainRoot(expression) ? getNonNullableType(exprType) :
50548                 ts.isOptionalChain(expression) ? removeOptionalTypeMarker(exprType) :
50549                     exprType;
50550         }
50551         function isCoercibleUnderDoubleEquals(source, target) {
50552             return ((source.flags & (8 | 4 | 512)) !== 0)
50553                 && ((target.flags & (8 | 4 | 16)) !== 0);
50554         }
50555         function isObjectTypeWithInferableIndex(type) {
50556             return type.flags & 2097152 ? ts.every(type.types, isObjectTypeWithInferableIndex) :
50557                 !!(type.symbol && (type.symbol.flags & (4096 | 2048 | 384 | 512)) !== 0 &&
50558                     !typeHasCallOrConstructSignatures(type)) || !!(ts.getObjectFlags(type) & 2048 && isObjectTypeWithInferableIndex(type.source));
50559         }
50560         function createSymbolWithType(source, type) {
50561             var symbol = createSymbol(source.flags, source.escapedName, ts.getCheckFlags(source) & 8);
50562             symbol.declarations = source.declarations;
50563             symbol.parent = source.parent;
50564             symbol.type = type;
50565             symbol.target = source;
50566             if (source.valueDeclaration) {
50567                 symbol.valueDeclaration = source.valueDeclaration;
50568             }
50569             var nameType = getSymbolLinks(source).nameType;
50570             if (nameType) {
50571                 symbol.nameType = nameType;
50572             }
50573             return symbol;
50574         }
50575         function transformTypeOfMembers(type, f) {
50576             var members = ts.createSymbolTable();
50577             for (var _i = 0, _a = getPropertiesOfObjectType(type); _i < _a.length; _i++) {
50578                 var property = _a[_i];
50579                 var original = getTypeOfSymbol(property);
50580                 var updated = f(original);
50581                 members.set(property.escapedName, updated === original ? property : createSymbolWithType(property, updated));
50582             }
50583             return members;
50584         }
50585         function getRegularTypeOfObjectLiteral(type) {
50586             if (!(isObjectLiteralType(type) && ts.getObjectFlags(type) & 32768)) {
50587                 return type;
50588             }
50589             var regularType = type.regularType;
50590             if (regularType) {
50591                 return regularType;
50592             }
50593             var resolved = type;
50594             var members = transformTypeOfMembers(type, getRegularTypeOfObjectLiteral);
50595             var regularNew = createAnonymousType(resolved.symbol, members, resolved.callSignatures, resolved.constructSignatures, resolved.stringIndexInfo, resolved.numberIndexInfo);
50596             regularNew.flags = resolved.flags;
50597             regularNew.objectFlags |= resolved.objectFlags & ~32768;
50598             type.regularType = regularNew;
50599             return regularNew;
50600         }
50601         function createWideningContext(parent, propertyName, siblings) {
50602             return { parent: parent, propertyName: propertyName, siblings: siblings, resolvedProperties: undefined };
50603         }
50604         function getSiblingsOfContext(context) {
50605             if (!context.siblings) {
50606                 var siblings_1 = [];
50607                 for (var _i = 0, _a = getSiblingsOfContext(context.parent); _i < _a.length; _i++) {
50608                     var type = _a[_i];
50609                     if (isObjectLiteralType(type)) {
50610                         var prop = getPropertyOfObjectType(type, context.propertyName);
50611                         if (prop) {
50612                             forEachType(getTypeOfSymbol(prop), function (t) {
50613                                 siblings_1.push(t);
50614                             });
50615                         }
50616                     }
50617                 }
50618                 context.siblings = siblings_1;
50619             }
50620             return context.siblings;
50621         }
50622         function getPropertiesOfContext(context) {
50623             if (!context.resolvedProperties) {
50624                 var names = new ts.Map();
50625                 for (var _i = 0, _a = getSiblingsOfContext(context); _i < _a.length; _i++) {
50626                     var t = _a[_i];
50627                     if (isObjectLiteralType(t) && !(ts.getObjectFlags(t) & 1024)) {
50628                         for (var _b = 0, _c = getPropertiesOfType(t); _b < _c.length; _b++) {
50629                             var prop = _c[_b];
50630                             names.set(prop.escapedName, prop);
50631                         }
50632                     }
50633                 }
50634                 context.resolvedProperties = ts.arrayFrom(names.values());
50635             }
50636             return context.resolvedProperties;
50637         }
50638         function getWidenedProperty(prop, context) {
50639             if (!(prop.flags & 4)) {
50640                 return prop;
50641             }
50642             var original = getTypeOfSymbol(prop);
50643             var propContext = context && createWideningContext(context, prop.escapedName, undefined);
50644             var widened = getWidenedTypeWithContext(original, propContext);
50645             return widened === original ? prop : createSymbolWithType(prop, widened);
50646         }
50647         function getUndefinedProperty(prop) {
50648             var cached = undefinedProperties.get(prop.escapedName);
50649             if (cached) {
50650                 return cached;
50651             }
50652             var result = createSymbolWithType(prop, undefinedType);
50653             result.flags |= 16777216;
50654             undefinedProperties.set(prop.escapedName, result);
50655             return result;
50656         }
50657         function getWidenedTypeOfObjectLiteral(type, context) {
50658             var members = ts.createSymbolTable();
50659             for (var _i = 0, _a = getPropertiesOfObjectType(type); _i < _a.length; _i++) {
50660                 var prop = _a[_i];
50661                 members.set(prop.escapedName, getWidenedProperty(prop, context));
50662             }
50663             if (context) {
50664                 for (var _b = 0, _c = getPropertiesOfContext(context); _b < _c.length; _b++) {
50665                     var prop = _c[_b];
50666                     if (!members.has(prop.escapedName)) {
50667                         members.set(prop.escapedName, getUndefinedProperty(prop));
50668                     }
50669                 }
50670             }
50671             var stringIndexInfo = getIndexInfoOfType(type, 0);
50672             var numberIndexInfo = getIndexInfoOfType(type, 1);
50673             var result = createAnonymousType(type.symbol, members, ts.emptyArray, ts.emptyArray, stringIndexInfo && createIndexInfo(getWidenedType(stringIndexInfo.type), stringIndexInfo.isReadonly), numberIndexInfo && createIndexInfo(getWidenedType(numberIndexInfo.type), numberIndexInfo.isReadonly));
50674             result.objectFlags |= (ts.getObjectFlags(type) & (16384 | 2097152));
50675             return result;
50676         }
50677         function getWidenedType(type) {
50678             return getWidenedTypeWithContext(type, undefined);
50679         }
50680         function getWidenedTypeWithContext(type, context) {
50681             if (ts.getObjectFlags(type) & 1572864) {
50682                 if (context === undefined && type.widened) {
50683                     return type.widened;
50684                 }
50685                 var result = void 0;
50686                 if (type.flags & (1 | 98304)) {
50687                     result = anyType;
50688                 }
50689                 else if (isObjectLiteralType(type)) {
50690                     result = getWidenedTypeOfObjectLiteral(type, context);
50691                 }
50692                 else if (type.flags & 1048576) {
50693                     var unionContext_1 = context || createWideningContext(undefined, undefined, type.types);
50694                     var widenedTypes = ts.sameMap(type.types, function (t) { return t.flags & 98304 ? t : getWidenedTypeWithContext(t, unionContext_1); });
50695                     result = getUnionType(widenedTypes, ts.some(widenedTypes, isEmptyObjectType) ? 2 : 1);
50696                 }
50697                 else if (type.flags & 2097152) {
50698                     result = getIntersectionType(ts.sameMap(type.types, getWidenedType));
50699                 }
50700                 else if (isArrayType(type) || isTupleType(type)) {
50701                     result = createTypeReference(type.target, ts.sameMap(getTypeArguments(type), getWidenedType));
50702                 }
50703                 if (result && context === undefined) {
50704                     type.widened = result;
50705                 }
50706                 return result || type;
50707             }
50708             return type;
50709         }
50710         function reportWideningErrorsInType(type) {
50711             var errorReported = false;
50712             if (ts.getObjectFlags(type) & 524288) {
50713                 if (type.flags & 1048576) {
50714                     if (ts.some(type.types, isEmptyObjectType)) {
50715                         errorReported = true;
50716                     }
50717                     else {
50718                         for (var _i = 0, _a = type.types; _i < _a.length; _i++) {
50719                             var t = _a[_i];
50720                             if (reportWideningErrorsInType(t)) {
50721                                 errorReported = true;
50722                             }
50723                         }
50724                     }
50725                 }
50726                 if (isArrayType(type) || isTupleType(type)) {
50727                     for (var _b = 0, _c = getTypeArguments(type); _b < _c.length; _b++) {
50728                         var t = _c[_b];
50729                         if (reportWideningErrorsInType(t)) {
50730                             errorReported = true;
50731                         }
50732                     }
50733                 }
50734                 if (isObjectLiteralType(type)) {
50735                     for (var _d = 0, _e = getPropertiesOfObjectType(type); _d < _e.length; _d++) {
50736                         var p = _e[_d];
50737                         var t = getTypeOfSymbol(p);
50738                         if (ts.getObjectFlags(t) & 524288) {
50739                             if (!reportWideningErrorsInType(t)) {
50740                                 error(p.valueDeclaration, ts.Diagnostics.Object_literal_s_property_0_implicitly_has_an_1_type, symbolToString(p), typeToString(getWidenedType(t)));
50741                             }
50742                             errorReported = true;
50743                         }
50744                     }
50745                 }
50746             }
50747             return errorReported;
50748         }
50749         function reportImplicitAny(declaration, type, wideningKind) {
50750             var typeAsString = typeToString(getWidenedType(type));
50751             if (ts.isInJSFile(declaration) && !ts.isCheckJsEnabledForFile(ts.getSourceFileOfNode(declaration), compilerOptions)) {
50752                 return;
50753             }
50754             var diagnostic;
50755             switch (declaration.kind) {
50756                 case 216:
50757                 case 163:
50758                 case 162:
50759                     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;
50760                     break;
50761                 case 160:
50762                     var param = declaration;
50763                     if (ts.isIdentifier(param.name) &&
50764                         (ts.isCallSignatureDeclaration(param.parent) || ts.isMethodSignature(param.parent) || ts.isFunctionTypeNode(param.parent)) &&
50765                         param.parent.parameters.indexOf(param) > -1 &&
50766                         (resolveName(param, param.name.escapedText, 788968, undefined, param.name.escapedText, true) ||
50767                             param.name.originalKeywordKind && ts.isTypeNodeKind(param.name.originalKeywordKind))) {
50768                         var newName = "arg" + param.parent.parameters.indexOf(param);
50769                         errorOrSuggestion(noImplicitAny, declaration, ts.Diagnostics.Parameter_has_a_name_but_no_type_Did_you_mean_0_Colon_1, newName, ts.declarationNameToString(param.name));
50770                         return;
50771                     }
50772                     diagnostic = declaration.dotDotDotToken ?
50773                         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 :
50774                         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;
50775                     break;
50776                 case 198:
50777                     diagnostic = ts.Diagnostics.Binding_element_0_implicitly_has_an_1_type;
50778                     if (!noImplicitAny) {
50779                         return;
50780                     }
50781                     break;
50782                 case 308:
50783                     error(declaration, ts.Diagnostics.Function_type_which_lacks_return_type_annotation_implicitly_has_an_0_return_type, typeAsString);
50784                     return;
50785                 case 251:
50786                 case 165:
50787                 case 164:
50788                 case 167:
50789                 case 168:
50790                 case 208:
50791                 case 209:
50792                     if (noImplicitAny && !declaration.name) {
50793                         if (wideningKind === 3) {
50794                             error(declaration, ts.Diagnostics.Generator_implicitly_has_yield_type_0_because_it_does_not_yield_any_values_Consider_supplying_a_return_type_annotation, typeAsString);
50795                         }
50796                         else {
50797                             error(declaration, ts.Diagnostics.Function_expression_which_lacks_return_type_annotation_implicitly_has_an_0_return_type, typeAsString);
50798                         }
50799                         return;
50800                     }
50801                     diagnostic = !noImplicitAny ? ts.Diagnostics._0_implicitly_has_an_1_return_type_but_a_better_type_may_be_inferred_from_usage :
50802                         wideningKind === 3 ? ts.Diagnostics._0_which_lacks_return_type_annotation_implicitly_has_an_1_yield_type :
50803                             ts.Diagnostics._0_which_lacks_return_type_annotation_implicitly_has_an_1_return_type;
50804                     break;
50805                 case 190:
50806                     if (noImplicitAny) {
50807                         error(declaration, ts.Diagnostics.Mapped_object_type_implicitly_has_an_any_template_type);
50808                     }
50809                     return;
50810                 default:
50811                     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;
50812             }
50813             errorOrSuggestion(noImplicitAny, declaration, diagnostic, ts.declarationNameToString(ts.getNameOfDeclaration(declaration)), typeAsString);
50814         }
50815         function reportErrorsFromWidening(declaration, type, wideningKind) {
50816             if (produceDiagnostics && noImplicitAny && ts.getObjectFlags(type) & 524288 && (!wideningKind || !getContextualSignatureForFunctionLikeDeclaration(declaration))) {
50817                 if (!reportWideningErrorsInType(type)) {
50818                     reportImplicitAny(declaration, type, wideningKind);
50819                 }
50820             }
50821         }
50822         function applyToParameterTypes(source, target, callback) {
50823             var sourceCount = getParameterCount(source);
50824             var targetCount = getParameterCount(target);
50825             var sourceRestType = getEffectiveRestType(source);
50826             var targetRestType = getEffectiveRestType(target);
50827             var targetNonRestCount = targetRestType ? targetCount - 1 : targetCount;
50828             var paramCount = sourceRestType ? targetNonRestCount : Math.min(sourceCount, targetNonRestCount);
50829             var sourceThisType = getThisTypeOfSignature(source);
50830             if (sourceThisType) {
50831                 var targetThisType = getThisTypeOfSignature(target);
50832                 if (targetThisType) {
50833                     callback(sourceThisType, targetThisType);
50834                 }
50835             }
50836             for (var i = 0; i < paramCount; i++) {
50837                 callback(getTypeAtPosition(source, i), getTypeAtPosition(target, i));
50838             }
50839             if (targetRestType) {
50840                 callback(getRestTypeAtPosition(source, paramCount), targetRestType);
50841             }
50842         }
50843         function applyToReturnTypes(source, target, callback) {
50844             var sourceTypePredicate = getTypePredicateOfSignature(source);
50845             var targetTypePredicate = getTypePredicateOfSignature(target);
50846             if (sourceTypePredicate && targetTypePredicate && typePredicateKindsMatch(sourceTypePredicate, targetTypePredicate) && sourceTypePredicate.type && targetTypePredicate.type) {
50847                 callback(sourceTypePredicate.type, targetTypePredicate.type);
50848             }
50849             else {
50850                 callback(getReturnTypeOfSignature(source), getReturnTypeOfSignature(target));
50851             }
50852         }
50853         function createInferenceContext(typeParameters, signature, flags, compareTypes) {
50854             return createInferenceContextWorker(typeParameters.map(createInferenceInfo), signature, flags, compareTypes || compareTypesAssignable);
50855         }
50856         function cloneInferenceContext(context, extraFlags) {
50857             if (extraFlags === void 0) { extraFlags = 0; }
50858             return context && createInferenceContextWorker(ts.map(context.inferences, cloneInferenceInfo), context.signature, context.flags | extraFlags, context.compareTypes);
50859         }
50860         function createInferenceContextWorker(inferences, signature, flags, compareTypes) {
50861             var context = {
50862                 inferences: inferences,
50863                 signature: signature,
50864                 flags: flags,
50865                 compareTypes: compareTypes,
50866                 mapper: makeFunctionTypeMapper(function (t) { return mapToInferredType(context, t, true); }),
50867                 nonFixingMapper: makeFunctionTypeMapper(function (t) { return mapToInferredType(context, t, false); }),
50868             };
50869             return context;
50870         }
50871         function mapToInferredType(context, t, fix) {
50872             var inferences = context.inferences;
50873             for (var i = 0; i < inferences.length; i++) {
50874                 var inference = inferences[i];
50875                 if (t === inference.typeParameter) {
50876                     if (fix && !inference.isFixed) {
50877                         clearCachedInferences(inferences);
50878                         inference.isFixed = true;
50879                     }
50880                     return getInferredType(context, i);
50881                 }
50882             }
50883             return t;
50884         }
50885         function clearCachedInferences(inferences) {
50886             for (var _i = 0, inferences_1 = inferences; _i < inferences_1.length; _i++) {
50887                 var inference = inferences_1[_i];
50888                 if (!inference.isFixed) {
50889                     inference.inferredType = undefined;
50890                 }
50891             }
50892         }
50893         function createInferenceInfo(typeParameter) {
50894             return {
50895                 typeParameter: typeParameter,
50896                 candidates: undefined,
50897                 contraCandidates: undefined,
50898                 inferredType: undefined,
50899                 priority: undefined,
50900                 topLevel: true,
50901                 isFixed: false,
50902                 impliedArity: undefined
50903             };
50904         }
50905         function cloneInferenceInfo(inference) {
50906             return {
50907                 typeParameter: inference.typeParameter,
50908                 candidates: inference.candidates && inference.candidates.slice(),
50909                 contraCandidates: inference.contraCandidates && inference.contraCandidates.slice(),
50910                 inferredType: inference.inferredType,
50911                 priority: inference.priority,
50912                 topLevel: inference.topLevel,
50913                 isFixed: inference.isFixed,
50914                 impliedArity: inference.impliedArity
50915             };
50916         }
50917         function cloneInferredPartOfContext(context) {
50918             var inferences = ts.filter(context.inferences, hasInferenceCandidates);
50919             return inferences.length ?
50920                 createInferenceContextWorker(ts.map(inferences, cloneInferenceInfo), context.signature, context.flags, context.compareTypes) :
50921                 undefined;
50922         }
50923         function getMapperFromContext(context) {
50924             return context && context.mapper;
50925         }
50926         function couldContainTypeVariables(type) {
50927             var objectFlags = ts.getObjectFlags(type);
50928             if (objectFlags & 67108864) {
50929                 return !!(objectFlags & 134217728);
50930             }
50931             var result = !!(type.flags & 465829888 ||
50932                 type.flags & 524288 && !isNonGenericTopLevelType(type) && (objectFlags & 4 && (type.node || ts.forEach(getTypeArguments(type), couldContainTypeVariables)) ||
50933                     objectFlags & 16 && type.symbol && type.symbol.flags & (16 | 8192 | 32 | 2048 | 4096) && type.symbol.declarations ||
50934                     objectFlags & (32 | 131072)) ||
50935                 type.flags & 3145728 && !(type.flags & 1024) && !isNonGenericTopLevelType(type) && ts.some(type.types, couldContainTypeVariables));
50936             if (type.flags & 3899393) {
50937                 type.objectFlags |= 67108864 | (result ? 134217728 : 0);
50938             }
50939             return result;
50940         }
50941         function isNonGenericTopLevelType(type) {
50942             if (type.aliasSymbol && !type.aliasTypeArguments) {
50943                 var declaration = ts.getDeclarationOfKind(type.aliasSymbol, 254);
50944                 return !!(declaration && ts.findAncestor(declaration.parent, function (n) { return n.kind === 297 ? true : n.kind === 256 ? false : "quit"; }));
50945             }
50946             return false;
50947         }
50948         function isTypeParameterAtTopLevel(type, typeParameter) {
50949             return !!(type === typeParameter ||
50950                 type.flags & 3145728 && ts.some(type.types, function (t) { return isTypeParameterAtTopLevel(t, typeParameter); }) ||
50951                 type.flags & 16777216 && (getTrueTypeFromConditionalType(type) === typeParameter || getFalseTypeFromConditionalType(type) === typeParameter));
50952         }
50953         function createEmptyObjectTypeFromStringLiteral(type) {
50954             var members = ts.createSymbolTable();
50955             forEachType(type, function (t) {
50956                 if (!(t.flags & 128)) {
50957                     return;
50958                 }
50959                 var name = ts.escapeLeadingUnderscores(t.value);
50960                 var literalProp = createSymbol(4, name);
50961                 literalProp.type = anyType;
50962                 if (t.symbol) {
50963                     literalProp.declarations = t.symbol.declarations;
50964                     literalProp.valueDeclaration = t.symbol.valueDeclaration;
50965                 }
50966                 members.set(name, literalProp);
50967             });
50968             var indexInfo = type.flags & 4 ? createIndexInfo(emptyObjectType, false) : undefined;
50969             return createAnonymousType(undefined, members, ts.emptyArray, ts.emptyArray, indexInfo, undefined);
50970         }
50971         function inferTypeForHomomorphicMappedType(source, target, constraint) {
50972             if (inInferTypeForHomomorphicMappedType) {
50973                 return undefined;
50974             }
50975             var key = source.id + "," + target.id + "," + constraint.id;
50976             if (reverseMappedCache.has(key)) {
50977                 return reverseMappedCache.get(key);
50978             }
50979             inInferTypeForHomomorphicMappedType = true;
50980             var type = createReverseMappedType(source, target, constraint);
50981             inInferTypeForHomomorphicMappedType = false;
50982             reverseMappedCache.set(key, type);
50983             return type;
50984         }
50985         function isPartiallyInferableType(type) {
50986             return !(ts.getObjectFlags(type) & 2097152) ||
50987                 isObjectLiteralType(type) && ts.some(getPropertiesOfType(type), function (prop) { return isPartiallyInferableType(getTypeOfSymbol(prop)); }) ||
50988                 isTupleType(type) && ts.some(getTypeArguments(type), isPartiallyInferableType);
50989         }
50990         function createReverseMappedType(source, target, constraint) {
50991             if (!(getIndexInfoOfType(source, 0) || getPropertiesOfType(source).length !== 0 && isPartiallyInferableType(source))) {
50992                 return undefined;
50993             }
50994             if (isArrayType(source)) {
50995                 return createArrayType(inferReverseMappedType(getTypeArguments(source)[0], target, constraint), isReadonlyArrayType(source));
50996             }
50997             if (isTupleType(source)) {
50998                 var elementTypes = ts.map(getTypeArguments(source), function (t) { return inferReverseMappedType(t, target, constraint); });
50999                 var elementFlags = getMappedTypeModifiers(target) & 4 ?
51000                     ts.sameMap(source.target.elementFlags, function (f) { return f & 2 ? 1 : f; }) :
51001                     source.target.elementFlags;
51002                 return createTupleType(elementTypes, elementFlags, source.target.readonly, source.target.labeledElementDeclarations);
51003             }
51004             var reversed = createObjectType(2048 | 16, undefined);
51005             reversed.source = source;
51006             reversed.mappedType = target;
51007             reversed.constraintType = constraint;
51008             return reversed;
51009         }
51010         function getTypeOfReverseMappedSymbol(symbol) {
51011             return inferReverseMappedType(symbol.propertyType, symbol.mappedType, symbol.constraintType);
51012         }
51013         function inferReverseMappedType(sourceType, target, constraint) {
51014             var typeParameter = getIndexedAccessType(constraint.type, getTypeParameterFromMappedType(target));
51015             var templateType = getTemplateTypeFromMappedType(target);
51016             var inference = createInferenceInfo(typeParameter);
51017             inferTypes([inference], sourceType, templateType);
51018             return getTypeFromInference(inference) || unknownType;
51019         }
51020         function getUnmatchedProperties(source, target, requireOptionalProperties, matchDiscriminantProperties) {
51021             var properties, _i, properties_2, targetProp, sourceProp, targetType, sourceType;
51022             return __generator(this, function (_a) {
51023                 switch (_a.label) {
51024                     case 0:
51025                         properties = getPropertiesOfType(target);
51026                         _i = 0, properties_2 = properties;
51027                         _a.label = 1;
51028                     case 1:
51029                         if (!(_i < properties_2.length)) return [3, 6];
51030                         targetProp = properties_2[_i];
51031                         if (isStaticPrivateIdentifierProperty(targetProp)) {
51032                             return [3, 5];
51033                         }
51034                         if (!(requireOptionalProperties || !(targetProp.flags & 16777216 || ts.getCheckFlags(targetProp) & 48))) return [3, 5];
51035                         sourceProp = getPropertyOfType(source, targetProp.escapedName);
51036                         if (!!sourceProp) return [3, 3];
51037                         return [4, targetProp];
51038                     case 2:
51039                         _a.sent();
51040                         return [3, 5];
51041                     case 3:
51042                         if (!matchDiscriminantProperties) return [3, 5];
51043                         targetType = getTypeOfSymbol(targetProp);
51044                         if (!(targetType.flags & 109440)) return [3, 5];
51045                         sourceType = getTypeOfSymbol(sourceProp);
51046                         if (!!(sourceType.flags & 1 || getRegularTypeOfLiteralType(sourceType) === getRegularTypeOfLiteralType(targetType))) return [3, 5];
51047                         return [4, targetProp];
51048                     case 4:
51049                         _a.sent();
51050                         _a.label = 5;
51051                     case 5:
51052                         _i++;
51053                         return [3, 1];
51054                     case 6: return [2];
51055                 }
51056             });
51057         }
51058         function getUnmatchedProperty(source, target, requireOptionalProperties, matchDiscriminantProperties) {
51059             var result = getUnmatchedProperties(source, target, requireOptionalProperties, matchDiscriminantProperties).next();
51060             if (!result.done)
51061                 return result.value;
51062         }
51063         function tupleTypesDefinitelyUnrelated(source, target) {
51064             return !(target.target.combinedFlags & 8) && target.target.minLength > source.target.minLength ||
51065                 !target.target.hasRestElement && (source.target.hasRestElement || target.target.fixedLength < source.target.fixedLength);
51066         }
51067         function typesDefinitelyUnrelated(source, target) {
51068             return isTupleType(source) && isTupleType(target) ? tupleTypesDefinitelyUnrelated(source, target) :
51069                 !!getUnmatchedProperty(source, target, false, true) &&
51070                     !!getUnmatchedProperty(target, source, false, true);
51071         }
51072         function getTypeFromInference(inference) {
51073             return inference.candidates ? getUnionType(inference.candidates, 2) :
51074                 inference.contraCandidates ? getIntersectionType(inference.contraCandidates) :
51075                     undefined;
51076         }
51077         function hasSkipDirectInferenceFlag(node) {
51078             return !!getNodeLinks(node).skipDirectInference;
51079         }
51080         function isFromInferenceBlockedSource(type) {
51081             return !!(type.symbol && ts.some(type.symbol.declarations, hasSkipDirectInferenceFlag));
51082         }
51083         function isValidBigIntString(s) {
51084             var scanner = ts.createScanner(99, false);
51085             var success = true;
51086             scanner.setOnError(function () { return success = false; });
51087             scanner.setText(s + "n");
51088             var result = scanner.scan();
51089             if (result === 40) {
51090                 result = scanner.scan();
51091             }
51092             var flags = scanner.getTokenFlags();
51093             return success && result === 9 && scanner.getTextPos() === (s.length + 1) && !(flags & 512);
51094         }
51095         function isStringLiteralTypeValueParsableAsType(s, target) {
51096             if (target.flags & 1048576) {
51097                 return !!forEachType(target, function (t) { return isStringLiteralTypeValueParsableAsType(s, t); });
51098             }
51099             switch (target) {
51100                 case stringType: return true;
51101                 case numberType: return s.value !== "" && isFinite(+(s.value));
51102                 case bigintType: return s.value !== "" && isValidBigIntString(s.value);
51103                 case trueType: return s.value === "true";
51104                 case falseType: return s.value === "false";
51105                 case undefinedType: return s.value === "undefined";
51106                 case nullType: return s.value === "null";
51107                 default: return !!(target.flags & 1);
51108             }
51109         }
51110         function inferLiteralsFromTemplateLiteralType(source, target) {
51111             var value = source.value;
51112             var texts = target.texts;
51113             var lastIndex = texts.length - 1;
51114             var startText = texts[0];
51115             var endText = texts[lastIndex];
51116             if (!(value.startsWith(startText) && value.slice(startText.length).endsWith(endText)))
51117                 return undefined;
51118             var matches = [];
51119             var str = value.slice(startText.length, value.length - endText.length);
51120             var pos = 0;
51121             for (var i = 1; i < lastIndex; i++) {
51122                 var delim = texts[i];
51123                 var delimPos = delim.length > 0 ? str.indexOf(delim, pos) : pos < str.length ? pos + 1 : -1;
51124                 if (delimPos < 0)
51125                     return undefined;
51126                 matches.push(getLiteralType(str.slice(pos, delimPos)));
51127                 pos = delimPos + delim.length;
51128             }
51129             matches.push(getLiteralType(str.slice(pos)));
51130             return matches;
51131         }
51132         function inferTypes(inferences, originalSource, originalTarget, priority, contravariant) {
51133             if (priority === void 0) { priority = 0; }
51134             if (contravariant === void 0) { contravariant = false; }
51135             var bivariant = false;
51136             var propagationType;
51137             var inferencePriority = 1024;
51138             var allowComplexConstraintInference = true;
51139             var visited;
51140             var sourceStack;
51141             var targetStack;
51142             var expandingFlags = 0;
51143             inferFromTypes(originalSource, originalTarget);
51144             function inferFromTypes(source, target) {
51145                 if (!couldContainTypeVariables(target)) {
51146                     return;
51147                 }
51148                 if (source === wildcardType) {
51149                     var savePropagationType = propagationType;
51150                     propagationType = source;
51151                     inferFromTypes(target, target);
51152                     propagationType = savePropagationType;
51153                     return;
51154                 }
51155                 if (source.aliasSymbol && source.aliasTypeArguments && source.aliasSymbol === target.aliasSymbol) {
51156                     inferFromTypeArguments(source.aliasTypeArguments, target.aliasTypeArguments, getAliasVariances(source.aliasSymbol));
51157                     return;
51158                 }
51159                 if (source === target && source.flags & 3145728) {
51160                     for (var _i = 0, _a = source.types; _i < _a.length; _i++) {
51161                         var t = _a[_i];
51162                         inferFromTypes(t, t);
51163                     }
51164                     return;
51165                 }
51166                 if (target.flags & 1048576) {
51167                     var _b = inferFromMatchingTypes(source.flags & 1048576 ? source.types : [source], target.types, isTypeOrBaseIdenticalTo), tempSources = _b[0], tempTargets = _b[1];
51168                     var _c = inferFromMatchingTypes(tempSources, tempTargets, isTypeCloselyMatchedBy), sources = _c[0], targets = _c[1];
51169                     if (targets.length === 0) {
51170                         return;
51171                     }
51172                     target = getUnionType(targets);
51173                     if (sources.length === 0) {
51174                         inferWithPriority(source, target, 1);
51175                         return;
51176                     }
51177                     source = getUnionType(sources);
51178                 }
51179                 else if (target.flags & 2097152 && ts.some(target.types, function (t) { return !!getInferenceInfoForType(t) || (isGenericMappedType(t) && !!getInferenceInfoForType(getHomomorphicTypeVariable(t) || neverType)); })) {
51180                     if (!(source.flags & 1048576)) {
51181                         var _d = inferFromMatchingTypes(source.flags & 2097152 ? source.types : [source], target.types, isTypeIdenticalTo), sources = _d[0], targets = _d[1];
51182                         if (sources.length === 0 || targets.length === 0) {
51183                             return;
51184                         }
51185                         source = getIntersectionType(sources);
51186                         target = getIntersectionType(targets);
51187                     }
51188                 }
51189                 else if (target.flags & (8388608 | 33554432)) {
51190                     target = getActualTypeVariable(target);
51191                 }
51192                 if (target.flags & 8650752) {
51193                     if (ts.getObjectFlags(source) & 2097152 || source === nonInferrableAnyType || source === silentNeverType ||
51194                         (priority & 64 && (source === autoType || source === autoArrayType)) || isFromInferenceBlockedSource(source)) {
51195                         return;
51196                     }
51197                     var inference = getInferenceInfoForType(target);
51198                     if (inference) {
51199                         if (!inference.isFixed) {
51200                             if (inference.priority === undefined || priority < inference.priority) {
51201                                 inference.candidates = undefined;
51202                                 inference.contraCandidates = undefined;
51203                                 inference.topLevel = true;
51204                                 inference.priority = priority;
51205                             }
51206                             if (priority === inference.priority) {
51207                                 var candidate = propagationType || source;
51208                                 if (contravariant && !bivariant) {
51209                                     if (!ts.contains(inference.contraCandidates, candidate)) {
51210                                         inference.contraCandidates = ts.append(inference.contraCandidates, candidate);
51211                                         clearCachedInferences(inferences);
51212                                     }
51213                                 }
51214                                 else if (!ts.contains(inference.candidates, candidate)) {
51215                                     inference.candidates = ts.append(inference.candidates, candidate);
51216                                     clearCachedInferences(inferences);
51217                                 }
51218                             }
51219                             if (!(priority & 64) && target.flags & 262144 && inference.topLevel && !isTypeParameterAtTopLevel(originalTarget, target)) {
51220                                 inference.topLevel = false;
51221                                 clearCachedInferences(inferences);
51222                             }
51223                         }
51224                         inferencePriority = Math.min(inferencePriority, priority);
51225                         return;
51226                     }
51227                     else {
51228                         var simplified = getSimplifiedType(target, false);
51229                         if (simplified !== target) {
51230                             invokeOnce(source, simplified, inferFromTypes);
51231                         }
51232                         else if (target.flags & 8388608) {
51233                             var indexType = getSimplifiedType(target.indexType, false);
51234                             if (indexType.flags & 465829888) {
51235                                 var simplified_1 = distributeIndexOverObjectType(getSimplifiedType(target.objectType, false), indexType, false);
51236                                 if (simplified_1 && simplified_1 !== target) {
51237                                     invokeOnce(source, simplified_1, inferFromTypes);
51238                                 }
51239                             }
51240                         }
51241                     }
51242                 }
51243                 if (ts.getObjectFlags(source) & 4 && ts.getObjectFlags(target) & 4 && (source.target === target.target || isArrayType(source) && isArrayType(target)) &&
51244                     !(source.node && target.node)) {
51245                     inferFromTypeArguments(getTypeArguments(source), getTypeArguments(target), getVariances(source.target));
51246                 }
51247                 else if (source.flags & 4194304 && target.flags & 4194304) {
51248                     contravariant = !contravariant;
51249                     inferFromTypes(source.type, target.type);
51250                     contravariant = !contravariant;
51251                 }
51252                 else if ((isLiteralType(source) || source.flags & 4) && target.flags & 4194304) {
51253                     var empty = createEmptyObjectTypeFromStringLiteral(source);
51254                     contravariant = !contravariant;
51255                     inferWithPriority(empty, target.type, 128);
51256                     contravariant = !contravariant;
51257                 }
51258                 else if (source.flags & 8388608 && target.flags & 8388608) {
51259                     inferFromTypes(source.objectType, target.objectType);
51260                     inferFromTypes(source.indexType, target.indexType);
51261                 }
51262                 else if (source.flags & 268435456 && target.flags & 268435456) {
51263                     if (source.symbol === target.symbol) {
51264                         inferFromTypes(source.type, target.type);
51265                     }
51266                 }
51267                 else if (target.flags & 16777216) {
51268                     invokeOnce(source, target, inferToConditionalType);
51269                 }
51270                 else if (target.flags & 3145728) {
51271                     inferToMultipleTypes(source, target.types, target.flags);
51272                 }
51273                 else if (source.flags & 1048576) {
51274                     var sourceTypes = source.types;
51275                     for (var _e = 0, sourceTypes_2 = sourceTypes; _e < sourceTypes_2.length; _e++) {
51276                         var sourceType = sourceTypes_2[_e];
51277                         inferFromTypes(sourceType, target);
51278                     }
51279                 }
51280                 else if (target.flags & 134217728) {
51281                     inferToTemplateLiteralType(source, target);
51282                 }
51283                 else {
51284                     source = getReducedType(source);
51285                     if (!(priority & 256 && source.flags & (2097152 | 465829888))) {
51286                         var apparentSource = getApparentType(source);
51287                         if (apparentSource !== source && allowComplexConstraintInference && !(apparentSource.flags & (524288 | 2097152))) {
51288                             allowComplexConstraintInference = false;
51289                             return inferFromTypes(apparentSource, target);
51290                         }
51291                         source = apparentSource;
51292                     }
51293                     if (source.flags & (524288 | 2097152)) {
51294                         invokeOnce(source, target, inferFromObjectTypes);
51295                     }
51296                 }
51297                 if (source.flags & 25165824) {
51298                     var simplified = getSimplifiedType(source, contravariant);
51299                     if (simplified !== source) {
51300                         inferFromTypes(simplified, target);
51301                     }
51302                 }
51303             }
51304             function inferWithPriority(source, target, newPriority) {
51305                 var savePriority = priority;
51306                 priority |= newPriority;
51307                 inferFromTypes(source, target);
51308                 priority = savePriority;
51309             }
51310             function invokeOnce(source, target, action) {
51311                 var key = source.id + "," + target.id;
51312                 var status = visited && visited.get(key);
51313                 if (status !== undefined) {
51314                     inferencePriority = Math.min(inferencePriority, status);
51315                     return;
51316                 }
51317                 (visited || (visited = new ts.Map())).set(key, -1);
51318                 var saveInferencePriority = inferencePriority;
51319                 inferencePriority = 1024;
51320                 var saveExpandingFlags = expandingFlags;
51321                 var sourceIdentity = getRecursionIdentity(source) || source;
51322                 var targetIdentity = getRecursionIdentity(target) || target;
51323                 if (sourceIdentity && ts.contains(sourceStack, sourceIdentity))
51324                     expandingFlags |= 1;
51325                 if (targetIdentity && ts.contains(targetStack, targetIdentity))
51326                     expandingFlags |= 2;
51327                 if (expandingFlags !== 3) {
51328                     if (sourceIdentity)
51329                         (sourceStack || (sourceStack = [])).push(sourceIdentity);
51330                     if (targetIdentity)
51331                         (targetStack || (targetStack = [])).push(targetIdentity);
51332                     action(source, target);
51333                     if (targetIdentity)
51334                         targetStack.pop();
51335                     if (sourceIdentity)
51336                         sourceStack.pop();
51337                 }
51338                 else {
51339                     inferencePriority = -1;
51340                 }
51341                 expandingFlags = saveExpandingFlags;
51342                 visited.set(key, inferencePriority);
51343                 inferencePriority = Math.min(inferencePriority, saveInferencePriority);
51344             }
51345             function inferFromMatchingTypes(sources, targets, matches) {
51346                 var matchedSources;
51347                 var matchedTargets;
51348                 for (var _i = 0, targets_1 = targets; _i < targets_1.length; _i++) {
51349                     var t = targets_1[_i];
51350                     for (var _a = 0, sources_1 = sources; _a < sources_1.length; _a++) {
51351                         var s = sources_1[_a];
51352                         if (matches(s, t)) {
51353                             inferFromTypes(s, t);
51354                             matchedSources = ts.appendIfUnique(matchedSources, s);
51355                             matchedTargets = ts.appendIfUnique(matchedTargets, t);
51356                         }
51357                     }
51358                 }
51359                 return [
51360                     matchedSources ? ts.filter(sources, function (t) { return !ts.contains(matchedSources, t); }) : sources,
51361                     matchedTargets ? ts.filter(targets, function (t) { return !ts.contains(matchedTargets, t); }) : targets,
51362                 ];
51363             }
51364             function inferFromTypeArguments(sourceTypes, targetTypes, variances) {
51365                 var count = sourceTypes.length < targetTypes.length ? sourceTypes.length : targetTypes.length;
51366                 for (var i = 0; i < count; i++) {
51367                     if (i < variances.length && (variances[i] & 7) === 2) {
51368                         inferFromContravariantTypes(sourceTypes[i], targetTypes[i]);
51369                     }
51370                     else {
51371                         inferFromTypes(sourceTypes[i], targetTypes[i]);
51372                     }
51373                 }
51374             }
51375             function inferFromContravariantTypes(source, target) {
51376                 if (strictFunctionTypes || priority & 512) {
51377                     contravariant = !contravariant;
51378                     inferFromTypes(source, target);
51379                     contravariant = !contravariant;
51380                 }
51381                 else {
51382                     inferFromTypes(source, target);
51383                 }
51384             }
51385             function getInferenceInfoForType(type) {
51386                 if (type.flags & 8650752) {
51387                     for (var _i = 0, inferences_2 = inferences; _i < inferences_2.length; _i++) {
51388                         var inference = inferences_2[_i];
51389                         if (type === inference.typeParameter) {
51390                             return inference;
51391                         }
51392                     }
51393                 }
51394                 return undefined;
51395             }
51396             function getSingleTypeVariableFromIntersectionTypes(types) {
51397                 var typeVariable;
51398                 for (var _i = 0, types_15 = types; _i < types_15.length; _i++) {
51399                     var type = types_15[_i];
51400                     var t = type.flags & 2097152 && ts.find(type.types, function (t) { return !!getInferenceInfoForType(t); });
51401                     if (!t || typeVariable && t !== typeVariable) {
51402                         return undefined;
51403                     }
51404                     typeVariable = t;
51405                 }
51406                 return typeVariable;
51407             }
51408             function inferToMultipleTypes(source, targets, targetFlags) {
51409                 var typeVariableCount = 0;
51410                 if (targetFlags & 1048576) {
51411                     var nakedTypeVariable = void 0;
51412                     var sources = source.flags & 1048576 ? source.types : [source];
51413                     var matched_1 = new Array(sources.length);
51414                     var inferenceCircularity = false;
51415                     for (var _i = 0, targets_2 = targets; _i < targets_2.length; _i++) {
51416                         var t = targets_2[_i];
51417                         if (getInferenceInfoForType(t)) {
51418                             nakedTypeVariable = t;
51419                             typeVariableCount++;
51420                         }
51421                         else {
51422                             for (var i = 0; i < sources.length; i++) {
51423                                 var saveInferencePriority = inferencePriority;
51424                                 inferencePriority = 1024;
51425                                 inferFromTypes(sources[i], t);
51426                                 if (inferencePriority === priority)
51427                                     matched_1[i] = true;
51428                                 inferenceCircularity = inferenceCircularity || inferencePriority === -1;
51429                                 inferencePriority = Math.min(inferencePriority, saveInferencePriority);
51430                             }
51431                         }
51432                     }
51433                     if (typeVariableCount === 0) {
51434                         var intersectionTypeVariable = getSingleTypeVariableFromIntersectionTypes(targets);
51435                         if (intersectionTypeVariable) {
51436                             inferWithPriority(source, intersectionTypeVariable, 1);
51437                         }
51438                         return;
51439                     }
51440                     if (typeVariableCount === 1 && !inferenceCircularity) {
51441                         var unmatched = ts.flatMap(sources, function (s, i) { return matched_1[i] ? undefined : s; });
51442                         if (unmatched.length) {
51443                             inferFromTypes(getUnionType(unmatched), nakedTypeVariable);
51444                             return;
51445                         }
51446                     }
51447                 }
51448                 else {
51449                     for (var _a = 0, targets_3 = targets; _a < targets_3.length; _a++) {
51450                         var t = targets_3[_a];
51451                         if (getInferenceInfoForType(t)) {
51452                             typeVariableCount++;
51453                         }
51454                         else {
51455                             inferFromTypes(source, t);
51456                         }
51457                     }
51458                 }
51459                 if (targetFlags & 2097152 ? typeVariableCount === 1 : typeVariableCount > 0) {
51460                     for (var _b = 0, targets_4 = targets; _b < targets_4.length; _b++) {
51461                         var t = targets_4[_b];
51462                         if (getInferenceInfoForType(t)) {
51463                             inferWithPriority(source, t, 1);
51464                         }
51465                     }
51466                 }
51467             }
51468             function inferToMappedType(source, target, constraintType) {
51469                 if (constraintType.flags & 1048576) {
51470                     var result = false;
51471                     for (var _i = 0, _a = constraintType.types; _i < _a.length; _i++) {
51472                         var type = _a[_i];
51473                         result = inferToMappedType(source, target, type) || result;
51474                     }
51475                     return result;
51476                 }
51477                 if (constraintType.flags & 4194304) {
51478                     var inference = getInferenceInfoForType(constraintType.type);
51479                     if (inference && !inference.isFixed && !isFromInferenceBlockedSource(source)) {
51480                         var inferredType = inferTypeForHomomorphicMappedType(source, target, constraintType);
51481                         if (inferredType) {
51482                             inferWithPriority(inferredType, inference.typeParameter, ts.getObjectFlags(source) & 2097152 ?
51483                                 8 :
51484                                 4);
51485                         }
51486                     }
51487                     return true;
51488                 }
51489                 if (constraintType.flags & 262144) {
51490                     inferWithPriority(getIndexType(source), constraintType, 16);
51491                     var extendedConstraint = getConstraintOfType(constraintType);
51492                     if (extendedConstraint && inferToMappedType(source, target, extendedConstraint)) {
51493                         return true;
51494                     }
51495                     var propTypes = ts.map(getPropertiesOfType(source), getTypeOfSymbol);
51496                     var stringIndexType = getIndexTypeOfType(source, 0);
51497                     var numberIndexInfo = getNonEnumNumberIndexInfo(source);
51498                     var numberIndexType = numberIndexInfo && numberIndexInfo.type;
51499                     inferFromTypes(getUnionType(ts.append(ts.append(propTypes, stringIndexType), numberIndexType)), getTemplateTypeFromMappedType(target));
51500                     return true;
51501                 }
51502                 return false;
51503             }
51504             function inferToConditionalType(source, target) {
51505                 if (source.flags & 16777216) {
51506                     inferFromTypes(source.checkType, target.checkType);
51507                     inferFromTypes(source.extendsType, target.extendsType);
51508                     inferFromTypes(getTrueTypeFromConditionalType(source), getTrueTypeFromConditionalType(target));
51509                     inferFromTypes(getFalseTypeFromConditionalType(source), getFalseTypeFromConditionalType(target));
51510                 }
51511                 else {
51512                     var savePriority = priority;
51513                     priority |= contravariant ? 32 : 0;
51514                     var targetTypes = [getTrueTypeFromConditionalType(target), getFalseTypeFromConditionalType(target)];
51515                     inferToMultipleTypes(source, targetTypes, target.flags);
51516                     priority = savePriority;
51517                 }
51518             }
51519             function inferToTemplateLiteralType(source, target) {
51520                 var matches = source.flags & 128 ? inferLiteralsFromTemplateLiteralType(source, target) :
51521                     source.flags & 134217728 && ts.arraysEqual(source.texts, target.texts) ? source.types :
51522                         undefined;
51523                 var types = target.types;
51524                 for (var i = 0; i < types.length; i++) {
51525                     inferFromTypes(matches ? matches[i] : neverType, types[i]);
51526                 }
51527             }
51528             function inferFromObjectTypes(source, target) {
51529                 if (ts.getObjectFlags(source) & 4 && ts.getObjectFlags(target) & 4 && (source.target === target.target || isArrayType(source) && isArrayType(target))) {
51530                     inferFromTypeArguments(getTypeArguments(source), getTypeArguments(target), getVariances(source.target));
51531                     return;
51532                 }
51533                 if (isGenericMappedType(source) && isGenericMappedType(target)) {
51534                     inferFromTypes(getConstraintTypeFromMappedType(source), getConstraintTypeFromMappedType(target));
51535                     inferFromTypes(getTemplateTypeFromMappedType(source), getTemplateTypeFromMappedType(target));
51536                     var sourceNameType = getNameTypeFromMappedType(source);
51537                     var targetNameType = getNameTypeFromMappedType(target);
51538                     if (sourceNameType && targetNameType)
51539                         inferFromTypes(sourceNameType, targetNameType);
51540                 }
51541                 if (ts.getObjectFlags(target) & 32 && !target.declaration.nameType) {
51542                     var constraintType = getConstraintTypeFromMappedType(target);
51543                     if (inferToMappedType(source, target, constraintType)) {
51544                         return;
51545                     }
51546                 }
51547                 if (!typesDefinitelyUnrelated(source, target)) {
51548                     if (isArrayType(source) || isTupleType(source)) {
51549                         if (isTupleType(target)) {
51550                             var sourceArity = getTypeReferenceArity(source);
51551                             var targetArity = getTypeReferenceArity(target);
51552                             var elementTypes = getTypeArguments(target);
51553                             var elementFlags = target.target.elementFlags;
51554                             if (isTupleType(source) && isTupleTypeStructureMatching(source, target)) {
51555                                 for (var i = 0; i < targetArity; i++) {
51556                                     inferFromTypes(getTypeArguments(source)[i], elementTypes[i]);
51557                                 }
51558                                 return;
51559                             }
51560                             var startLength = isTupleType(source) ? Math.min(source.target.fixedLength, target.target.fixedLength) : 0;
51561                             var sourceRestType = !isTupleType(source) || sourceArity > 0 && source.target.elementFlags[sourceArity - 1] & 4 ?
51562                                 getTypeArguments(source)[sourceArity - 1] : undefined;
51563                             var endLength = !(target.target.combinedFlags & 12) ? 0 :
51564                                 sourceRestType ? getEndLengthOfType(target) :
51565                                     Math.min(getEndLengthOfType(source), getEndLengthOfType(target));
51566                             var sourceEndLength = sourceRestType ? 0 : endLength;
51567                             for (var i = 0; i < startLength; i++) {
51568                                 inferFromTypes(getTypeArguments(source)[i], elementTypes[i]);
51569                             }
51570                             if (sourceRestType && sourceArity - startLength === 1) {
51571                                 for (var i = startLength; i < targetArity - endLength; i++) {
51572                                     inferFromTypes(elementFlags[i] & 8 ? createArrayType(sourceRestType) : sourceRestType, elementTypes[i]);
51573                                 }
51574                             }
51575                             else {
51576                                 var middleLength = targetArity - startLength - endLength;
51577                                 if (middleLength === 2 && elementFlags[startLength] & elementFlags[startLength + 1] & 8 && isTupleType(source)) {
51578                                     var targetInfo = getInferenceInfoForType(elementTypes[startLength]);
51579                                     if (targetInfo && targetInfo.impliedArity !== undefined) {
51580                                         inferFromTypes(sliceTupleType(source, startLength, sourceEndLength + sourceArity - targetInfo.impliedArity), elementTypes[startLength]);
51581                                         inferFromTypes(sliceTupleType(source, startLength + targetInfo.impliedArity, sourceEndLength), elementTypes[startLength + 1]);
51582                                     }
51583                                 }
51584                                 else if (middleLength === 1 && elementFlags[startLength] & 8) {
51585                                     var endsInOptional = target.target.elementFlags[targetArity - 1] & 2;
51586                                     var sourceSlice = isTupleType(source) ? sliceTupleType(source, startLength, sourceEndLength) : createArrayType(sourceRestType);
51587                                     inferWithPriority(sourceSlice, elementTypes[startLength], endsInOptional ? 2 : 0);
51588                                 }
51589                                 else if (middleLength === 1 && elementFlags[startLength] & 4) {
51590                                     var restType = isTupleType(source) ? getElementTypeOfSliceOfTupleType(source, startLength, sourceEndLength) : sourceRestType;
51591                                     if (restType) {
51592                                         inferFromTypes(restType, elementTypes[startLength]);
51593                                     }
51594                                 }
51595                             }
51596                             for (var i = 0; i < endLength; i++) {
51597                                 inferFromTypes(sourceRestType || getTypeArguments(source)[sourceArity - i - 1], elementTypes[targetArity - i - 1]);
51598                             }
51599                             return;
51600                         }
51601                         if (isArrayType(target)) {
51602                             inferFromIndexTypes(source, target);
51603                             return;
51604                         }
51605                     }
51606                     inferFromProperties(source, target);
51607                     inferFromSignatures(source, target, 0);
51608                     inferFromSignatures(source, target, 1);
51609                     inferFromIndexTypes(source, target);
51610                 }
51611             }
51612             function inferFromProperties(source, target) {
51613                 var properties = getPropertiesOfObjectType(target);
51614                 for (var _i = 0, properties_3 = properties; _i < properties_3.length; _i++) {
51615                     var targetProp = properties_3[_i];
51616                     var sourceProp = getPropertyOfType(source, targetProp.escapedName);
51617                     if (sourceProp) {
51618                         inferFromTypes(getTypeOfSymbol(sourceProp), getTypeOfSymbol(targetProp));
51619                     }
51620                 }
51621             }
51622             function inferFromSignatures(source, target, kind) {
51623                 var sourceSignatures = getSignaturesOfType(source, kind);
51624                 var targetSignatures = getSignaturesOfType(target, kind);
51625                 var sourceLen = sourceSignatures.length;
51626                 var targetLen = targetSignatures.length;
51627                 var len = sourceLen < targetLen ? sourceLen : targetLen;
51628                 var skipParameters = !!(ts.getObjectFlags(source) & 2097152);
51629                 for (var i = 0; i < len; i++) {
51630                     inferFromSignature(getBaseSignature(sourceSignatures[sourceLen - len + i]), getErasedSignature(targetSignatures[targetLen - len + i]), skipParameters);
51631                 }
51632             }
51633             function inferFromSignature(source, target, skipParameters) {
51634                 if (!skipParameters) {
51635                     var saveBivariant = bivariant;
51636                     var kind = target.declaration ? target.declaration.kind : 0;
51637                     bivariant = bivariant || kind === 165 || kind === 164 || kind === 166;
51638                     applyToParameterTypes(source, target, inferFromContravariantTypes);
51639                     bivariant = saveBivariant;
51640                 }
51641                 applyToReturnTypes(source, target, inferFromTypes);
51642             }
51643             function inferFromIndexTypes(source, target) {
51644                 var targetStringIndexType = getIndexTypeOfType(target, 0);
51645                 if (targetStringIndexType) {
51646                     var sourceIndexType = getIndexTypeOfType(source, 0) ||
51647                         getImplicitIndexTypeOfType(source, 0);
51648                     if (sourceIndexType) {
51649                         inferFromTypes(sourceIndexType, targetStringIndexType);
51650                     }
51651                 }
51652                 var targetNumberIndexType = getIndexTypeOfType(target, 1);
51653                 if (targetNumberIndexType) {
51654                     var sourceIndexType = getIndexTypeOfType(source, 1) ||
51655                         getIndexTypeOfType(source, 0) ||
51656                         getImplicitIndexTypeOfType(source, 1);
51657                     if (sourceIndexType) {
51658                         inferFromTypes(sourceIndexType, targetNumberIndexType);
51659                     }
51660                 }
51661             }
51662         }
51663         function isTypeOrBaseIdenticalTo(s, t) {
51664             return isTypeIdenticalTo(s, t) || !!(t.flags & 4 && s.flags & 128 || t.flags & 8 && s.flags & 256);
51665         }
51666         function isTypeCloselyMatchedBy(s, t) {
51667             return !!(s.flags & 524288 && t.flags & 524288 && s.symbol && s.symbol === t.symbol ||
51668                 s.aliasSymbol && s.aliasTypeArguments && s.aliasSymbol === t.aliasSymbol);
51669         }
51670         function hasPrimitiveConstraint(type) {
51671             var constraint = getConstraintOfTypeParameter(type);
51672             return !!constraint && maybeTypeOfKind(constraint.flags & 16777216 ? getDefaultConstraintOfConditionalType(constraint) : constraint, 131068 | 4194304 | 134217728 | 268435456);
51673         }
51674         function isObjectLiteralType(type) {
51675             return !!(ts.getObjectFlags(type) & 128);
51676         }
51677         function isObjectOrArrayLiteralType(type) {
51678             return !!(ts.getObjectFlags(type) & (128 | 65536));
51679         }
51680         function unionObjectAndArrayLiteralCandidates(candidates) {
51681             if (candidates.length > 1) {
51682                 var objectLiterals = ts.filter(candidates, isObjectOrArrayLiteralType);
51683                 if (objectLiterals.length) {
51684                     var literalsType = getUnionType(objectLiterals, 2);
51685                     return ts.concatenate(ts.filter(candidates, function (t) { return !isObjectOrArrayLiteralType(t); }), [literalsType]);
51686                 }
51687             }
51688             return candidates;
51689         }
51690         function getContravariantInference(inference) {
51691             return inference.priority & 208 ? getIntersectionType(inference.contraCandidates) : getCommonSubtype(inference.contraCandidates);
51692         }
51693         function getCovariantInference(inference, signature) {
51694             var candidates = unionObjectAndArrayLiteralCandidates(inference.candidates);
51695             var primitiveConstraint = hasPrimitiveConstraint(inference.typeParameter);
51696             var widenLiteralTypes = !primitiveConstraint && inference.topLevel &&
51697                 (inference.isFixed || !isTypeParameterAtTopLevel(getReturnTypeOfSignature(signature), inference.typeParameter));
51698             var baseCandidates = primitiveConstraint ? ts.sameMap(candidates, getRegularTypeOfLiteralType) :
51699                 widenLiteralTypes ? ts.sameMap(candidates, getWidenedLiteralType) :
51700                     candidates;
51701             var unwidenedType = inference.priority & 208 ?
51702                 getUnionType(baseCandidates, 2) :
51703                 getCommonSupertype(baseCandidates);
51704             return getWidenedType(unwidenedType);
51705         }
51706         function getInferredType(context, index) {
51707             var inference = context.inferences[index];
51708             if (!inference.inferredType) {
51709                 var inferredType = void 0;
51710                 var signature = context.signature;
51711                 if (signature) {
51712                     var inferredCovariantType = inference.candidates ? getCovariantInference(inference, signature) : undefined;
51713                     if (inference.contraCandidates) {
51714                         var inferredContravariantType = getContravariantInference(inference);
51715                         inferredType = inferredCovariantType && !(inferredCovariantType.flags & 131072) &&
51716                             isTypeSubtypeOf(inferredCovariantType, inferredContravariantType) ?
51717                             inferredCovariantType : inferredContravariantType;
51718                     }
51719                     else if (inferredCovariantType) {
51720                         inferredType = inferredCovariantType;
51721                     }
51722                     else if (context.flags & 1) {
51723                         inferredType = silentNeverType;
51724                     }
51725                     else {
51726                         var defaultType = getDefaultFromTypeParameter(inference.typeParameter);
51727                         if (defaultType) {
51728                             inferredType = instantiateType(defaultType, mergeTypeMappers(createBackreferenceMapper(context, index), context.nonFixingMapper));
51729                         }
51730                     }
51731                 }
51732                 else {
51733                     inferredType = getTypeFromInference(inference);
51734                 }
51735                 inference.inferredType = inferredType || getDefaultTypeArgumentType(!!(context.flags & 2));
51736                 var constraint = getConstraintOfTypeParameter(inference.typeParameter);
51737                 if (constraint) {
51738                     var instantiatedConstraint = instantiateType(constraint, context.nonFixingMapper);
51739                     if (!inferredType || !context.compareTypes(inferredType, getTypeWithThisArgument(instantiatedConstraint, inferredType))) {
51740                         inference.inferredType = inferredType = instantiatedConstraint;
51741                     }
51742                 }
51743             }
51744             return inference.inferredType;
51745         }
51746         function getDefaultTypeArgumentType(isInJavaScriptFile) {
51747             return isInJavaScriptFile ? anyType : unknownType;
51748         }
51749         function getInferredTypes(context) {
51750             var result = [];
51751             for (var i = 0; i < context.inferences.length; i++) {
51752                 result.push(getInferredType(context, i));
51753             }
51754             return result;
51755         }
51756         function getCannotFindNameDiagnosticForName(node) {
51757             switch (node.escapedText) {
51758                 case "document":
51759                 case "console":
51760                     return ts.Diagnostics.Cannot_find_name_0_Do_you_need_to_change_your_target_library_Try_changing_the_lib_compiler_option_to_include_dom;
51761                 case "$":
51762                     return compilerOptions.types
51763                         ? ts.Diagnostics.Cannot_find_name_0_Do_you_need_to_install_type_definitions_for_jQuery_Try_npm_i_save_dev_types_Slashjquery_and_then_add_jquery_to_the_types_field_in_your_tsconfig
51764                         : ts.Diagnostics.Cannot_find_name_0_Do_you_need_to_install_type_definitions_for_jQuery_Try_npm_i_save_dev_types_Slashjquery;
51765                 case "describe":
51766                 case "suite":
51767                 case "it":
51768                 case "test":
51769                     return compilerOptions.types
51770                         ? ts.Diagnostics.Cannot_find_name_0_Do_you_need_to_install_type_definitions_for_a_test_runner_Try_npm_i_save_dev_types_Slashjest_or_npm_i_save_dev_types_Slashmocha_and_then_add_jest_or_mocha_to_the_types_field_in_your_tsconfig
51771                         : ts.Diagnostics.Cannot_find_name_0_Do_you_need_to_install_type_definitions_for_a_test_runner_Try_npm_i_save_dev_types_Slashjest_or_npm_i_save_dev_types_Slashmocha;
51772                 case "process":
51773                 case "require":
51774                 case "Buffer":
51775                 case "module":
51776                     return compilerOptions.types
51777                         ? ts.Diagnostics.Cannot_find_name_0_Do_you_need_to_install_type_definitions_for_node_Try_npm_i_save_dev_types_Slashnode_and_then_add_node_to_the_types_field_in_your_tsconfig
51778                         : ts.Diagnostics.Cannot_find_name_0_Do_you_need_to_install_type_definitions_for_node_Try_npm_i_save_dev_types_Slashnode;
51779                 case "Map":
51780                 case "Set":
51781                 case "Promise":
51782                 case "Symbol":
51783                 case "WeakMap":
51784                 case "WeakSet":
51785                 case "Iterator":
51786                 case "AsyncIterator":
51787                 case "SharedArrayBuffer":
51788                 case "Atomics":
51789                 case "AsyncIterable":
51790                 case "AsyncIterableIterator":
51791                 case "AsyncGenerator":
51792                 case "AsyncGeneratorFunction":
51793                 case "BigInt":
51794                 case "Reflect":
51795                 case "BigInt64Array":
51796                 case "BigUint64Array":
51797                     return ts.Diagnostics.Cannot_find_name_0_Do_you_need_to_change_your_target_library_Try_changing_the_lib_compiler_option_to_1_or_later;
51798                 default:
51799                     if (node.parent.kind === 289) {
51800                         return ts.Diagnostics.No_value_exists_in_scope_for_the_shorthand_property_0_Either_declare_one_or_provide_an_initializer;
51801                     }
51802                     else {
51803                         return ts.Diagnostics.Cannot_find_name_0;
51804                     }
51805             }
51806         }
51807         function getResolvedSymbol(node) {
51808             var links = getNodeLinks(node);
51809             if (!links.resolvedSymbol) {
51810                 links.resolvedSymbol = !ts.nodeIsMissing(node) &&
51811                     resolveName(node, node.escapedText, 111551 | 1048576, getCannotFindNameDiagnosticForName(node), node, !ts.isWriteOnlyAccess(node), false, ts.Diagnostics.Cannot_find_name_0_Did_you_mean_1) || unknownSymbol;
51812             }
51813             return links.resolvedSymbol;
51814         }
51815         function isInTypeQuery(node) {
51816             return !!ts.findAncestor(node, function (n) { return n.kind === 176 ? true : n.kind === 78 || n.kind === 157 ? false : "quit"; });
51817         }
51818         function getFlowCacheKey(node, declaredType, initialType, flowContainer) {
51819             switch (node.kind) {
51820                 case 78:
51821                     var symbol = getResolvedSymbol(node);
51822                     return symbol !== unknownSymbol ? (flowContainer ? getNodeId(flowContainer) : "-1") + "|" + getTypeId(declaredType) + "|" + getTypeId(initialType) + "|" + (isConstraintPosition(node) ? "@" : "") + getSymbolId(symbol) : undefined;
51823                 case 107:
51824                     return "0|" + (flowContainer ? getNodeId(flowContainer) : "-1") + "|" + getTypeId(declaredType) + "|" + getTypeId(initialType);
51825                 case 225:
51826                 case 207:
51827                     return getFlowCacheKey(node.expression, declaredType, initialType, flowContainer);
51828                 case 201:
51829                 case 202:
51830                     var propName = getAccessedPropertyName(node);
51831                     if (propName !== undefined) {
51832                         var key = getFlowCacheKey(node.expression, declaredType, initialType, flowContainer);
51833                         return key && key + "." + propName;
51834                     }
51835             }
51836             return undefined;
51837         }
51838         function isMatchingReference(source, target) {
51839             switch (target.kind) {
51840                 case 207:
51841                 case 225:
51842                     return isMatchingReference(source, target.expression);
51843                 case 216:
51844                     return (ts.isAssignmentExpression(target) && isMatchingReference(source, target.left)) ||
51845                         (ts.isBinaryExpression(target) && target.operatorToken.kind === 27 && isMatchingReference(source, target.right));
51846             }
51847             switch (source.kind) {
51848                 case 78:
51849                 case 79:
51850                     return target.kind === 78 && getResolvedSymbol(source) === getResolvedSymbol(target) ||
51851                         (target.kind === 249 || target.kind === 198) &&
51852                             getExportSymbolOfValueSymbolIfExported(getResolvedSymbol(source)) === getSymbolOfNode(target);
51853                 case 107:
51854                     return target.kind === 107;
51855                 case 105:
51856                     return target.kind === 105;
51857                 case 225:
51858                 case 207:
51859                     return isMatchingReference(source.expression, target);
51860                 case 201:
51861                 case 202:
51862                     return ts.isAccessExpression(target) &&
51863                         getAccessedPropertyName(source) === getAccessedPropertyName(target) &&
51864                         isMatchingReference(source.expression, target.expression);
51865             }
51866             return false;
51867         }
51868         function containsTruthyCheck(source, target) {
51869             return isMatchingReference(source, target) ||
51870                 (target.kind === 216 && target.operatorToken.kind === 55 &&
51871                     (containsTruthyCheck(source, target.left) || containsTruthyCheck(source, target.right)));
51872         }
51873         function getAccessedPropertyName(access) {
51874             return access.kind === 201 ? access.name.escapedText :
51875                 ts.isStringOrNumericLiteralLike(access.argumentExpression) ? ts.escapeLeadingUnderscores(access.argumentExpression.text) :
51876                     undefined;
51877         }
51878         function containsMatchingReference(source, target) {
51879             while (ts.isAccessExpression(source)) {
51880                 source = source.expression;
51881                 if (isMatchingReference(source, target)) {
51882                     return true;
51883                 }
51884             }
51885             return false;
51886         }
51887         function optionalChainContainsReference(source, target) {
51888             while (ts.isOptionalChain(source)) {
51889                 source = source.expression;
51890                 if (isMatchingReference(source, target)) {
51891                     return true;
51892                 }
51893             }
51894             return false;
51895         }
51896         function isDiscriminantProperty(type, name) {
51897             if (type && type.flags & 1048576) {
51898                 var prop = getUnionOrIntersectionProperty(type, name);
51899                 if (prop && ts.getCheckFlags(prop) & 2) {
51900                     if (prop.isDiscriminantProperty === undefined) {
51901                         prop.isDiscriminantProperty =
51902                             (prop.checkFlags & 192) === 192 &&
51903                                 !maybeTypeOfKind(getTypeOfSymbol(prop), 465829888);
51904                     }
51905                     return !!prop.isDiscriminantProperty;
51906                 }
51907             }
51908             return false;
51909         }
51910         function findDiscriminantProperties(sourceProperties, target) {
51911             var result;
51912             for (var _i = 0, sourceProperties_2 = sourceProperties; _i < sourceProperties_2.length; _i++) {
51913                 var sourceProperty = sourceProperties_2[_i];
51914                 if (isDiscriminantProperty(target, sourceProperty.escapedName)) {
51915                     if (result) {
51916                         result.push(sourceProperty);
51917                         continue;
51918                     }
51919                     result = [sourceProperty];
51920                 }
51921             }
51922             return result;
51923         }
51924         function isOrContainsMatchingReference(source, target) {
51925             return isMatchingReference(source, target) || containsMatchingReference(source, target);
51926         }
51927         function hasMatchingArgument(callExpression, reference) {
51928             if (callExpression.arguments) {
51929                 for (var _i = 0, _a = callExpression.arguments; _i < _a.length; _i++) {
51930                     var argument = _a[_i];
51931                     if (isOrContainsMatchingReference(reference, argument)) {
51932                         return true;
51933                     }
51934                 }
51935             }
51936             if (callExpression.expression.kind === 201 &&
51937                 isOrContainsMatchingReference(reference, callExpression.expression.expression)) {
51938                 return true;
51939             }
51940             return false;
51941         }
51942         function getFlowNodeId(flow) {
51943             if (!flow.id || flow.id < 0) {
51944                 flow.id = nextFlowId;
51945                 nextFlowId++;
51946             }
51947             return flow.id;
51948         }
51949         function typeMaybeAssignableTo(source, target) {
51950             if (!(source.flags & 1048576)) {
51951                 return isTypeAssignableTo(source, target);
51952             }
51953             for (var _i = 0, _a = source.types; _i < _a.length; _i++) {
51954                 var t = _a[_i];
51955                 if (isTypeAssignableTo(t, target)) {
51956                     return true;
51957                 }
51958             }
51959             return false;
51960         }
51961         function getAssignmentReducedType(declaredType, assignedType) {
51962             if (declaredType !== assignedType) {
51963                 if (assignedType.flags & 131072) {
51964                     return assignedType;
51965                 }
51966                 var reducedType = filterType(declaredType, function (t) { return typeMaybeAssignableTo(assignedType, t); });
51967                 if (assignedType.flags & 512 && isFreshLiteralType(assignedType)) {
51968                     reducedType = mapType(reducedType, getFreshTypeOfLiteralType);
51969                 }
51970                 if (isTypeAssignableTo(assignedType, reducedType)) {
51971                     return reducedType;
51972                 }
51973             }
51974             return declaredType;
51975         }
51976         function getTypeFactsOfTypes(types) {
51977             var result = 0;
51978             for (var _i = 0, types_16 = types; _i < types_16.length; _i++) {
51979                 var t = types_16[_i];
51980                 result |= getTypeFacts(t);
51981             }
51982             return result;
51983         }
51984         function isFunctionObjectType(type) {
51985             var resolved = resolveStructuredTypeMembers(type);
51986             return !!(resolved.callSignatures.length || resolved.constructSignatures.length ||
51987                 resolved.members.get("bind") && isTypeSubtypeOf(type, globalFunctionType));
51988         }
51989         function getTypeFacts(type) {
51990             var flags = type.flags;
51991             if (flags & 4) {
51992                 return strictNullChecks ? 16317953 : 16776705;
51993             }
51994             if (flags & 128) {
51995                 var isEmpty = type.value === "";
51996                 return strictNullChecks ?
51997                     isEmpty ? 12123649 : 7929345 :
51998                     isEmpty ? 12582401 : 16776705;
51999             }
52000             if (flags & (8 | 32)) {
52001                 return strictNullChecks ? 16317698 : 16776450;
52002             }
52003             if (flags & 256) {
52004                 var isZero = type.value === 0;
52005                 return strictNullChecks ?
52006                     isZero ? 12123394 : 7929090 :
52007                     isZero ? 12582146 : 16776450;
52008             }
52009             if (flags & 64) {
52010                 return strictNullChecks ? 16317188 : 16775940;
52011             }
52012             if (flags & 2048) {
52013                 var isZero = isZeroBigInt(type);
52014                 return strictNullChecks ?
52015                     isZero ? 12122884 : 7928580 :
52016                     isZero ? 12581636 : 16775940;
52017             }
52018             if (flags & 16) {
52019                 return strictNullChecks ? 16316168 : 16774920;
52020             }
52021             if (flags & 528) {
52022                 return strictNullChecks ?
52023                     (type === falseType || type === regularFalseType) ? 12121864 : 7927560 :
52024                     (type === falseType || type === regularFalseType) ? 12580616 : 16774920;
52025             }
52026             if (flags & 524288) {
52027                 return ts.getObjectFlags(type) & 16 && isEmptyObjectType(type) ?
52028                     strictNullChecks ? 16318463 : 16777215 :
52029                     isFunctionObjectType(type) ?
52030                         strictNullChecks ? 7880640 : 16728000 :
52031                         strictNullChecks ? 7888800 : 16736160;
52032             }
52033             if (flags & (16384 | 32768)) {
52034                 return 9830144;
52035             }
52036             if (flags & 65536) {
52037                 return 9363232;
52038             }
52039             if (flags & 12288) {
52040                 return strictNullChecks ? 7925520 : 16772880;
52041             }
52042             if (flags & 67108864) {
52043                 return strictNullChecks ? 7888800 : 16736160;
52044             }
52045             if (flags & 131072) {
52046                 return 0;
52047             }
52048             if (flags & 465829888) {
52049                 return getTypeFacts(getBaseConstraintOfType(type) || unknownType);
52050             }
52051             if (flags & 3145728) {
52052                 return getTypeFactsOfTypes(type.types);
52053             }
52054             return 16777215;
52055         }
52056         function getTypeWithFacts(type, include) {
52057             return filterType(type, function (t) { return (getTypeFacts(t) & include) !== 0; });
52058         }
52059         function getTypeWithDefault(type, defaultExpression) {
52060             if (defaultExpression) {
52061                 var defaultType = getTypeOfExpression(defaultExpression);
52062                 return getUnionType([getTypeWithFacts(type, 524288), defaultType]);
52063             }
52064             return type;
52065         }
52066         function getTypeOfDestructuredProperty(type, name) {
52067             var nameType = getLiteralTypeFromPropertyName(name);
52068             if (!isTypeUsableAsPropertyName(nameType))
52069                 return errorType;
52070             var text = getPropertyNameFromType(nameType);
52071             return getConstraintForLocation(getTypeOfPropertyOfType(type, text), name) ||
52072                 isNumericLiteralName(text) && includeUndefinedInIndexSignature(getIndexTypeOfType(type, 1)) ||
52073                 includeUndefinedInIndexSignature(getIndexTypeOfType(type, 0)) ||
52074                 errorType;
52075         }
52076         function getTypeOfDestructuredArrayElement(type, index) {
52077             return everyType(type, isTupleLikeType) && getTupleElementType(type, index) ||
52078                 includeUndefinedInIndexSignature(checkIteratedTypeOrElementType(65, type, undefinedType, undefined)) ||
52079                 errorType;
52080         }
52081         function includeUndefinedInIndexSignature(type) {
52082             if (!type)
52083                 return type;
52084             return compilerOptions.noUncheckedIndexedAccess ?
52085                 getUnionType([type, undefinedType]) :
52086                 type;
52087         }
52088         function getTypeOfDestructuredSpreadExpression(type) {
52089             return createArrayType(checkIteratedTypeOrElementType(65, type, undefinedType, undefined) || errorType);
52090         }
52091         function getAssignedTypeOfBinaryExpression(node) {
52092             var isDestructuringDefaultAssignment = node.parent.kind === 199 && isDestructuringAssignmentTarget(node.parent) ||
52093                 node.parent.kind === 288 && isDestructuringAssignmentTarget(node.parent.parent);
52094             return isDestructuringDefaultAssignment ?
52095                 getTypeWithDefault(getAssignedType(node), node.right) :
52096                 getTypeOfExpression(node.right);
52097         }
52098         function isDestructuringAssignmentTarget(parent) {
52099             return parent.parent.kind === 216 && parent.parent.left === parent ||
52100                 parent.parent.kind === 239 && parent.parent.initializer === parent;
52101         }
52102         function getAssignedTypeOfArrayLiteralElement(node, element) {
52103             return getTypeOfDestructuredArrayElement(getAssignedType(node), node.elements.indexOf(element));
52104         }
52105         function getAssignedTypeOfSpreadExpression(node) {
52106             return getTypeOfDestructuredSpreadExpression(getAssignedType(node.parent));
52107         }
52108         function getAssignedTypeOfPropertyAssignment(node) {
52109             return getTypeOfDestructuredProperty(getAssignedType(node.parent), node.name);
52110         }
52111         function getAssignedTypeOfShorthandPropertyAssignment(node) {
52112             return getTypeWithDefault(getAssignedTypeOfPropertyAssignment(node), node.objectAssignmentInitializer);
52113         }
52114         function getAssignedType(node) {
52115             var parent = node.parent;
52116             switch (parent.kind) {
52117                 case 238:
52118                     return stringType;
52119                 case 239:
52120                     return checkRightHandSideOfForOf(parent) || errorType;
52121                 case 216:
52122                     return getAssignedTypeOfBinaryExpression(parent);
52123                 case 210:
52124                     return undefinedType;
52125                 case 199:
52126                     return getAssignedTypeOfArrayLiteralElement(parent, node);
52127                 case 220:
52128                     return getAssignedTypeOfSpreadExpression(parent);
52129                 case 288:
52130                     return getAssignedTypeOfPropertyAssignment(parent);
52131                 case 289:
52132                     return getAssignedTypeOfShorthandPropertyAssignment(parent);
52133             }
52134             return errorType;
52135         }
52136         function getInitialTypeOfBindingElement(node) {
52137             var pattern = node.parent;
52138             var parentType = getInitialType(pattern.parent);
52139             var type = pattern.kind === 196 ?
52140                 getTypeOfDestructuredProperty(parentType, node.propertyName || node.name) :
52141                 !node.dotDotDotToken ?
52142                     getTypeOfDestructuredArrayElement(parentType, pattern.elements.indexOf(node)) :
52143                     getTypeOfDestructuredSpreadExpression(parentType);
52144             return getTypeWithDefault(type, node.initializer);
52145         }
52146         function getTypeOfInitializer(node) {
52147             var links = getNodeLinks(node);
52148             return links.resolvedType || getTypeOfExpression(node);
52149         }
52150         function getInitialTypeOfVariableDeclaration(node) {
52151             if (node.initializer) {
52152                 return getTypeOfInitializer(node.initializer);
52153             }
52154             if (node.parent.parent.kind === 238) {
52155                 return stringType;
52156             }
52157             if (node.parent.parent.kind === 239) {
52158                 return checkRightHandSideOfForOf(node.parent.parent) || errorType;
52159             }
52160             return errorType;
52161         }
52162         function getInitialType(node) {
52163             return node.kind === 249 ?
52164                 getInitialTypeOfVariableDeclaration(node) :
52165                 getInitialTypeOfBindingElement(node);
52166         }
52167         function isEmptyArrayAssignment(node) {
52168             return node.kind === 249 && node.initializer &&
52169                 isEmptyArrayLiteral(node.initializer) ||
52170                 node.kind !== 198 && node.parent.kind === 216 &&
52171                     isEmptyArrayLiteral(node.parent.right);
52172         }
52173         function getReferenceCandidate(node) {
52174             switch (node.kind) {
52175                 case 207:
52176                     return getReferenceCandidate(node.expression);
52177                 case 216:
52178                     switch (node.operatorToken.kind) {
52179                         case 62:
52180                         case 74:
52181                         case 75:
52182                         case 76:
52183                             return getReferenceCandidate(node.left);
52184                         case 27:
52185                             return getReferenceCandidate(node.right);
52186                     }
52187             }
52188             return node;
52189         }
52190         function getReferenceRoot(node) {
52191             var parent = node.parent;
52192             return parent.kind === 207 ||
52193                 parent.kind === 216 && parent.operatorToken.kind === 62 && parent.left === node ||
52194                 parent.kind === 216 && parent.operatorToken.kind === 27 && parent.right === node ?
52195                 getReferenceRoot(parent) : node;
52196         }
52197         function getTypeOfSwitchClause(clause) {
52198             if (clause.kind === 284) {
52199                 return getRegularTypeOfLiteralType(getTypeOfExpression(clause.expression));
52200             }
52201             return neverType;
52202         }
52203         function getSwitchClauseTypes(switchStatement) {
52204             var links = getNodeLinks(switchStatement);
52205             if (!links.switchTypes) {
52206                 links.switchTypes = [];
52207                 for (var _i = 0, _a = switchStatement.caseBlock.clauses; _i < _a.length; _i++) {
52208                     var clause = _a[_i];
52209                     links.switchTypes.push(getTypeOfSwitchClause(clause));
52210                 }
52211             }
52212             return links.switchTypes;
52213         }
52214         function getSwitchClauseTypeOfWitnesses(switchStatement, retainDefault) {
52215             var witnesses = [];
52216             for (var _i = 0, _a = switchStatement.caseBlock.clauses; _i < _a.length; _i++) {
52217                 var clause = _a[_i];
52218                 if (clause.kind === 284) {
52219                     if (ts.isStringLiteralLike(clause.expression)) {
52220                         witnesses.push(clause.expression.text);
52221                         continue;
52222                     }
52223                     return ts.emptyArray;
52224                 }
52225                 if (retainDefault)
52226                     witnesses.push(undefined);
52227             }
52228             return witnesses;
52229         }
52230         function eachTypeContainedIn(source, types) {
52231             return source.flags & 1048576 ? !ts.forEach(source.types, function (t) { return !ts.contains(types, t); }) : ts.contains(types, source);
52232         }
52233         function isTypeSubsetOf(source, target) {
52234             return source === target || target.flags & 1048576 && isTypeSubsetOfUnion(source, target);
52235         }
52236         function isTypeSubsetOfUnion(source, target) {
52237             if (source.flags & 1048576) {
52238                 for (var _i = 0, _a = source.types; _i < _a.length; _i++) {
52239                     var t = _a[_i];
52240                     if (!containsType(target.types, t)) {
52241                         return false;
52242                     }
52243                 }
52244                 return true;
52245             }
52246             if (source.flags & 1024 && getBaseTypeOfEnumLiteralType(source) === target) {
52247                 return true;
52248             }
52249             return containsType(target.types, source);
52250         }
52251         function forEachType(type, f) {
52252             return type.flags & 1048576 ? ts.forEach(type.types, f) : f(type);
52253         }
52254         function everyType(type, f) {
52255             return type.flags & 1048576 ? ts.every(type.types, f) : f(type);
52256         }
52257         function filterType(type, f) {
52258             if (type.flags & 1048576) {
52259                 var types = type.types;
52260                 var filtered = ts.filter(types, f);
52261                 return filtered === types ? type : getUnionTypeFromSortedList(filtered, type.objectFlags);
52262             }
52263             return type.flags & 131072 || f(type) ? type : neverType;
52264         }
52265         function countTypes(type) {
52266             return type.flags & 1048576 ? type.types.length : 1;
52267         }
52268         function mapType(type, mapper, noReductions) {
52269             if (type.flags & 131072) {
52270                 return type;
52271             }
52272             if (!(type.flags & 1048576)) {
52273                 return mapper(type);
52274             }
52275             var mappedTypes;
52276             for (var _i = 0, _a = type.types; _i < _a.length; _i++) {
52277                 var t = _a[_i];
52278                 var mapped = mapper(t);
52279                 if (mapped) {
52280                     if (!mappedTypes) {
52281                         mappedTypes = [mapped];
52282                     }
52283                     else {
52284                         mappedTypes.push(mapped);
52285                     }
52286                 }
52287             }
52288             return mappedTypes && getUnionType(mappedTypes, noReductions ? 0 : 1);
52289         }
52290         function extractTypesOfKind(type, kind) {
52291             return filterType(type, function (t) { return (t.flags & kind) !== 0; });
52292         }
52293         function replacePrimitivesWithLiterals(typeWithPrimitives, typeWithLiterals) {
52294             if (isTypeSubsetOf(stringType, typeWithPrimitives) && maybeTypeOfKind(typeWithLiterals, 128) ||
52295                 isTypeSubsetOf(numberType, typeWithPrimitives) && maybeTypeOfKind(typeWithLiterals, 256) ||
52296                 isTypeSubsetOf(bigintType, typeWithPrimitives) && maybeTypeOfKind(typeWithLiterals, 2048)) {
52297                 return mapType(typeWithPrimitives, function (t) {
52298                     return t.flags & 4 ? extractTypesOfKind(typeWithLiterals, 4 | 128) :
52299                         t.flags & 8 ? extractTypesOfKind(typeWithLiterals, 8 | 256) :
52300                             t.flags & 64 ? extractTypesOfKind(typeWithLiterals, 64 | 2048) : t;
52301                 });
52302             }
52303             return typeWithPrimitives;
52304         }
52305         function isIncomplete(flowType) {
52306             return flowType.flags === 0;
52307         }
52308         function getTypeFromFlowType(flowType) {
52309             return flowType.flags === 0 ? flowType.type : flowType;
52310         }
52311         function createFlowType(type, incomplete) {
52312             return incomplete ? { flags: 0, type: type.flags & 131072 ? silentNeverType : type } : type;
52313         }
52314         function createEvolvingArrayType(elementType) {
52315             var result = createObjectType(256);
52316             result.elementType = elementType;
52317             return result;
52318         }
52319         function getEvolvingArrayType(elementType) {
52320             return evolvingArrayTypes[elementType.id] || (evolvingArrayTypes[elementType.id] = createEvolvingArrayType(elementType));
52321         }
52322         function addEvolvingArrayElementType(evolvingArrayType, node) {
52323             var elementType = getRegularTypeOfObjectLiteral(getBaseTypeOfLiteralType(getContextFreeTypeOfExpression(node)));
52324             return isTypeSubsetOf(elementType, evolvingArrayType.elementType) ? evolvingArrayType : getEvolvingArrayType(getUnionType([evolvingArrayType.elementType, elementType]));
52325         }
52326         function createFinalArrayType(elementType) {
52327             return elementType.flags & 131072 ?
52328                 autoArrayType :
52329                 createArrayType(elementType.flags & 1048576 ?
52330                     getUnionType(elementType.types, 2) :
52331                     elementType);
52332         }
52333         function getFinalArrayType(evolvingArrayType) {
52334             return evolvingArrayType.finalArrayType || (evolvingArrayType.finalArrayType = createFinalArrayType(evolvingArrayType.elementType));
52335         }
52336         function finalizeEvolvingArrayType(type) {
52337             return ts.getObjectFlags(type) & 256 ? getFinalArrayType(type) : type;
52338         }
52339         function getElementTypeOfEvolvingArrayType(type) {
52340             return ts.getObjectFlags(type) & 256 ? type.elementType : neverType;
52341         }
52342         function isEvolvingArrayTypeList(types) {
52343             var hasEvolvingArrayType = false;
52344             for (var _i = 0, types_17 = types; _i < types_17.length; _i++) {
52345                 var t = types_17[_i];
52346                 if (!(t.flags & 131072)) {
52347                     if (!(ts.getObjectFlags(t) & 256)) {
52348                         return false;
52349                     }
52350                     hasEvolvingArrayType = true;
52351                 }
52352             }
52353             return hasEvolvingArrayType;
52354         }
52355         function getUnionOrEvolvingArrayType(types, subtypeReduction) {
52356             return isEvolvingArrayTypeList(types) ?
52357                 getEvolvingArrayType(getUnionType(ts.map(types, getElementTypeOfEvolvingArrayType))) :
52358                 getUnionType(ts.sameMap(types, finalizeEvolvingArrayType), subtypeReduction);
52359         }
52360         function isEvolvingArrayOperationTarget(node) {
52361             var root = getReferenceRoot(node);
52362             var parent = root.parent;
52363             var isLengthPushOrUnshift = ts.isPropertyAccessExpression(parent) && (parent.name.escapedText === "length" ||
52364                 parent.parent.kind === 203
52365                     && ts.isIdentifier(parent.name)
52366                     && ts.isPushOrUnshiftIdentifier(parent.name));
52367             var isElementAssignment = parent.kind === 202 &&
52368                 parent.expression === root &&
52369                 parent.parent.kind === 216 &&
52370                 parent.parent.operatorToken.kind === 62 &&
52371                 parent.parent.left === parent &&
52372                 !ts.isAssignmentTarget(parent.parent) &&
52373                 isTypeAssignableToKind(getTypeOfExpression(parent.argumentExpression), 296);
52374             return isLengthPushOrUnshift || isElementAssignment;
52375         }
52376         function isDeclarationWithExplicitTypeAnnotation(declaration) {
52377             return (declaration.kind === 249 || declaration.kind === 160 ||
52378                 declaration.kind === 163 || declaration.kind === 162) &&
52379                 !!ts.getEffectiveTypeAnnotationNode(declaration);
52380         }
52381         function getExplicitTypeOfSymbol(symbol, diagnostic) {
52382             if (symbol.flags & (16 | 8192 | 32 | 512)) {
52383                 return getTypeOfSymbol(symbol);
52384             }
52385             if (symbol.flags & (3 | 4)) {
52386                 if (ts.getCheckFlags(symbol) & 262144) {
52387                     var origin = symbol.syntheticOrigin;
52388                     if (origin && getExplicitTypeOfSymbol(origin)) {
52389                         return getTypeOfSymbol(symbol);
52390                     }
52391                 }
52392                 var declaration = symbol.valueDeclaration;
52393                 if (declaration) {
52394                     if (isDeclarationWithExplicitTypeAnnotation(declaration)) {
52395                         return getTypeOfSymbol(symbol);
52396                     }
52397                     if (ts.isVariableDeclaration(declaration) && declaration.parent.parent.kind === 239) {
52398                         var statement = declaration.parent.parent;
52399                         var expressionType = getTypeOfDottedName(statement.expression, undefined);
52400                         if (expressionType) {
52401                             var use = statement.awaitModifier ? 15 : 13;
52402                             return checkIteratedTypeOrElementType(use, expressionType, undefinedType, undefined);
52403                         }
52404                     }
52405                     if (diagnostic) {
52406                         ts.addRelatedInfo(diagnostic, ts.createDiagnosticForNode(declaration, ts.Diagnostics._0_needs_an_explicit_type_annotation, symbolToString(symbol)));
52407                     }
52408                 }
52409             }
52410         }
52411         function getTypeOfDottedName(node, diagnostic) {
52412             if (!(node.flags & 16777216)) {
52413                 switch (node.kind) {
52414                     case 78:
52415                         var symbol = getExportSymbolOfValueSymbolIfExported(getResolvedSymbol(node));
52416                         return getExplicitTypeOfSymbol(symbol.flags & 2097152 ? resolveAlias(symbol) : symbol, diagnostic);
52417                     case 107:
52418                         return getExplicitThisType(node);
52419                     case 105:
52420                         return checkSuperExpression(node);
52421                     case 201:
52422                         var type = getTypeOfDottedName(node.expression, diagnostic);
52423                         var prop = type && getPropertyOfType(type, node.name.escapedText);
52424                         return prop && getExplicitTypeOfSymbol(prop, diagnostic);
52425                     case 207:
52426                         return getTypeOfDottedName(node.expression, diagnostic);
52427                 }
52428             }
52429         }
52430         function getEffectsSignature(node) {
52431             var links = getNodeLinks(node);
52432             var signature = links.effectsSignature;
52433             if (signature === undefined) {
52434                 var funcType = void 0;
52435                 if (node.parent.kind === 233) {
52436                     funcType = getTypeOfDottedName(node.expression, undefined);
52437                 }
52438                 else if (node.expression.kind !== 105) {
52439                     if (ts.isOptionalChain(node)) {
52440                         funcType = checkNonNullType(getOptionalExpressionType(checkExpression(node.expression), node.expression), node.expression);
52441                     }
52442                     else {
52443                         funcType = checkNonNullExpression(node.expression);
52444                     }
52445                 }
52446                 var signatures = getSignaturesOfType(funcType && getApparentType(funcType) || unknownType, 0);
52447                 var candidate = signatures.length === 1 && !signatures[0].typeParameters ? signatures[0] :
52448                     ts.some(signatures, hasTypePredicateOrNeverReturnType) ? getResolvedSignature(node) :
52449                         undefined;
52450                 signature = links.effectsSignature = candidate && hasTypePredicateOrNeverReturnType(candidate) ? candidate : unknownSignature;
52451             }
52452             return signature === unknownSignature ? undefined : signature;
52453         }
52454         function hasTypePredicateOrNeverReturnType(signature) {
52455             return !!(getTypePredicateOfSignature(signature) ||
52456                 signature.declaration && (getReturnTypeFromAnnotation(signature.declaration) || unknownType).flags & 131072);
52457         }
52458         function getTypePredicateArgument(predicate, callExpression) {
52459             if (predicate.kind === 1 || predicate.kind === 3) {
52460                 return callExpression.arguments[predicate.parameterIndex];
52461             }
52462             var invokedExpression = ts.skipParentheses(callExpression.expression);
52463             return ts.isAccessExpression(invokedExpression) ? ts.skipParentheses(invokedExpression.expression) : undefined;
52464         }
52465         function reportFlowControlError(node) {
52466             var block = ts.findAncestor(node, ts.isFunctionOrModuleBlock);
52467             var sourceFile = ts.getSourceFileOfNode(node);
52468             var span = ts.getSpanOfTokenAtPosition(sourceFile, block.statements.pos);
52469             diagnostics.add(ts.createFileDiagnostic(sourceFile, span.start, span.length, ts.Diagnostics.The_containing_function_or_module_body_is_too_large_for_control_flow_analysis));
52470         }
52471         function isReachableFlowNode(flow) {
52472             var result = isReachableFlowNodeWorker(flow, false);
52473             lastFlowNode = flow;
52474             lastFlowNodeReachable = result;
52475             return result;
52476         }
52477         function isFalseExpression(expr) {
52478             var node = ts.skipParentheses(expr);
52479             return node.kind === 94 || node.kind === 216 && (node.operatorToken.kind === 55 && (isFalseExpression(node.left) || isFalseExpression(node.right)) ||
52480                 node.operatorToken.kind === 56 && isFalseExpression(node.left) && isFalseExpression(node.right));
52481         }
52482         function isReachableFlowNodeWorker(flow, noCacheCheck) {
52483             while (true) {
52484                 if (flow === lastFlowNode) {
52485                     return lastFlowNodeReachable;
52486                 }
52487                 var flags = flow.flags;
52488                 if (flags & 4096) {
52489                     if (!noCacheCheck) {
52490                         var id = getFlowNodeId(flow);
52491                         var reachable = flowNodeReachable[id];
52492                         return reachable !== undefined ? reachable : (flowNodeReachable[id] = isReachableFlowNodeWorker(flow, true));
52493                     }
52494                     noCacheCheck = false;
52495                 }
52496                 if (flags & (16 | 96 | 256)) {
52497                     flow = flow.antecedent;
52498                 }
52499                 else if (flags & 512) {
52500                     var signature = getEffectsSignature(flow.node);
52501                     if (signature) {
52502                         var predicate = getTypePredicateOfSignature(signature);
52503                         if (predicate && predicate.kind === 3 && !predicate.type) {
52504                             var predicateArgument = flow.node.arguments[predicate.parameterIndex];
52505                             if (predicateArgument && isFalseExpression(predicateArgument)) {
52506                                 return false;
52507                             }
52508                         }
52509                         if (getReturnTypeOfSignature(signature).flags & 131072) {
52510                             return false;
52511                         }
52512                     }
52513                     flow = flow.antecedent;
52514                 }
52515                 else if (flags & 4) {
52516                     return ts.some(flow.antecedents, function (f) { return isReachableFlowNodeWorker(f, false); });
52517                 }
52518                 else if (flags & 8) {
52519                     flow = flow.antecedents[0];
52520                 }
52521                 else if (flags & 128) {
52522                     if (flow.clauseStart === flow.clauseEnd && isExhaustiveSwitchStatement(flow.switchStatement)) {
52523                         return false;
52524                     }
52525                     flow = flow.antecedent;
52526                 }
52527                 else if (flags & 1024) {
52528                     lastFlowNode = undefined;
52529                     var target = flow.target;
52530                     var saveAntecedents = target.antecedents;
52531                     target.antecedents = flow.antecedents;
52532                     var result = isReachableFlowNodeWorker(flow.antecedent, false);
52533                     target.antecedents = saveAntecedents;
52534                     return result;
52535                 }
52536                 else {
52537                     return !(flags & 1);
52538                 }
52539             }
52540         }
52541         function isPostSuperFlowNode(flow, noCacheCheck) {
52542             while (true) {
52543                 var flags = flow.flags;
52544                 if (flags & 4096) {
52545                     if (!noCacheCheck) {
52546                         var id = getFlowNodeId(flow);
52547                         var postSuper = flowNodePostSuper[id];
52548                         return postSuper !== undefined ? postSuper : (flowNodePostSuper[id] = isPostSuperFlowNode(flow, true));
52549                     }
52550                     noCacheCheck = false;
52551                 }
52552                 if (flags & (16 | 96 | 256 | 128)) {
52553                     flow = flow.antecedent;
52554                 }
52555                 else if (flags & 512) {
52556                     if (flow.node.expression.kind === 105) {
52557                         return true;
52558                     }
52559                     flow = flow.antecedent;
52560                 }
52561                 else if (flags & 4) {
52562                     return ts.every(flow.antecedents, function (f) { return isPostSuperFlowNode(f, false); });
52563                 }
52564                 else if (flags & 8) {
52565                     flow = flow.antecedents[0];
52566                 }
52567                 else if (flags & 1024) {
52568                     var target = flow.target;
52569                     var saveAntecedents = target.antecedents;
52570                     target.antecedents = flow.antecedents;
52571                     var result = isPostSuperFlowNode(flow.antecedent, false);
52572                     target.antecedents = saveAntecedents;
52573                     return result;
52574                 }
52575                 else {
52576                     return !!(flags & 1);
52577                 }
52578             }
52579         }
52580         function getFlowTypeOfReference(reference, declaredType, initialType, flowContainer, couldBeUninitialized) {
52581             if (initialType === void 0) { initialType = declaredType; }
52582             var key;
52583             var isKeySet = false;
52584             var flowDepth = 0;
52585             if (flowAnalysisDisabled) {
52586                 return errorType;
52587             }
52588             if (!reference.flowNode || !couldBeUninitialized && !(declaredType.flags & 536624127)) {
52589                 return declaredType;
52590             }
52591             flowInvocationCount++;
52592             var sharedFlowStart = sharedFlowCount;
52593             var evolvedType = getTypeFromFlowType(getTypeAtFlowNode(reference.flowNode));
52594             sharedFlowCount = sharedFlowStart;
52595             var resultType = ts.getObjectFlags(evolvedType) & 256 && isEvolvingArrayOperationTarget(reference) ? autoArrayType : finalizeEvolvingArrayType(evolvedType);
52596             if (resultType === unreachableNeverType || reference.parent && reference.parent.kind === 225 && getTypeWithFacts(resultType, 2097152).flags & 131072) {
52597                 return declaredType;
52598             }
52599             return resultType;
52600             function getOrSetCacheKey() {
52601                 if (isKeySet) {
52602                     return key;
52603                 }
52604                 isKeySet = true;
52605                 return key = getFlowCacheKey(reference, declaredType, initialType, flowContainer);
52606             }
52607             function getTypeAtFlowNode(flow) {
52608                 if (flowDepth === 2000) {
52609                     ts.tracing.instant("check", "getTypeAtFlowNode_DepthLimit", { flowId: flow.id });
52610                     flowAnalysisDisabled = true;
52611                     reportFlowControlError(reference);
52612                     return errorType;
52613                 }
52614                 flowDepth++;
52615                 var sharedFlow;
52616                 while (true) {
52617                     var flags = flow.flags;
52618                     if (flags & 4096) {
52619                         for (var i = sharedFlowStart; i < sharedFlowCount; i++) {
52620                             if (sharedFlowNodes[i] === flow) {
52621                                 flowDepth--;
52622                                 return sharedFlowTypes[i];
52623                             }
52624                         }
52625                         sharedFlow = flow;
52626                     }
52627                     var type = void 0;
52628                     if (flags & 16) {
52629                         type = getTypeAtFlowAssignment(flow);
52630                         if (!type) {
52631                             flow = flow.antecedent;
52632                             continue;
52633                         }
52634                     }
52635                     else if (flags & 512) {
52636                         type = getTypeAtFlowCall(flow);
52637                         if (!type) {
52638                             flow = flow.antecedent;
52639                             continue;
52640                         }
52641                     }
52642                     else if (flags & 96) {
52643                         type = getTypeAtFlowCondition(flow);
52644                     }
52645                     else if (flags & 128) {
52646                         type = getTypeAtSwitchClause(flow);
52647                     }
52648                     else if (flags & 12) {
52649                         if (flow.antecedents.length === 1) {
52650                             flow = flow.antecedents[0];
52651                             continue;
52652                         }
52653                         type = flags & 4 ?
52654                             getTypeAtFlowBranchLabel(flow) :
52655                             getTypeAtFlowLoopLabel(flow);
52656                     }
52657                     else if (flags & 256) {
52658                         type = getTypeAtFlowArrayMutation(flow);
52659                         if (!type) {
52660                             flow = flow.antecedent;
52661                             continue;
52662                         }
52663                     }
52664                     else if (flags & 1024) {
52665                         var target = flow.target;
52666                         var saveAntecedents = target.antecedents;
52667                         target.antecedents = flow.antecedents;
52668                         type = getTypeAtFlowNode(flow.antecedent);
52669                         target.antecedents = saveAntecedents;
52670                     }
52671                     else if (flags & 2) {
52672                         var container = flow.node;
52673                         if (container && container !== flowContainer &&
52674                             reference.kind !== 201 &&
52675                             reference.kind !== 202 &&
52676                             reference.kind !== 107) {
52677                             flow = container.flowNode;
52678                             continue;
52679                         }
52680                         type = initialType;
52681                     }
52682                     else {
52683                         type = convertAutoToAny(declaredType);
52684                     }
52685                     if (sharedFlow) {
52686                         sharedFlowNodes[sharedFlowCount] = sharedFlow;
52687                         sharedFlowTypes[sharedFlowCount] = type;
52688                         sharedFlowCount++;
52689                     }
52690                     flowDepth--;
52691                     return type;
52692                 }
52693             }
52694             function getInitialOrAssignedType(flow) {
52695                 var node = flow.node;
52696                 return getConstraintForLocation(node.kind === 249 || node.kind === 198 ?
52697                     getInitialType(node) :
52698                     getAssignedType(node), reference);
52699             }
52700             function getTypeAtFlowAssignment(flow) {
52701                 var node = flow.node;
52702                 if (isMatchingReference(reference, node)) {
52703                     if (!isReachableFlowNode(flow)) {
52704                         return unreachableNeverType;
52705                     }
52706                     if (ts.getAssignmentTargetKind(node) === 2) {
52707                         var flowType = getTypeAtFlowNode(flow.antecedent);
52708                         return createFlowType(getBaseTypeOfLiteralType(getTypeFromFlowType(flowType)), isIncomplete(flowType));
52709                     }
52710                     if (declaredType === autoType || declaredType === autoArrayType) {
52711                         if (isEmptyArrayAssignment(node)) {
52712                             return getEvolvingArrayType(neverType);
52713                         }
52714                         var assignedType = getWidenedLiteralType(getInitialOrAssignedType(flow));
52715                         return isTypeAssignableTo(assignedType, declaredType) ? assignedType : anyArrayType;
52716                     }
52717                     if (declaredType.flags & 1048576) {
52718                         return getAssignmentReducedType(declaredType, getInitialOrAssignedType(flow));
52719                     }
52720                     return declaredType;
52721                 }
52722                 if (containsMatchingReference(reference, node)) {
52723                     if (!isReachableFlowNode(flow)) {
52724                         return unreachableNeverType;
52725                     }
52726                     if (ts.isVariableDeclaration(node) && (ts.isInJSFile(node) || ts.isVarConst(node))) {
52727                         var init = ts.getDeclaredExpandoInitializer(node);
52728                         if (init && (init.kind === 208 || init.kind === 209)) {
52729                             return getTypeAtFlowNode(flow.antecedent);
52730                         }
52731                     }
52732                     return declaredType;
52733                 }
52734                 if (ts.isVariableDeclaration(node) && node.parent.parent.kind === 238 && isMatchingReference(reference, node.parent.parent.expression)) {
52735                     return getNonNullableTypeIfNeeded(getTypeFromFlowType(getTypeAtFlowNode(flow.antecedent)));
52736                 }
52737                 return undefined;
52738             }
52739             function narrowTypeByAssertion(type, expr) {
52740                 var node = ts.skipParentheses(expr);
52741                 if (node.kind === 94) {
52742                     return unreachableNeverType;
52743                 }
52744                 if (node.kind === 216) {
52745                     if (node.operatorToken.kind === 55) {
52746                         return narrowTypeByAssertion(narrowTypeByAssertion(type, node.left), node.right);
52747                     }
52748                     if (node.operatorToken.kind === 56) {
52749                         return getUnionType([narrowTypeByAssertion(type, node.left), narrowTypeByAssertion(type, node.right)]);
52750                     }
52751                 }
52752                 return narrowType(type, node, true);
52753             }
52754             function getTypeAtFlowCall(flow) {
52755                 var signature = getEffectsSignature(flow.node);
52756                 if (signature) {
52757                     var predicate = getTypePredicateOfSignature(signature);
52758                     if (predicate && (predicate.kind === 2 || predicate.kind === 3)) {
52759                         var flowType = getTypeAtFlowNode(flow.antecedent);
52760                         var type = finalizeEvolvingArrayType(getTypeFromFlowType(flowType));
52761                         var narrowedType = predicate.type ? narrowTypeByTypePredicate(type, predicate, flow.node, true) :
52762                             predicate.kind === 3 && predicate.parameterIndex >= 0 && predicate.parameterIndex < flow.node.arguments.length ? narrowTypeByAssertion(type, flow.node.arguments[predicate.parameterIndex]) :
52763                                 type;
52764                         return narrowedType === type ? flowType : createFlowType(narrowedType, isIncomplete(flowType));
52765                     }
52766                     if (getReturnTypeOfSignature(signature).flags & 131072) {
52767                         return unreachableNeverType;
52768                     }
52769                 }
52770                 return undefined;
52771             }
52772             function getTypeAtFlowArrayMutation(flow) {
52773                 if (declaredType === autoType || declaredType === autoArrayType) {
52774                     var node = flow.node;
52775                     var expr = node.kind === 203 ?
52776                         node.expression.expression :
52777                         node.left.expression;
52778                     if (isMatchingReference(reference, getReferenceCandidate(expr))) {
52779                         var flowType = getTypeAtFlowNode(flow.antecedent);
52780                         var type = getTypeFromFlowType(flowType);
52781                         if (ts.getObjectFlags(type) & 256) {
52782                             var evolvedType_1 = type;
52783                             if (node.kind === 203) {
52784                                 for (var _i = 0, _a = node.arguments; _i < _a.length; _i++) {
52785                                     var arg = _a[_i];
52786                                     evolvedType_1 = addEvolvingArrayElementType(evolvedType_1, arg);
52787                                 }
52788                             }
52789                             else {
52790                                 var indexType = getContextFreeTypeOfExpression(node.left.argumentExpression);
52791                                 if (isTypeAssignableToKind(indexType, 296)) {
52792                                     evolvedType_1 = addEvolvingArrayElementType(evolvedType_1, node.right);
52793                                 }
52794                             }
52795                             return evolvedType_1 === type ? flowType : createFlowType(evolvedType_1, isIncomplete(flowType));
52796                         }
52797                         return flowType;
52798                     }
52799                 }
52800                 return undefined;
52801             }
52802             function getTypeAtFlowCondition(flow) {
52803                 var flowType = getTypeAtFlowNode(flow.antecedent);
52804                 var type = getTypeFromFlowType(flowType);
52805                 if (type.flags & 131072) {
52806                     return flowType;
52807                 }
52808                 var assumeTrue = (flow.flags & 32) !== 0;
52809                 var nonEvolvingType = finalizeEvolvingArrayType(type);
52810                 var narrowedType = narrowType(nonEvolvingType, flow.node, assumeTrue);
52811                 if (narrowedType === nonEvolvingType) {
52812                     return flowType;
52813                 }
52814                 return createFlowType(narrowedType, isIncomplete(flowType));
52815             }
52816             function getTypeAtSwitchClause(flow) {
52817                 var expr = flow.switchStatement.expression;
52818                 var flowType = getTypeAtFlowNode(flow.antecedent);
52819                 var type = getTypeFromFlowType(flowType);
52820                 if (isMatchingReference(reference, expr)) {
52821                     type = narrowTypeBySwitchOnDiscriminant(type, flow.switchStatement, flow.clauseStart, flow.clauseEnd);
52822                 }
52823                 else if (expr.kind === 211 && isMatchingReference(reference, expr.expression)) {
52824                     type = narrowBySwitchOnTypeOf(type, flow.switchStatement, flow.clauseStart, flow.clauseEnd);
52825                 }
52826                 else {
52827                     if (strictNullChecks) {
52828                         if (optionalChainContainsReference(expr, reference)) {
52829                             type = narrowTypeBySwitchOptionalChainContainment(type, flow.switchStatement, flow.clauseStart, flow.clauseEnd, function (t) { return !(t.flags & (32768 | 131072)); });
52830                         }
52831                         else if (expr.kind === 211 && optionalChainContainsReference(expr.expression, reference)) {
52832                             type = narrowTypeBySwitchOptionalChainContainment(type, flow.switchStatement, flow.clauseStart, flow.clauseEnd, function (t) { return !(t.flags & 131072 || t.flags & 128 && t.value === "undefined"); });
52833                         }
52834                     }
52835                     if (isMatchingReferenceDiscriminant(expr, type)) {
52836                         type = narrowTypeByDiscriminant(type, expr, function (t) { return narrowTypeBySwitchOnDiscriminant(t, flow.switchStatement, flow.clauseStart, flow.clauseEnd); });
52837                     }
52838                 }
52839                 return createFlowType(type, isIncomplete(flowType));
52840             }
52841             function getTypeAtFlowBranchLabel(flow) {
52842                 var antecedentTypes = [];
52843                 var subtypeReduction = false;
52844                 var seenIncomplete = false;
52845                 var bypassFlow;
52846                 for (var _i = 0, _a = flow.antecedents; _i < _a.length; _i++) {
52847                     var antecedent = _a[_i];
52848                     if (!bypassFlow && antecedent.flags & 128 && antecedent.clauseStart === antecedent.clauseEnd) {
52849                         bypassFlow = antecedent;
52850                         continue;
52851                     }
52852                     var flowType = getTypeAtFlowNode(antecedent);
52853                     var type = getTypeFromFlowType(flowType);
52854                     if (type === declaredType && declaredType === initialType) {
52855                         return type;
52856                     }
52857                     ts.pushIfUnique(antecedentTypes, type);
52858                     if (!isTypeSubsetOf(type, declaredType)) {
52859                         subtypeReduction = true;
52860                     }
52861                     if (isIncomplete(flowType)) {
52862                         seenIncomplete = true;
52863                     }
52864                 }
52865                 if (bypassFlow) {
52866                     var flowType = getTypeAtFlowNode(bypassFlow);
52867                     var type = getTypeFromFlowType(flowType);
52868                     if (!ts.contains(antecedentTypes, type) && !isExhaustiveSwitchStatement(bypassFlow.switchStatement)) {
52869                         if (type === declaredType && declaredType === initialType) {
52870                             return type;
52871                         }
52872                         antecedentTypes.push(type);
52873                         if (!isTypeSubsetOf(type, declaredType)) {
52874                             subtypeReduction = true;
52875                         }
52876                         if (isIncomplete(flowType)) {
52877                             seenIncomplete = true;
52878                         }
52879                     }
52880                 }
52881                 return createFlowType(getUnionOrEvolvingArrayType(antecedentTypes, subtypeReduction ? 2 : 1), seenIncomplete);
52882             }
52883             function getTypeAtFlowLoopLabel(flow) {
52884                 var id = getFlowNodeId(flow);
52885                 var cache = flowLoopCaches[id] || (flowLoopCaches[id] = new ts.Map());
52886                 var key = getOrSetCacheKey();
52887                 if (!key) {
52888                     return declaredType;
52889                 }
52890                 var cached = cache.get(key);
52891                 if (cached) {
52892                     return cached;
52893                 }
52894                 for (var i = flowLoopStart; i < flowLoopCount; i++) {
52895                     if (flowLoopNodes[i] === flow && flowLoopKeys[i] === key && flowLoopTypes[i].length) {
52896                         return createFlowType(getUnionOrEvolvingArrayType(flowLoopTypes[i], 1), true);
52897                     }
52898                 }
52899                 var antecedentTypes = [];
52900                 var subtypeReduction = false;
52901                 var firstAntecedentType;
52902                 for (var _i = 0, _a = flow.antecedents; _i < _a.length; _i++) {
52903                     var antecedent = _a[_i];
52904                     var flowType = void 0;
52905                     if (!firstAntecedentType) {
52906                         flowType = firstAntecedentType = getTypeAtFlowNode(antecedent);
52907                     }
52908                     else {
52909                         flowLoopNodes[flowLoopCount] = flow;
52910                         flowLoopKeys[flowLoopCount] = key;
52911                         flowLoopTypes[flowLoopCount] = antecedentTypes;
52912                         flowLoopCount++;
52913                         var saveFlowTypeCache = flowTypeCache;
52914                         flowTypeCache = undefined;
52915                         flowType = getTypeAtFlowNode(antecedent);
52916                         flowTypeCache = saveFlowTypeCache;
52917                         flowLoopCount--;
52918                         var cached_1 = cache.get(key);
52919                         if (cached_1) {
52920                             return cached_1;
52921                         }
52922                     }
52923                     var type = getTypeFromFlowType(flowType);
52924                     ts.pushIfUnique(antecedentTypes, type);
52925                     if (!isTypeSubsetOf(type, declaredType)) {
52926                         subtypeReduction = true;
52927                     }
52928                     if (type === declaredType) {
52929                         break;
52930                     }
52931                 }
52932                 var result = getUnionOrEvolvingArrayType(antecedentTypes, subtypeReduction ? 2 : 1);
52933                 if (isIncomplete(firstAntecedentType)) {
52934                     return createFlowType(result, true);
52935                 }
52936                 cache.set(key, result);
52937                 return result;
52938             }
52939             function isMatchingReferenceDiscriminant(expr, computedType) {
52940                 var type = declaredType.flags & 1048576 ? declaredType : computedType;
52941                 if (!(type.flags & 1048576) || !ts.isAccessExpression(expr)) {
52942                     return false;
52943                 }
52944                 var name = getAccessedPropertyName(expr);
52945                 if (name === undefined) {
52946                     return false;
52947                 }
52948                 return isMatchingReference(reference, expr.expression) && isDiscriminantProperty(type, name);
52949             }
52950             function narrowTypeByDiscriminant(type, access, narrowType) {
52951                 var propName = getAccessedPropertyName(access);
52952                 if (propName === undefined) {
52953                     return type;
52954                 }
52955                 var propType = getTypeOfPropertyOfType(type, propName);
52956                 if (!propType) {
52957                     return type;
52958                 }
52959                 var narrowedPropType = narrowType(propType);
52960                 return filterType(type, function (t) {
52961                     var discriminantType = getTypeOfPropertyOrIndexSignature(t, propName);
52962                     return !(discriminantType.flags & 131072) && isTypeComparableTo(discriminantType, narrowedPropType);
52963                 });
52964             }
52965             function narrowTypeByTruthiness(type, expr, assumeTrue) {
52966                 if (isMatchingReference(reference, expr)) {
52967                     return getTypeWithFacts(type, assumeTrue ? 4194304 : 8388608);
52968                 }
52969                 if (strictNullChecks && assumeTrue && optionalChainContainsReference(expr, reference)) {
52970                     type = getTypeWithFacts(type, 2097152);
52971                 }
52972                 if (isMatchingReferenceDiscriminant(expr, type)) {
52973                     return narrowTypeByDiscriminant(type, expr, function (t) { return getTypeWithFacts(t, assumeTrue ? 4194304 : 8388608); });
52974                 }
52975                 return type;
52976             }
52977             function isTypePresencePossible(type, propName, assumeTrue) {
52978                 if (getIndexInfoOfType(type, 0)) {
52979                     return true;
52980                 }
52981                 var prop = getPropertyOfType(type, propName);
52982                 if (prop) {
52983                     return prop.flags & 16777216 ? true : assumeTrue;
52984                 }
52985                 return !assumeTrue;
52986             }
52987             function narrowByInKeyword(type, literal, assumeTrue) {
52988                 if (type.flags & (1048576 | 524288)
52989                     || isThisTypeParameter(type)
52990                     || type.flags & 2097152 && ts.every(type.types, function (t) { return t.symbol !== globalThisSymbol; })) {
52991                     var propName_1 = ts.escapeLeadingUnderscores(literal.text);
52992                     return filterType(type, function (t) { return isTypePresencePossible(t, propName_1, assumeTrue); });
52993                 }
52994                 return type;
52995             }
52996             function narrowTypeByBinaryExpression(type, expr, assumeTrue) {
52997                 switch (expr.operatorToken.kind) {
52998                     case 62:
52999                     case 74:
53000                     case 75:
53001                     case 76:
53002                         return narrowTypeByTruthiness(narrowType(type, expr.right, assumeTrue), expr.left, assumeTrue);
53003                     case 34:
53004                     case 35:
53005                     case 36:
53006                     case 37:
53007                         var operator_1 = expr.operatorToken.kind;
53008                         var left_1 = getReferenceCandidate(expr.left);
53009                         var right_1 = getReferenceCandidate(expr.right);
53010                         if (left_1.kind === 211 && ts.isStringLiteralLike(right_1)) {
53011                             return narrowTypeByTypeof(type, left_1, operator_1, right_1, assumeTrue);
53012                         }
53013                         if (right_1.kind === 211 && ts.isStringLiteralLike(left_1)) {
53014                             return narrowTypeByTypeof(type, right_1, operator_1, left_1, assumeTrue);
53015                         }
53016                         if (isMatchingReference(reference, left_1)) {
53017                             return narrowTypeByEquality(type, operator_1, right_1, assumeTrue);
53018                         }
53019                         if (isMatchingReference(reference, right_1)) {
53020                             return narrowTypeByEquality(type, operator_1, left_1, assumeTrue);
53021                         }
53022                         if (strictNullChecks) {
53023                             if (optionalChainContainsReference(left_1, reference)) {
53024                                 type = narrowTypeByOptionalChainContainment(type, operator_1, right_1, assumeTrue);
53025                             }
53026                             else if (optionalChainContainsReference(right_1, reference)) {
53027                                 type = narrowTypeByOptionalChainContainment(type, operator_1, left_1, assumeTrue);
53028                             }
53029                         }
53030                         if (isMatchingReferenceDiscriminant(left_1, type)) {
53031                             return narrowTypeByDiscriminant(type, left_1, function (t) { return narrowTypeByEquality(t, operator_1, right_1, assumeTrue); });
53032                         }
53033                         if (isMatchingReferenceDiscriminant(right_1, type)) {
53034                             return narrowTypeByDiscriminant(type, right_1, function (t) { return narrowTypeByEquality(t, operator_1, left_1, assumeTrue); });
53035                         }
53036                         if (isMatchingConstructorReference(left_1)) {
53037                             return narrowTypeByConstructor(type, operator_1, right_1, assumeTrue);
53038                         }
53039                         if (isMatchingConstructorReference(right_1)) {
53040                             return narrowTypeByConstructor(type, operator_1, left_1, assumeTrue);
53041                         }
53042                         break;
53043                     case 101:
53044                         return narrowTypeByInstanceof(type, expr, assumeTrue);
53045                     case 100:
53046                         var target = getReferenceCandidate(expr.right);
53047                         if (ts.isStringLiteralLike(expr.left) && isMatchingReference(reference, target)) {
53048                             return narrowByInKeyword(type, expr.left, assumeTrue);
53049                         }
53050                         break;
53051                     case 27:
53052                         return narrowType(type, expr.right, assumeTrue);
53053                 }
53054                 return type;
53055             }
53056             function narrowTypeByOptionalChainContainment(type, operator, value, assumeTrue) {
53057                 var equalsOperator = operator === 34 || operator === 36;
53058                 var nullableFlags = operator === 34 || operator === 35 ? 98304 : 32768;
53059                 var valueType = getTypeOfExpression(value);
53060                 var removeNullable = equalsOperator !== assumeTrue && everyType(valueType, function (t) { return !!(t.flags & nullableFlags); }) ||
53061                     equalsOperator === assumeTrue && everyType(valueType, function (t) { return !(t.flags & (3 | nullableFlags)); });
53062                 return removeNullable ? getTypeWithFacts(type, 2097152) : type;
53063             }
53064             function narrowTypeByEquality(type, operator, value, assumeTrue) {
53065                 if (type.flags & 1) {
53066                     return type;
53067                 }
53068                 if (operator === 35 || operator === 37) {
53069                     assumeTrue = !assumeTrue;
53070                 }
53071                 var valueType = getTypeOfExpression(value);
53072                 if ((type.flags & 2) && assumeTrue && (operator === 36 || operator === 37)) {
53073                     if (valueType.flags & (131068 | 67108864)) {
53074                         return valueType;
53075                     }
53076                     if (valueType.flags & 524288) {
53077                         return nonPrimitiveType;
53078                     }
53079                     return type;
53080                 }
53081                 if (valueType.flags & 98304) {
53082                     if (!strictNullChecks) {
53083                         return type;
53084                     }
53085                     var doubleEquals = operator === 34 || operator === 35;
53086                     var facts = doubleEquals ?
53087                         assumeTrue ? 262144 : 2097152 :
53088                         valueType.flags & 65536 ?
53089                             assumeTrue ? 131072 : 1048576 :
53090                             assumeTrue ? 65536 : 524288;
53091                     return getTypeWithFacts(type, facts);
53092                 }
53093                 if (assumeTrue) {
53094                     var filterFn = operator === 34 ?
53095                         (function (t) { return areTypesComparable(t, valueType) || isCoercibleUnderDoubleEquals(t, valueType); }) :
53096                         function (t) { return areTypesComparable(t, valueType); };
53097                     return replacePrimitivesWithLiterals(filterType(type, filterFn), valueType);
53098                 }
53099                 if (isUnitType(valueType)) {
53100                     var regularType_1 = getRegularTypeOfLiteralType(valueType);
53101                     return filterType(type, function (t) { return isUnitType(t) ? !areTypesComparable(t, valueType) : getRegularTypeOfLiteralType(t) !== regularType_1; });
53102                 }
53103                 return type;
53104             }
53105             function narrowTypeByTypeof(type, typeOfExpr, operator, literal, assumeTrue) {
53106                 if (operator === 35 || operator === 37) {
53107                     assumeTrue = !assumeTrue;
53108                 }
53109                 var target = getReferenceCandidate(typeOfExpr.expression);
53110                 if (!isMatchingReference(reference, target)) {
53111                     if (strictNullChecks && optionalChainContainsReference(target, reference) && assumeTrue === (literal.text !== "undefined")) {
53112                         return getTypeWithFacts(type, 2097152);
53113                     }
53114                     return type;
53115                 }
53116                 if (type.flags & 1 && literal.text === "function") {
53117                     return type;
53118                 }
53119                 if (assumeTrue && type.flags & 2 && literal.text === "object") {
53120                     if (typeOfExpr.parent.parent.kind === 216) {
53121                         var expr = typeOfExpr.parent.parent;
53122                         if (expr.operatorToken.kind === 55 && expr.right === typeOfExpr.parent && containsTruthyCheck(reference, expr.left)) {
53123                             return nonPrimitiveType;
53124                         }
53125                     }
53126                     return getUnionType([nonPrimitiveType, nullType]);
53127                 }
53128                 var facts = assumeTrue ?
53129                     typeofEQFacts.get(literal.text) || 128 :
53130                     typeofNEFacts.get(literal.text) || 32768;
53131                 var impliedType = getImpliedTypeFromTypeofGuard(type, literal.text);
53132                 return getTypeWithFacts(assumeTrue && impliedType ? mapType(type, narrowUnionMemberByTypeof(impliedType)) : type, facts);
53133             }
53134             function narrowTypeBySwitchOptionalChainContainment(type, switchStatement, clauseStart, clauseEnd, clauseCheck) {
53135                 var everyClauseChecks = clauseStart !== clauseEnd && ts.every(getSwitchClauseTypes(switchStatement).slice(clauseStart, clauseEnd), clauseCheck);
53136                 return everyClauseChecks ? getTypeWithFacts(type, 2097152) : type;
53137             }
53138             function narrowTypeBySwitchOnDiscriminant(type, switchStatement, clauseStart, clauseEnd) {
53139                 var switchTypes = getSwitchClauseTypes(switchStatement);
53140                 if (!switchTypes.length) {
53141                     return type;
53142                 }
53143                 var clauseTypes = switchTypes.slice(clauseStart, clauseEnd);
53144                 var hasDefaultClause = clauseStart === clauseEnd || ts.contains(clauseTypes, neverType);
53145                 if ((type.flags & 2) && !hasDefaultClause) {
53146                     var groundClauseTypes = void 0;
53147                     for (var i = 0; i < clauseTypes.length; i += 1) {
53148                         var t = clauseTypes[i];
53149                         if (t.flags & (131068 | 67108864)) {
53150                             if (groundClauseTypes !== undefined) {
53151                                 groundClauseTypes.push(t);
53152                             }
53153                         }
53154                         else if (t.flags & 524288) {
53155                             if (groundClauseTypes === undefined) {
53156                                 groundClauseTypes = clauseTypes.slice(0, i);
53157                             }
53158                             groundClauseTypes.push(nonPrimitiveType);
53159                         }
53160                         else {
53161                             return type;
53162                         }
53163                     }
53164                     return getUnionType(groundClauseTypes === undefined ? clauseTypes : groundClauseTypes);
53165                 }
53166                 var discriminantType = getUnionType(clauseTypes);
53167                 var caseType = discriminantType.flags & 131072 ? neverType :
53168                     replacePrimitivesWithLiterals(filterType(type, function (t) { return areTypesComparable(discriminantType, t); }), discriminantType);
53169                 if (!hasDefaultClause) {
53170                     return caseType;
53171                 }
53172                 var defaultType = filterType(type, function (t) { return !(isUnitType(t) && ts.contains(switchTypes, getRegularTypeOfLiteralType(t))); });
53173                 return caseType.flags & 131072 ? defaultType : getUnionType([caseType, defaultType]);
53174             }
53175             function getImpliedTypeFromTypeofGuard(type, text) {
53176                 switch (text) {
53177                     case "function":
53178                         return type.flags & 1 ? type : globalFunctionType;
53179                     case "object":
53180                         return type.flags & 2 ? getUnionType([nonPrimitiveType, nullType]) : type;
53181                     default:
53182                         return typeofTypesByName.get(text);
53183                 }
53184             }
53185             function narrowUnionMemberByTypeof(candidate) {
53186                 return function (type) {
53187                     if (isTypeSubtypeOf(type, candidate)) {
53188                         return type;
53189                     }
53190                     if (isTypeSubtypeOf(candidate, type)) {
53191                         return candidate;
53192                     }
53193                     if (type.flags & 465829888) {
53194                         var constraint = getBaseConstraintOfType(type) || anyType;
53195                         if (isTypeSubtypeOf(candidate, constraint)) {
53196                             return getIntersectionType([type, candidate]);
53197                         }
53198                     }
53199                     return type;
53200                 };
53201             }
53202             function narrowBySwitchOnTypeOf(type, switchStatement, clauseStart, clauseEnd) {
53203                 var switchWitnesses = getSwitchClauseTypeOfWitnesses(switchStatement, true);
53204                 if (!switchWitnesses.length) {
53205                     return type;
53206                 }
53207                 var defaultCaseLocation = ts.findIndex(switchWitnesses, function (elem) { return elem === undefined; });
53208                 var hasDefaultClause = clauseStart === clauseEnd || (defaultCaseLocation >= clauseStart && defaultCaseLocation < clauseEnd);
53209                 var clauseWitnesses;
53210                 var switchFacts;
53211                 if (defaultCaseLocation > -1) {
53212                     var witnesses = switchWitnesses.filter(function (witness) { return witness !== undefined; });
53213                     var fixedClauseStart = defaultCaseLocation < clauseStart ? clauseStart - 1 : clauseStart;
53214                     var fixedClauseEnd = defaultCaseLocation < clauseEnd ? clauseEnd - 1 : clauseEnd;
53215                     clauseWitnesses = witnesses.slice(fixedClauseStart, fixedClauseEnd);
53216                     switchFacts = getFactsFromTypeofSwitch(fixedClauseStart, fixedClauseEnd, witnesses, hasDefaultClause);
53217                 }
53218                 else {
53219                     clauseWitnesses = switchWitnesses.slice(clauseStart, clauseEnd);
53220                     switchFacts = getFactsFromTypeofSwitch(clauseStart, clauseEnd, switchWitnesses, hasDefaultClause);
53221                 }
53222                 if (hasDefaultClause) {
53223                     return filterType(type, function (t) { return (getTypeFacts(t) & switchFacts) === switchFacts; });
53224                 }
53225                 var impliedType = getTypeWithFacts(getUnionType(clauseWitnesses.map(function (text) { return getImpliedTypeFromTypeofGuard(type, text) || type; })), switchFacts);
53226                 return getTypeWithFacts(mapType(type, narrowUnionMemberByTypeof(impliedType)), switchFacts);
53227             }
53228             function isMatchingConstructorReference(expr) {
53229                 return (ts.isPropertyAccessExpression(expr) && ts.idText(expr.name) === "constructor" ||
53230                     ts.isElementAccessExpression(expr) && ts.isStringLiteralLike(expr.argumentExpression) && expr.argumentExpression.text === "constructor") &&
53231                     isMatchingReference(reference, expr.expression);
53232             }
53233             function narrowTypeByConstructor(type, operator, identifier, assumeTrue) {
53234                 if (assumeTrue ? (operator !== 34 && operator !== 36) : (operator !== 35 && operator !== 37)) {
53235                     return type;
53236                 }
53237                 var identifierType = getTypeOfExpression(identifier);
53238                 if (!isFunctionType(identifierType) && !isConstructorType(identifierType)) {
53239                     return type;
53240                 }
53241                 var prototypeProperty = getPropertyOfType(identifierType, "prototype");
53242                 if (!prototypeProperty) {
53243                     return type;
53244                 }
53245                 var prototypeType = getTypeOfSymbol(prototypeProperty);
53246                 var candidate = !isTypeAny(prototypeType) ? prototypeType : undefined;
53247                 if (!candidate || candidate === globalObjectType || candidate === globalFunctionType) {
53248                     return type;
53249                 }
53250                 if (isTypeAny(type)) {
53251                     return candidate;
53252                 }
53253                 return filterType(type, function (t) { return isConstructedBy(t, candidate); });
53254                 function isConstructedBy(source, target) {
53255                     if (source.flags & 524288 && ts.getObjectFlags(source) & 1 ||
53256                         target.flags & 524288 && ts.getObjectFlags(target) & 1) {
53257                         return source.symbol === target.symbol;
53258                     }
53259                     return isTypeSubtypeOf(source, target);
53260                 }
53261             }
53262             function narrowTypeByInstanceof(type, expr, assumeTrue) {
53263                 var left = getReferenceCandidate(expr.left);
53264                 if (!isMatchingReference(reference, left)) {
53265                     if (assumeTrue && strictNullChecks && optionalChainContainsReference(left, reference)) {
53266                         return getTypeWithFacts(type, 2097152);
53267                     }
53268                     return type;
53269                 }
53270                 var rightType = getTypeOfExpression(expr.right);
53271                 if (!isTypeDerivedFrom(rightType, globalFunctionType)) {
53272                     return type;
53273                 }
53274                 var targetType;
53275                 var prototypeProperty = getPropertyOfType(rightType, "prototype");
53276                 if (prototypeProperty) {
53277                     var prototypePropertyType = getTypeOfSymbol(prototypeProperty);
53278                     if (!isTypeAny(prototypePropertyType)) {
53279                         targetType = prototypePropertyType;
53280                     }
53281                 }
53282                 if (isTypeAny(type) && (targetType === globalObjectType || targetType === globalFunctionType)) {
53283                     return type;
53284                 }
53285                 if (!targetType) {
53286                     var constructSignatures = getSignaturesOfType(rightType, 1);
53287                     targetType = constructSignatures.length ?
53288                         getUnionType(ts.map(constructSignatures, function (signature) { return getReturnTypeOfSignature(getErasedSignature(signature)); })) :
53289                         emptyObjectType;
53290                 }
53291                 if (!assumeTrue && rightType.flags & 1048576) {
53292                     var nonConstructorTypeInUnion = ts.find(rightType.types, function (t) { return !isConstructorType(t); });
53293                     if (!nonConstructorTypeInUnion)
53294                         return type;
53295                 }
53296                 return getNarrowedType(type, targetType, assumeTrue, isTypeDerivedFrom);
53297             }
53298             function getNarrowedType(type, candidate, assumeTrue, isRelated) {
53299                 if (!assumeTrue) {
53300                     return filterType(type, function (t) { return !isRelated(t, candidate); });
53301                 }
53302                 if (type.flags & 1048576) {
53303                     var assignableType = filterType(type, function (t) { return isRelated(t, candidate); });
53304                     if (!(assignableType.flags & 131072)) {
53305                         return assignableType;
53306                     }
53307                 }
53308                 return isTypeSubtypeOf(candidate, type) ? candidate : isTypeSubtypeOf(type, candidate) ? type : getIntersectionType([type, candidate]);
53309             }
53310             function narrowTypeByCallExpression(type, callExpression, assumeTrue) {
53311                 if (hasMatchingArgument(callExpression, reference)) {
53312                     var signature = assumeTrue || !ts.isCallChain(callExpression) ? getEffectsSignature(callExpression) : undefined;
53313                     var predicate = signature && getTypePredicateOfSignature(signature);
53314                     if (predicate && (predicate.kind === 0 || predicate.kind === 1)) {
53315                         return narrowTypeByTypePredicate(type, predicate, callExpression, assumeTrue);
53316                     }
53317                 }
53318                 return type;
53319             }
53320             function narrowTypeByTypePredicate(type, predicate, callExpression, assumeTrue) {
53321                 if (predicate.type && !(isTypeAny(type) && (predicate.type === globalObjectType || predicate.type === globalFunctionType))) {
53322                     var predicateArgument = getTypePredicateArgument(predicate, callExpression);
53323                     if (predicateArgument) {
53324                         if (isMatchingReference(reference, predicateArgument)) {
53325                             return getNarrowedType(type, predicate.type, assumeTrue, isTypeSubtypeOf);
53326                         }
53327                         if (strictNullChecks && assumeTrue && optionalChainContainsReference(predicateArgument, reference) &&
53328                             !(getTypeFacts(predicate.type) & 65536)) {
53329                             type = getTypeWithFacts(type, 2097152);
53330                         }
53331                         if (isMatchingReferenceDiscriminant(predicateArgument, type)) {
53332                             return narrowTypeByDiscriminant(type, predicateArgument, function (t) { return getNarrowedType(t, predicate.type, assumeTrue, isTypeSubtypeOf); });
53333                         }
53334                     }
53335                 }
53336                 return type;
53337             }
53338             function narrowType(type, expr, assumeTrue) {
53339                 if (ts.isExpressionOfOptionalChainRoot(expr) ||
53340                     ts.isBinaryExpression(expr.parent) && expr.parent.operatorToken.kind === 60 && expr.parent.left === expr) {
53341                     return narrowTypeByOptionality(type, expr, assumeTrue);
53342                 }
53343                 switch (expr.kind) {
53344                     case 78:
53345                     case 107:
53346                     case 105:
53347                     case 201:
53348                     case 202:
53349                         return narrowTypeByTruthiness(type, expr, assumeTrue);
53350                     case 203:
53351                         return narrowTypeByCallExpression(type, expr, assumeTrue);
53352                     case 207:
53353                     case 225:
53354                         return narrowType(type, expr.expression, assumeTrue);
53355                     case 216:
53356                         return narrowTypeByBinaryExpression(type, expr, assumeTrue);
53357                     case 214:
53358                         if (expr.operator === 53) {
53359                             return narrowType(type, expr.operand, !assumeTrue);
53360                         }
53361                         break;
53362                 }
53363                 return type;
53364             }
53365             function narrowTypeByOptionality(type, expr, assumePresent) {
53366                 if (isMatchingReference(reference, expr)) {
53367                     return getTypeWithFacts(type, assumePresent ? 2097152 : 262144);
53368                 }
53369                 if (isMatchingReferenceDiscriminant(expr, type)) {
53370                     return narrowTypeByDiscriminant(type, expr, function (t) { return getTypeWithFacts(t, assumePresent ? 2097152 : 262144); });
53371                 }
53372                 return type;
53373             }
53374         }
53375         function getTypeOfSymbolAtLocation(symbol, location) {
53376             symbol = symbol.exportSymbol || symbol;
53377             if (location.kind === 78) {
53378                 if (ts.isRightSideOfQualifiedNameOrPropertyAccess(location)) {
53379                     location = location.parent;
53380                 }
53381                 if (ts.isExpressionNode(location) && !ts.isAssignmentTarget(location)) {
53382                     var type = getTypeOfExpression(location);
53383                     if (getExportSymbolOfValueSymbolIfExported(getNodeLinks(location).resolvedSymbol) === symbol) {
53384                         return type;
53385                     }
53386                 }
53387             }
53388             return getTypeOfSymbol(symbol);
53389         }
53390         function getControlFlowContainer(node) {
53391             return ts.findAncestor(node.parent, function (node) {
53392                 return ts.isFunctionLike(node) && !ts.getImmediatelyInvokedFunctionExpression(node) ||
53393                     node.kind === 257 ||
53394                     node.kind === 297 ||
53395                     node.kind === 163;
53396             });
53397         }
53398         function isParameterAssigned(symbol) {
53399             var func = ts.getRootDeclaration(symbol.valueDeclaration).parent;
53400             var links = getNodeLinks(func);
53401             if (!(links.flags & 8388608)) {
53402                 links.flags |= 8388608;
53403                 if (!hasParentWithAssignmentsMarked(func)) {
53404                     markParameterAssignments(func);
53405                 }
53406             }
53407             return symbol.isAssigned || false;
53408         }
53409         function hasParentWithAssignmentsMarked(node) {
53410             return !!ts.findAncestor(node.parent, function (node) { return ts.isFunctionLike(node) && !!(getNodeLinks(node).flags & 8388608); });
53411         }
53412         function markParameterAssignments(node) {
53413             if (node.kind === 78) {
53414                 if (ts.isAssignmentTarget(node)) {
53415                     var symbol = getResolvedSymbol(node);
53416                     if (symbol.valueDeclaration && ts.getRootDeclaration(symbol.valueDeclaration).kind === 160) {
53417                         symbol.isAssigned = true;
53418                     }
53419                 }
53420             }
53421             else {
53422                 ts.forEachChild(node, markParameterAssignments);
53423             }
53424         }
53425         function isConstVariable(symbol) {
53426             return symbol.flags & 3 && (getDeclarationNodeFlagsFromSymbol(symbol) & 2) !== 0 && getTypeOfSymbol(symbol) !== autoArrayType;
53427         }
53428         function removeOptionalityFromDeclaredType(declaredType, declaration) {
53429             if (pushTypeResolution(declaration.symbol, 2)) {
53430                 var annotationIncludesUndefined = strictNullChecks &&
53431                     declaration.kind === 160 &&
53432                     declaration.initializer &&
53433                     getFalsyFlags(declaredType) & 32768 &&
53434                     !(getFalsyFlags(checkExpression(declaration.initializer)) & 32768);
53435                 popTypeResolution();
53436                 return annotationIncludesUndefined ? getTypeWithFacts(declaredType, 524288) : declaredType;
53437             }
53438             else {
53439                 reportCircularityError(declaration.symbol);
53440                 return declaredType;
53441             }
53442         }
53443         function isConstraintPosition(node) {
53444             var parent = node.parent;
53445             return parent.kind === 201 ||
53446                 parent.kind === 203 && parent.expression === node ||
53447                 parent.kind === 202 && parent.expression === node ||
53448                 parent.kind === 198 && parent.name === node && !!parent.initializer;
53449         }
53450         function typeHasNullableConstraint(type) {
53451             return type.flags & 58982400 && maybeTypeOfKind(getBaseConstraintOfType(type) || unknownType, 98304);
53452         }
53453         function getConstraintForLocation(type, node) {
53454             if (type && isConstraintPosition(node) && forEachType(type, typeHasNullableConstraint)) {
53455                 return mapType(getWidenedType(type), getBaseConstraintOrType);
53456             }
53457             return type;
53458         }
53459         function isExportOrExportExpression(location) {
53460             return !!ts.findAncestor(location, function (e) { return e.parent && ts.isExportAssignment(e.parent) && e.parent.expression === e && ts.isEntityNameExpression(e); });
53461         }
53462         function markAliasReferenced(symbol, location) {
53463             if (isNonLocalAlias(symbol, 111551) && !isInTypeQuery(location) && !getTypeOnlyAliasDeclaration(symbol)) {
53464                 if (compilerOptions.preserveConstEnums && isExportOrExportExpression(location) || !isConstEnumOrConstEnumOnlyModule(resolveAlias(symbol))) {
53465                     markAliasSymbolAsReferenced(symbol);
53466                 }
53467                 else {
53468                     markConstEnumAliasAsReferenced(symbol);
53469                 }
53470             }
53471         }
53472         function checkIdentifier(node) {
53473             var symbol = getResolvedSymbol(node);
53474             if (symbol === unknownSymbol) {
53475                 return errorType;
53476             }
53477             if (symbol === argumentsSymbol) {
53478                 var container = ts.getContainingFunction(node);
53479                 if (languageVersion < 2) {
53480                     if (container.kind === 209) {
53481                         error(node, ts.Diagnostics.The_arguments_object_cannot_be_referenced_in_an_arrow_function_in_ES3_and_ES5_Consider_using_a_standard_function_expression);
53482                     }
53483                     else if (ts.hasSyntacticModifier(container, 256)) {
53484                         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);
53485                     }
53486                 }
53487                 getNodeLinks(container).flags |= 8192;
53488                 return getTypeOfSymbol(symbol);
53489             }
53490             if (!(node.parent && ts.isPropertyAccessExpression(node.parent) && node.parent.expression === node)) {
53491                 markAliasReferenced(symbol, node);
53492             }
53493             var localOrExportSymbol = getExportSymbolOfValueSymbolIfExported(symbol);
53494             var sourceSymbol = localOrExportSymbol.flags & 2097152 ? resolveAlias(localOrExportSymbol) : localOrExportSymbol;
53495             if (getDeclarationNodeFlagsFromSymbol(sourceSymbol) & 134217728 && isUncalledFunctionReference(node.parent, sourceSymbol)) {
53496                 errorOrSuggestion(false, node, ts.Diagnostics._0_is_deprecated, node.escapedText);
53497             }
53498             var declaration = localOrExportSymbol.valueDeclaration;
53499             if (localOrExportSymbol.flags & 32) {
53500                 if (declaration.kind === 252
53501                     && ts.nodeIsDecorated(declaration)) {
53502                     var container = ts.getContainingClass(node);
53503                     while (container !== undefined) {
53504                         if (container === declaration && container.name !== node) {
53505                             getNodeLinks(declaration).flags |= 16777216;
53506                             getNodeLinks(node).flags |= 33554432;
53507                             break;
53508                         }
53509                         container = ts.getContainingClass(container);
53510                     }
53511                 }
53512                 else if (declaration.kind === 221) {
53513                     var container = ts.getThisContainer(node, false);
53514                     while (container.kind !== 297) {
53515                         if (container.parent === declaration) {
53516                             if (container.kind === 163 && ts.hasSyntacticModifier(container, 32)) {
53517                                 getNodeLinks(declaration).flags |= 16777216;
53518                                 getNodeLinks(node).flags |= 33554432;
53519                             }
53520                             break;
53521                         }
53522                         container = ts.getThisContainer(container, false);
53523                     }
53524                 }
53525             }
53526             checkNestedBlockScopedBinding(node, symbol);
53527             var type = getConstraintForLocation(getTypeOfSymbol(localOrExportSymbol), node);
53528             var assignmentKind = ts.getAssignmentTargetKind(node);
53529             if (assignmentKind) {
53530                 if (!(localOrExportSymbol.flags & 3) &&
53531                     !(ts.isInJSFile(node) && localOrExportSymbol.flags & 512)) {
53532                     error(node, ts.Diagnostics.Cannot_assign_to_0_because_it_is_not_a_variable, symbolToString(symbol));
53533                     return errorType;
53534                 }
53535                 if (isReadonlySymbol(localOrExportSymbol)) {
53536                     if (localOrExportSymbol.flags & 3) {
53537                         error(node, ts.Diagnostics.Cannot_assign_to_0_because_it_is_a_constant, symbolToString(symbol));
53538                     }
53539                     else {
53540                         error(node, ts.Diagnostics.Cannot_assign_to_0_because_it_is_a_read_only_property, symbolToString(symbol));
53541                     }
53542                     return errorType;
53543                 }
53544             }
53545             var isAlias = localOrExportSymbol.flags & 2097152;
53546             if (localOrExportSymbol.flags & 3) {
53547                 if (assignmentKind === 1) {
53548                     return type;
53549                 }
53550             }
53551             else if (isAlias) {
53552                 declaration = ts.find(symbol.declarations, isSomeImportDeclaration);
53553             }
53554             else {
53555                 return type;
53556             }
53557             if (!declaration) {
53558                 return type;
53559             }
53560             var isParameter = ts.getRootDeclaration(declaration).kind === 160;
53561             var declarationContainer = getControlFlowContainer(declaration);
53562             var flowContainer = getControlFlowContainer(node);
53563             var isOuterVariable = flowContainer !== declarationContainer;
53564             var isSpreadDestructuringAssignmentTarget = node.parent && node.parent.parent && ts.isSpreadAssignment(node.parent) && isDestructuringAssignmentTarget(node.parent.parent);
53565             var isModuleExports = symbol.flags & 134217728;
53566             while (flowContainer !== declarationContainer && (flowContainer.kind === 208 ||
53567                 flowContainer.kind === 209 || ts.isObjectLiteralOrClassExpressionMethod(flowContainer)) &&
53568                 (isConstVariable(localOrExportSymbol) || isParameter && !isParameterAssigned(localOrExportSymbol))) {
53569                 flowContainer = getControlFlowContainer(flowContainer);
53570             }
53571             var assumeInitialized = isParameter || isAlias || isOuterVariable || isSpreadDestructuringAssignmentTarget || isModuleExports || ts.isBindingElement(declaration) ||
53572                 type !== autoType && type !== autoArrayType && (!strictNullChecks || (type.flags & (3 | 16384)) !== 0 ||
53573                     isInTypeQuery(node) || node.parent.kind === 270) ||
53574                 node.parent.kind === 225 ||
53575                 declaration.kind === 249 && declaration.exclamationToken ||
53576                 declaration.flags & 8388608;
53577             var initialType = assumeInitialized ? (isParameter ? removeOptionalityFromDeclaredType(type, declaration) : type) :
53578                 type === autoType || type === autoArrayType ? undefinedType :
53579                     getOptionalType(type);
53580             var flowType = getFlowTypeOfReference(node, type, initialType, flowContainer, !assumeInitialized);
53581             if (!isEvolvingArrayOperationTarget(node) && (type === autoType || type === autoArrayType)) {
53582                 if (flowType === autoType || flowType === autoArrayType) {
53583                     if (noImplicitAny) {
53584                         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));
53585                         error(node, ts.Diagnostics.Variable_0_implicitly_has_an_1_type, symbolToString(symbol), typeToString(flowType));
53586                     }
53587                     return convertAutoToAny(flowType);
53588                 }
53589             }
53590             else if (!assumeInitialized && !(getFalsyFlags(type) & 32768) && getFalsyFlags(flowType) & 32768) {
53591                 error(node, ts.Diagnostics.Variable_0_is_used_before_being_assigned, symbolToString(symbol));
53592                 return type;
53593             }
53594             return assignmentKind ? getBaseTypeOfLiteralType(flowType) : flowType;
53595         }
53596         function isInsideFunction(node, threshold) {
53597             return !!ts.findAncestor(node, function (n) { return n === threshold ? "quit" : ts.isFunctionLike(n); });
53598         }
53599         function getPartOfForStatementContainingNode(node, container) {
53600             return ts.findAncestor(node, function (n) { return n === container ? "quit" : n === container.initializer || n === container.condition || n === container.incrementor || n === container.statement; });
53601         }
53602         function checkNestedBlockScopedBinding(node, symbol) {
53603             if (languageVersion >= 2 ||
53604                 (symbol.flags & (2 | 32)) === 0 ||
53605                 ts.isSourceFile(symbol.valueDeclaration) ||
53606                 symbol.valueDeclaration.parent.kind === 287) {
53607                 return;
53608             }
53609             var container = ts.getEnclosingBlockScopeContainer(symbol.valueDeclaration);
53610             var usedInFunction = isInsideFunction(node.parent, container);
53611             var current = container;
53612             var containedInIterationStatement = false;
53613             while (current && !ts.nodeStartsNewLexicalEnvironment(current)) {
53614                 if (ts.isIterationStatement(current, false)) {
53615                     containedInIterationStatement = true;
53616                     break;
53617                 }
53618                 current = current.parent;
53619             }
53620             if (containedInIterationStatement) {
53621                 if (usedInFunction) {
53622                     var capturesBlockScopeBindingInLoopBody = true;
53623                     if (ts.isForStatement(container)) {
53624                         var varDeclList = ts.getAncestor(symbol.valueDeclaration, 250);
53625                         if (varDeclList && varDeclList.parent === container) {
53626                             var part = getPartOfForStatementContainingNode(node.parent, container);
53627                             if (part) {
53628                                 var links = getNodeLinks(part);
53629                                 links.flags |= 131072;
53630                                 var capturedBindings = links.capturedBlockScopeBindings || (links.capturedBlockScopeBindings = []);
53631                                 ts.pushIfUnique(capturedBindings, symbol);
53632                                 if (part === container.initializer) {
53633                                     capturesBlockScopeBindingInLoopBody = false;
53634                                 }
53635                             }
53636                         }
53637                     }
53638                     if (capturesBlockScopeBindingInLoopBody) {
53639                         getNodeLinks(current).flags |= 65536;
53640                     }
53641                 }
53642                 if (ts.isForStatement(container)) {
53643                     var varDeclList = ts.getAncestor(symbol.valueDeclaration, 250);
53644                     if (varDeclList && varDeclList.parent === container && isAssignedInBodyOfForStatement(node, container)) {
53645                         getNodeLinks(symbol.valueDeclaration).flags |= 4194304;
53646                     }
53647                 }
53648                 getNodeLinks(symbol.valueDeclaration).flags |= 524288;
53649             }
53650             if (usedInFunction) {
53651                 getNodeLinks(symbol.valueDeclaration).flags |= 262144;
53652             }
53653         }
53654         function isBindingCapturedByNode(node, decl) {
53655             var links = getNodeLinks(node);
53656             return !!links && ts.contains(links.capturedBlockScopeBindings, getSymbolOfNode(decl));
53657         }
53658         function isAssignedInBodyOfForStatement(node, container) {
53659             var current = node;
53660             while (current.parent.kind === 207) {
53661                 current = current.parent;
53662             }
53663             var isAssigned = false;
53664             if (ts.isAssignmentTarget(current)) {
53665                 isAssigned = true;
53666             }
53667             else if ((current.parent.kind === 214 || current.parent.kind === 215)) {
53668                 var expr = current.parent;
53669                 isAssigned = expr.operator === 45 || expr.operator === 46;
53670             }
53671             if (!isAssigned) {
53672                 return false;
53673             }
53674             return !!ts.findAncestor(current, function (n) { return n === container ? "quit" : n === container.statement; });
53675         }
53676         function captureLexicalThis(node, container) {
53677             getNodeLinks(node).flags |= 2;
53678             if (container.kind === 163 || container.kind === 166) {
53679                 var classNode = container.parent;
53680                 getNodeLinks(classNode).flags |= 4;
53681             }
53682             else {
53683                 getNodeLinks(container).flags |= 4;
53684             }
53685         }
53686         function findFirstSuperCall(node) {
53687             return ts.isSuperCall(node) ? node :
53688                 ts.isFunctionLike(node) ? undefined :
53689                     ts.forEachChild(node, findFirstSuperCall);
53690         }
53691         function classDeclarationExtendsNull(classDecl) {
53692             var classSymbol = getSymbolOfNode(classDecl);
53693             var classInstanceType = getDeclaredTypeOfSymbol(classSymbol);
53694             var baseConstructorType = getBaseConstructorTypeOfClass(classInstanceType);
53695             return baseConstructorType === nullWideningType;
53696         }
53697         function checkThisBeforeSuper(node, container, diagnosticMessage) {
53698             var containingClassDecl = container.parent;
53699             var baseTypeNode = ts.getClassExtendsHeritageElement(containingClassDecl);
53700             if (baseTypeNode && !classDeclarationExtendsNull(containingClassDecl)) {
53701                 if (node.flowNode && !isPostSuperFlowNode(node.flowNode, false)) {
53702                     error(node, diagnosticMessage);
53703                 }
53704             }
53705         }
53706         function checkThisExpression(node) {
53707             var container = ts.getThisContainer(node, true);
53708             var capturedByArrowFunction = false;
53709             if (container.kind === 166) {
53710                 checkThisBeforeSuper(node, container, ts.Diagnostics.super_must_be_called_before_accessing_this_in_the_constructor_of_a_derived_class);
53711             }
53712             if (container.kind === 209) {
53713                 container = ts.getThisContainer(container, false);
53714                 capturedByArrowFunction = true;
53715             }
53716             switch (container.kind) {
53717                 case 256:
53718                     error(node, ts.Diagnostics.this_cannot_be_referenced_in_a_module_or_namespace_body);
53719                     break;
53720                 case 255:
53721                     error(node, ts.Diagnostics.this_cannot_be_referenced_in_current_location);
53722                     break;
53723                 case 166:
53724                     if (isInConstructorArgumentInitializer(node, container)) {
53725                         error(node, ts.Diagnostics.this_cannot_be_referenced_in_constructor_arguments);
53726                     }
53727                     break;
53728                 case 163:
53729                 case 162:
53730                     if (ts.hasSyntacticModifier(container, 32) && !(compilerOptions.target === 99 && compilerOptions.useDefineForClassFields)) {
53731                         error(node, ts.Diagnostics.this_cannot_be_referenced_in_a_static_property_initializer);
53732                     }
53733                     break;
53734                 case 158:
53735                     error(node, ts.Diagnostics.this_cannot_be_referenced_in_a_computed_property_name);
53736                     break;
53737             }
53738             if (capturedByArrowFunction && languageVersion < 2) {
53739                 captureLexicalThis(node, container);
53740             }
53741             var type = tryGetThisTypeAt(node, true, container);
53742             if (noImplicitThis) {
53743                 var globalThisType_1 = getTypeOfSymbol(globalThisSymbol);
53744                 if (type === globalThisType_1 && capturedByArrowFunction) {
53745                     error(node, ts.Diagnostics.The_containing_arrow_function_captures_the_global_value_of_this);
53746                 }
53747                 else if (!type) {
53748                     var diag = error(node, ts.Diagnostics.this_implicitly_has_type_any_because_it_does_not_have_a_type_annotation);
53749                     if (!ts.isSourceFile(container)) {
53750                         var outsideThis = tryGetThisTypeAt(container);
53751                         if (outsideThis && outsideThis !== globalThisType_1) {
53752                             ts.addRelatedInfo(diag, ts.createDiagnosticForNode(container, ts.Diagnostics.An_outer_value_of_this_is_shadowed_by_this_container));
53753                         }
53754                     }
53755                 }
53756             }
53757             return type || anyType;
53758         }
53759         function tryGetThisTypeAt(node, includeGlobalThis, container) {
53760             if (includeGlobalThis === void 0) { includeGlobalThis = true; }
53761             if (container === void 0) { container = ts.getThisContainer(node, false); }
53762             var isInJS = ts.isInJSFile(node);
53763             if (ts.isFunctionLike(container) &&
53764                 (!isInParameterInitializerBeforeContainingFunction(node) || ts.getThisParameter(container))) {
53765                 var thisType = getThisTypeOfDeclaration(container) || isInJS && getTypeForThisExpressionFromJSDoc(container);
53766                 if (!thisType) {
53767                     var className = getClassNameFromPrototypeMethod(container);
53768                     if (isInJS && className) {
53769                         var classSymbol = checkExpression(className).symbol;
53770                         if (classSymbol && classSymbol.members && (classSymbol.flags & 16)) {
53771                             thisType = getDeclaredTypeOfSymbol(classSymbol).thisType;
53772                         }
53773                     }
53774                     else if (isJSConstructor(container)) {
53775                         thisType = getDeclaredTypeOfSymbol(getMergedSymbol(container.symbol)).thisType;
53776                     }
53777                     thisType || (thisType = getContextualThisParameterType(container));
53778                 }
53779                 if (thisType) {
53780                     return getFlowTypeOfReference(node, thisType);
53781                 }
53782             }
53783             if (ts.isClassLike(container.parent)) {
53784                 var symbol = getSymbolOfNode(container.parent);
53785                 var type = ts.hasSyntacticModifier(container, 32) ? getTypeOfSymbol(symbol) : getDeclaredTypeOfSymbol(symbol).thisType;
53786                 return getFlowTypeOfReference(node, type);
53787             }
53788             if (ts.isSourceFile(container)) {
53789                 if (container.commonJsModuleIndicator) {
53790                     var fileSymbol = getSymbolOfNode(container);
53791                     return fileSymbol && getTypeOfSymbol(fileSymbol);
53792                 }
53793                 else if (container.externalModuleIndicator) {
53794                     return undefinedType;
53795                 }
53796                 else if (includeGlobalThis) {
53797                     return getTypeOfSymbol(globalThisSymbol);
53798                 }
53799             }
53800         }
53801         function getExplicitThisType(node) {
53802             var container = ts.getThisContainer(node, false);
53803             if (ts.isFunctionLike(container)) {
53804                 var signature = getSignatureFromDeclaration(container);
53805                 if (signature.thisParameter) {
53806                     return getExplicitTypeOfSymbol(signature.thisParameter);
53807                 }
53808             }
53809             if (ts.isClassLike(container.parent)) {
53810                 var symbol = getSymbolOfNode(container.parent);
53811                 return ts.hasSyntacticModifier(container, 32) ? getTypeOfSymbol(symbol) : getDeclaredTypeOfSymbol(symbol).thisType;
53812             }
53813         }
53814         function getClassNameFromPrototypeMethod(container) {
53815             if (container.kind === 208 &&
53816                 ts.isBinaryExpression(container.parent) &&
53817                 ts.getAssignmentDeclarationKind(container.parent) === 3) {
53818                 return container.parent
53819                     .left
53820                     .expression
53821                     .expression;
53822             }
53823             else if (container.kind === 165 &&
53824                 container.parent.kind === 200 &&
53825                 ts.isBinaryExpression(container.parent.parent) &&
53826                 ts.getAssignmentDeclarationKind(container.parent.parent) === 6) {
53827                 return container.parent.parent.left.expression;
53828             }
53829             else if (container.kind === 208 &&
53830                 container.parent.kind === 288 &&
53831                 container.parent.parent.kind === 200 &&
53832                 ts.isBinaryExpression(container.parent.parent.parent) &&
53833                 ts.getAssignmentDeclarationKind(container.parent.parent.parent) === 6) {
53834                 return container.parent.parent.parent.left.expression;
53835             }
53836             else if (container.kind === 208 &&
53837                 ts.isPropertyAssignment(container.parent) &&
53838                 ts.isIdentifier(container.parent.name) &&
53839                 (container.parent.name.escapedText === "value" || container.parent.name.escapedText === "get" || container.parent.name.escapedText === "set") &&
53840                 ts.isObjectLiteralExpression(container.parent.parent) &&
53841                 ts.isCallExpression(container.parent.parent.parent) &&
53842                 container.parent.parent.parent.arguments[2] === container.parent.parent &&
53843                 ts.getAssignmentDeclarationKind(container.parent.parent.parent) === 9) {
53844                 return container.parent.parent.parent.arguments[0].expression;
53845             }
53846             else if (ts.isMethodDeclaration(container) &&
53847                 ts.isIdentifier(container.name) &&
53848                 (container.name.escapedText === "value" || container.name.escapedText === "get" || container.name.escapedText === "set") &&
53849                 ts.isObjectLiteralExpression(container.parent) &&
53850                 ts.isCallExpression(container.parent.parent) &&
53851                 container.parent.parent.arguments[2] === container.parent &&
53852                 ts.getAssignmentDeclarationKind(container.parent.parent) === 9) {
53853                 return container.parent.parent.arguments[0].expression;
53854             }
53855         }
53856         function getTypeForThisExpressionFromJSDoc(node) {
53857             var jsdocType = ts.getJSDocType(node);
53858             if (jsdocType && jsdocType.kind === 308) {
53859                 var jsDocFunctionType = jsdocType;
53860                 if (jsDocFunctionType.parameters.length > 0 &&
53861                     jsDocFunctionType.parameters[0].name &&
53862                     jsDocFunctionType.parameters[0].name.escapedText === "this") {
53863                     return getTypeFromTypeNode(jsDocFunctionType.parameters[0].type);
53864                 }
53865             }
53866             var thisTag = ts.getJSDocThisTag(node);
53867             if (thisTag && thisTag.typeExpression) {
53868                 return getTypeFromTypeNode(thisTag.typeExpression);
53869             }
53870         }
53871         function isInConstructorArgumentInitializer(node, constructorDecl) {
53872             return !!ts.findAncestor(node, function (n) { return ts.isFunctionLikeDeclaration(n) ? "quit" : n.kind === 160 && n.parent === constructorDecl; });
53873         }
53874         function checkSuperExpression(node) {
53875             var isCallExpression = node.parent.kind === 203 && node.parent.expression === node;
53876             var immediateContainer = ts.getSuperContainer(node, true);
53877             var container = immediateContainer;
53878             var needToCaptureLexicalThis = false;
53879             if (!isCallExpression) {
53880                 while (container && container.kind === 209) {
53881                     container = ts.getSuperContainer(container, true);
53882                     needToCaptureLexicalThis = languageVersion < 2;
53883                 }
53884             }
53885             var canUseSuperExpression = isLegalUsageOfSuperExpression(container);
53886             var nodeCheckFlag = 0;
53887             if (!canUseSuperExpression) {
53888                 var current = ts.findAncestor(node, function (n) { return n === container ? "quit" : n.kind === 158; });
53889                 if (current && current.kind === 158) {
53890                     error(node, ts.Diagnostics.super_cannot_be_referenced_in_a_computed_property_name);
53891                 }
53892                 else if (isCallExpression) {
53893                     error(node, ts.Diagnostics.Super_calls_are_not_permitted_outside_constructors_or_in_nested_functions_inside_constructors);
53894                 }
53895                 else if (!container || !container.parent || !(ts.isClassLike(container.parent) || container.parent.kind === 200)) {
53896                     error(node, ts.Diagnostics.super_can_only_be_referenced_in_members_of_derived_classes_or_object_literal_expressions);
53897                 }
53898                 else {
53899                     error(node, ts.Diagnostics.super_property_access_is_permitted_only_in_a_constructor_member_function_or_member_accessor_of_a_derived_class);
53900                 }
53901                 return errorType;
53902             }
53903             if (!isCallExpression && immediateContainer.kind === 166) {
53904                 checkThisBeforeSuper(node, container, ts.Diagnostics.super_must_be_called_before_accessing_a_property_of_super_in_the_constructor_of_a_derived_class);
53905             }
53906             if (ts.hasSyntacticModifier(container, 32) || isCallExpression) {
53907                 nodeCheckFlag = 512;
53908             }
53909             else {
53910                 nodeCheckFlag = 256;
53911             }
53912             getNodeLinks(node).flags |= nodeCheckFlag;
53913             if (container.kind === 165 && ts.hasSyntacticModifier(container, 256)) {
53914                 if (ts.isSuperProperty(node.parent) && ts.isAssignmentTarget(node.parent)) {
53915                     getNodeLinks(container).flags |= 4096;
53916                 }
53917                 else {
53918                     getNodeLinks(container).flags |= 2048;
53919                 }
53920             }
53921             if (needToCaptureLexicalThis) {
53922                 captureLexicalThis(node.parent, container);
53923             }
53924             if (container.parent.kind === 200) {
53925                 if (languageVersion < 2) {
53926                     error(node, ts.Diagnostics.super_is_only_allowed_in_members_of_object_literal_expressions_when_option_target_is_ES2015_or_higher);
53927                     return errorType;
53928                 }
53929                 else {
53930                     return anyType;
53931                 }
53932             }
53933             var classLikeDeclaration = container.parent;
53934             if (!ts.getClassExtendsHeritageElement(classLikeDeclaration)) {
53935                 error(node, ts.Diagnostics.super_can_only_be_referenced_in_a_derived_class);
53936                 return errorType;
53937             }
53938             var classType = getDeclaredTypeOfSymbol(getSymbolOfNode(classLikeDeclaration));
53939             var baseClassType = classType && getBaseTypes(classType)[0];
53940             if (!baseClassType) {
53941                 return errorType;
53942             }
53943             if (container.kind === 166 && isInConstructorArgumentInitializer(node, container)) {
53944                 error(node, ts.Diagnostics.super_cannot_be_referenced_in_constructor_arguments);
53945                 return errorType;
53946             }
53947             return nodeCheckFlag === 512
53948                 ? getBaseConstructorTypeOfClass(classType)
53949                 : getTypeWithThisArgument(baseClassType, classType.thisType);
53950             function isLegalUsageOfSuperExpression(container) {
53951                 if (!container) {
53952                     return false;
53953                 }
53954                 if (isCallExpression) {
53955                     return container.kind === 166;
53956                 }
53957                 else {
53958                     if (ts.isClassLike(container.parent) || container.parent.kind === 200) {
53959                         if (ts.hasSyntacticModifier(container, 32)) {
53960                             return container.kind === 165 ||
53961                                 container.kind === 164 ||
53962                                 container.kind === 167 ||
53963                                 container.kind === 168;
53964                         }
53965                         else {
53966                             return container.kind === 165 ||
53967                                 container.kind === 164 ||
53968                                 container.kind === 167 ||
53969                                 container.kind === 168 ||
53970                                 container.kind === 163 ||
53971                                 container.kind === 162 ||
53972                                 container.kind === 166;
53973                         }
53974                     }
53975                 }
53976                 return false;
53977             }
53978         }
53979         function getContainingObjectLiteral(func) {
53980             return (func.kind === 165 ||
53981                 func.kind === 167 ||
53982                 func.kind === 168) && func.parent.kind === 200 ? func.parent :
53983                 func.kind === 208 && func.parent.kind === 288 ? func.parent.parent :
53984                     undefined;
53985         }
53986         function getThisTypeArgument(type) {
53987             return ts.getObjectFlags(type) & 4 && type.target === globalThisType ? getTypeArguments(type)[0] : undefined;
53988         }
53989         function getThisTypeFromContextualType(type) {
53990             return mapType(type, function (t) {
53991                 return t.flags & 2097152 ? ts.forEach(t.types, getThisTypeArgument) : getThisTypeArgument(t);
53992             });
53993         }
53994         function getContextualThisParameterType(func) {
53995             if (func.kind === 209) {
53996                 return undefined;
53997             }
53998             if (isContextSensitiveFunctionOrObjectLiteralMethod(func)) {
53999                 var contextualSignature = getContextualSignature(func);
54000                 if (contextualSignature) {
54001                     var thisParameter = contextualSignature.thisParameter;
54002                     if (thisParameter) {
54003                         return getTypeOfSymbol(thisParameter);
54004                     }
54005                 }
54006             }
54007             var inJs = ts.isInJSFile(func);
54008             if (noImplicitThis || inJs) {
54009                 var containingLiteral = getContainingObjectLiteral(func);
54010                 if (containingLiteral) {
54011                     var contextualType = getApparentTypeOfContextualType(containingLiteral);
54012                     var literal = containingLiteral;
54013                     var type = contextualType;
54014                     while (type) {
54015                         var thisType = getThisTypeFromContextualType(type);
54016                         if (thisType) {
54017                             return instantiateType(thisType, getMapperFromContext(getInferenceContext(containingLiteral)));
54018                         }
54019                         if (literal.parent.kind !== 288) {
54020                             break;
54021                         }
54022                         literal = literal.parent.parent;
54023                         type = getApparentTypeOfContextualType(literal);
54024                     }
54025                     return getWidenedType(contextualType ? getNonNullableType(contextualType) : checkExpressionCached(containingLiteral));
54026                 }
54027                 var parent = ts.walkUpParenthesizedExpressions(func.parent);
54028                 if (parent.kind === 216 && parent.operatorToken.kind === 62) {
54029                     var target = parent.left;
54030                     if (ts.isAccessExpression(target)) {
54031                         var expression = target.expression;
54032                         if (inJs && ts.isIdentifier(expression)) {
54033                             var sourceFile = ts.getSourceFileOfNode(parent);
54034                             if (sourceFile.commonJsModuleIndicator && getResolvedSymbol(expression) === sourceFile.symbol) {
54035                                 return undefined;
54036                             }
54037                         }
54038                         return getWidenedType(checkExpressionCached(expression));
54039                     }
54040                 }
54041             }
54042             return undefined;
54043         }
54044         function getContextuallyTypedParameterType(parameter) {
54045             var func = parameter.parent;
54046             if (!isContextSensitiveFunctionOrObjectLiteralMethod(func)) {
54047                 return undefined;
54048             }
54049             var iife = ts.getImmediatelyInvokedFunctionExpression(func);
54050             if (iife && iife.arguments) {
54051                 var args = getEffectiveCallArguments(iife);
54052                 var indexOfParameter = func.parameters.indexOf(parameter);
54053                 if (parameter.dotDotDotToken) {
54054                     return getSpreadArgumentType(args, indexOfParameter, args.length, anyType, undefined, 0);
54055                 }
54056                 var links = getNodeLinks(iife);
54057                 var cached = links.resolvedSignature;
54058                 links.resolvedSignature = anySignature;
54059                 var type = indexOfParameter < args.length ?
54060                     getWidenedLiteralType(checkExpression(args[indexOfParameter])) :
54061                     parameter.initializer ? undefined : undefinedWideningType;
54062                 links.resolvedSignature = cached;
54063                 return type;
54064             }
54065             var contextualSignature = getContextualSignature(func);
54066             if (contextualSignature) {
54067                 var index = func.parameters.indexOf(parameter) - (ts.getThisParameter(func) ? 1 : 0);
54068                 return parameter.dotDotDotToken && ts.lastOrUndefined(func.parameters) === parameter ?
54069                     getRestTypeAtPosition(contextualSignature, index) :
54070                     tryGetTypeAtPosition(contextualSignature, index);
54071             }
54072         }
54073         function getContextualTypeForVariableLikeDeclaration(declaration) {
54074             var typeNode = ts.getEffectiveTypeAnnotationNode(declaration);
54075             if (typeNode) {
54076                 return getTypeFromTypeNode(typeNode);
54077             }
54078             switch (declaration.kind) {
54079                 case 160:
54080                     return getContextuallyTypedParameterType(declaration);
54081                 case 198:
54082                     return getContextualTypeForBindingElement(declaration);
54083                 case 163:
54084                     if (ts.hasSyntacticModifier(declaration, 32)) {
54085                         return getContextualTypeForStaticPropertyDeclaration(declaration);
54086                     }
54087             }
54088         }
54089         function getContextualTypeForBindingElement(declaration) {
54090             var parent = declaration.parent.parent;
54091             var name = declaration.propertyName || declaration.name;
54092             var parentType = getContextualTypeForVariableLikeDeclaration(parent) ||
54093                 parent.kind !== 198 && parent.initializer && checkDeclarationInitializer(parent);
54094             if (!parentType || ts.isBindingPattern(name) || ts.isComputedNonLiteralName(name))
54095                 return undefined;
54096             if (parent.name.kind === 197) {
54097                 var index = ts.indexOfNode(declaration.parent.elements, declaration);
54098                 if (index < 0)
54099                     return undefined;
54100                 return getContextualTypeForElementExpression(parentType, index);
54101             }
54102             var nameType = getLiteralTypeFromPropertyName(name);
54103             if (isTypeUsableAsPropertyName(nameType)) {
54104                 var text = getPropertyNameFromType(nameType);
54105                 return getTypeOfPropertyOfType(parentType, text);
54106             }
54107         }
54108         function getContextualTypeForStaticPropertyDeclaration(declaration) {
54109             var parentType = ts.isExpression(declaration.parent) && getContextualType(declaration.parent);
54110             if (!parentType)
54111                 return undefined;
54112             return getTypeOfPropertyOfContextualType(parentType, getSymbolOfNode(declaration).escapedName);
54113         }
54114         function getContextualTypeForInitializerExpression(node, contextFlags) {
54115             var declaration = node.parent;
54116             if (ts.hasInitializer(declaration) && node === declaration.initializer) {
54117                 var result = getContextualTypeForVariableLikeDeclaration(declaration);
54118                 if (result) {
54119                     return result;
54120                 }
54121                 if (!(contextFlags & 8) && ts.isBindingPattern(declaration.name)) {
54122                     return getTypeFromBindingPattern(declaration.name, true, false);
54123                 }
54124             }
54125             return undefined;
54126         }
54127         function getContextualTypeForReturnExpression(node) {
54128             var func = ts.getContainingFunction(node);
54129             if (func) {
54130                 var contextualReturnType = getContextualReturnType(func);
54131                 if (contextualReturnType) {
54132                     var functionFlags = ts.getFunctionFlags(func);
54133                     if (functionFlags & 1) {
54134                         var use = functionFlags & 2 ? 2 : 1;
54135                         var iterationTypes = getIterationTypesOfIterable(contextualReturnType, use, undefined);
54136                         if (!iterationTypes) {
54137                             return undefined;
54138                         }
54139                         contextualReturnType = iterationTypes.returnType;
54140                     }
54141                     if (functionFlags & 2) {
54142                         var contextualAwaitedType = mapType(contextualReturnType, getAwaitedType);
54143                         return contextualAwaitedType && getUnionType([contextualAwaitedType, createPromiseLikeType(contextualAwaitedType)]);
54144                     }
54145                     return contextualReturnType;
54146                 }
54147             }
54148             return undefined;
54149         }
54150         function getContextualTypeForAwaitOperand(node, contextFlags) {
54151             var contextualType = getContextualType(node, contextFlags);
54152             if (contextualType) {
54153                 var contextualAwaitedType = getAwaitedType(contextualType);
54154                 return contextualAwaitedType && getUnionType([contextualAwaitedType, createPromiseLikeType(contextualAwaitedType)]);
54155             }
54156             return undefined;
54157         }
54158         function getContextualTypeForYieldOperand(node) {
54159             var func = ts.getContainingFunction(node);
54160             if (func) {
54161                 var functionFlags = ts.getFunctionFlags(func);
54162                 var contextualReturnType = getContextualReturnType(func);
54163                 if (contextualReturnType) {
54164                     return node.asteriskToken
54165                         ? contextualReturnType
54166                         : getIterationTypeOfGeneratorFunctionReturnType(0, contextualReturnType, (functionFlags & 2) !== 0);
54167                 }
54168             }
54169             return undefined;
54170         }
54171         function isInParameterInitializerBeforeContainingFunction(node) {
54172             var inBindingInitializer = false;
54173             while (node.parent && !ts.isFunctionLike(node.parent)) {
54174                 if (ts.isParameter(node.parent) && (inBindingInitializer || node.parent.initializer === node)) {
54175                     return true;
54176                 }
54177                 if (ts.isBindingElement(node.parent) && node.parent.initializer === node) {
54178                     inBindingInitializer = true;
54179                 }
54180                 node = node.parent;
54181             }
54182             return false;
54183         }
54184         function getContextualIterationType(kind, functionDecl) {
54185             var isAsync = !!(ts.getFunctionFlags(functionDecl) & 2);
54186             var contextualReturnType = getContextualReturnType(functionDecl);
54187             if (contextualReturnType) {
54188                 return getIterationTypeOfGeneratorFunctionReturnType(kind, contextualReturnType, isAsync)
54189                     || undefined;
54190             }
54191             return undefined;
54192         }
54193         function getContextualReturnType(functionDecl) {
54194             var returnType = getReturnTypeFromAnnotation(functionDecl);
54195             if (returnType) {
54196                 return returnType;
54197             }
54198             var signature = getContextualSignatureForFunctionLikeDeclaration(functionDecl);
54199             if (signature && !isResolvingReturnTypeOfSignature(signature)) {
54200                 return getReturnTypeOfSignature(signature);
54201             }
54202             return undefined;
54203         }
54204         function getContextualTypeForArgument(callTarget, arg) {
54205             var args = getEffectiveCallArguments(callTarget);
54206             var argIndex = args.indexOf(arg);
54207             return argIndex === -1 ? undefined : getContextualTypeForArgumentAtIndex(callTarget, argIndex);
54208         }
54209         function getContextualTypeForArgumentAtIndex(callTarget, argIndex) {
54210             var signature = getNodeLinks(callTarget).resolvedSignature === resolvingSignature ? resolvingSignature : getResolvedSignature(callTarget);
54211             if (ts.isJsxOpeningLikeElement(callTarget) && argIndex === 0) {
54212                 return getEffectiveFirstArgumentForJsxSignature(signature, callTarget);
54213             }
54214             return getTypeAtPosition(signature, argIndex);
54215         }
54216         function getContextualTypeForSubstitutionExpression(template, substitutionExpression) {
54217             if (template.parent.kind === 205) {
54218                 return getContextualTypeForArgument(template.parent, substitutionExpression);
54219             }
54220             return undefined;
54221         }
54222         function getContextualTypeForBinaryOperand(node, contextFlags) {
54223             var binaryExpression = node.parent;
54224             var left = binaryExpression.left, operatorToken = binaryExpression.operatorToken, right = binaryExpression.right;
54225             switch (operatorToken.kind) {
54226                 case 62:
54227                 case 75:
54228                 case 74:
54229                 case 76:
54230                     return node === right ? getContextualTypeForAssignmentDeclaration(binaryExpression) : undefined;
54231                 case 56:
54232                 case 60:
54233                     var type = getContextualType(binaryExpression, contextFlags);
54234                     return node === right && (type && type.pattern || !type && !ts.isDefaultedExpandoInitializer(binaryExpression)) ?
54235                         getTypeOfExpression(left) : type;
54236                 case 55:
54237                 case 27:
54238                     return node === right ? getContextualType(binaryExpression, contextFlags) : undefined;
54239                 default:
54240                     return undefined;
54241             }
54242         }
54243         function getContextualTypeForAssignmentDeclaration(binaryExpression) {
54244             var kind = ts.getAssignmentDeclarationKind(binaryExpression);
54245             switch (kind) {
54246                 case 0:
54247                     return getTypeOfExpression(binaryExpression.left);
54248                 case 5:
54249                 case 1:
54250                 case 6:
54251                 case 3:
54252                     if (isPossiblyAliasedThisProperty(binaryExpression, kind)) {
54253                         return getContextualTypeForThisPropertyAssignment(binaryExpression, kind);
54254                     }
54255                     else if (!binaryExpression.left.symbol) {
54256                         return getTypeOfExpression(binaryExpression.left);
54257                     }
54258                     else {
54259                         var decl = binaryExpression.left.symbol.valueDeclaration;
54260                         if (!decl) {
54261                             return undefined;
54262                         }
54263                         var lhs = ts.cast(binaryExpression.left, ts.isAccessExpression);
54264                         var overallAnnotation = ts.getEffectiveTypeAnnotationNode(decl);
54265                         if (overallAnnotation) {
54266                             return getTypeFromTypeNode(overallAnnotation);
54267                         }
54268                         else if (ts.isIdentifier(lhs.expression)) {
54269                             var id = lhs.expression;
54270                             var parentSymbol = resolveName(id, id.escapedText, 111551, undefined, id.escapedText, true);
54271                             if (parentSymbol) {
54272                                 var annotated = parentSymbol.valueDeclaration && ts.getEffectiveTypeAnnotationNode(parentSymbol.valueDeclaration);
54273                                 if (annotated) {
54274                                     var nameStr = ts.getElementOrPropertyAccessName(lhs);
54275                                     if (nameStr !== undefined) {
54276                                         return getTypeOfPropertyOfContextualType(getTypeFromTypeNode(annotated), nameStr);
54277                                     }
54278                                 }
54279                                 return undefined;
54280                             }
54281                         }
54282                         return ts.isInJSFile(decl) ? undefined : getTypeOfExpression(binaryExpression.left);
54283                     }
54284                 case 2:
54285                 case 4:
54286                     return getContextualTypeForThisPropertyAssignment(binaryExpression, kind);
54287                 case 7:
54288                 case 8:
54289                 case 9:
54290                     return ts.Debug.fail("Does not apply");
54291                 default:
54292                     return ts.Debug.assertNever(kind);
54293             }
54294         }
54295         function isPossiblyAliasedThisProperty(declaration, kind) {
54296             if (kind === void 0) { kind = ts.getAssignmentDeclarationKind(declaration); }
54297             if (kind === 4) {
54298                 return true;
54299             }
54300             if (!ts.isInJSFile(declaration) || kind !== 5 || !ts.isIdentifier(declaration.left.expression)) {
54301                 return false;
54302             }
54303             var name = declaration.left.expression.escapedText;
54304             var symbol = resolveName(declaration.left, name, 111551, undefined, undefined, true, true);
54305             return ts.isThisInitializedDeclaration(symbol === null || symbol === void 0 ? void 0 : symbol.valueDeclaration);
54306         }
54307         function getContextualTypeForThisPropertyAssignment(binaryExpression, kind) {
54308             if (!binaryExpression.symbol)
54309                 return getTypeOfExpression(binaryExpression.left);
54310             if (binaryExpression.symbol.valueDeclaration) {
54311                 var annotated = ts.getEffectiveTypeAnnotationNode(binaryExpression.symbol.valueDeclaration);
54312                 if (annotated) {
54313                     var type = getTypeFromTypeNode(annotated);
54314                     if (type) {
54315                         return type;
54316                     }
54317                 }
54318             }
54319             if (kind === 2)
54320                 return undefined;
54321             var thisAccess = ts.cast(binaryExpression.left, ts.isAccessExpression);
54322             if (!ts.isObjectLiteralMethod(ts.getThisContainer(thisAccess.expression, false))) {
54323                 return undefined;
54324             }
54325             var thisType = checkThisExpression(thisAccess.expression);
54326             var nameStr = ts.getElementOrPropertyAccessName(thisAccess);
54327             return nameStr !== undefined && getTypeOfPropertyOfContextualType(thisType, nameStr) || undefined;
54328         }
54329         function isCircularMappedProperty(symbol) {
54330             return !!(ts.getCheckFlags(symbol) & 262144 && !symbol.type && findResolutionCycleStartIndex(symbol, 0) >= 0);
54331         }
54332         function getTypeOfPropertyOfContextualType(type, name) {
54333             return mapType(type, function (t) {
54334                 if (isGenericMappedType(t)) {
54335                     var constraint = getConstraintTypeFromMappedType(t);
54336                     var constraintOfConstraint = getBaseConstraintOfType(constraint) || constraint;
54337                     var propertyNameType = getLiteralType(ts.unescapeLeadingUnderscores(name));
54338                     if (isTypeAssignableTo(propertyNameType, constraintOfConstraint)) {
54339                         return substituteIndexedMappedType(t, propertyNameType);
54340                     }
54341                 }
54342                 else if (t.flags & 3670016) {
54343                     var prop = getPropertyOfType(t, name);
54344                     if (prop) {
54345                         return isCircularMappedProperty(prop) ? undefined : getTypeOfSymbol(prop);
54346                     }
54347                     if (isTupleType(t)) {
54348                         var restType = getRestTypeOfTupleType(t);
54349                         if (restType && isNumericLiteralName(name) && +name >= 0) {
54350                             return restType;
54351                         }
54352                     }
54353                     return isNumericLiteralName(name) && getIndexTypeOfContextualType(t, 1) ||
54354                         getIndexTypeOfContextualType(t, 0);
54355                 }
54356                 return undefined;
54357             }, true);
54358         }
54359         function getIndexTypeOfContextualType(type, kind) {
54360             return mapType(type, function (t) { return getIndexTypeOfStructuredType(t, kind); }, true);
54361         }
54362         function getContextualTypeForObjectLiteralMethod(node, contextFlags) {
54363             ts.Debug.assert(ts.isObjectLiteralMethod(node));
54364             if (node.flags & 16777216) {
54365                 return undefined;
54366             }
54367             return getContextualTypeForObjectLiteralElement(node, contextFlags);
54368         }
54369         function getContextualTypeForObjectLiteralElement(element, contextFlags) {
54370             var objectLiteral = element.parent;
54371             var type = getApparentTypeOfContextualType(objectLiteral, contextFlags);
54372             if (type) {
54373                 if (!hasNonBindableDynamicName(element)) {
54374                     var symbolName_3 = getSymbolOfNode(element).escapedName;
54375                     var propertyType = getTypeOfPropertyOfContextualType(type, symbolName_3);
54376                     if (propertyType) {
54377                         return propertyType;
54378                     }
54379                 }
54380                 return isNumericName(element.name) && getIndexTypeOfContextualType(type, 1) ||
54381                     getIndexTypeOfContextualType(type, 0);
54382             }
54383             return undefined;
54384         }
54385         function getContextualTypeForElementExpression(arrayContextualType, index) {
54386             return arrayContextualType && (getTypeOfPropertyOfContextualType(arrayContextualType, "" + index)
54387                 || mapType(arrayContextualType, function (t) { return getIteratedTypeOrElementType(1, t, undefinedType, undefined, false); }, true));
54388         }
54389         function getContextualTypeForConditionalOperand(node, contextFlags) {
54390             var conditional = node.parent;
54391             return node === conditional.whenTrue || node === conditional.whenFalse ? getContextualType(conditional, contextFlags) : undefined;
54392         }
54393         function getContextualTypeForChildJsxExpression(node, child) {
54394             var attributesType = getApparentTypeOfContextualType(node.openingElement.tagName);
54395             var jsxChildrenPropertyName = getJsxElementChildrenPropertyName(getJsxNamespaceAt(node));
54396             if (!(attributesType && !isTypeAny(attributesType) && jsxChildrenPropertyName && jsxChildrenPropertyName !== "")) {
54397                 return undefined;
54398             }
54399             var realChildren = ts.getSemanticJsxChildren(node.children);
54400             var childIndex = realChildren.indexOf(child);
54401             var childFieldType = getTypeOfPropertyOfContextualType(attributesType, jsxChildrenPropertyName);
54402             return childFieldType && (realChildren.length === 1 ? childFieldType : mapType(childFieldType, function (t) {
54403                 if (isArrayLikeType(t)) {
54404                     return getIndexedAccessType(t, getLiteralType(childIndex));
54405                 }
54406                 else {
54407                     return t;
54408                 }
54409             }, true));
54410         }
54411         function getContextualTypeForJsxExpression(node) {
54412             var exprParent = node.parent;
54413             return ts.isJsxAttributeLike(exprParent)
54414                 ? getContextualType(node)
54415                 : ts.isJsxElement(exprParent)
54416                     ? getContextualTypeForChildJsxExpression(exprParent, node)
54417                     : undefined;
54418         }
54419         function getContextualTypeForJsxAttribute(attribute) {
54420             if (ts.isJsxAttribute(attribute)) {
54421                 var attributesType = getApparentTypeOfContextualType(attribute.parent);
54422                 if (!attributesType || isTypeAny(attributesType)) {
54423                     return undefined;
54424                 }
54425                 return getTypeOfPropertyOfContextualType(attributesType, attribute.name.escapedText);
54426             }
54427             else {
54428                 return getContextualType(attribute.parent);
54429             }
54430         }
54431         function isPossiblyDiscriminantValue(node) {
54432             switch (node.kind) {
54433                 case 10:
54434                 case 8:
54435                 case 9:
54436                 case 14:
54437                 case 109:
54438                 case 94:
54439                 case 103:
54440                 case 78:
54441                 case 150:
54442                     return true;
54443                 case 201:
54444                 case 207:
54445                     return isPossiblyDiscriminantValue(node.expression);
54446                 case 283:
54447                     return !node.expression || isPossiblyDiscriminantValue(node.expression);
54448             }
54449             return false;
54450         }
54451         function discriminateContextualTypeByObjectMembers(node, contextualType) {
54452             return discriminateTypeByDiscriminableItems(contextualType, ts.map(ts.filter(node.properties, function (p) { return !!p.symbol && p.kind === 288 && isPossiblyDiscriminantValue(p.initializer) && isDiscriminantProperty(contextualType, p.symbol.escapedName); }), function (prop) { return [function () { return checkExpression(prop.initializer); }, prop.symbol.escapedName]; }), isTypeAssignableTo, contextualType);
54453         }
54454         function discriminateContextualTypeByJSXAttributes(node, contextualType) {
54455             return discriminateTypeByDiscriminableItems(contextualType, ts.map(ts.filter(node.properties, function (p) { return !!p.symbol && p.kind === 280 && 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);
54456         }
54457         function getApparentTypeOfContextualType(node, contextFlags) {
54458             var contextualType = ts.isObjectLiteralMethod(node) ?
54459                 getContextualTypeForObjectLiteralMethod(node, contextFlags) :
54460                 getContextualType(node, contextFlags);
54461             var instantiatedType = instantiateContextualType(contextualType, node, contextFlags);
54462             if (instantiatedType && !(contextFlags && contextFlags & 2 && instantiatedType.flags & 8650752)) {
54463                 var apparentType = mapType(instantiatedType, getApparentType, true);
54464                 if (apparentType.flags & 1048576) {
54465                     if (ts.isObjectLiteralExpression(node)) {
54466                         return discriminateContextualTypeByObjectMembers(node, apparentType);
54467                     }
54468                     else if (ts.isJsxAttributes(node)) {
54469                         return discriminateContextualTypeByJSXAttributes(node, apparentType);
54470                     }
54471                 }
54472                 return apparentType;
54473             }
54474         }
54475         function instantiateContextualType(contextualType, node, contextFlags) {
54476             if (contextualType && maybeTypeOfKind(contextualType, 465829888)) {
54477                 var inferenceContext = getInferenceContext(node);
54478                 if (inferenceContext && ts.some(inferenceContext.inferences, hasInferenceCandidates)) {
54479                     if (contextFlags && contextFlags & 1) {
54480                         return instantiateInstantiableTypes(contextualType, inferenceContext.nonFixingMapper);
54481                     }
54482                     if (inferenceContext.returnMapper) {
54483                         return instantiateInstantiableTypes(contextualType, inferenceContext.returnMapper);
54484                     }
54485                 }
54486             }
54487             return contextualType;
54488         }
54489         function instantiateInstantiableTypes(type, mapper) {
54490             if (type.flags & 465829888) {
54491                 return instantiateType(type, mapper);
54492             }
54493             if (type.flags & 1048576) {
54494                 return getUnionType(ts.map(type.types, function (t) { return instantiateInstantiableTypes(t, mapper); }), 0);
54495             }
54496             if (type.flags & 2097152) {
54497                 return getIntersectionType(ts.map(type.types, function (t) { return instantiateInstantiableTypes(t, mapper); }));
54498             }
54499             return type;
54500         }
54501         function getContextualType(node, contextFlags) {
54502             if (node.flags & 16777216) {
54503                 return undefined;
54504             }
54505             if (node.contextualType) {
54506                 return node.contextualType;
54507             }
54508             var parent = node.parent;
54509             switch (parent.kind) {
54510                 case 249:
54511                 case 160:
54512                 case 163:
54513                 case 162:
54514                 case 198:
54515                     return getContextualTypeForInitializerExpression(node, contextFlags);
54516                 case 209:
54517                 case 242:
54518                     return getContextualTypeForReturnExpression(node);
54519                 case 219:
54520                     return getContextualTypeForYieldOperand(parent);
54521                 case 213:
54522                     return getContextualTypeForAwaitOperand(parent, contextFlags);
54523                 case 203:
54524                     if (parent.expression.kind === 99) {
54525                         return stringType;
54526                     }
54527                 case 204:
54528                     return getContextualTypeForArgument(parent, node);
54529                 case 206:
54530                 case 224:
54531                     return ts.isConstTypeReference(parent.type) ? tryFindWhenConstTypeReference(parent) : getTypeFromTypeNode(parent.type);
54532                 case 216:
54533                     return getContextualTypeForBinaryOperand(node, contextFlags);
54534                 case 288:
54535                 case 289:
54536                     return getContextualTypeForObjectLiteralElement(parent, contextFlags);
54537                 case 290:
54538                     return getApparentTypeOfContextualType(parent.parent, contextFlags);
54539                 case 199: {
54540                     var arrayLiteral = parent;
54541                     var type = getApparentTypeOfContextualType(arrayLiteral, contextFlags);
54542                     return getContextualTypeForElementExpression(type, ts.indexOfNode(arrayLiteral.elements, node));
54543                 }
54544                 case 217:
54545                     return getContextualTypeForConditionalOperand(node, contextFlags);
54546                 case 228:
54547                     ts.Debug.assert(parent.parent.kind === 218);
54548                     return getContextualTypeForSubstitutionExpression(parent.parent, node);
54549                 case 207: {
54550                     var tag = ts.isInJSFile(parent) ? ts.getJSDocTypeTag(parent) : undefined;
54551                     return tag ? getTypeFromTypeNode(tag.typeExpression.type) : getContextualType(parent, contextFlags);
54552                 }
54553                 case 283:
54554                     return getContextualTypeForJsxExpression(parent);
54555                 case 280:
54556                 case 282:
54557                     return getContextualTypeForJsxAttribute(parent);
54558                 case 275:
54559                 case 274:
54560                     return getContextualJsxElementAttributesType(parent, contextFlags);
54561             }
54562             return undefined;
54563             function tryFindWhenConstTypeReference(node) {
54564                 if (ts.isCallLikeExpression(node.parent)) {
54565                     return getContextualTypeForArgument(node.parent, node);
54566                 }
54567                 return undefined;
54568             }
54569         }
54570         function getInferenceContext(node) {
54571             var ancestor = ts.findAncestor(node, function (n) { return !!n.inferenceContext; });
54572             return ancestor && ancestor.inferenceContext;
54573         }
54574         function getContextualJsxElementAttributesType(node, contextFlags) {
54575             if (ts.isJsxOpeningElement(node) && node.parent.contextualType && contextFlags !== 4) {
54576                 return node.parent.contextualType;
54577             }
54578             return getContextualTypeForArgumentAtIndex(node, 0);
54579         }
54580         function getEffectiveFirstArgumentForJsxSignature(signature, node) {
54581             return getJsxReferenceKind(node) !== 0
54582                 ? getJsxPropsTypeFromCallSignature(signature, node)
54583                 : getJsxPropsTypeFromClassType(signature, node);
54584         }
54585         function getJsxPropsTypeFromCallSignature(sig, context) {
54586             var propsType = getTypeOfFirstParameterOfSignatureWithFallback(sig, unknownType);
54587             propsType = getJsxManagedAttributesFromLocatedAttributes(context, getJsxNamespaceAt(context), propsType);
54588             var intrinsicAttribs = getJsxType(JsxNames.IntrinsicAttributes, context);
54589             if (intrinsicAttribs !== errorType) {
54590                 propsType = intersectTypes(intrinsicAttribs, propsType);
54591             }
54592             return propsType;
54593         }
54594         function getJsxPropsTypeForSignatureFromMember(sig, forcedLookupLocation) {
54595             if (sig.unionSignatures) {
54596                 var results = [];
54597                 for (var _i = 0, _a = sig.unionSignatures; _i < _a.length; _i++) {
54598                     var signature = _a[_i];
54599                     var instance = getReturnTypeOfSignature(signature);
54600                     if (isTypeAny(instance)) {
54601                         return instance;
54602                     }
54603                     var propType = getTypeOfPropertyOfType(instance, forcedLookupLocation);
54604                     if (!propType) {
54605                         return;
54606                     }
54607                     results.push(propType);
54608                 }
54609                 return getIntersectionType(results);
54610             }
54611             var instanceType = getReturnTypeOfSignature(sig);
54612             return isTypeAny(instanceType) ? instanceType : getTypeOfPropertyOfType(instanceType, forcedLookupLocation);
54613         }
54614         function getStaticTypeOfReferencedJsxConstructor(context) {
54615             if (isJsxIntrinsicIdentifier(context.tagName)) {
54616                 var result = getIntrinsicAttributesTypeFromJsxOpeningLikeElement(context);
54617                 var fakeSignature = createSignatureForJSXIntrinsic(context, result);
54618                 return getOrCreateTypeFromSignature(fakeSignature);
54619             }
54620             var tagType = checkExpressionCached(context.tagName);
54621             if (tagType.flags & 128) {
54622                 var result = getIntrinsicAttributesTypeFromStringLiteralType(tagType, context);
54623                 if (!result) {
54624                     return errorType;
54625                 }
54626                 var fakeSignature = createSignatureForJSXIntrinsic(context, result);
54627                 return getOrCreateTypeFromSignature(fakeSignature);
54628             }
54629             return tagType;
54630         }
54631         function getJsxManagedAttributesFromLocatedAttributes(context, ns, attributesType) {
54632             var managedSym = getJsxLibraryManagedAttributes(ns);
54633             if (managedSym) {
54634                 var declaredManagedType = getDeclaredTypeOfSymbol(managedSym);
54635                 var ctorType = getStaticTypeOfReferencedJsxConstructor(context);
54636                 if (ts.length(declaredManagedType.typeParameters) >= 2) {
54637                     var args = fillMissingTypeArguments([ctorType, attributesType], declaredManagedType.typeParameters, 2, ts.isInJSFile(context));
54638                     return createTypeReference(declaredManagedType, args);
54639                 }
54640                 else if (ts.length(declaredManagedType.aliasTypeArguments) >= 2) {
54641                     var args = fillMissingTypeArguments([ctorType, attributesType], declaredManagedType.aliasTypeArguments, 2, ts.isInJSFile(context));
54642                     return getTypeAliasInstantiation(declaredManagedType.aliasSymbol, args);
54643                 }
54644             }
54645             return attributesType;
54646         }
54647         function getJsxPropsTypeFromClassType(sig, context) {
54648             var ns = getJsxNamespaceAt(context);
54649             var forcedLookupLocation = getJsxElementPropertiesName(ns);
54650             var attributesType = forcedLookupLocation === undefined
54651                 ? getTypeOfFirstParameterOfSignatureWithFallback(sig, unknownType)
54652                 : forcedLookupLocation === ""
54653                     ? getReturnTypeOfSignature(sig)
54654                     : getJsxPropsTypeForSignatureFromMember(sig, forcedLookupLocation);
54655             if (!attributesType) {
54656                 if (!!forcedLookupLocation && !!ts.length(context.attributes.properties)) {
54657                     error(context, ts.Diagnostics.JSX_element_class_does_not_support_attributes_because_it_does_not_have_a_0_property, ts.unescapeLeadingUnderscores(forcedLookupLocation));
54658                 }
54659                 return unknownType;
54660             }
54661             attributesType = getJsxManagedAttributesFromLocatedAttributes(context, ns, attributesType);
54662             if (isTypeAny(attributesType)) {
54663                 return attributesType;
54664             }
54665             else {
54666                 var apparentAttributesType = attributesType;
54667                 var intrinsicClassAttribs = getJsxType(JsxNames.IntrinsicClassAttributes, context);
54668                 if (intrinsicClassAttribs !== errorType) {
54669                     var typeParams = getLocalTypeParametersOfClassOrInterfaceOrTypeAlias(intrinsicClassAttribs.symbol);
54670                     var hostClassType = getReturnTypeOfSignature(sig);
54671                     apparentAttributesType = intersectTypes(typeParams
54672                         ? createTypeReference(intrinsicClassAttribs, fillMissingTypeArguments([hostClassType], typeParams, getMinTypeArgumentCount(typeParams), ts.isInJSFile(context)))
54673                         : intrinsicClassAttribs, apparentAttributesType);
54674                 }
54675                 var intrinsicAttribs = getJsxType(JsxNames.IntrinsicAttributes, context);
54676                 if (intrinsicAttribs !== errorType) {
54677                     apparentAttributesType = intersectTypes(intrinsicAttribs, apparentAttributesType);
54678                 }
54679                 return apparentAttributesType;
54680             }
54681         }
54682         function getContextualCallSignature(type, node) {
54683             var signatures = getSignaturesOfType(type, 0);
54684             if (signatures.length === 1) {
54685                 var signature = signatures[0];
54686                 if (!isAritySmaller(signature, node)) {
54687                     return signature;
54688                 }
54689             }
54690         }
54691         function isAritySmaller(signature, target) {
54692             var targetParameterCount = 0;
54693             for (; targetParameterCount < target.parameters.length; targetParameterCount++) {
54694                 var param = target.parameters[targetParameterCount];
54695                 if (param.initializer || param.questionToken || param.dotDotDotToken || isJSDocOptionalParameter(param)) {
54696                     break;
54697                 }
54698             }
54699             if (target.parameters.length && ts.parameterIsThisKeyword(target.parameters[0])) {
54700                 targetParameterCount--;
54701             }
54702             return !hasEffectiveRestParameter(signature) && getParameterCount(signature) < targetParameterCount;
54703         }
54704         function isFunctionExpressionOrArrowFunction(node) {
54705             return node.kind === 208 || node.kind === 209;
54706         }
54707         function getContextualSignatureForFunctionLikeDeclaration(node) {
54708             return isFunctionExpressionOrArrowFunction(node) || ts.isObjectLiteralMethod(node)
54709                 ? getContextualSignature(node)
54710                 : undefined;
54711         }
54712         function getContextualSignature(node) {
54713             ts.Debug.assert(node.kind !== 165 || ts.isObjectLiteralMethod(node));
54714             var typeTagSignature = getSignatureOfTypeTag(node);
54715             if (typeTagSignature) {
54716                 return typeTagSignature;
54717             }
54718             var type = getApparentTypeOfContextualType(node, 1);
54719             if (!type) {
54720                 return undefined;
54721             }
54722             if (!(type.flags & 1048576)) {
54723                 return getContextualCallSignature(type, node);
54724             }
54725             var signatureList;
54726             var types = type.types;
54727             for (var _i = 0, types_18 = types; _i < types_18.length; _i++) {
54728                 var current = types_18[_i];
54729                 var signature = getContextualCallSignature(current, node);
54730                 if (signature) {
54731                     if (!signatureList) {
54732                         signatureList = [signature];
54733                     }
54734                     else if (!compareSignaturesIdentical(signatureList[0], signature, false, true, true, compareTypesIdentical)) {
54735                         return undefined;
54736                     }
54737                     else {
54738                         signatureList.push(signature);
54739                     }
54740                 }
54741             }
54742             if (signatureList) {
54743                 return signatureList.length === 1 ? signatureList[0] : createUnionSignature(signatureList[0], signatureList);
54744             }
54745         }
54746         function checkSpreadExpression(node, checkMode) {
54747             if (languageVersion < 2) {
54748                 checkExternalEmitHelpers(node, compilerOptions.downlevelIteration ? 1536 : 2048);
54749             }
54750             var arrayOrIterableType = checkExpression(node.expression, checkMode);
54751             return checkIteratedTypeOrElementType(33, arrayOrIterableType, undefinedType, node.expression);
54752         }
54753         function checkSyntheticExpression(node) {
54754             return node.isSpread ? getIndexedAccessType(node.type, numberType) : node.type;
54755         }
54756         function hasDefaultValue(node) {
54757             return (node.kind === 198 && !!node.initializer) ||
54758                 (node.kind === 216 && node.operatorToken.kind === 62);
54759         }
54760         function checkArrayLiteral(node, checkMode, forceTuple) {
54761             var elements = node.elements;
54762             var elementCount = elements.length;
54763             var elementTypes = [];
54764             var elementFlags = [];
54765             var contextualType = getApparentTypeOfContextualType(node);
54766             var inDestructuringPattern = ts.isAssignmentTarget(node);
54767             var inConstContext = isConstContext(node);
54768             for (var i = 0; i < elementCount; i++) {
54769                 var e = elements[i];
54770                 if (e.kind === 220) {
54771                     if (languageVersion < 2) {
54772                         checkExternalEmitHelpers(e, compilerOptions.downlevelIteration ? 1536 : 2048);
54773                     }
54774                     var spreadType = checkExpression(e.expression, checkMode, forceTuple);
54775                     if (isArrayLikeType(spreadType)) {
54776                         elementTypes.push(spreadType);
54777                         elementFlags.push(8);
54778                     }
54779                     else if (inDestructuringPattern) {
54780                         var restElementType = getIndexTypeOfType(spreadType, 1) ||
54781                             getIteratedTypeOrElementType(65, spreadType, undefinedType, undefined, false) ||
54782                             unknownType;
54783                         elementTypes.push(restElementType);
54784                         elementFlags.push(4);
54785                     }
54786                     else {
54787                         elementTypes.push(checkIteratedTypeOrElementType(33, spreadType, undefinedType, e.expression));
54788                         elementFlags.push(4);
54789                     }
54790                 }
54791                 else {
54792                     var elementContextualType = getContextualTypeForElementExpression(contextualType, elementTypes.length);
54793                     var type = checkExpressionForMutableLocation(e, checkMode, elementContextualType, forceTuple);
54794                     elementTypes.push(type);
54795                     elementFlags.push(1);
54796                 }
54797             }
54798             if (inDestructuringPattern) {
54799                 return createTupleType(elementTypes, elementFlags);
54800             }
54801             if (forceTuple || inConstContext || contextualType && forEachType(contextualType, isTupleLikeType)) {
54802                 return createArrayLiteralType(createTupleType(elementTypes, elementFlags, inConstContext));
54803             }
54804             return createArrayLiteralType(createArrayType(elementTypes.length ?
54805                 getUnionType(ts.sameMap(elementTypes, function (t, i) { return elementFlags[i] & 8 ? getIndexedAccessTypeOrUndefined(t, numberType) || anyType : t; }), 2) :
54806                 strictNullChecks ? implicitNeverType : undefinedWideningType, inConstContext));
54807         }
54808         function createArrayLiteralType(type) {
54809             if (!(ts.getObjectFlags(type) & 4)) {
54810                 return type;
54811             }
54812             var literalType = type.literalType;
54813             if (!literalType) {
54814                 literalType = type.literalType = cloneTypeReference(type);
54815                 literalType.objectFlags |= 65536 | 1048576;
54816             }
54817             return literalType;
54818         }
54819         function isNumericName(name) {
54820             switch (name.kind) {
54821                 case 158:
54822                     return isNumericComputedName(name);
54823                 case 78:
54824                     return isNumericLiteralName(name.escapedText);
54825                 case 8:
54826                 case 10:
54827                     return isNumericLiteralName(name.text);
54828                 default:
54829                     return false;
54830             }
54831         }
54832         function isNumericComputedName(name) {
54833             return isTypeAssignableToKind(checkComputedPropertyName(name), 296);
54834         }
54835         function isInfinityOrNaNString(name) {
54836             return name === "Infinity" || name === "-Infinity" || name === "NaN";
54837         }
54838         function isNumericLiteralName(name) {
54839             return (+name).toString() === name;
54840         }
54841         function checkComputedPropertyName(node) {
54842             var links = getNodeLinks(node.expression);
54843             if (!links.resolvedType) {
54844                 links.resolvedType = checkExpression(node.expression);
54845                 if (links.resolvedType.flags & 98304 ||
54846                     !isTypeAssignableToKind(links.resolvedType, 402653316 | 296 | 12288) &&
54847                         !isTypeAssignableTo(links.resolvedType, stringNumberSymbolType)) {
54848                     error(node, ts.Diagnostics.A_computed_property_name_must_be_of_type_string_number_symbol_or_any);
54849                 }
54850                 else {
54851                     checkThatExpressionIsProperSymbolReference(node.expression, links.resolvedType, true);
54852                 }
54853             }
54854             return links.resolvedType;
54855         }
54856         function isSymbolWithNumericName(symbol) {
54857             var _a;
54858             var firstDecl = (_a = symbol.declarations) === null || _a === void 0 ? void 0 : _a[0];
54859             return isNumericLiteralName(symbol.escapedName) || (firstDecl && ts.isNamedDeclaration(firstDecl) && isNumericName(firstDecl.name));
54860         }
54861         function getObjectLiteralIndexInfo(node, offset, properties, kind) {
54862             var propTypes = [];
54863             for (var i = offset; i < properties.length; i++) {
54864                 if (kind === 0 || isSymbolWithNumericName(properties[i])) {
54865                     propTypes.push(getTypeOfSymbol(properties[i]));
54866                 }
54867             }
54868             var unionType = propTypes.length ? getUnionType(propTypes, 2) : undefinedType;
54869             return createIndexInfo(unionType, isConstContext(node));
54870         }
54871         function getImmediateAliasedSymbol(symbol) {
54872             ts.Debug.assert((symbol.flags & 2097152) !== 0, "Should only get Alias here.");
54873             var links = getSymbolLinks(symbol);
54874             if (!links.immediateTarget) {
54875                 var node = getDeclarationOfAliasSymbol(symbol);
54876                 if (!node)
54877                     return ts.Debug.fail();
54878                 links.immediateTarget = getTargetOfAliasDeclaration(node, true);
54879             }
54880             return links.immediateTarget;
54881         }
54882         function checkObjectLiteral(node, checkMode) {
54883             var inDestructuringPattern = ts.isAssignmentTarget(node);
54884             checkGrammarObjectLiteralExpression(node, inDestructuringPattern);
54885             var allPropertiesTable = strictNullChecks ? ts.createSymbolTable() : undefined;
54886             var propertiesTable = ts.createSymbolTable();
54887             var propertiesArray = [];
54888             var spread = emptyObjectType;
54889             var contextualType = getApparentTypeOfContextualType(node);
54890             var contextualTypeHasPattern = contextualType && contextualType.pattern &&
54891                 (contextualType.pattern.kind === 196 || contextualType.pattern.kind === 200);
54892             var inConstContext = isConstContext(node);
54893             var checkFlags = inConstContext ? 8 : 0;
54894             var isInJavascript = ts.isInJSFile(node) && !ts.isInJsonFile(node);
54895             var enumTag = ts.getJSDocEnumTag(node);
54896             var isJSObjectLiteral = !contextualType && isInJavascript && !enumTag;
54897             var objectFlags = freshObjectLiteralFlag;
54898             var patternWithComputedProperties = false;
54899             var hasComputedStringProperty = false;
54900             var hasComputedNumberProperty = false;
54901             for (var _i = 0, _a = node.properties; _i < _a.length; _i++) {
54902                 var elem = _a[_i];
54903                 if (elem.name && ts.isComputedPropertyName(elem.name) && !ts.isWellKnownSymbolSyntactically(elem.name)) {
54904                     checkComputedPropertyName(elem.name);
54905                 }
54906             }
54907             var offset = 0;
54908             for (var _b = 0, _c = node.properties; _b < _c.length; _b++) {
54909                 var memberDecl = _c[_b];
54910                 var member = getSymbolOfNode(memberDecl);
54911                 var computedNameType = memberDecl.name && memberDecl.name.kind === 158 && !ts.isWellKnownSymbolSyntactically(memberDecl.name.expression) ?
54912                     checkComputedPropertyName(memberDecl.name) : undefined;
54913                 if (memberDecl.kind === 288 ||
54914                     memberDecl.kind === 289 ||
54915                     ts.isObjectLiteralMethod(memberDecl)) {
54916                     var type = memberDecl.kind === 288 ? checkPropertyAssignment(memberDecl, checkMode) :
54917                         memberDecl.kind === 289 ? checkExpressionForMutableLocation(!inDestructuringPattern && memberDecl.objectAssignmentInitializer ? memberDecl.objectAssignmentInitializer : memberDecl.name, checkMode) :
54918                             checkObjectLiteralMethod(memberDecl, checkMode);
54919                     if (isInJavascript) {
54920                         var jsDocType = getTypeForDeclarationFromJSDocComment(memberDecl);
54921                         if (jsDocType) {
54922                             checkTypeAssignableTo(type, jsDocType, memberDecl);
54923                             type = jsDocType;
54924                         }
54925                         else if (enumTag && enumTag.typeExpression) {
54926                             checkTypeAssignableTo(type, getTypeFromTypeNode(enumTag.typeExpression), memberDecl);
54927                         }
54928                     }
54929                     objectFlags |= ts.getObjectFlags(type) & 3670016;
54930                     var nameType = computedNameType && isTypeUsableAsPropertyName(computedNameType) ? computedNameType : undefined;
54931                     var prop = nameType ?
54932                         createSymbol(4 | member.flags, getPropertyNameFromType(nameType), checkFlags | 4096) :
54933                         createSymbol(4 | member.flags, member.escapedName, checkFlags);
54934                     if (nameType) {
54935                         prop.nameType = nameType;
54936                     }
54937                     if (inDestructuringPattern) {
54938                         var isOptional = (memberDecl.kind === 288 && hasDefaultValue(memberDecl.initializer)) ||
54939                             (memberDecl.kind === 289 && memberDecl.objectAssignmentInitializer);
54940                         if (isOptional) {
54941                             prop.flags |= 16777216;
54942                         }
54943                     }
54944                     else if (contextualTypeHasPattern && !(ts.getObjectFlags(contextualType) & 512)) {
54945                         var impliedProp = getPropertyOfType(contextualType, member.escapedName);
54946                         if (impliedProp) {
54947                             prop.flags |= impliedProp.flags & 16777216;
54948                         }
54949                         else if (!compilerOptions.suppressExcessPropertyErrors && !getIndexInfoOfType(contextualType, 0)) {
54950                             error(memberDecl.name, ts.Diagnostics.Object_literal_may_only_specify_known_properties_and_0_does_not_exist_in_type_1, symbolToString(member), typeToString(contextualType));
54951                         }
54952                     }
54953                     prop.declarations = member.declarations;
54954                     prop.parent = member.parent;
54955                     if (member.valueDeclaration) {
54956                         prop.valueDeclaration = member.valueDeclaration;
54957                     }
54958                     prop.type = type;
54959                     prop.target = member;
54960                     member = prop;
54961                     allPropertiesTable === null || allPropertiesTable === void 0 ? void 0 : allPropertiesTable.set(prop.escapedName, prop);
54962                 }
54963                 else if (memberDecl.kind === 290) {
54964                     if (languageVersion < 2) {
54965                         checkExternalEmitHelpers(memberDecl, 2);
54966                     }
54967                     if (propertiesArray.length > 0) {
54968                         spread = getSpreadType(spread, createObjectLiteralType(), node.symbol, objectFlags, inConstContext);
54969                         propertiesArray = [];
54970                         propertiesTable = ts.createSymbolTable();
54971                         hasComputedStringProperty = false;
54972                         hasComputedNumberProperty = false;
54973                     }
54974                     var type = getReducedType(checkExpression(memberDecl.expression));
54975                     if (!isValidSpreadType(type)) {
54976                         error(memberDecl, ts.Diagnostics.Spread_types_may_only_be_created_from_object_types);
54977                         return errorType;
54978                     }
54979                     if (allPropertiesTable) {
54980                         checkSpreadPropOverrides(type, allPropertiesTable, memberDecl);
54981                     }
54982                     spread = getSpreadType(spread, type, node.symbol, objectFlags, inConstContext);
54983                     offset = propertiesArray.length;
54984                     continue;
54985                 }
54986                 else {
54987                     ts.Debug.assert(memberDecl.kind === 167 || memberDecl.kind === 168);
54988                     checkNodeDeferred(memberDecl);
54989                 }
54990                 if (computedNameType && !(computedNameType.flags & 8576)) {
54991                     if (isTypeAssignableTo(computedNameType, stringNumberSymbolType)) {
54992                         if (isTypeAssignableTo(computedNameType, numberType)) {
54993                             hasComputedNumberProperty = true;
54994                         }
54995                         else {
54996                             hasComputedStringProperty = true;
54997                         }
54998                         if (inDestructuringPattern) {
54999                             patternWithComputedProperties = true;
55000                         }
55001                     }
55002                 }
55003                 else {
55004                     propertiesTable.set(member.escapedName, member);
55005                 }
55006                 propertiesArray.push(member);
55007             }
55008             if (contextualTypeHasPattern && node.parent.kind !== 290) {
55009                 for (var _d = 0, _e = getPropertiesOfType(contextualType); _d < _e.length; _d++) {
55010                     var prop = _e[_d];
55011                     if (!propertiesTable.get(prop.escapedName) && !getPropertyOfType(spread, prop.escapedName)) {
55012                         if (!(prop.flags & 16777216)) {
55013                             error(prop.valueDeclaration || prop.bindingElement, ts.Diagnostics.Initializer_provides_no_value_for_this_binding_element_and_the_binding_element_has_no_default_value);
55014                         }
55015                         propertiesTable.set(prop.escapedName, prop);
55016                         propertiesArray.push(prop);
55017                     }
55018                 }
55019             }
55020             if (spread !== emptyObjectType) {
55021                 if (propertiesArray.length > 0) {
55022                     spread = getSpreadType(spread, createObjectLiteralType(), node.symbol, objectFlags, inConstContext);
55023                     propertiesArray = [];
55024                     propertiesTable = ts.createSymbolTable();
55025                     hasComputedStringProperty = false;
55026                     hasComputedNumberProperty = false;
55027                 }
55028                 return mapType(spread, function (t) { return t === emptyObjectType ? createObjectLiteralType() : t; });
55029             }
55030             return createObjectLiteralType();
55031             function createObjectLiteralType() {
55032                 var stringIndexInfo = hasComputedStringProperty ? getObjectLiteralIndexInfo(node, offset, propertiesArray, 0) : undefined;
55033                 var numberIndexInfo = hasComputedNumberProperty ? getObjectLiteralIndexInfo(node, offset, propertiesArray, 1) : undefined;
55034                 var result = createAnonymousType(node.symbol, propertiesTable, ts.emptyArray, ts.emptyArray, stringIndexInfo, numberIndexInfo);
55035                 result.objectFlags |= objectFlags | 128 | 1048576;
55036                 if (isJSObjectLiteral) {
55037                     result.objectFlags |= 16384;
55038                 }
55039                 if (patternWithComputedProperties) {
55040                     result.objectFlags |= 512;
55041                 }
55042                 if (inDestructuringPattern) {
55043                     result.pattern = node;
55044                 }
55045                 return result;
55046             }
55047         }
55048         function isValidSpreadType(type) {
55049             if (type.flags & 465829888) {
55050                 var constraint = getBaseConstraintOfType(type);
55051                 if (constraint !== undefined) {
55052                     return isValidSpreadType(constraint);
55053                 }
55054             }
55055             return !!(type.flags & (1 | 67108864 | 524288 | 58982400) ||
55056                 getFalsyFlags(type) & 117632 && isValidSpreadType(removeDefinitelyFalsyTypes(type)) ||
55057                 type.flags & 3145728 && ts.every(type.types, isValidSpreadType));
55058         }
55059         function checkJsxSelfClosingElementDeferred(node) {
55060             checkJsxOpeningLikeElementOrOpeningFragment(node);
55061         }
55062         function checkJsxSelfClosingElement(node, _checkMode) {
55063             checkNodeDeferred(node);
55064             return getJsxElementTypeAt(node) || anyType;
55065         }
55066         function checkJsxElementDeferred(node) {
55067             checkJsxOpeningLikeElementOrOpeningFragment(node.openingElement);
55068             if (isJsxIntrinsicIdentifier(node.closingElement.tagName)) {
55069                 getIntrinsicTagSymbol(node.closingElement);
55070             }
55071             else {
55072                 checkExpression(node.closingElement.tagName);
55073             }
55074             checkJsxChildren(node);
55075         }
55076         function checkJsxElement(node, _checkMode) {
55077             checkNodeDeferred(node);
55078             return getJsxElementTypeAt(node) || anyType;
55079         }
55080         function checkJsxFragment(node) {
55081             checkJsxOpeningLikeElementOrOpeningFragment(node.openingFragment);
55082             var nodeSourceFile = ts.getSourceFileOfNode(node);
55083             if (ts.getJSXTransformEnabled(compilerOptions) && (compilerOptions.jsxFactory || nodeSourceFile.pragmas.has("jsx"))
55084                 && !compilerOptions.jsxFragmentFactory && !nodeSourceFile.pragmas.has("jsxfrag")) {
55085                 error(node, compilerOptions.jsxFactory
55086                     ? ts.Diagnostics.The_jsxFragmentFactory_compiler_option_must_be_provided_to_use_JSX_fragments_with_the_jsxFactory_compiler_option
55087                     : ts.Diagnostics.An_jsxFrag_pragma_is_required_when_using_an_jsx_pragma_with_JSX_fragments);
55088             }
55089             checkJsxChildren(node);
55090             return getJsxElementTypeAt(node) || anyType;
55091         }
55092         function isUnhyphenatedJsxName(name) {
55093             return !ts.stringContains(name, "-");
55094         }
55095         function isJsxIntrinsicIdentifier(tagName) {
55096             return tagName.kind === 78 && ts.isIntrinsicJsxName(tagName.escapedText);
55097         }
55098         function checkJsxAttribute(node, checkMode) {
55099             return node.initializer
55100                 ? checkExpressionForMutableLocation(node.initializer, checkMode)
55101                 : trueType;
55102         }
55103         function createJsxAttributesTypeFromAttributesProperty(openingLikeElement, checkMode) {
55104             var attributes = openingLikeElement.attributes;
55105             var allAttributesTable = strictNullChecks ? ts.createSymbolTable() : undefined;
55106             var attributesTable = ts.createSymbolTable();
55107             var spread = emptyJsxObjectType;
55108             var hasSpreadAnyType = false;
55109             var typeToIntersect;
55110             var explicitlySpecifyChildrenAttribute = false;
55111             var objectFlags = 4096;
55112             var jsxChildrenPropertyName = getJsxElementChildrenPropertyName(getJsxNamespaceAt(openingLikeElement));
55113             for (var _i = 0, _a = attributes.properties; _i < _a.length; _i++) {
55114                 var attributeDecl = _a[_i];
55115                 var member = attributeDecl.symbol;
55116                 if (ts.isJsxAttribute(attributeDecl)) {
55117                     var exprType = checkJsxAttribute(attributeDecl, checkMode);
55118                     objectFlags |= ts.getObjectFlags(exprType) & 3670016;
55119                     var attributeSymbol = createSymbol(4 | member.flags, member.escapedName);
55120                     attributeSymbol.declarations = member.declarations;
55121                     attributeSymbol.parent = member.parent;
55122                     if (member.valueDeclaration) {
55123                         attributeSymbol.valueDeclaration = member.valueDeclaration;
55124                     }
55125                     attributeSymbol.type = exprType;
55126                     attributeSymbol.target = member;
55127                     attributesTable.set(attributeSymbol.escapedName, attributeSymbol);
55128                     allAttributesTable === null || allAttributesTable === void 0 ? void 0 : allAttributesTable.set(attributeSymbol.escapedName, attributeSymbol);
55129                     if (attributeDecl.name.escapedText === jsxChildrenPropertyName) {
55130                         explicitlySpecifyChildrenAttribute = true;
55131                     }
55132                 }
55133                 else {
55134                     ts.Debug.assert(attributeDecl.kind === 282);
55135                     if (attributesTable.size > 0) {
55136                         spread = getSpreadType(spread, createJsxAttributesType(), attributes.symbol, objectFlags, false);
55137                         attributesTable = ts.createSymbolTable();
55138                     }
55139                     var exprType = getReducedType(checkExpressionCached(attributeDecl.expression, checkMode));
55140                     if (isTypeAny(exprType)) {
55141                         hasSpreadAnyType = true;
55142                     }
55143                     if (isValidSpreadType(exprType)) {
55144                         spread = getSpreadType(spread, exprType, attributes.symbol, objectFlags, false);
55145                         if (allAttributesTable) {
55146                             checkSpreadPropOverrides(exprType, allAttributesTable, attributeDecl);
55147                         }
55148                     }
55149                     else {
55150                         typeToIntersect = typeToIntersect ? getIntersectionType([typeToIntersect, exprType]) : exprType;
55151                     }
55152                 }
55153             }
55154             if (!hasSpreadAnyType) {
55155                 if (attributesTable.size > 0) {
55156                     spread = getSpreadType(spread, createJsxAttributesType(), attributes.symbol, objectFlags, false);
55157                 }
55158             }
55159             var parent = openingLikeElement.parent.kind === 273 ? openingLikeElement.parent : undefined;
55160             if (parent && parent.openingElement === openingLikeElement && parent.children.length > 0) {
55161                 var childrenTypes = checkJsxChildren(parent, checkMode);
55162                 if (!hasSpreadAnyType && jsxChildrenPropertyName && jsxChildrenPropertyName !== "") {
55163                     if (explicitlySpecifyChildrenAttribute) {
55164                         error(attributes, ts.Diagnostics._0_are_specified_twice_The_attribute_named_0_will_be_overwritten, ts.unescapeLeadingUnderscores(jsxChildrenPropertyName));
55165                     }
55166                     var contextualType = getApparentTypeOfContextualType(openingLikeElement.attributes);
55167                     var childrenContextualType = contextualType && getTypeOfPropertyOfContextualType(contextualType, jsxChildrenPropertyName);
55168                     var childrenPropSymbol = createSymbol(4, jsxChildrenPropertyName);
55169                     childrenPropSymbol.type = childrenTypes.length === 1 ? childrenTypes[0] :
55170                         childrenContextualType && forEachType(childrenContextualType, isTupleLikeType) ? createTupleType(childrenTypes) :
55171                             createArrayType(getUnionType(childrenTypes));
55172                     childrenPropSymbol.valueDeclaration = ts.factory.createPropertySignature(undefined, ts.unescapeLeadingUnderscores(jsxChildrenPropertyName), undefined, undefined);
55173                     ts.setParent(childrenPropSymbol.valueDeclaration, attributes);
55174                     childrenPropSymbol.valueDeclaration.symbol = childrenPropSymbol;
55175                     var childPropMap = ts.createSymbolTable();
55176                     childPropMap.set(jsxChildrenPropertyName, childrenPropSymbol);
55177                     spread = getSpreadType(spread, createAnonymousType(attributes.symbol, childPropMap, ts.emptyArray, ts.emptyArray, undefined, undefined), attributes.symbol, objectFlags, false);
55178                 }
55179             }
55180             if (hasSpreadAnyType) {
55181                 return anyType;
55182             }
55183             if (typeToIntersect && spread !== emptyJsxObjectType) {
55184                 return getIntersectionType([typeToIntersect, spread]);
55185             }
55186             return typeToIntersect || (spread === emptyJsxObjectType ? createJsxAttributesType() : spread);
55187             function createJsxAttributesType() {
55188                 objectFlags |= freshObjectLiteralFlag;
55189                 var result = createAnonymousType(attributes.symbol, attributesTable, ts.emptyArray, ts.emptyArray, undefined, undefined);
55190                 result.objectFlags |= objectFlags | 128 | 1048576;
55191                 return result;
55192             }
55193         }
55194         function checkJsxChildren(node, checkMode) {
55195             var childrenTypes = [];
55196             for (var _i = 0, _a = node.children; _i < _a.length; _i++) {
55197                 var child = _a[_i];
55198                 if (child.kind === 11) {
55199                     if (!child.containsOnlyTriviaWhiteSpaces) {
55200                         childrenTypes.push(stringType);
55201                     }
55202                 }
55203                 else if (child.kind === 283 && !child.expression) {
55204                     continue;
55205                 }
55206                 else {
55207                     childrenTypes.push(checkExpressionForMutableLocation(child, checkMode));
55208                 }
55209             }
55210             return childrenTypes;
55211         }
55212         function checkSpreadPropOverrides(type, props, spread) {
55213             for (var _i = 0, _a = getPropertiesOfType(type); _i < _a.length; _i++) {
55214                 var right = _a[_i];
55215                 var left = props.get(right.escapedName);
55216                 var rightType = getTypeOfSymbol(right);
55217                 if (left && !maybeTypeOfKind(rightType, 98304) && !(maybeTypeOfKind(rightType, 3) && right.flags & 16777216)) {
55218                     var diagnostic = error(left.valueDeclaration, ts.Diagnostics._0_is_specified_more_than_once_so_this_usage_will_be_overwritten, ts.unescapeLeadingUnderscores(left.escapedName));
55219                     ts.addRelatedInfo(diagnostic, ts.createDiagnosticForNode(spread, ts.Diagnostics.This_spread_always_overwrites_this_property));
55220                 }
55221             }
55222         }
55223         function checkJsxAttributes(node, checkMode) {
55224             return createJsxAttributesTypeFromAttributesProperty(node.parent, checkMode);
55225         }
55226         function getJsxType(name, location) {
55227             var namespace = getJsxNamespaceAt(location);
55228             var exports = namespace && getExportsOfSymbol(namespace);
55229             var typeSymbol = exports && getSymbol(exports, name, 788968);
55230             return typeSymbol ? getDeclaredTypeOfSymbol(typeSymbol) : errorType;
55231         }
55232         function getIntrinsicTagSymbol(node) {
55233             var links = getNodeLinks(node);
55234             if (!links.resolvedSymbol) {
55235                 var intrinsicElementsType = getJsxType(JsxNames.IntrinsicElements, node);
55236                 if (intrinsicElementsType !== errorType) {
55237                     if (!ts.isIdentifier(node.tagName))
55238                         return ts.Debug.fail();
55239                     var intrinsicProp = getPropertyOfType(intrinsicElementsType, node.tagName.escapedText);
55240                     if (intrinsicProp) {
55241                         links.jsxFlags |= 1;
55242                         return links.resolvedSymbol = intrinsicProp;
55243                     }
55244                     var indexSignatureType = getIndexTypeOfType(intrinsicElementsType, 0);
55245                     if (indexSignatureType) {
55246                         links.jsxFlags |= 2;
55247                         return links.resolvedSymbol = intrinsicElementsType.symbol;
55248                     }
55249                     error(node, ts.Diagnostics.Property_0_does_not_exist_on_type_1, ts.idText(node.tagName), "JSX." + JsxNames.IntrinsicElements);
55250                     return links.resolvedSymbol = unknownSymbol;
55251                 }
55252                 else {
55253                     if (noImplicitAny) {
55254                         error(node, ts.Diagnostics.JSX_element_implicitly_has_type_any_because_no_interface_JSX_0_exists, ts.unescapeLeadingUnderscores(JsxNames.IntrinsicElements));
55255                     }
55256                     return links.resolvedSymbol = unknownSymbol;
55257                 }
55258             }
55259             return links.resolvedSymbol;
55260         }
55261         function getJsxNamespaceContainerForImplicitImport(location) {
55262             var file = location && ts.getSourceFileOfNode(location);
55263             var links = file && getNodeLinks(file);
55264             if (links && links.jsxImplicitImportContainer === false) {
55265                 return undefined;
55266             }
55267             if (links && links.jsxImplicitImportContainer) {
55268                 return links.jsxImplicitImportContainer;
55269             }
55270             var runtimeImportSpecifier = ts.getJSXRuntimeImport(ts.getJSXImplicitImportBase(compilerOptions, file), compilerOptions);
55271             if (!runtimeImportSpecifier) {
55272                 return undefined;
55273             }
55274             var isClassic = ts.getEmitModuleResolutionKind(compilerOptions) === ts.ModuleResolutionKind.Classic;
55275             var errorMessage = isClassic
55276                 ? ts.Diagnostics.Cannot_find_module_0_Did_you_mean_to_set_the_moduleResolution_option_to_node_or_to_add_aliases_to_the_paths_option
55277                 : ts.Diagnostics.Cannot_find_module_0_or_its_corresponding_type_declarations;
55278             var mod = resolveExternalModule(location, runtimeImportSpecifier, errorMessage, location);
55279             var result = mod && mod !== unknownSymbol ? getMergedSymbol(resolveSymbol(mod)) : undefined;
55280             if (links) {
55281                 links.jsxImplicitImportContainer = result || false;
55282             }
55283             return result;
55284         }
55285         function getJsxNamespaceAt(location) {
55286             var links = location && getNodeLinks(location);
55287             if (links && links.jsxNamespace) {
55288                 return links.jsxNamespace;
55289             }
55290             if (!links || links.jsxNamespace !== false) {
55291                 var resolvedNamespace = getJsxNamespaceContainerForImplicitImport(location);
55292                 if (!resolvedNamespace || resolvedNamespace === unknownSymbol) {
55293                     var namespaceName = getJsxNamespace(location);
55294                     resolvedNamespace = resolveName(location, namespaceName, 1920, undefined, namespaceName, false);
55295                 }
55296                 if (resolvedNamespace) {
55297                     var candidate = resolveSymbol(getSymbol(getExportsOfSymbol(resolveSymbol(resolvedNamespace)), JsxNames.JSX, 1920));
55298                     if (candidate && candidate !== unknownSymbol) {
55299                         if (links) {
55300                             links.jsxNamespace = candidate;
55301                         }
55302                         return candidate;
55303                     }
55304                 }
55305                 if (links) {
55306                     links.jsxNamespace = false;
55307                 }
55308             }
55309             var s = resolveSymbol(getGlobalSymbol(JsxNames.JSX, 1920, undefined));
55310             if (s === unknownSymbol) {
55311                 return undefined;
55312             }
55313             return s;
55314         }
55315         function getNameFromJsxElementAttributesContainer(nameOfAttribPropContainer, jsxNamespace) {
55316             var jsxElementAttribPropInterfaceSym = jsxNamespace && getSymbol(jsxNamespace.exports, nameOfAttribPropContainer, 788968);
55317             var jsxElementAttribPropInterfaceType = jsxElementAttribPropInterfaceSym && getDeclaredTypeOfSymbol(jsxElementAttribPropInterfaceSym);
55318             var propertiesOfJsxElementAttribPropInterface = jsxElementAttribPropInterfaceType && getPropertiesOfType(jsxElementAttribPropInterfaceType);
55319             if (propertiesOfJsxElementAttribPropInterface) {
55320                 if (propertiesOfJsxElementAttribPropInterface.length === 0) {
55321                     return "";
55322                 }
55323                 else if (propertiesOfJsxElementAttribPropInterface.length === 1) {
55324                     return propertiesOfJsxElementAttribPropInterface[0].escapedName;
55325                 }
55326                 else if (propertiesOfJsxElementAttribPropInterface.length > 1) {
55327                     error(jsxElementAttribPropInterfaceSym.declarations[0], ts.Diagnostics.The_global_type_JSX_0_may_not_have_more_than_one_property, ts.unescapeLeadingUnderscores(nameOfAttribPropContainer));
55328                 }
55329             }
55330             return undefined;
55331         }
55332         function getJsxLibraryManagedAttributes(jsxNamespace) {
55333             return jsxNamespace && getSymbol(jsxNamespace.exports, JsxNames.LibraryManagedAttributes, 788968);
55334         }
55335         function getJsxElementPropertiesName(jsxNamespace) {
55336             return getNameFromJsxElementAttributesContainer(JsxNames.ElementAttributesPropertyNameContainer, jsxNamespace);
55337         }
55338         function getJsxElementChildrenPropertyName(jsxNamespace) {
55339             return getNameFromJsxElementAttributesContainer(JsxNames.ElementChildrenAttributeNameContainer, jsxNamespace);
55340         }
55341         function getUninstantiatedJsxSignaturesOfType(elementType, caller) {
55342             if (elementType.flags & 4) {
55343                 return [anySignature];
55344             }
55345             else if (elementType.flags & 128) {
55346                 var intrinsicType = getIntrinsicAttributesTypeFromStringLiteralType(elementType, caller);
55347                 if (!intrinsicType) {
55348                     error(caller, ts.Diagnostics.Property_0_does_not_exist_on_type_1, elementType.value, "JSX." + JsxNames.IntrinsicElements);
55349                     return ts.emptyArray;
55350                 }
55351                 else {
55352                     var fakeSignature = createSignatureForJSXIntrinsic(caller, intrinsicType);
55353                     return [fakeSignature];
55354                 }
55355             }
55356             var apparentElemType = getApparentType(elementType);
55357             var signatures = getSignaturesOfType(apparentElemType, 1);
55358             if (signatures.length === 0) {
55359                 signatures = getSignaturesOfType(apparentElemType, 0);
55360             }
55361             if (signatures.length === 0 && apparentElemType.flags & 1048576) {
55362                 signatures = getUnionSignatures(ts.map(apparentElemType.types, function (t) { return getUninstantiatedJsxSignaturesOfType(t, caller); }));
55363             }
55364             return signatures;
55365         }
55366         function getIntrinsicAttributesTypeFromStringLiteralType(type, location) {
55367             var intrinsicElementsType = getJsxType(JsxNames.IntrinsicElements, location);
55368             if (intrinsicElementsType !== errorType) {
55369                 var stringLiteralTypeName = type.value;
55370                 var intrinsicProp = getPropertyOfType(intrinsicElementsType, ts.escapeLeadingUnderscores(stringLiteralTypeName));
55371                 if (intrinsicProp) {
55372                     return getTypeOfSymbol(intrinsicProp);
55373                 }
55374                 var indexSignatureType = getIndexTypeOfType(intrinsicElementsType, 0);
55375                 if (indexSignatureType) {
55376                     return indexSignatureType;
55377                 }
55378                 return undefined;
55379             }
55380             return anyType;
55381         }
55382         function checkJsxReturnAssignableToAppropriateBound(refKind, elemInstanceType, openingLikeElement) {
55383             if (refKind === 1) {
55384                 var sfcReturnConstraint = getJsxStatelessElementTypeAt(openingLikeElement);
55385                 if (sfcReturnConstraint) {
55386                     checkTypeRelatedTo(elemInstanceType, sfcReturnConstraint, assignableRelation, openingLikeElement.tagName, ts.Diagnostics.Its_return_type_0_is_not_a_valid_JSX_element, generateInitialErrorChain);
55387                 }
55388             }
55389             else if (refKind === 0) {
55390                 var classConstraint = getJsxElementClassTypeAt(openingLikeElement);
55391                 if (classConstraint) {
55392                     checkTypeRelatedTo(elemInstanceType, classConstraint, assignableRelation, openingLikeElement.tagName, ts.Diagnostics.Its_instance_type_0_is_not_a_valid_JSX_element, generateInitialErrorChain);
55393                 }
55394             }
55395             else {
55396                 var sfcReturnConstraint = getJsxStatelessElementTypeAt(openingLikeElement);
55397                 var classConstraint = getJsxElementClassTypeAt(openingLikeElement);
55398                 if (!sfcReturnConstraint || !classConstraint) {
55399                     return;
55400                 }
55401                 var combined = getUnionType([sfcReturnConstraint, classConstraint]);
55402                 checkTypeRelatedTo(elemInstanceType, combined, assignableRelation, openingLikeElement.tagName, ts.Diagnostics.Its_element_type_0_is_not_a_valid_JSX_element, generateInitialErrorChain);
55403             }
55404             function generateInitialErrorChain() {
55405                 var componentName = ts.getTextOfNode(openingLikeElement.tagName);
55406                 return ts.chainDiagnosticMessages(undefined, ts.Diagnostics._0_cannot_be_used_as_a_JSX_component, componentName);
55407             }
55408         }
55409         function getIntrinsicAttributesTypeFromJsxOpeningLikeElement(node) {
55410             ts.Debug.assert(isJsxIntrinsicIdentifier(node.tagName));
55411             var links = getNodeLinks(node);
55412             if (!links.resolvedJsxElementAttributesType) {
55413                 var symbol = getIntrinsicTagSymbol(node);
55414                 if (links.jsxFlags & 1) {
55415                     return links.resolvedJsxElementAttributesType = getTypeOfSymbol(symbol);
55416                 }
55417                 else if (links.jsxFlags & 2) {
55418                     return links.resolvedJsxElementAttributesType =
55419                         getIndexTypeOfType(getDeclaredTypeOfSymbol(symbol), 0);
55420                 }
55421                 else {
55422                     return links.resolvedJsxElementAttributesType = errorType;
55423                 }
55424             }
55425             return links.resolvedJsxElementAttributesType;
55426         }
55427         function getJsxElementClassTypeAt(location) {
55428             var type = getJsxType(JsxNames.ElementClass, location);
55429             if (type === errorType)
55430                 return undefined;
55431             return type;
55432         }
55433         function getJsxElementTypeAt(location) {
55434             return getJsxType(JsxNames.Element, location);
55435         }
55436         function getJsxStatelessElementTypeAt(location) {
55437             var jsxElementType = getJsxElementTypeAt(location);
55438             if (jsxElementType) {
55439                 return getUnionType([jsxElementType, nullType]);
55440             }
55441         }
55442         function getJsxIntrinsicTagNamesAt(location) {
55443             var intrinsics = getJsxType(JsxNames.IntrinsicElements, location);
55444             return intrinsics ? getPropertiesOfType(intrinsics) : ts.emptyArray;
55445         }
55446         function checkJsxPreconditions(errorNode) {
55447             if ((compilerOptions.jsx || 0) === 0) {
55448                 error(errorNode, ts.Diagnostics.Cannot_use_JSX_unless_the_jsx_flag_is_provided);
55449             }
55450             if (getJsxElementTypeAt(errorNode) === undefined) {
55451                 if (noImplicitAny) {
55452                     error(errorNode, ts.Diagnostics.JSX_element_implicitly_has_type_any_because_the_global_type_JSX_Element_does_not_exist);
55453                 }
55454             }
55455         }
55456         function checkJsxOpeningLikeElementOrOpeningFragment(node) {
55457             var isNodeOpeningLikeElement = ts.isJsxOpeningLikeElement(node);
55458             if (isNodeOpeningLikeElement) {
55459                 checkGrammarJsxElement(node);
55460             }
55461             checkJsxPreconditions(node);
55462             if (!getJsxNamespaceContainerForImplicitImport(node)) {
55463                 var jsxFactoryRefErr = diagnostics && compilerOptions.jsx === 2 ? ts.Diagnostics.Cannot_find_name_0 : undefined;
55464                 var jsxFactoryNamespace = getJsxNamespace(node);
55465                 var jsxFactoryLocation = isNodeOpeningLikeElement ? node.tagName : node;
55466                 var jsxFactorySym = void 0;
55467                 if (!(ts.isJsxOpeningFragment(node) && jsxFactoryNamespace === "null")) {
55468                     jsxFactorySym = resolveName(jsxFactoryLocation, jsxFactoryNamespace, 111551, jsxFactoryRefErr, jsxFactoryNamespace, true);
55469                 }
55470                 if (jsxFactorySym) {
55471                     jsxFactorySym.isReferenced = 67108863;
55472                     if (jsxFactorySym.flags & 2097152 && !getTypeOnlyAliasDeclaration(jsxFactorySym)) {
55473                         markAliasSymbolAsReferenced(jsxFactorySym);
55474                     }
55475                 }
55476             }
55477             if (isNodeOpeningLikeElement) {
55478                 var jsxOpeningLikeNode = node;
55479                 var sig = getResolvedSignature(jsxOpeningLikeNode);
55480                 checkDeprecatedSignature(sig, node);
55481                 checkJsxReturnAssignableToAppropriateBound(getJsxReferenceKind(jsxOpeningLikeNode), getReturnTypeOfSignature(sig), jsxOpeningLikeNode);
55482             }
55483         }
55484         function isKnownProperty(targetType, name, isComparingJsxAttributes) {
55485             if (targetType.flags & 524288) {
55486                 var resolved = resolveStructuredTypeMembers(targetType);
55487                 if (resolved.stringIndexInfo ||
55488                     resolved.numberIndexInfo && isNumericLiteralName(name) ||
55489                     getPropertyOfObjectType(targetType, name) ||
55490                     isComparingJsxAttributes && !isUnhyphenatedJsxName(name)) {
55491                     return true;
55492                 }
55493             }
55494             else if (targetType.flags & 3145728 && isExcessPropertyCheckTarget(targetType)) {
55495                 for (var _i = 0, _a = targetType.types; _i < _a.length; _i++) {
55496                     var t = _a[_i];
55497                     if (isKnownProperty(t, name, isComparingJsxAttributes)) {
55498                         return true;
55499                     }
55500                 }
55501             }
55502             return false;
55503         }
55504         function isExcessPropertyCheckTarget(type) {
55505             return !!(type.flags & 524288 && !(ts.getObjectFlags(type) & 512) ||
55506                 type.flags & 67108864 ||
55507                 type.flags & 1048576 && ts.some(type.types, isExcessPropertyCheckTarget) ||
55508                 type.flags & 2097152 && ts.every(type.types, isExcessPropertyCheckTarget));
55509         }
55510         function checkJsxExpression(node, checkMode) {
55511             checkGrammarJsxExpression(node);
55512             if (node.expression) {
55513                 var type = checkExpression(node.expression, checkMode);
55514                 if (node.dotDotDotToken && type !== anyType && !isArrayType(type)) {
55515                     error(node, ts.Diagnostics.JSX_spread_child_must_be_an_array_type);
55516                 }
55517                 return type;
55518             }
55519             else {
55520                 return errorType;
55521             }
55522         }
55523         function getDeclarationNodeFlagsFromSymbol(s) {
55524             return s.valueDeclaration ? ts.getCombinedNodeFlags(s.valueDeclaration) : 0;
55525         }
55526         function isPrototypeProperty(symbol) {
55527             if (symbol.flags & 8192 || ts.getCheckFlags(symbol) & 4) {
55528                 return true;
55529             }
55530             if (ts.isInJSFile(symbol.valueDeclaration)) {
55531                 var parent = symbol.valueDeclaration.parent;
55532                 return parent && ts.isBinaryExpression(parent) &&
55533                     ts.getAssignmentDeclarationKind(parent) === 3;
55534             }
55535         }
55536         function checkPropertyAccessibility(node, isSuper, type, prop) {
55537             var flags = ts.getDeclarationModifierFlagsFromSymbol(prop);
55538             var errorNode = node.kind === 157 ? node.right : node.kind === 195 ? node : node.name;
55539             if (isSuper) {
55540                 if (languageVersion < 2) {
55541                     if (symbolHasNonMethodDeclaration(prop)) {
55542                         error(errorNode, ts.Diagnostics.Only_public_and_protected_methods_of_the_base_class_are_accessible_via_the_super_keyword);
55543                         return false;
55544                     }
55545                 }
55546                 if (flags & 128) {
55547                     error(errorNode, ts.Diagnostics.Abstract_method_0_in_class_1_cannot_be_accessed_via_super_expression, symbolToString(prop), typeToString(getDeclaringClass(prop)));
55548                     return false;
55549                 }
55550             }
55551             if ((flags & 128) && ts.isThisProperty(node) && symbolHasNonMethodDeclaration(prop)) {
55552                 var declaringClassDeclaration = ts.getClassLikeDeclarationOfSymbol(getParentOfSymbol(prop));
55553                 if (declaringClassDeclaration && isNodeUsedDuringClassInitialization(node)) {
55554                     error(errorNode, ts.Diagnostics.Abstract_property_0_in_class_1_cannot_be_accessed_in_the_constructor, symbolToString(prop), ts.getTextOfIdentifierOrLiteral(declaringClassDeclaration.name));
55555                     return false;
55556                 }
55557             }
55558             if (ts.isPropertyAccessExpression(node) && ts.isPrivateIdentifier(node.name)) {
55559                 if (!ts.getContainingClass(node)) {
55560                     error(errorNode, ts.Diagnostics.Private_identifiers_are_not_allowed_outside_class_bodies);
55561                     return false;
55562                 }
55563                 return true;
55564             }
55565             if (!(flags & 24)) {
55566                 return true;
55567             }
55568             if (flags & 8) {
55569                 var declaringClassDeclaration = ts.getClassLikeDeclarationOfSymbol(getParentOfSymbol(prop));
55570                 if (!isNodeWithinClass(node, declaringClassDeclaration)) {
55571                     error(errorNode, ts.Diagnostics.Property_0_is_private_and_only_accessible_within_class_1, symbolToString(prop), typeToString(getDeclaringClass(prop)));
55572                     return false;
55573                 }
55574                 return true;
55575             }
55576             if (isSuper) {
55577                 return true;
55578             }
55579             var enclosingClass = forEachEnclosingClass(node, function (enclosingDeclaration) {
55580                 var enclosingClass = getDeclaredTypeOfSymbol(getSymbolOfNode(enclosingDeclaration));
55581                 return isClassDerivedFromDeclaringClasses(enclosingClass, prop) ? enclosingClass : undefined;
55582             });
55583             if (!enclosingClass) {
55584                 var thisParameter = void 0;
55585                 if (flags & 32 || !(thisParameter = getThisParameterFromNodeContext(node)) || !thisParameter.type) {
55586                     error(errorNode, ts.Diagnostics.Property_0_is_protected_and_only_accessible_within_class_1_and_its_subclasses, symbolToString(prop), typeToString(getDeclaringClass(prop) || type));
55587                     return false;
55588                 }
55589                 var thisType = getTypeFromTypeNode(thisParameter.type);
55590                 enclosingClass = ((thisType.flags & 262144) ? getConstraintOfTypeParameter(thisType) : thisType).target;
55591             }
55592             if (flags & 32) {
55593                 return true;
55594             }
55595             if (type.flags & 262144) {
55596                 type = type.isThisType ? getConstraintOfTypeParameter(type) : getBaseConstraintOfType(type);
55597             }
55598             if (!type || !hasBaseType(type, enclosingClass)) {
55599                 error(errorNode, ts.Diagnostics.Property_0_is_protected_and_only_accessible_through_an_instance_of_class_1, symbolToString(prop), typeToString(enclosingClass));
55600                 return false;
55601             }
55602             return true;
55603         }
55604         function getThisParameterFromNodeContext(node) {
55605             var thisContainer = ts.getThisContainer(node, false);
55606             return thisContainer && ts.isFunctionLike(thisContainer) ? ts.getThisParameter(thisContainer) : undefined;
55607         }
55608         function symbolHasNonMethodDeclaration(symbol) {
55609             return !!forEachProperty(symbol, function (prop) { return !(prop.flags & 8192); });
55610         }
55611         function checkNonNullExpression(node) {
55612             return checkNonNullType(checkExpression(node), node);
55613         }
55614         function isNullableType(type) {
55615             return !!((strictNullChecks ? getFalsyFlags(type) : type.flags) & 98304);
55616         }
55617         function getNonNullableTypeIfNeeded(type) {
55618             return isNullableType(type) ? getNonNullableType(type) : type;
55619         }
55620         function reportObjectPossiblyNullOrUndefinedError(node, flags) {
55621             error(node, flags & 32768 ? flags & 65536 ?
55622                 ts.Diagnostics.Object_is_possibly_null_or_undefined :
55623                 ts.Diagnostics.Object_is_possibly_undefined :
55624                 ts.Diagnostics.Object_is_possibly_null);
55625         }
55626         function reportCannotInvokePossiblyNullOrUndefinedError(node, flags) {
55627             error(node, flags & 32768 ? flags & 65536 ?
55628                 ts.Diagnostics.Cannot_invoke_an_object_which_is_possibly_null_or_undefined :
55629                 ts.Diagnostics.Cannot_invoke_an_object_which_is_possibly_undefined :
55630                 ts.Diagnostics.Cannot_invoke_an_object_which_is_possibly_null);
55631         }
55632         function checkNonNullTypeWithReporter(type, node, reportError) {
55633             if (strictNullChecks && type.flags & 2) {
55634                 error(node, ts.Diagnostics.Object_is_of_type_unknown);
55635                 return errorType;
55636             }
55637             var kind = (strictNullChecks ? getFalsyFlags(type) : type.flags) & 98304;
55638             if (kind) {
55639                 reportError(node, kind);
55640                 var t = getNonNullableType(type);
55641                 return t.flags & (98304 | 131072) ? errorType : t;
55642             }
55643             return type;
55644         }
55645         function checkNonNullType(type, node) {
55646             return checkNonNullTypeWithReporter(type, node, reportObjectPossiblyNullOrUndefinedError);
55647         }
55648         function checkNonNullNonVoidType(type, node) {
55649             var nonNullType = checkNonNullType(type, node);
55650             if (nonNullType !== errorType && nonNullType.flags & 16384) {
55651                 error(node, ts.Diagnostics.Object_is_possibly_undefined);
55652             }
55653             return nonNullType;
55654         }
55655         function checkPropertyAccessExpression(node) {
55656             return node.flags & 32 ? checkPropertyAccessChain(node) :
55657                 checkPropertyAccessExpressionOrQualifiedName(node, node.expression, checkNonNullExpression(node.expression), node.name);
55658         }
55659         function checkPropertyAccessChain(node) {
55660             var leftType = checkExpression(node.expression);
55661             var nonOptionalType = getOptionalExpressionType(leftType, node.expression);
55662             return propagateOptionalTypeMarker(checkPropertyAccessExpressionOrQualifiedName(node, node.expression, checkNonNullType(nonOptionalType, node.expression), node.name), node, nonOptionalType !== leftType);
55663         }
55664         function checkQualifiedName(node) {
55665             return checkPropertyAccessExpressionOrQualifiedName(node, node.left, checkNonNullExpression(node.left), node.right);
55666         }
55667         function isMethodAccessForCall(node) {
55668             while (node.parent.kind === 207) {
55669                 node = node.parent;
55670             }
55671             return ts.isCallOrNewExpression(node.parent) && node.parent.expression === node;
55672         }
55673         function lookupSymbolForPrivateIdentifierDeclaration(propName, location) {
55674             for (var containingClass = ts.getContainingClass(location); !!containingClass; containingClass = ts.getContainingClass(containingClass)) {
55675                 var symbol = containingClass.symbol;
55676                 var name = ts.getSymbolNameForPrivateIdentifier(symbol, propName);
55677                 var prop = (symbol.members && symbol.members.get(name)) || (symbol.exports && symbol.exports.get(name));
55678                 if (prop) {
55679                     return prop;
55680                 }
55681             }
55682         }
55683         function getPrivateIdentifierPropertyOfType(leftType, lexicallyScopedIdentifier) {
55684             return getPropertyOfType(leftType, lexicallyScopedIdentifier.escapedName);
55685         }
55686         function checkPrivateIdentifierPropertyAccess(leftType, right, lexicallyScopedIdentifier) {
55687             var propertyOnType;
55688             var properties = getPropertiesOfType(leftType);
55689             if (properties) {
55690                 ts.forEach(properties, function (symbol) {
55691                     var decl = symbol.valueDeclaration;
55692                     if (decl && ts.isNamedDeclaration(decl) && ts.isPrivateIdentifier(decl.name) && decl.name.escapedText === right.escapedText) {
55693                         propertyOnType = symbol;
55694                         return true;
55695                     }
55696                 });
55697             }
55698             var diagName = diagnosticName(right);
55699             if (propertyOnType) {
55700                 var typeValueDecl = propertyOnType.valueDeclaration;
55701                 var typeClass_1 = ts.getContainingClass(typeValueDecl);
55702                 ts.Debug.assert(!!typeClass_1);
55703                 if (lexicallyScopedIdentifier) {
55704                     var lexicalValueDecl = lexicallyScopedIdentifier.valueDeclaration;
55705                     var lexicalClass = ts.getContainingClass(lexicalValueDecl);
55706                     ts.Debug.assert(!!lexicalClass);
55707                     if (ts.findAncestor(lexicalClass, function (n) { return typeClass_1 === n; })) {
55708                         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));
55709                         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));
55710                         return true;
55711                     }
55712                 }
55713                 error(right, ts.Diagnostics.Property_0_is_not_accessible_outside_class_1_because_it_has_a_private_identifier, diagName, diagnosticName(typeClass_1.name || anon));
55714                 return true;
55715             }
55716             return false;
55717         }
55718         function isThisPropertyAccessInConstructor(node, prop) {
55719             return (isConstructorDeclaredProperty(prop) || ts.isThisProperty(node) && isAutoTypedProperty(prop))
55720                 && ts.getThisContainer(node, true) === getDeclaringConstructor(prop);
55721         }
55722         function checkPropertyAccessExpressionOrQualifiedName(node, left, leftType, right) {
55723             var parentSymbol = getNodeLinks(left).resolvedSymbol;
55724             var assignmentKind = ts.getAssignmentTargetKind(node);
55725             var apparentType = getApparentType(assignmentKind !== 0 || isMethodAccessForCall(node) ? getWidenedType(leftType) : leftType);
55726             if (ts.isPrivateIdentifier(right)) {
55727                 checkExternalEmitHelpers(node, 1048576);
55728             }
55729             var isAnyLike = isTypeAny(apparentType) || apparentType === silentNeverType;
55730             var prop;
55731             if (ts.isPrivateIdentifier(right)) {
55732                 var lexicallyScopedSymbol = lookupSymbolForPrivateIdentifierDeclaration(right.escapedText, right);
55733                 if (isAnyLike) {
55734                     if (lexicallyScopedSymbol) {
55735                         return apparentType;
55736                     }
55737                     if (!ts.getContainingClass(right)) {
55738                         grammarErrorOnNode(right, ts.Diagnostics.Private_identifiers_are_not_allowed_outside_class_bodies);
55739                         return anyType;
55740                     }
55741                 }
55742                 prop = lexicallyScopedSymbol ? getPrivateIdentifierPropertyOfType(leftType, lexicallyScopedSymbol) : undefined;
55743                 if (!prop && checkPrivateIdentifierPropertyAccess(leftType, right, lexicallyScopedSymbol)) {
55744                     return errorType;
55745                 }
55746             }
55747             else {
55748                 if (isAnyLike) {
55749                     if (ts.isIdentifier(left) && parentSymbol) {
55750                         markAliasReferenced(parentSymbol, node);
55751                     }
55752                     return apparentType;
55753                 }
55754                 prop = getPropertyOfType(apparentType, right.escapedText);
55755             }
55756             if (ts.isIdentifier(left) && parentSymbol && !(prop && isConstEnumOrConstEnumOnlyModule(prop))) {
55757                 markAliasReferenced(parentSymbol, node);
55758             }
55759             var propType;
55760             if (!prop) {
55761                 var indexInfo = !ts.isPrivateIdentifier(right) && (assignmentKind === 0 || !isGenericObjectType(leftType) || isThisTypeParameter(leftType)) ? getIndexInfoOfType(apparentType, 0) : undefined;
55762                 if (!(indexInfo && indexInfo.type)) {
55763                     if (isJSLiteralType(leftType)) {
55764                         return anyType;
55765                     }
55766                     if (leftType.symbol === globalThisSymbol) {
55767                         if (globalThisSymbol.exports.has(right.escapedText) && (globalThisSymbol.exports.get(right.escapedText).flags & 418)) {
55768                             error(right, ts.Diagnostics.Property_0_does_not_exist_on_type_1, ts.unescapeLeadingUnderscores(right.escapedText), typeToString(leftType));
55769                         }
55770                         else if (noImplicitAny) {
55771                             error(right, ts.Diagnostics.Element_implicitly_has_an_any_type_because_type_0_has_no_index_signature, typeToString(leftType));
55772                         }
55773                         return anyType;
55774                     }
55775                     if (right.escapedText && !checkAndReportErrorForExtendingInterface(node)) {
55776                         reportNonexistentProperty(right, isThisTypeParameter(leftType) ? apparentType : leftType);
55777                     }
55778                     return errorType;
55779                 }
55780                 if (indexInfo.isReadonly && (ts.isAssignmentTarget(node) || ts.isDeleteTarget(node))) {
55781                     error(node, ts.Diagnostics.Index_signature_in_type_0_only_permits_reading, typeToString(apparentType));
55782                 }
55783                 propType = (compilerOptions.noUncheckedIndexedAccess && !ts.isAssignmentTarget(node)) ? getUnionType([indexInfo.type, undefinedType]) : indexInfo.type;
55784             }
55785             else {
55786                 if (getDeclarationNodeFlagsFromSymbol(prop) & 134217728 && isUncalledFunctionReference(node, prop)) {
55787                     errorOrSuggestion(false, right, ts.Diagnostics._0_is_deprecated, right.escapedText);
55788                 }
55789                 checkPropertyNotUsedBeforeDeclaration(prop, node, right);
55790                 markPropertyAsReferenced(prop, node, left.kind === 107);
55791                 getNodeLinks(node).resolvedSymbol = prop;
55792                 checkPropertyAccessibility(node, left.kind === 105, apparentType, prop);
55793                 if (isAssignmentToReadonlyEntity(node, prop, assignmentKind)) {
55794                     error(right, ts.Diagnostics.Cannot_assign_to_0_because_it_is_a_read_only_property, ts.idText(right));
55795                     return errorType;
55796                 }
55797                 propType = isThisPropertyAccessInConstructor(node, prop) ? autoType : getConstraintForLocation(getTypeOfSymbol(prop), node);
55798             }
55799             return getFlowTypeOfAccessExpression(node, prop, propType, right);
55800         }
55801         function getFlowTypeOfAccessExpression(node, prop, propType, errorNode) {
55802             var assignmentKind = ts.getAssignmentTargetKind(node);
55803             if (!ts.isAccessExpression(node) ||
55804                 assignmentKind === 1 ||
55805                 prop && !(prop.flags & (3 | 4 | 98304)) && !(prop.flags & 8192 && propType.flags & 1048576)) {
55806                 return propType;
55807             }
55808             if (propType === autoType) {
55809                 return getFlowTypeOfProperty(node, prop);
55810             }
55811             var assumeUninitialized = false;
55812             if (strictNullChecks && strictPropertyInitialization && node.expression.kind === 107) {
55813                 var declaration = prop && prop.valueDeclaration;
55814                 if (declaration && isInstancePropertyWithoutInitializer(declaration)) {
55815                     var flowContainer = getControlFlowContainer(node);
55816                     if (flowContainer.kind === 166 && flowContainer.parent === declaration.parent && !(declaration.flags & 8388608)) {
55817                         assumeUninitialized = true;
55818                     }
55819                 }
55820             }
55821             else if (strictNullChecks && prop && prop.valueDeclaration &&
55822                 ts.isPropertyAccessExpression(prop.valueDeclaration) &&
55823                 ts.getAssignmentDeclarationPropertyAccessKind(prop.valueDeclaration) &&
55824                 getControlFlowContainer(node) === getControlFlowContainer(prop.valueDeclaration)) {
55825                 assumeUninitialized = true;
55826             }
55827             var flowType = getFlowTypeOfReference(node, propType, assumeUninitialized ? getOptionalType(propType) : propType);
55828             if (assumeUninitialized && !(getFalsyFlags(propType) & 32768) && getFalsyFlags(flowType) & 32768) {
55829                 error(errorNode, ts.Diagnostics.Property_0_is_used_before_being_assigned, symbolToString(prop));
55830                 return propType;
55831             }
55832             return assignmentKind ? getBaseTypeOfLiteralType(flowType) : flowType;
55833         }
55834         function checkPropertyNotUsedBeforeDeclaration(prop, node, right) {
55835             var valueDeclaration = prop.valueDeclaration;
55836             if (!valueDeclaration || ts.getSourceFileOfNode(node).isDeclarationFile) {
55837                 return;
55838             }
55839             var diagnosticMessage;
55840             var declarationName = ts.idText(right);
55841             if (isInPropertyInitializer(node)
55842                 && !(ts.isAccessExpression(node) && ts.isAccessExpression(node.expression))
55843                 && !isBlockScopedNameDeclaredBeforeUse(valueDeclaration, right)
55844                 && !isPropertyDeclaredInAncestorClass(prop)) {
55845                 diagnosticMessage = error(right, ts.Diagnostics.Property_0_is_used_before_its_initialization, declarationName);
55846             }
55847             else if (valueDeclaration.kind === 252 &&
55848                 node.parent.kind !== 173 &&
55849                 !(valueDeclaration.flags & 8388608) &&
55850                 !isBlockScopedNameDeclaredBeforeUse(valueDeclaration, right)) {
55851                 diagnosticMessage = error(right, ts.Diagnostics.Class_0_used_before_its_declaration, declarationName);
55852             }
55853             if (diagnosticMessage) {
55854                 ts.addRelatedInfo(diagnosticMessage, ts.createDiagnosticForNode(valueDeclaration, ts.Diagnostics._0_is_declared_here, declarationName));
55855             }
55856         }
55857         function isInPropertyInitializer(node) {
55858             return !!ts.findAncestor(node, function (node) {
55859                 switch (node.kind) {
55860                     case 163:
55861                         return true;
55862                     case 288:
55863                     case 165:
55864                     case 167:
55865                     case 168:
55866                     case 290:
55867                     case 158:
55868                     case 228:
55869                     case 283:
55870                     case 280:
55871                     case 281:
55872                     case 282:
55873                     case 275:
55874                     case 223:
55875                     case 286:
55876                         return false;
55877                     default:
55878                         return ts.isExpressionNode(node) ? false : "quit";
55879                 }
55880             });
55881         }
55882         function isPropertyDeclaredInAncestorClass(prop) {
55883             if (!(prop.parent.flags & 32)) {
55884                 return false;
55885             }
55886             var classType = getTypeOfSymbol(prop.parent);
55887             while (true) {
55888                 classType = classType.symbol && getSuperClass(classType);
55889                 if (!classType) {
55890                     return false;
55891                 }
55892                 var superProperty = getPropertyOfType(classType, prop.escapedName);
55893                 if (superProperty && superProperty.valueDeclaration) {
55894                     return true;
55895                 }
55896             }
55897         }
55898         function getSuperClass(classType) {
55899             var x = getBaseTypes(classType);
55900             if (x.length === 0) {
55901                 return undefined;
55902             }
55903             return getIntersectionType(x);
55904         }
55905         function reportNonexistentProperty(propNode, containingType) {
55906             var errorInfo;
55907             var relatedInfo;
55908             if (!ts.isPrivateIdentifier(propNode) && containingType.flags & 1048576 && !(containingType.flags & 131068)) {
55909                 for (var _i = 0, _a = containingType.types; _i < _a.length; _i++) {
55910                     var subtype = _a[_i];
55911                     if (!getPropertyOfType(subtype, propNode.escapedText) && !getIndexInfoOfType(subtype, 0)) {
55912                         errorInfo = ts.chainDiagnosticMessages(errorInfo, ts.Diagnostics.Property_0_does_not_exist_on_type_1, ts.declarationNameToString(propNode), typeToString(subtype));
55913                         break;
55914                     }
55915                 }
55916             }
55917             if (typeHasStaticProperty(propNode.escapedText, containingType)) {
55918                 errorInfo = ts.chainDiagnosticMessages(errorInfo, ts.Diagnostics.Property_0_is_a_static_member_of_type_1, ts.declarationNameToString(propNode), typeToString(containingType));
55919             }
55920             else {
55921                 var promisedType = getPromisedTypeOfPromise(containingType);
55922                 if (promisedType && getPropertyOfType(promisedType, propNode.escapedText)) {
55923                     errorInfo = ts.chainDiagnosticMessages(errorInfo, ts.Diagnostics.Property_0_does_not_exist_on_type_1, ts.declarationNameToString(propNode), typeToString(containingType));
55924                     relatedInfo = ts.createDiagnosticForNode(propNode, ts.Diagnostics.Did_you_forget_to_use_await);
55925                 }
55926                 else {
55927                     var missingProperty = ts.declarationNameToString(propNode);
55928                     var container = typeToString(containingType);
55929                     var libSuggestion = getSuggestedLibForNonExistentProperty(missingProperty, containingType);
55930                     if (libSuggestion !== undefined) {
55931                         errorInfo = ts.chainDiagnosticMessages(errorInfo, ts.Diagnostics.Property_0_does_not_exist_on_type_1_Do_you_need_to_change_your_target_library_Try_changing_the_lib_compiler_option_to_2_or_later, missingProperty, container, libSuggestion);
55932                     }
55933                     else {
55934                         var suggestion = getSuggestedSymbolForNonexistentProperty(propNode, containingType);
55935                         if (suggestion !== undefined) {
55936                             var suggestedName = ts.symbolName(suggestion);
55937                             errorInfo = ts.chainDiagnosticMessages(errorInfo, ts.Diagnostics.Property_0_does_not_exist_on_type_1_Did_you_mean_2, missingProperty, container, suggestedName);
55938                             relatedInfo = suggestion.valueDeclaration && ts.createDiagnosticForNode(suggestion.valueDeclaration, ts.Diagnostics._0_is_declared_here, suggestedName);
55939                         }
55940                         else {
55941                             errorInfo = ts.chainDiagnosticMessages(elaborateNeverIntersection(errorInfo, containingType), ts.Diagnostics.Property_0_does_not_exist_on_type_1, missingProperty, container);
55942                         }
55943                     }
55944                 }
55945             }
55946             var resultDiagnostic = ts.createDiagnosticForNodeFromMessageChain(propNode, errorInfo);
55947             if (relatedInfo) {
55948                 ts.addRelatedInfo(resultDiagnostic, relatedInfo);
55949             }
55950             diagnostics.add(resultDiagnostic);
55951         }
55952         function typeHasStaticProperty(propName, containingType) {
55953             var prop = containingType.symbol && getPropertyOfType(getTypeOfSymbol(containingType.symbol), propName);
55954             return prop !== undefined && prop.valueDeclaration && ts.hasSyntacticModifier(prop.valueDeclaration, 32);
55955         }
55956         function getSuggestedLibForNonExistentName(name) {
55957             var missingName = diagnosticName(name);
55958             var allFeatures = ts.getScriptTargetFeatures();
55959             var libTargets = ts.getOwnKeys(allFeatures);
55960             for (var _i = 0, libTargets_1 = libTargets; _i < libTargets_1.length; _i++) {
55961                 var libTarget = libTargets_1[_i];
55962                 var containingTypes = ts.getOwnKeys(allFeatures[libTarget]);
55963                 if (containingTypes !== undefined && ts.contains(containingTypes, missingName)) {
55964                     return libTarget;
55965                 }
55966             }
55967         }
55968         function getSuggestedLibForNonExistentProperty(missingProperty, containingType) {
55969             var container = getApparentType(containingType).symbol;
55970             if (!container) {
55971                 return undefined;
55972             }
55973             var allFeatures = ts.getScriptTargetFeatures();
55974             var libTargets = ts.getOwnKeys(allFeatures);
55975             for (var _i = 0, libTargets_2 = libTargets; _i < libTargets_2.length; _i++) {
55976                 var libTarget = libTargets_2[_i];
55977                 var featuresOfLib = allFeatures[libTarget];
55978                 var featuresOfContainingType = featuresOfLib[ts.symbolName(container)];
55979                 if (featuresOfContainingType !== undefined && ts.contains(featuresOfContainingType, missingProperty)) {
55980                     return libTarget;
55981                 }
55982             }
55983         }
55984         function getSuggestedSymbolForNonexistentProperty(name, containingType) {
55985             return getSpellingSuggestionForName(ts.isString(name) ? name : ts.idText(name), getPropertiesOfType(containingType), 111551);
55986         }
55987         function getSuggestedSymbolForNonexistentJSXAttribute(name, containingType) {
55988             var strName = ts.isString(name) ? name : ts.idText(name);
55989             var properties = getPropertiesOfType(containingType);
55990             var jsxSpecific = strName === "for" ? ts.find(properties, function (x) { return ts.symbolName(x) === "htmlFor"; })
55991                 : strName === "class" ? ts.find(properties, function (x) { return ts.symbolName(x) === "className"; })
55992                     : undefined;
55993             return jsxSpecific !== null && jsxSpecific !== void 0 ? jsxSpecific : getSpellingSuggestionForName(strName, properties, 111551);
55994         }
55995         function getSuggestionForNonexistentProperty(name, containingType) {
55996             var suggestion = getSuggestedSymbolForNonexistentProperty(name, containingType);
55997             return suggestion && ts.symbolName(suggestion);
55998         }
55999         function getSuggestedSymbolForNonexistentSymbol(location, outerName, meaning) {
56000             ts.Debug.assert(outerName !== undefined, "outername should always be defined");
56001             var result = resolveNameHelper(location, outerName, meaning, undefined, outerName, false, false, function (symbols, name, meaning) {
56002                 ts.Debug.assertEqual(outerName, name, "name should equal outerName");
56003                 var symbol = getSymbol(symbols, name, meaning);
56004                 return symbol || getSpellingSuggestionForName(ts.unescapeLeadingUnderscores(name), ts.arrayFrom(symbols.values()), meaning);
56005             });
56006             return result;
56007         }
56008         function getSuggestionForNonexistentSymbol(location, outerName, meaning) {
56009             var symbolResult = getSuggestedSymbolForNonexistentSymbol(location, outerName, meaning);
56010             return symbolResult && ts.symbolName(symbolResult);
56011         }
56012         function getSuggestedSymbolForNonexistentModule(name, targetModule) {
56013             return targetModule.exports && getSpellingSuggestionForName(ts.idText(name), getExportsOfModuleAsArray(targetModule), 2623475);
56014         }
56015         function getSuggestionForNonexistentExport(name, targetModule) {
56016             var suggestion = getSuggestedSymbolForNonexistentModule(name, targetModule);
56017             return suggestion && ts.symbolName(suggestion);
56018         }
56019         function getSuggestionForNonexistentIndexSignature(objectType, expr, keyedType) {
56020             function hasProp(name) {
56021                 var prop = getPropertyOfObjectType(objectType, name);
56022                 if (prop) {
56023                     var s = getSingleCallSignature(getTypeOfSymbol(prop));
56024                     return !!s && getMinArgumentCount(s) >= 1 && isTypeAssignableTo(keyedType, getTypeAtPosition(s, 0));
56025                 }
56026                 return false;
56027             }
56028             ;
56029             var suggestedMethod = ts.isAssignmentTarget(expr) ? "set" : "get";
56030             if (!hasProp(suggestedMethod)) {
56031                 return undefined;
56032             }
56033             var suggestion = ts.tryGetPropertyAccessOrIdentifierToString(expr.expression);
56034             if (suggestion === undefined) {
56035                 suggestion = suggestedMethod;
56036             }
56037             else {
56038                 suggestion += "." + suggestedMethod;
56039             }
56040             return suggestion;
56041         }
56042         function getSpellingSuggestionForName(name, symbols, meaning) {
56043             return ts.getSpellingSuggestion(name, symbols, getCandidateName);
56044             function getCandidateName(candidate) {
56045                 var candidateName = ts.symbolName(candidate);
56046                 if (ts.startsWith(candidateName, "\"")) {
56047                     return undefined;
56048                 }
56049                 if (candidate.flags & meaning) {
56050                     return candidateName;
56051                 }
56052                 if (candidate.flags & 2097152) {
56053                     var alias = tryResolveAlias(candidate);
56054                     if (alias && alias.flags & meaning) {
56055                         return candidateName;
56056                     }
56057                 }
56058                 return undefined;
56059             }
56060         }
56061         function markPropertyAsReferenced(prop, nodeForCheckWriteOnly, isThisAccess) {
56062             var valueDeclaration = prop && (prop.flags & 106500) && prop.valueDeclaration;
56063             if (!valueDeclaration) {
56064                 return;
56065             }
56066             var hasPrivateModifier = ts.hasEffectiveModifier(valueDeclaration, 8);
56067             var hasPrivateIdentifier = ts.isNamedDeclaration(prop.valueDeclaration) && ts.isPrivateIdentifier(prop.valueDeclaration.name);
56068             if (!hasPrivateModifier && !hasPrivateIdentifier) {
56069                 return;
56070             }
56071             if (nodeForCheckWriteOnly && ts.isWriteOnlyAccess(nodeForCheckWriteOnly) && !(prop.flags & 65536)) {
56072                 return;
56073             }
56074             if (isThisAccess) {
56075                 var containingMethod = ts.findAncestor(nodeForCheckWriteOnly, ts.isFunctionLikeDeclaration);
56076                 if (containingMethod && containingMethod.symbol === prop) {
56077                     return;
56078                 }
56079             }
56080             (ts.getCheckFlags(prop) & 1 ? getSymbolLinks(prop).target : prop).isReferenced = 67108863;
56081         }
56082         function isValidPropertyAccess(node, propertyName) {
56083             switch (node.kind) {
56084                 case 201:
56085                     return isValidPropertyAccessWithType(node, node.expression.kind === 105, propertyName, getWidenedType(checkExpression(node.expression)));
56086                 case 157:
56087                     return isValidPropertyAccessWithType(node, false, propertyName, getWidenedType(checkExpression(node.left)));
56088                 case 195:
56089                     return isValidPropertyAccessWithType(node, false, propertyName, getTypeFromTypeNode(node));
56090             }
56091         }
56092         function isValidPropertyAccessForCompletions(node, type, property) {
56093             return isValidPropertyAccessWithType(node, node.kind === 201 && node.expression.kind === 105, property.escapedName, type);
56094         }
56095         function isValidPropertyAccessWithType(node, isSuper, propertyName, type) {
56096             if (type === errorType || isTypeAny(type)) {
56097                 return true;
56098             }
56099             var prop = getPropertyOfType(type, propertyName);
56100             if (prop) {
56101                 if (ts.isPropertyAccessExpression(node) && prop.valueDeclaration && ts.isPrivateIdentifierPropertyDeclaration(prop.valueDeclaration)) {
56102                     var declClass_1 = ts.getContainingClass(prop.valueDeclaration);
56103                     return !ts.isOptionalChain(node) && !!ts.findAncestor(node, function (parent) { return parent === declClass_1; });
56104                 }
56105                 return checkPropertyAccessibility(node, isSuper, type, prop);
56106             }
56107             return ts.isInJSFile(node) && (type.flags & 1048576) !== 0 && type.types.some(function (elementType) { return isValidPropertyAccessWithType(node, isSuper, propertyName, elementType); });
56108         }
56109         function getForInVariableSymbol(node) {
56110             var initializer = node.initializer;
56111             if (initializer.kind === 250) {
56112                 var variable = initializer.declarations[0];
56113                 if (variable && !ts.isBindingPattern(variable.name)) {
56114                     return getSymbolOfNode(variable);
56115                 }
56116             }
56117             else if (initializer.kind === 78) {
56118                 return getResolvedSymbol(initializer);
56119             }
56120             return undefined;
56121         }
56122         function hasNumericPropertyNames(type) {
56123             return getIndexTypeOfType(type, 1) && !getIndexTypeOfType(type, 0);
56124         }
56125         function isForInVariableForNumericPropertyNames(expr) {
56126             var e = ts.skipParentheses(expr);
56127             if (e.kind === 78) {
56128                 var symbol = getResolvedSymbol(e);
56129                 if (symbol.flags & 3) {
56130                     var child = expr;
56131                     var node = expr.parent;
56132                     while (node) {
56133                         if (node.kind === 238 &&
56134                             child === node.statement &&
56135                             getForInVariableSymbol(node) === symbol &&
56136                             hasNumericPropertyNames(getTypeOfExpression(node.expression))) {
56137                             return true;
56138                         }
56139                         child = node;
56140                         node = node.parent;
56141                     }
56142                 }
56143             }
56144             return false;
56145         }
56146         function checkIndexedAccess(node) {
56147             return node.flags & 32 ? checkElementAccessChain(node) :
56148                 checkElementAccessExpression(node, checkNonNullExpression(node.expression));
56149         }
56150         function checkElementAccessChain(node) {
56151             var exprType = checkExpression(node.expression);
56152             var nonOptionalType = getOptionalExpressionType(exprType, node.expression);
56153             return propagateOptionalTypeMarker(checkElementAccessExpression(node, checkNonNullType(nonOptionalType, node.expression)), node, nonOptionalType !== exprType);
56154         }
56155         function checkElementAccessExpression(node, exprType) {
56156             var objectType = ts.getAssignmentTargetKind(node) !== 0 || isMethodAccessForCall(node) ? getWidenedType(exprType) : exprType;
56157             var indexExpression = node.argumentExpression;
56158             var indexType = checkExpression(indexExpression);
56159             if (objectType === errorType || objectType === silentNeverType) {
56160                 return objectType;
56161             }
56162             if (isConstEnumObjectType(objectType) && !ts.isStringLiteralLike(indexExpression)) {
56163                 error(indexExpression, ts.Diagnostics.A_const_enum_member_can_only_be_accessed_using_a_string_literal);
56164                 return errorType;
56165             }
56166             var effectiveIndexType = isForInVariableForNumericPropertyNames(indexExpression) ? numberType : indexType;
56167             var accessFlags = ts.isAssignmentTarget(node) ?
56168                 2 | (isGenericObjectType(objectType) && !isThisTypeParameter(objectType) ? 1 : 0) :
56169                 0;
56170             var indexedAccessType = getIndexedAccessTypeOrUndefined(objectType, effectiveIndexType, undefined, node, accessFlags | 16) || errorType;
56171             return checkIndexedAccessIndexType(getFlowTypeOfAccessExpression(node, indexedAccessType.symbol, indexedAccessType, indexExpression), node);
56172         }
56173         function checkThatExpressionIsProperSymbolReference(expression, expressionType, reportError) {
56174             if (expressionType === errorType) {
56175                 return false;
56176             }
56177             if (!ts.isWellKnownSymbolSyntactically(expression)) {
56178                 return false;
56179             }
56180             if ((expressionType.flags & 12288) === 0) {
56181                 if (reportError) {
56182                     error(expression, ts.Diagnostics.A_computed_property_name_of_the_form_0_must_be_of_type_symbol, ts.getTextOfNode(expression));
56183                 }
56184                 return false;
56185             }
56186             var leftHandSide = expression.expression;
56187             var leftHandSideSymbol = getResolvedSymbol(leftHandSide);
56188             if (!leftHandSideSymbol) {
56189                 return false;
56190             }
56191             var globalESSymbol = getGlobalESSymbolConstructorSymbol(true);
56192             if (!globalESSymbol) {
56193                 return false;
56194             }
56195             if (leftHandSideSymbol !== globalESSymbol) {
56196                 if (reportError) {
56197                     error(leftHandSide, ts.Diagnostics.Symbol_reference_does_not_refer_to_the_global_Symbol_constructor_object);
56198                 }
56199                 return false;
56200             }
56201             return true;
56202         }
56203         function callLikeExpressionMayHaveTypeArguments(node) {
56204             return ts.isCallOrNewExpression(node) || ts.isTaggedTemplateExpression(node) || ts.isJsxOpeningLikeElement(node);
56205         }
56206         function resolveUntypedCall(node) {
56207             if (callLikeExpressionMayHaveTypeArguments(node)) {
56208                 ts.forEach(node.typeArguments, checkSourceElement);
56209             }
56210             if (node.kind === 205) {
56211                 checkExpression(node.template);
56212             }
56213             else if (ts.isJsxOpeningLikeElement(node)) {
56214                 checkExpression(node.attributes);
56215             }
56216             else if (node.kind !== 161) {
56217                 ts.forEach(node.arguments, function (argument) {
56218                     checkExpression(argument);
56219                 });
56220             }
56221             return anySignature;
56222         }
56223         function resolveErrorCall(node) {
56224             resolveUntypedCall(node);
56225             return unknownSignature;
56226         }
56227         function reorderCandidates(signatures, result, callChainFlags) {
56228             var lastParent;
56229             var lastSymbol;
56230             var cutoffIndex = 0;
56231             var index;
56232             var specializedIndex = -1;
56233             var spliceIndex;
56234             ts.Debug.assert(!result.length);
56235             for (var _i = 0, signatures_7 = signatures; _i < signatures_7.length; _i++) {
56236                 var signature = signatures_7[_i];
56237                 var symbol = signature.declaration && getSymbolOfNode(signature.declaration);
56238                 var parent = signature.declaration && signature.declaration.parent;
56239                 if (!lastSymbol || symbol === lastSymbol) {
56240                     if (lastParent && parent === lastParent) {
56241                         index = index + 1;
56242                     }
56243                     else {
56244                         lastParent = parent;
56245                         index = cutoffIndex;
56246                     }
56247                 }
56248                 else {
56249                     index = cutoffIndex = result.length;
56250                     lastParent = parent;
56251                 }
56252                 lastSymbol = symbol;
56253                 if (signatureHasLiteralTypes(signature)) {
56254                     specializedIndex++;
56255                     spliceIndex = specializedIndex;
56256                     cutoffIndex++;
56257                 }
56258                 else {
56259                     spliceIndex = index;
56260                 }
56261                 result.splice(spliceIndex, 0, callChainFlags ? getOptionalCallSignature(signature, callChainFlags) : signature);
56262             }
56263         }
56264         function isSpreadArgument(arg) {
56265             return !!arg && (arg.kind === 220 || arg.kind === 227 && arg.isSpread);
56266         }
56267         function getSpreadArgumentIndex(args) {
56268             return ts.findIndex(args, isSpreadArgument);
56269         }
56270         function acceptsVoid(t) {
56271             return !!(t.flags & 16384);
56272         }
56273         function acceptsVoidUndefinedUnknownOrAny(t) {
56274             return !!(t.flags & (16384 | 32768 | 2 | 1));
56275         }
56276         function hasCorrectArity(node, args, signature, signatureHelpTrailingComma) {
56277             if (signatureHelpTrailingComma === void 0) { signatureHelpTrailingComma = false; }
56278             var argCount;
56279             var callIsIncomplete = false;
56280             var effectiveParameterCount = getParameterCount(signature);
56281             var effectiveMinimumArguments = getMinArgumentCount(signature);
56282             if (node.kind === 205) {
56283                 argCount = args.length;
56284                 if (node.template.kind === 218) {
56285                     var lastSpan = ts.last(node.template.templateSpans);
56286                     callIsIncomplete = ts.nodeIsMissing(lastSpan.literal) || !!lastSpan.literal.isUnterminated;
56287                 }
56288                 else {
56289                     var templateLiteral = node.template;
56290                     ts.Debug.assert(templateLiteral.kind === 14);
56291                     callIsIncomplete = !!templateLiteral.isUnterminated;
56292                 }
56293             }
56294             else if (node.kind === 161) {
56295                 argCount = getDecoratorArgumentCount(node, signature);
56296             }
56297             else if (ts.isJsxOpeningLikeElement(node)) {
56298                 callIsIncomplete = node.attributes.end === node.end;
56299                 if (callIsIncomplete) {
56300                     return true;
56301                 }
56302                 argCount = effectiveMinimumArguments === 0 ? args.length : 1;
56303                 effectiveParameterCount = args.length === 0 ? effectiveParameterCount : 1;
56304                 effectiveMinimumArguments = Math.min(effectiveMinimumArguments, 1);
56305             }
56306             else if (!node.arguments) {
56307                 ts.Debug.assert(node.kind === 204);
56308                 return getMinArgumentCount(signature) === 0;
56309             }
56310             else {
56311                 argCount = signatureHelpTrailingComma ? args.length + 1 : args.length;
56312                 callIsIncomplete = node.arguments.end === node.end;
56313                 var spreadArgIndex = getSpreadArgumentIndex(args);
56314                 if (spreadArgIndex >= 0) {
56315                     return spreadArgIndex >= getMinArgumentCount(signature) && (hasEffectiveRestParameter(signature) || spreadArgIndex < getParameterCount(signature));
56316                 }
56317             }
56318             if (!hasEffectiveRestParameter(signature) && argCount > effectiveParameterCount) {
56319                 return false;
56320             }
56321             if (callIsIncomplete || argCount >= effectiveMinimumArguments) {
56322                 return true;
56323             }
56324             for (var i = argCount; i < effectiveMinimumArguments; i++) {
56325                 var type = getTypeAtPosition(signature, i);
56326                 if (filterType(type, ts.isInJSFile(node) && !strictNullChecks ? acceptsVoidUndefinedUnknownOrAny : acceptsVoid).flags & 131072) {
56327                     return false;
56328                 }
56329             }
56330             return true;
56331         }
56332         function hasCorrectTypeArgumentArity(signature, typeArguments) {
56333             var numTypeParameters = ts.length(signature.typeParameters);
56334             var minTypeArgumentCount = getMinTypeArgumentCount(signature.typeParameters);
56335             return !ts.some(typeArguments) ||
56336                 (typeArguments.length >= minTypeArgumentCount && typeArguments.length <= numTypeParameters);
56337         }
56338         function getSingleCallSignature(type) {
56339             return getSingleSignature(type, 0, false);
56340         }
56341         function getSingleCallOrConstructSignature(type) {
56342             return getSingleSignature(type, 0, false) ||
56343                 getSingleSignature(type, 1, false);
56344         }
56345         function getSingleSignature(type, kind, allowMembers) {
56346             if (type.flags & 524288) {
56347                 var resolved = resolveStructuredTypeMembers(type);
56348                 if (allowMembers || resolved.properties.length === 0 && !resolved.stringIndexInfo && !resolved.numberIndexInfo) {
56349                     if (kind === 0 && resolved.callSignatures.length === 1 && resolved.constructSignatures.length === 0) {
56350                         return resolved.callSignatures[0];
56351                     }
56352                     if (kind === 1 && resolved.constructSignatures.length === 1 && resolved.callSignatures.length === 0) {
56353                         return resolved.constructSignatures[0];
56354                     }
56355                 }
56356             }
56357             return undefined;
56358         }
56359         function instantiateSignatureInContextOf(signature, contextualSignature, inferenceContext, compareTypes) {
56360             var context = createInferenceContext(signature.typeParameters, signature, 0, compareTypes);
56361             var restType = getEffectiveRestType(contextualSignature);
56362             var mapper = inferenceContext && (restType && restType.flags & 262144 ? inferenceContext.nonFixingMapper : inferenceContext.mapper);
56363             var sourceSignature = mapper ? instantiateSignature(contextualSignature, mapper) : contextualSignature;
56364             applyToParameterTypes(sourceSignature, signature, function (source, target) {
56365                 inferTypes(context.inferences, source, target);
56366             });
56367             if (!inferenceContext) {
56368                 applyToReturnTypes(contextualSignature, signature, function (source, target) {
56369                     inferTypes(context.inferences, source, target, 64);
56370                 });
56371             }
56372             return getSignatureInstantiation(signature, getInferredTypes(context), ts.isInJSFile(contextualSignature.declaration));
56373         }
56374         function inferJsxTypeArguments(node, signature, checkMode, context) {
56375             var paramType = getEffectiveFirstArgumentForJsxSignature(signature, node);
56376             var checkAttrType = checkExpressionWithContextualType(node.attributes, paramType, context, checkMode);
56377             inferTypes(context.inferences, checkAttrType, paramType);
56378             return getInferredTypes(context);
56379         }
56380         function inferTypeArguments(node, signature, args, checkMode, context) {
56381             if (ts.isJsxOpeningLikeElement(node)) {
56382                 return inferJsxTypeArguments(node, signature, checkMode, context);
56383             }
56384             if (node.kind !== 161) {
56385                 var contextualType = getContextualType(node, ts.every(signature.typeParameters, function (p) { return !!getDefaultFromTypeParameter(p); }) ? 8 : 0);
56386                 if (contextualType) {
56387                     var outerContext = getInferenceContext(node);
56388                     var outerMapper = getMapperFromContext(cloneInferenceContext(outerContext, 1));
56389                     var instantiatedType = instantiateType(contextualType, outerMapper);
56390                     var contextualSignature = getSingleCallSignature(instantiatedType);
56391                     var inferenceSourceType = contextualSignature && contextualSignature.typeParameters ?
56392                         getOrCreateTypeFromSignature(getSignatureInstantiationWithoutFillingInTypeArguments(contextualSignature, contextualSignature.typeParameters)) :
56393                         instantiatedType;
56394                     var inferenceTargetType = getReturnTypeOfSignature(signature);
56395                     inferTypes(context.inferences, inferenceSourceType, inferenceTargetType, 64);
56396                     var returnContext = createInferenceContext(signature.typeParameters, signature, context.flags);
56397                     var returnSourceType = instantiateType(contextualType, outerContext && outerContext.returnMapper);
56398                     inferTypes(returnContext.inferences, returnSourceType, inferenceTargetType);
56399                     context.returnMapper = ts.some(returnContext.inferences, hasInferenceCandidates) ? getMapperFromContext(cloneInferredPartOfContext(returnContext)) : undefined;
56400                 }
56401             }
56402             var restType = getNonArrayRestType(signature);
56403             var argCount = restType ? Math.min(getParameterCount(signature) - 1, args.length) : args.length;
56404             if (restType && restType.flags & 262144) {
56405                 var info = ts.find(context.inferences, function (info) { return info.typeParameter === restType; });
56406                 if (info) {
56407                     info.impliedArity = ts.findIndex(args, isSpreadArgument, argCount) < 0 ? args.length - argCount : undefined;
56408                 }
56409             }
56410             var thisType = getThisTypeOfSignature(signature);
56411             if (thisType) {
56412                 var thisArgumentNode = getThisArgumentOfCall(node);
56413                 var thisArgumentType = thisArgumentNode ? checkExpression(thisArgumentNode) : voidType;
56414                 inferTypes(context.inferences, thisArgumentType, thisType);
56415             }
56416             for (var i = 0; i < argCount; i++) {
56417                 var arg = args[i];
56418                 if (arg.kind !== 222) {
56419                     var paramType = getTypeAtPosition(signature, i);
56420                     var argType = checkExpressionWithContextualType(arg, paramType, context, checkMode);
56421                     inferTypes(context.inferences, argType, paramType);
56422                 }
56423             }
56424             if (restType) {
56425                 var spreadType = getSpreadArgumentType(args, argCount, args.length, restType, context, checkMode);
56426                 inferTypes(context.inferences, spreadType, restType);
56427             }
56428             return getInferredTypes(context);
56429         }
56430         function getMutableArrayOrTupleType(type) {
56431             return type.flags & 1048576 ? mapType(type, getMutableArrayOrTupleType) :
56432                 type.flags & 1 || isMutableArrayOrTuple(getBaseConstraintOfType(type) || type) ? type :
56433                     isTupleType(type) ? createTupleType(getTypeArguments(type), type.target.elementFlags, false, type.target.labeledElementDeclarations) :
56434                         createTupleType([type], [8]);
56435         }
56436         function getSpreadArgumentType(args, index, argCount, restType, context, checkMode) {
56437             if (index >= argCount - 1) {
56438                 var arg = args[argCount - 1];
56439                 if (isSpreadArgument(arg)) {
56440                     return getMutableArrayOrTupleType(arg.kind === 227 ? arg.type :
56441                         checkExpressionWithContextualType(arg.expression, restType, context, checkMode));
56442                 }
56443             }
56444             var types = [];
56445             var flags = [];
56446             var names = [];
56447             for (var i = index; i < argCount; i++) {
56448                 var arg = args[i];
56449                 if (isSpreadArgument(arg)) {
56450                     var spreadType = arg.kind === 227 ? arg.type : checkExpression(arg.expression);
56451                     if (isArrayLikeType(spreadType)) {
56452                         types.push(spreadType);
56453                         flags.push(8);
56454                     }
56455                     else {
56456                         types.push(checkIteratedTypeOrElementType(33, spreadType, undefinedType, arg.kind === 220 ? arg.expression : arg));
56457                         flags.push(4);
56458                     }
56459                 }
56460                 else {
56461                     var contextualType = getIndexedAccessType(restType, getLiteralType(i - index));
56462                     var argType = checkExpressionWithContextualType(arg, contextualType, context, checkMode);
56463                     var hasPrimitiveContextualType = maybeTypeOfKind(contextualType, 131068 | 4194304 | 134217728 | 268435456);
56464                     types.push(hasPrimitiveContextualType ? getRegularTypeOfLiteralType(argType) : getWidenedLiteralType(argType));
56465                     flags.push(1);
56466                 }
56467                 if (arg.kind === 227 && arg.tupleNameSource) {
56468                     names.push(arg.tupleNameSource);
56469                 }
56470             }
56471             return createTupleType(types, flags, false, ts.length(names) === ts.length(types) ? names : undefined);
56472         }
56473         function checkTypeArguments(signature, typeArgumentNodes, reportErrors, headMessage) {
56474             var isJavascript = ts.isInJSFile(signature.declaration);
56475             var typeParameters = signature.typeParameters;
56476             var typeArgumentTypes = fillMissingTypeArguments(ts.map(typeArgumentNodes, getTypeFromTypeNode), typeParameters, getMinTypeArgumentCount(typeParameters), isJavascript);
56477             var mapper;
56478             for (var i = 0; i < typeArgumentNodes.length; i++) {
56479                 ts.Debug.assert(typeParameters[i] !== undefined, "Should not call checkTypeArguments with too many type arguments");
56480                 var constraint = getConstraintOfTypeParameter(typeParameters[i]);
56481                 if (constraint) {
56482                     var errorInfo = reportErrors && headMessage ? (function () { return ts.chainDiagnosticMessages(undefined, ts.Diagnostics.Type_0_does_not_satisfy_the_constraint_1); }) : undefined;
56483                     var typeArgumentHeadMessage = headMessage || ts.Diagnostics.Type_0_does_not_satisfy_the_constraint_1;
56484                     if (!mapper) {
56485                         mapper = createTypeMapper(typeParameters, typeArgumentTypes);
56486                     }
56487                     var typeArgument = typeArgumentTypes[i];
56488                     if (!checkTypeAssignableTo(typeArgument, getTypeWithThisArgument(instantiateType(constraint, mapper), typeArgument), reportErrors ? typeArgumentNodes[i] : undefined, typeArgumentHeadMessage, errorInfo)) {
56489                         return undefined;
56490                     }
56491                 }
56492             }
56493             return typeArgumentTypes;
56494         }
56495         function getJsxReferenceKind(node) {
56496             if (isJsxIntrinsicIdentifier(node.tagName)) {
56497                 return 2;
56498             }
56499             var tagType = getApparentType(checkExpression(node.tagName));
56500             if (ts.length(getSignaturesOfType(tagType, 1))) {
56501                 return 0;
56502             }
56503             if (ts.length(getSignaturesOfType(tagType, 0))) {
56504                 return 1;
56505             }
56506             return 2;
56507         }
56508         function checkApplicableSignatureForJsxOpeningLikeElement(node, signature, relation, checkMode, reportErrors, containingMessageChain, errorOutputContainer) {
56509             var paramType = getEffectiveFirstArgumentForJsxSignature(signature, node);
56510             var attributesType = checkExpressionWithContextualType(node.attributes, paramType, undefined, checkMode);
56511             return checkTagNameDoesNotExpectTooManyArguments() && checkTypeRelatedToAndOptionallyElaborate(attributesType, paramType, relation, reportErrors ? node.tagName : undefined, node.attributes, undefined, containingMessageChain, errorOutputContainer);
56512             function checkTagNameDoesNotExpectTooManyArguments() {
56513                 var _a;
56514                 var tagType = ts.isJsxOpeningElement(node) || ts.isJsxSelfClosingElement(node) && !isJsxIntrinsicIdentifier(node.tagName) ? checkExpression(node.tagName) : undefined;
56515                 if (!tagType) {
56516                     return true;
56517                 }
56518                 var tagCallSignatures = getSignaturesOfType(tagType, 0);
56519                 if (!ts.length(tagCallSignatures)) {
56520                     return true;
56521                 }
56522                 var factory = getJsxFactoryEntity(node);
56523                 if (!factory) {
56524                     return true;
56525                 }
56526                 var factorySymbol = resolveEntityName(factory, 111551, true, false, node);
56527                 if (!factorySymbol) {
56528                     return true;
56529                 }
56530                 var factoryType = getTypeOfSymbol(factorySymbol);
56531                 var callSignatures = getSignaturesOfType(factoryType, 0);
56532                 if (!ts.length(callSignatures)) {
56533                     return true;
56534                 }
56535                 var hasFirstParamSignatures = false;
56536                 var maxParamCount = 0;
56537                 for (var _i = 0, callSignatures_1 = callSignatures; _i < callSignatures_1.length; _i++) {
56538                     var sig = callSignatures_1[_i];
56539                     var firstparam = getTypeAtPosition(sig, 0);
56540                     var signaturesOfParam = getSignaturesOfType(firstparam, 0);
56541                     if (!ts.length(signaturesOfParam))
56542                         continue;
56543                     for (var _b = 0, signaturesOfParam_1 = signaturesOfParam; _b < signaturesOfParam_1.length; _b++) {
56544                         var paramSig = signaturesOfParam_1[_b];
56545                         hasFirstParamSignatures = true;
56546                         if (hasEffectiveRestParameter(paramSig)) {
56547                             return true;
56548                         }
56549                         var paramCount = getParameterCount(paramSig);
56550                         if (paramCount > maxParamCount) {
56551                             maxParamCount = paramCount;
56552                         }
56553                     }
56554                 }
56555                 if (!hasFirstParamSignatures) {
56556                     return true;
56557                 }
56558                 var absoluteMinArgCount = Infinity;
56559                 for (var _c = 0, tagCallSignatures_1 = tagCallSignatures; _c < tagCallSignatures_1.length; _c++) {
56560                     var tagSig = tagCallSignatures_1[_c];
56561                     var tagRequiredArgCount = getMinArgumentCount(tagSig);
56562                     if (tagRequiredArgCount < absoluteMinArgCount) {
56563                         absoluteMinArgCount = tagRequiredArgCount;
56564                     }
56565                 }
56566                 if (absoluteMinArgCount <= maxParamCount) {
56567                     return true;
56568                 }
56569                 if (reportErrors) {
56570                     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);
56571                     var tagNameDeclaration = (_a = getSymbolAtLocation(node.tagName)) === null || _a === void 0 ? void 0 : _a.valueDeclaration;
56572                     if (tagNameDeclaration) {
56573                         ts.addRelatedInfo(diag, ts.createDiagnosticForNode(tagNameDeclaration, ts.Diagnostics._0_is_declared_here, ts.entityNameToString(node.tagName)));
56574                     }
56575                     if (errorOutputContainer && errorOutputContainer.skipLogging) {
56576                         (errorOutputContainer.errors || (errorOutputContainer.errors = [])).push(diag);
56577                     }
56578                     if (!errorOutputContainer.skipLogging) {
56579                         diagnostics.add(diag);
56580                     }
56581                 }
56582                 return false;
56583             }
56584         }
56585         function getSignatureApplicabilityError(node, args, signature, relation, checkMode, reportErrors, containingMessageChain) {
56586             var errorOutputContainer = { errors: undefined, skipLogging: true };
56587             if (ts.isJsxOpeningLikeElement(node)) {
56588                 if (!checkApplicableSignatureForJsxOpeningLikeElement(node, signature, relation, checkMode, reportErrors, containingMessageChain, errorOutputContainer)) {
56589                     ts.Debug.assert(!reportErrors || !!errorOutputContainer.errors, "jsx should have errors when reporting errors");
56590                     return errorOutputContainer.errors || ts.emptyArray;
56591                 }
56592                 return undefined;
56593             }
56594             var thisType = getThisTypeOfSignature(signature);
56595             if (thisType && thisType !== voidType && node.kind !== 204) {
56596                 var thisArgumentNode = getThisArgumentOfCall(node);
56597                 var thisArgumentType = void 0;
56598                 if (thisArgumentNode) {
56599                     thisArgumentType = checkExpression(thisArgumentNode);
56600                     if (ts.isOptionalChainRoot(thisArgumentNode.parent)) {
56601                         thisArgumentType = getNonNullableType(thisArgumentType);
56602                     }
56603                     else if (ts.isOptionalChain(thisArgumentNode.parent)) {
56604                         thisArgumentType = removeOptionalTypeMarker(thisArgumentType);
56605                     }
56606                 }
56607                 else {
56608                     thisArgumentType = voidType;
56609                 }
56610                 var errorNode = reportErrors ? (thisArgumentNode || node) : undefined;
56611                 var headMessage_1 = ts.Diagnostics.The_this_context_of_type_0_is_not_assignable_to_method_s_this_of_type_1;
56612                 if (!checkTypeRelatedTo(thisArgumentType, thisType, relation, errorNode, headMessage_1, containingMessageChain, errorOutputContainer)) {
56613                     ts.Debug.assert(!reportErrors || !!errorOutputContainer.errors, "this parameter should have errors when reporting errors");
56614                     return errorOutputContainer.errors || ts.emptyArray;
56615                 }
56616             }
56617             var headMessage = ts.Diagnostics.Argument_of_type_0_is_not_assignable_to_parameter_of_type_1;
56618             var restType = getNonArrayRestType(signature);
56619             var argCount = restType ? Math.min(getParameterCount(signature) - 1, args.length) : args.length;
56620             for (var i = 0; i < argCount; i++) {
56621                 var arg = args[i];
56622                 if (arg.kind !== 222) {
56623                     var paramType = getTypeAtPosition(signature, i);
56624                     var argType = checkExpressionWithContextualType(arg, paramType, undefined, checkMode);
56625                     var checkArgType = checkMode & 4 ? getRegularTypeOfObjectLiteral(argType) : argType;
56626                     if (!checkTypeRelatedToAndOptionallyElaborate(checkArgType, paramType, relation, reportErrors ? arg : undefined, arg, headMessage, containingMessageChain, errorOutputContainer)) {
56627                         ts.Debug.assert(!reportErrors || !!errorOutputContainer.errors, "parameter should have errors when reporting errors");
56628                         maybeAddMissingAwaitInfo(arg, checkArgType, paramType);
56629                         return errorOutputContainer.errors || ts.emptyArray;
56630                     }
56631                 }
56632             }
56633             if (restType) {
56634                 var spreadType = getSpreadArgumentType(args, argCount, args.length, restType, undefined, checkMode);
56635                 var errorNode = reportErrors ? argCount < args.length ? args[argCount] : node : undefined;
56636                 if (!checkTypeRelatedTo(spreadType, restType, relation, errorNode, headMessage, undefined, errorOutputContainer)) {
56637                     ts.Debug.assert(!reportErrors || !!errorOutputContainer.errors, "rest parameter should have errors when reporting errors");
56638                     maybeAddMissingAwaitInfo(errorNode, spreadType, restType);
56639                     return errorOutputContainer.errors || ts.emptyArray;
56640                 }
56641             }
56642             return undefined;
56643             function maybeAddMissingAwaitInfo(errorNode, source, target) {
56644                 if (errorNode && reportErrors && errorOutputContainer.errors && errorOutputContainer.errors.length) {
56645                     if (getAwaitedTypeOfPromise(target)) {
56646                         return;
56647                     }
56648                     var awaitedTypeOfSource = getAwaitedTypeOfPromise(source);
56649                     if (awaitedTypeOfSource && isTypeRelatedTo(awaitedTypeOfSource, target, relation)) {
56650                         ts.addRelatedInfo(errorOutputContainer.errors[0], ts.createDiagnosticForNode(errorNode, ts.Diagnostics.Did_you_forget_to_use_await));
56651                     }
56652                 }
56653             }
56654         }
56655         function getThisArgumentOfCall(node) {
56656             if (node.kind === 203) {
56657                 var callee = ts.skipOuterExpressions(node.expression);
56658                 if (ts.isAccessExpression(callee)) {
56659                     return callee.expression;
56660                 }
56661             }
56662         }
56663         function createSyntheticExpression(parent, type, isSpread, tupleNameSource) {
56664             var result = ts.parseNodeFactory.createSyntheticExpression(type, isSpread, tupleNameSource);
56665             ts.setTextRange(result, parent);
56666             ts.setParent(result, parent);
56667             return result;
56668         }
56669         function getEffectiveCallArguments(node) {
56670             if (node.kind === 205) {
56671                 var template = node.template;
56672                 var args_3 = [createSyntheticExpression(template, getGlobalTemplateStringsArrayType())];
56673                 if (template.kind === 218) {
56674                     ts.forEach(template.templateSpans, function (span) {
56675                         args_3.push(span.expression);
56676                     });
56677                 }
56678                 return args_3;
56679             }
56680             if (node.kind === 161) {
56681                 return getEffectiveDecoratorArguments(node);
56682             }
56683             if (ts.isJsxOpeningLikeElement(node)) {
56684                 return node.attributes.properties.length > 0 || (ts.isJsxOpeningElement(node) && node.parent.children.length > 0) ? [node.attributes] : ts.emptyArray;
56685             }
56686             var args = node.arguments || ts.emptyArray;
56687             var spreadIndex = getSpreadArgumentIndex(args);
56688             if (spreadIndex >= 0) {
56689                 var effectiveArgs_1 = args.slice(0, spreadIndex);
56690                 var _loop_20 = function (i) {
56691                     var arg = args[i];
56692                     var spreadType = arg.kind === 220 && (flowLoopCount ? checkExpression(arg.expression) : checkExpressionCached(arg.expression));
56693                     if (spreadType && isTupleType(spreadType)) {
56694                         ts.forEach(getTypeArguments(spreadType), function (t, i) {
56695                             var _a;
56696                             var flags = spreadType.target.elementFlags[i];
56697                             var syntheticArg = createSyntheticExpression(arg, flags & 4 ? createArrayType(t) : t, !!(flags & 12), (_a = spreadType.target.labeledElementDeclarations) === null || _a === void 0 ? void 0 : _a[i]);
56698                             effectiveArgs_1.push(syntheticArg);
56699                         });
56700                     }
56701                     else {
56702                         effectiveArgs_1.push(arg);
56703                     }
56704                 };
56705                 for (var i = spreadIndex; i < args.length; i++) {
56706                     _loop_20(i);
56707                 }
56708                 return effectiveArgs_1;
56709             }
56710             return args;
56711         }
56712         function getEffectiveDecoratorArguments(node) {
56713             var parent = node.parent;
56714             var expr = node.expression;
56715             switch (parent.kind) {
56716                 case 252:
56717                 case 221:
56718                     return [
56719                         createSyntheticExpression(expr, getTypeOfSymbol(getSymbolOfNode(parent)))
56720                     ];
56721                 case 160:
56722                     var func = parent.parent;
56723                     return [
56724                         createSyntheticExpression(expr, parent.parent.kind === 166 ? getTypeOfSymbol(getSymbolOfNode(func)) : errorType),
56725                         createSyntheticExpression(expr, anyType),
56726                         createSyntheticExpression(expr, numberType)
56727                     ];
56728                 case 163:
56729                 case 165:
56730                 case 167:
56731                 case 168:
56732                     var hasPropDesc = parent.kind !== 163 && languageVersion !== 0;
56733                     return [
56734                         createSyntheticExpression(expr, getParentTypeOfClassElement(parent)),
56735                         createSyntheticExpression(expr, getClassElementPropertyKeyType(parent)),
56736                         createSyntheticExpression(expr, hasPropDesc ? createTypedPropertyDescriptorType(getTypeOfNode(parent)) : anyType)
56737                     ];
56738             }
56739             return ts.Debug.fail();
56740         }
56741         function getDecoratorArgumentCount(node, signature) {
56742             switch (node.parent.kind) {
56743                 case 252:
56744                 case 221:
56745                     return 1;
56746                 case 163:
56747                     return 2;
56748                 case 165:
56749                 case 167:
56750                 case 168:
56751                     return languageVersion === 0 || signature.parameters.length <= 2 ? 2 : 3;
56752                 case 160:
56753                     return 3;
56754                 default:
56755                     return ts.Debug.fail();
56756             }
56757         }
56758         function getDiagnosticSpanForCallNode(node, doNotIncludeArguments) {
56759             var start;
56760             var length;
56761             var sourceFile = ts.getSourceFileOfNode(node);
56762             if (ts.isPropertyAccessExpression(node.expression)) {
56763                 var nameSpan = ts.getErrorSpanForNode(sourceFile, node.expression.name);
56764                 start = nameSpan.start;
56765                 length = doNotIncludeArguments ? nameSpan.length : node.end - start;
56766             }
56767             else {
56768                 var expressionSpan = ts.getErrorSpanForNode(sourceFile, node.expression);
56769                 start = expressionSpan.start;
56770                 length = doNotIncludeArguments ? expressionSpan.length : node.end - start;
56771             }
56772             return { start: start, length: length, sourceFile: sourceFile };
56773         }
56774         function getDiagnosticForCallNode(node, message, arg0, arg1, arg2, arg3) {
56775             if (ts.isCallExpression(node)) {
56776                 var _a = getDiagnosticSpanForCallNode(node), sourceFile = _a.sourceFile, start = _a.start, length_5 = _a.length;
56777                 return ts.createFileDiagnostic(sourceFile, start, length_5, message, arg0, arg1, arg2, arg3);
56778             }
56779             else {
56780                 return ts.createDiagnosticForNode(node, message, arg0, arg1, arg2, arg3);
56781             }
56782         }
56783         function isPromiseResolveArityError(node) {
56784             if (!ts.isCallExpression(node) || !ts.isIdentifier(node.expression))
56785                 return false;
56786             var symbol = resolveName(node.expression, node.expression.escapedText, 111551, undefined, undefined, false);
56787             var decl = symbol === null || symbol === void 0 ? void 0 : symbol.valueDeclaration;
56788             if (!decl || !ts.isParameter(decl) || !isFunctionExpressionOrArrowFunction(decl.parent) || !ts.isNewExpression(decl.parent.parent) || !ts.isIdentifier(decl.parent.parent.expression)) {
56789                 return false;
56790             }
56791             var globalPromiseSymbol = getGlobalPromiseConstructorSymbol(false);
56792             if (!globalPromiseSymbol)
56793                 return false;
56794             var constructorSymbol = getSymbolAtLocation(decl.parent.parent.expression, true);
56795             return constructorSymbol === globalPromiseSymbol;
56796         }
56797         function getArgumentArityError(node, signatures, args) {
56798             var min = Number.POSITIVE_INFINITY;
56799             var max = Number.NEGATIVE_INFINITY;
56800             var belowArgCount = Number.NEGATIVE_INFINITY;
56801             var aboveArgCount = Number.POSITIVE_INFINITY;
56802             var argCount = args.length;
56803             var closestSignature;
56804             for (var _i = 0, signatures_8 = signatures; _i < signatures_8.length; _i++) {
56805                 var sig = signatures_8[_i];
56806                 var minCount = getMinArgumentCount(sig);
56807                 var maxCount = getParameterCount(sig);
56808                 if (minCount < argCount && minCount > belowArgCount)
56809                     belowArgCount = minCount;
56810                 if (argCount < maxCount && maxCount < aboveArgCount)
56811                     aboveArgCount = maxCount;
56812                 if (minCount < min) {
56813                     min = minCount;
56814                     closestSignature = sig;
56815                 }
56816                 max = Math.max(max, maxCount);
56817             }
56818             var hasRestParameter = ts.some(signatures, hasEffectiveRestParameter);
56819             var paramRange = hasRestParameter ? min :
56820                 min < max ? min + "-" + max :
56821                     min;
56822             var hasSpreadArgument = getSpreadArgumentIndex(args) > -1;
56823             if (argCount <= max && hasSpreadArgument) {
56824                 argCount--;
56825             }
56826             var spanArray;
56827             var related;
56828             var error = hasRestParameter || hasSpreadArgument ?
56829                 hasRestParameter && hasSpreadArgument ?
56830                     ts.Diagnostics.Expected_at_least_0_arguments_but_got_1_or_more :
56831                     hasRestParameter ?
56832                         ts.Diagnostics.Expected_at_least_0_arguments_but_got_1 :
56833                         ts.Diagnostics.Expected_0_arguments_but_got_1_or_more :
56834                 paramRange === 1 && argCount === 0 && isPromiseResolveArityError(node) ?
56835                     ts.Diagnostics.Expected_0_arguments_but_got_1_Did_you_forget_to_include_void_in_your_type_argument_to_Promise :
56836                     ts.Diagnostics.Expected_0_arguments_but_got_1;
56837             if (closestSignature && getMinArgumentCount(closestSignature) > argCount && closestSignature.declaration) {
56838                 var paramDecl = closestSignature.declaration.parameters[closestSignature.thisParameter ? argCount + 1 : argCount];
56839                 if (paramDecl) {
56840                     related = ts.createDiagnosticForNode(paramDecl, ts.isBindingPattern(paramDecl.name) ? ts.Diagnostics.An_argument_matching_this_binding_pattern_was_not_provided :
56841                         ts.isRestParameter(paramDecl) ? ts.Diagnostics.Arguments_for_the_rest_parameter_0_were_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);
56842                 }
56843             }
56844             if (min < argCount && argCount < max) {
56845                 return getDiagnosticForCallNode(node, ts.Diagnostics.No_overload_expects_0_arguments_but_overloads_do_exist_that_expect_either_1_or_2_arguments, argCount, belowArgCount, aboveArgCount);
56846             }
56847             if (!hasSpreadArgument && argCount < min) {
56848                 var diagnostic_1 = getDiagnosticForCallNode(node, error, paramRange, argCount);
56849                 return related ? ts.addRelatedInfo(diagnostic_1, related) : diagnostic_1;
56850             }
56851             if (hasRestParameter || hasSpreadArgument) {
56852                 spanArray = ts.factory.createNodeArray(args);
56853                 if (hasSpreadArgument && argCount) {
56854                     var nextArg = ts.elementAt(args, getSpreadArgumentIndex(args) + 1) || undefined;
56855                     spanArray = ts.factory.createNodeArray(args.slice(max > argCount && nextArg ? args.indexOf(nextArg) : Math.min(max, args.length - 1)));
56856                 }
56857             }
56858             else {
56859                 spanArray = ts.factory.createNodeArray(args.slice(max));
56860             }
56861             var pos = ts.first(spanArray).pos;
56862             var end = ts.last(spanArray).end;
56863             if (end === pos) {
56864                 end++;
56865             }
56866             ts.setTextRangePosEnd(spanArray, pos, end);
56867             var diagnostic = ts.createDiagnosticForNodeArray(ts.getSourceFileOfNode(node), spanArray, error, paramRange, argCount);
56868             return related ? ts.addRelatedInfo(diagnostic, related) : diagnostic;
56869         }
56870         function getTypeArgumentArityError(node, signatures, typeArguments) {
56871             var argCount = typeArguments.length;
56872             if (signatures.length === 1) {
56873                 var sig = signatures[0];
56874                 var min_1 = getMinTypeArgumentCount(sig.typeParameters);
56875                 var max = ts.length(sig.typeParameters);
56876                 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);
56877             }
56878             var belowArgCount = -Infinity;
56879             var aboveArgCount = Infinity;
56880             for (var _i = 0, signatures_9 = signatures; _i < signatures_9.length; _i++) {
56881                 var sig = signatures_9[_i];
56882                 var min_2 = getMinTypeArgumentCount(sig.typeParameters);
56883                 var max = ts.length(sig.typeParameters);
56884                 if (min_2 > argCount) {
56885                     aboveArgCount = Math.min(aboveArgCount, min_2);
56886                 }
56887                 else if (max < argCount) {
56888                     belowArgCount = Math.max(belowArgCount, max);
56889                 }
56890             }
56891             if (belowArgCount !== -Infinity && aboveArgCount !== Infinity) {
56892                 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);
56893             }
56894             return ts.createDiagnosticForNodeArray(ts.getSourceFileOfNode(node), typeArguments, ts.Diagnostics.Expected_0_type_arguments_but_got_1, belowArgCount === -Infinity ? aboveArgCount : belowArgCount, argCount);
56895         }
56896         function resolveCall(node, signatures, candidatesOutArray, checkMode, callChainFlags, fallbackError) {
56897             var isTaggedTemplate = node.kind === 205;
56898             var isDecorator = node.kind === 161;
56899             var isJsxOpeningOrSelfClosingElement = ts.isJsxOpeningLikeElement(node);
56900             var reportErrors = !candidatesOutArray && produceDiagnostics;
56901             var typeArguments;
56902             if (!isDecorator) {
56903                 typeArguments = node.typeArguments;
56904                 if (isTaggedTemplate || isJsxOpeningOrSelfClosingElement || node.expression.kind !== 105) {
56905                     ts.forEach(typeArguments, checkSourceElement);
56906                 }
56907             }
56908             var candidates = candidatesOutArray || [];
56909             reorderCandidates(signatures, candidates, callChainFlags);
56910             if (!candidates.length) {
56911                 if (reportErrors) {
56912                     diagnostics.add(getDiagnosticForCallNode(node, ts.Diagnostics.Call_target_does_not_contain_any_signatures));
56913                 }
56914                 return resolveErrorCall(node);
56915             }
56916             var args = getEffectiveCallArguments(node);
56917             var isSingleNonGenericCandidate = candidates.length === 1 && !candidates[0].typeParameters;
56918             var argCheckMode = !isDecorator && !isSingleNonGenericCandidate && ts.some(args, isContextSensitive) ? 4 : 0;
56919             var candidatesForArgumentError;
56920             var candidateForArgumentArityError;
56921             var candidateForTypeArgumentError;
56922             var result;
56923             var signatureHelpTrailingComma = !!(checkMode & 16) && node.kind === 203 && node.arguments.hasTrailingComma;
56924             if (candidates.length > 1) {
56925                 result = chooseOverload(candidates, subtypeRelation, isSingleNonGenericCandidate, signatureHelpTrailingComma);
56926             }
56927             if (!result) {
56928                 result = chooseOverload(candidates, assignableRelation, isSingleNonGenericCandidate, signatureHelpTrailingComma);
56929             }
56930             if (result) {
56931                 return result;
56932             }
56933             if (reportErrors) {
56934                 if (candidatesForArgumentError) {
56935                     if (candidatesForArgumentError.length === 1 || candidatesForArgumentError.length > 3) {
56936                         var last_2 = candidatesForArgumentError[candidatesForArgumentError.length - 1];
56937                         var chain_1;
56938                         if (candidatesForArgumentError.length > 3) {
56939                             chain_1 = ts.chainDiagnosticMessages(chain_1, ts.Diagnostics.The_last_overload_gave_the_following_error);
56940                             chain_1 = ts.chainDiagnosticMessages(chain_1, ts.Diagnostics.No_overload_matches_this_call);
56941                         }
56942                         var diags = getSignatureApplicabilityError(node, args, last_2, assignableRelation, 0, true, function () { return chain_1; });
56943                         if (diags) {
56944                             for (var _i = 0, diags_1 = diags; _i < diags_1.length; _i++) {
56945                                 var d = diags_1[_i];
56946                                 if (last_2.declaration && candidatesForArgumentError.length > 3) {
56947                                     ts.addRelatedInfo(d, ts.createDiagnosticForNode(last_2.declaration, ts.Diagnostics.The_last_overload_is_declared_here));
56948                                 }
56949                                 addImplementationSuccessElaboration(last_2, d);
56950                                 diagnostics.add(d);
56951                             }
56952                         }
56953                         else {
56954                             ts.Debug.fail("No error for last overload signature");
56955                         }
56956                     }
56957                     else {
56958                         var allDiagnostics = [];
56959                         var max = 0;
56960                         var min_3 = Number.MAX_VALUE;
56961                         var minIndex = 0;
56962                         var i_1 = 0;
56963                         var _loop_21 = function (c) {
56964                             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)); };
56965                             var diags_2 = getSignatureApplicabilityError(node, args, c, assignableRelation, 0, true, chain_2);
56966                             if (diags_2) {
56967                                 if (diags_2.length <= min_3) {
56968                                     min_3 = diags_2.length;
56969                                     minIndex = i_1;
56970                                 }
56971                                 max = Math.max(max, diags_2.length);
56972                                 allDiagnostics.push(diags_2);
56973                             }
56974                             else {
56975                                 ts.Debug.fail("No error for 3 or fewer overload signatures");
56976                             }
56977                             i_1++;
56978                         };
56979                         for (var _a = 0, candidatesForArgumentError_1 = candidatesForArgumentError; _a < candidatesForArgumentError_1.length; _a++) {
56980                             var c = candidatesForArgumentError_1[_a];
56981                             _loop_21(c);
56982                         }
56983                         var diags_3 = max > 1 ? allDiagnostics[minIndex] : ts.flatten(allDiagnostics);
56984                         ts.Debug.assert(diags_3.length > 0, "No errors reported for 3 or fewer overload signatures");
56985                         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);
56986                         var related = __spreadArrays(ts.flatMap(diags_3, function (d) { return d.relatedInformation; }));
56987                         var diag = void 0;
56988                         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; })) {
56989                             var _b = diags_3[0], file = _b.file, start = _b.start, length_6 = _b.length;
56990                             diag = { file: file, start: start, length: length_6, code: chain.code, category: chain.category, messageText: chain, relatedInformation: related };
56991                         }
56992                         else {
56993                             diag = ts.createDiagnosticForNodeFromMessageChain(node, chain, related);
56994                         }
56995                         addImplementationSuccessElaboration(candidatesForArgumentError[0], diag);
56996                         diagnostics.add(diag);
56997                     }
56998                 }
56999                 else if (candidateForArgumentArityError) {
57000                     diagnostics.add(getArgumentArityError(node, [candidateForArgumentArityError], args));
57001                 }
57002                 else if (candidateForTypeArgumentError) {
57003                     checkTypeArguments(candidateForTypeArgumentError, node.typeArguments, true, fallbackError);
57004                 }
57005                 else {
57006                     var signaturesWithCorrectTypeArgumentArity = ts.filter(signatures, function (s) { return hasCorrectTypeArgumentArity(s, typeArguments); });
57007                     if (signaturesWithCorrectTypeArgumentArity.length === 0) {
57008                         diagnostics.add(getTypeArgumentArityError(node, signatures, typeArguments));
57009                     }
57010                     else if (!isDecorator) {
57011                         diagnostics.add(getArgumentArityError(node, signaturesWithCorrectTypeArgumentArity, args));
57012                     }
57013                     else if (fallbackError) {
57014                         diagnostics.add(getDiagnosticForCallNode(node, fallbackError));
57015                     }
57016                 }
57017             }
57018             return getCandidateForOverloadFailure(node, candidates, args, !!candidatesOutArray);
57019             function addImplementationSuccessElaboration(failed, diagnostic) {
57020                 var _a, _b;
57021                 var oldCandidatesForArgumentError = candidatesForArgumentError;
57022                 var oldCandidateForArgumentArityError = candidateForArgumentArityError;
57023                 var oldCandidateForTypeArgumentError = candidateForTypeArgumentError;
57024                 var failedSignatureDeclarations = ((_b = (_a = failed.declaration) === null || _a === void 0 ? void 0 : _a.symbol) === null || _b === void 0 ? void 0 : _b.declarations) || ts.emptyArray;
57025                 var isOverload = failedSignatureDeclarations.length > 1;
57026                 var implDecl = isOverload ? ts.find(failedSignatureDeclarations, function (d) { return ts.isFunctionLikeDeclaration(d) && ts.nodeIsPresent(d.body); }) : undefined;
57027                 if (implDecl) {
57028                     var candidate = getSignatureFromDeclaration(implDecl);
57029                     var isSingleNonGenericCandidate_1 = !candidate.typeParameters;
57030                     if (chooseOverload([candidate], assignableRelation, isSingleNonGenericCandidate_1)) {
57031                         ts.addRelatedInfo(diagnostic, ts.createDiagnosticForNode(implDecl, ts.Diagnostics.The_call_would_have_succeeded_against_this_implementation_but_implementation_signatures_of_overloads_are_not_externally_visible));
57032                     }
57033                 }
57034                 candidatesForArgumentError = oldCandidatesForArgumentError;
57035                 candidateForArgumentArityError = oldCandidateForArgumentArityError;
57036                 candidateForTypeArgumentError = oldCandidateForTypeArgumentError;
57037             }
57038             function chooseOverload(candidates, relation, isSingleNonGenericCandidate, signatureHelpTrailingComma) {
57039                 if (signatureHelpTrailingComma === void 0) { signatureHelpTrailingComma = false; }
57040                 candidatesForArgumentError = undefined;
57041                 candidateForArgumentArityError = undefined;
57042                 candidateForTypeArgumentError = undefined;
57043                 if (isSingleNonGenericCandidate) {
57044                     var candidate = candidates[0];
57045                     if (ts.some(typeArguments) || !hasCorrectArity(node, args, candidate, signatureHelpTrailingComma)) {
57046                         return undefined;
57047                     }
57048                     if (getSignatureApplicabilityError(node, args, candidate, relation, 0, false, undefined)) {
57049                         candidatesForArgumentError = [candidate];
57050                         return undefined;
57051                     }
57052                     return candidate;
57053                 }
57054                 for (var candidateIndex = 0; candidateIndex < candidates.length; candidateIndex++) {
57055                     var candidate = candidates[candidateIndex];
57056                     if (!hasCorrectTypeArgumentArity(candidate, typeArguments) || !hasCorrectArity(node, args, candidate, signatureHelpTrailingComma)) {
57057                         continue;
57058                     }
57059                     var checkCandidate = void 0;
57060                     var inferenceContext = void 0;
57061                     if (candidate.typeParameters) {
57062                         var typeArgumentTypes = void 0;
57063                         if (ts.some(typeArguments)) {
57064                             typeArgumentTypes = checkTypeArguments(candidate, typeArguments, false);
57065                             if (!typeArgumentTypes) {
57066                                 candidateForTypeArgumentError = candidate;
57067                                 continue;
57068                             }
57069                         }
57070                         else {
57071                             inferenceContext = createInferenceContext(candidate.typeParameters, candidate, ts.isInJSFile(node) ? 2 : 0);
57072                             typeArgumentTypes = inferTypeArguments(node, candidate, args, argCheckMode | 8, inferenceContext);
57073                             argCheckMode |= inferenceContext.flags & 4 ? 8 : 0;
57074                         }
57075                         checkCandidate = getSignatureInstantiation(candidate, typeArgumentTypes, ts.isInJSFile(candidate.declaration), inferenceContext && inferenceContext.inferredTypeParameters);
57076                         if (getNonArrayRestType(candidate) && !hasCorrectArity(node, args, checkCandidate, signatureHelpTrailingComma)) {
57077                             candidateForArgumentArityError = checkCandidate;
57078                             continue;
57079                         }
57080                     }
57081                     else {
57082                         checkCandidate = candidate;
57083                     }
57084                     if (getSignatureApplicabilityError(node, args, checkCandidate, relation, argCheckMode, false, undefined)) {
57085                         (candidatesForArgumentError || (candidatesForArgumentError = [])).push(checkCandidate);
57086                         continue;
57087                     }
57088                     if (argCheckMode) {
57089                         argCheckMode = 0;
57090                         if (inferenceContext) {
57091                             var typeArgumentTypes = inferTypeArguments(node, candidate, args, argCheckMode, inferenceContext);
57092                             checkCandidate = getSignatureInstantiation(candidate, typeArgumentTypes, ts.isInJSFile(candidate.declaration), inferenceContext && inferenceContext.inferredTypeParameters);
57093                             if (getNonArrayRestType(candidate) && !hasCorrectArity(node, args, checkCandidate, signatureHelpTrailingComma)) {
57094                                 candidateForArgumentArityError = checkCandidate;
57095                                 continue;
57096                             }
57097                         }
57098                         if (getSignatureApplicabilityError(node, args, checkCandidate, relation, argCheckMode, false, undefined)) {
57099                             (candidatesForArgumentError || (candidatesForArgumentError = [])).push(checkCandidate);
57100                             continue;
57101                         }
57102                     }
57103                     candidates[candidateIndex] = checkCandidate;
57104                     return checkCandidate;
57105                 }
57106                 return undefined;
57107             }
57108         }
57109         function getCandidateForOverloadFailure(node, candidates, args, hasCandidatesOutArray) {
57110             ts.Debug.assert(candidates.length > 0);
57111             checkNodeDeferred(node);
57112             return hasCandidatesOutArray || candidates.length === 1 || candidates.some(function (c) { return !!c.typeParameters; })
57113                 ? pickLongestCandidateSignature(node, candidates, args)
57114                 : createUnionOfSignaturesForOverloadFailure(candidates);
57115         }
57116         function createUnionOfSignaturesForOverloadFailure(candidates) {
57117             var thisParameters = ts.mapDefined(candidates, function (c) { return c.thisParameter; });
57118             var thisParameter;
57119             if (thisParameters.length) {
57120                 thisParameter = createCombinedSymbolFromTypes(thisParameters, thisParameters.map(getTypeOfParameter));
57121             }
57122             var _a = ts.minAndMax(candidates, getNumNonRestParameters), minArgumentCount = _a.min, maxNonRestParam = _a.max;
57123             var parameters = [];
57124             var _loop_22 = function (i) {
57125                 var symbols = ts.mapDefined(candidates, function (s) { return signatureHasRestParameter(s) ?
57126                     i < s.parameters.length - 1 ? s.parameters[i] : ts.last(s.parameters) :
57127                     i < s.parameters.length ? s.parameters[i] : undefined; });
57128                 ts.Debug.assert(symbols.length !== 0);
57129                 parameters.push(createCombinedSymbolFromTypes(symbols, ts.mapDefined(candidates, function (candidate) { return tryGetTypeAtPosition(candidate, i); })));
57130             };
57131             for (var i = 0; i < maxNonRestParam; i++) {
57132                 _loop_22(i);
57133             }
57134             var restParameterSymbols = ts.mapDefined(candidates, function (c) { return signatureHasRestParameter(c) ? ts.last(c.parameters) : undefined; });
57135             var flags = 0;
57136             if (restParameterSymbols.length !== 0) {
57137                 var type = createArrayType(getUnionType(ts.mapDefined(candidates, tryGetRestTypeOfSignature), 2));
57138                 parameters.push(createCombinedSymbolForOverloadFailure(restParameterSymbols, type));
57139                 flags |= 1;
57140             }
57141             if (candidates.some(signatureHasLiteralTypes)) {
57142                 flags |= 2;
57143             }
57144             return createSignature(candidates[0].declaration, undefined, thisParameter, parameters, getIntersectionType(candidates.map(getReturnTypeOfSignature)), undefined, minArgumentCount, flags);
57145         }
57146         function getNumNonRestParameters(signature) {
57147             var numParams = signature.parameters.length;
57148             return signatureHasRestParameter(signature) ? numParams - 1 : numParams;
57149         }
57150         function createCombinedSymbolFromTypes(sources, types) {
57151             return createCombinedSymbolForOverloadFailure(sources, getUnionType(types, 2));
57152         }
57153         function createCombinedSymbolForOverloadFailure(sources, type) {
57154             return createSymbolWithType(ts.first(sources), type);
57155         }
57156         function pickLongestCandidateSignature(node, candidates, args) {
57157             var bestIndex = getLongestCandidateIndex(candidates, apparentArgumentCount === undefined ? args.length : apparentArgumentCount);
57158             var candidate = candidates[bestIndex];
57159             var typeParameters = candidate.typeParameters;
57160             if (!typeParameters) {
57161                 return candidate;
57162             }
57163             var typeArgumentNodes = callLikeExpressionMayHaveTypeArguments(node) ? node.typeArguments : undefined;
57164             var instantiated = typeArgumentNodes
57165                 ? createSignatureInstantiation(candidate, getTypeArgumentsFromNodes(typeArgumentNodes, typeParameters, ts.isInJSFile(node)))
57166                 : inferSignatureInstantiationForOverloadFailure(node, typeParameters, candidate, args);
57167             candidates[bestIndex] = instantiated;
57168             return instantiated;
57169         }
57170         function getTypeArgumentsFromNodes(typeArgumentNodes, typeParameters, isJs) {
57171             var typeArguments = typeArgumentNodes.map(getTypeOfNode);
57172             while (typeArguments.length > typeParameters.length) {
57173                 typeArguments.pop();
57174             }
57175             while (typeArguments.length < typeParameters.length) {
57176                 typeArguments.push(getConstraintOfTypeParameter(typeParameters[typeArguments.length]) || getDefaultTypeArgumentType(isJs));
57177             }
57178             return typeArguments;
57179         }
57180         function inferSignatureInstantiationForOverloadFailure(node, typeParameters, candidate, args) {
57181             var inferenceContext = createInferenceContext(typeParameters, candidate, ts.isInJSFile(node) ? 2 : 0);
57182             var typeArgumentTypes = inferTypeArguments(node, candidate, args, 4 | 8, inferenceContext);
57183             return createSignatureInstantiation(candidate, typeArgumentTypes);
57184         }
57185         function getLongestCandidateIndex(candidates, argsCount) {
57186             var maxParamsIndex = -1;
57187             var maxParams = -1;
57188             for (var i = 0; i < candidates.length; i++) {
57189                 var candidate = candidates[i];
57190                 var paramCount = getParameterCount(candidate);
57191                 if (hasEffectiveRestParameter(candidate) || paramCount >= argsCount) {
57192                     return i;
57193                 }
57194                 if (paramCount > maxParams) {
57195                     maxParams = paramCount;
57196                     maxParamsIndex = i;
57197                 }
57198             }
57199             return maxParamsIndex;
57200         }
57201         function resolveCallExpression(node, candidatesOutArray, checkMode) {
57202             if (node.expression.kind === 105) {
57203                 var superType = checkSuperExpression(node.expression);
57204                 if (isTypeAny(superType)) {
57205                     for (var _i = 0, _a = node.arguments; _i < _a.length; _i++) {
57206                         var arg = _a[_i];
57207                         checkExpression(arg);
57208                     }
57209                     return anySignature;
57210                 }
57211                 if (superType !== errorType) {
57212                     var baseTypeNode = ts.getEffectiveBaseTypeNode(ts.getContainingClass(node));
57213                     if (baseTypeNode) {
57214                         var baseConstructors = getInstantiatedConstructorsForTypeArguments(superType, baseTypeNode.typeArguments, baseTypeNode);
57215                         return resolveCall(node, baseConstructors, candidatesOutArray, checkMode, 0);
57216                     }
57217                 }
57218                 return resolveUntypedCall(node);
57219             }
57220             var callChainFlags;
57221             var funcType = checkExpression(node.expression);
57222             if (ts.isCallChain(node)) {
57223                 var nonOptionalType = getOptionalExpressionType(funcType, node.expression);
57224                 callChainFlags = nonOptionalType === funcType ? 0 :
57225                     ts.isOutermostOptionalChain(node) ? 8 :
57226                         4;
57227                 funcType = nonOptionalType;
57228             }
57229             else {
57230                 callChainFlags = 0;
57231             }
57232             funcType = checkNonNullTypeWithReporter(funcType, node.expression, reportCannotInvokePossiblyNullOrUndefinedError);
57233             if (funcType === silentNeverType) {
57234                 return silentNeverSignature;
57235             }
57236             var apparentType = getApparentType(funcType);
57237             if (apparentType === errorType) {
57238                 return resolveErrorCall(node);
57239             }
57240             var callSignatures = getSignaturesOfType(apparentType, 0);
57241             var numConstructSignatures = getSignaturesOfType(apparentType, 1).length;
57242             if (isUntypedFunctionCall(funcType, apparentType, callSignatures.length, numConstructSignatures)) {
57243                 if (funcType !== errorType && node.typeArguments) {
57244                     error(node, ts.Diagnostics.Untyped_function_calls_may_not_accept_type_arguments);
57245                 }
57246                 return resolveUntypedCall(node);
57247             }
57248             if (!callSignatures.length) {
57249                 if (numConstructSignatures) {
57250                     error(node, ts.Diagnostics.Value_of_type_0_is_not_callable_Did_you_mean_to_include_new, typeToString(funcType));
57251                 }
57252                 else {
57253                     var relatedInformation = void 0;
57254                     if (node.arguments.length === 1) {
57255                         var text = ts.getSourceFileOfNode(node).text;
57256                         if (ts.isLineBreak(text.charCodeAt(ts.skipTrivia(text, node.expression.end, true) - 1))) {
57257                             relatedInformation = ts.createDiagnosticForNode(node.expression, ts.Diagnostics.Are_you_missing_a_semicolon);
57258                         }
57259                     }
57260                     invocationError(node.expression, apparentType, 0, relatedInformation);
57261                 }
57262                 return resolveErrorCall(node);
57263             }
57264             if (checkMode & 8 && !node.typeArguments && callSignatures.some(isGenericFunctionReturningFunction)) {
57265                 skippedGenericFunction(node, checkMode);
57266                 return resolvingSignature;
57267             }
57268             if (callSignatures.some(function (sig) { return ts.isInJSFile(sig.declaration) && !!ts.getJSDocClassTag(sig.declaration); })) {
57269                 error(node, ts.Diagnostics.Value_of_type_0_is_not_callable_Did_you_mean_to_include_new, typeToString(funcType));
57270                 return resolveErrorCall(node);
57271             }
57272             return resolveCall(node, callSignatures, candidatesOutArray, checkMode, callChainFlags);
57273         }
57274         function isGenericFunctionReturningFunction(signature) {
57275             return !!(signature.typeParameters && isFunctionType(getReturnTypeOfSignature(signature)));
57276         }
57277         function isUntypedFunctionCall(funcType, apparentFuncType, numCallSignatures, numConstructSignatures) {
57278             return isTypeAny(funcType) || isTypeAny(apparentFuncType) && !!(funcType.flags & 262144) ||
57279                 !numCallSignatures && !numConstructSignatures && !(apparentFuncType.flags & (1048576 | 131072)) && isTypeAssignableTo(funcType, globalFunctionType);
57280         }
57281         function resolveNewExpression(node, candidatesOutArray, checkMode) {
57282             if (node.arguments && languageVersion < 1) {
57283                 var spreadIndex = getSpreadArgumentIndex(node.arguments);
57284                 if (spreadIndex >= 0) {
57285                     error(node.arguments[spreadIndex], ts.Diagnostics.Spread_operator_in_new_expressions_is_only_available_when_targeting_ECMAScript_5_and_higher);
57286                 }
57287             }
57288             var expressionType = checkNonNullExpression(node.expression);
57289             if (expressionType === silentNeverType) {
57290                 return silentNeverSignature;
57291             }
57292             expressionType = getApparentType(expressionType);
57293             if (expressionType === errorType) {
57294                 return resolveErrorCall(node);
57295             }
57296             if (isTypeAny(expressionType)) {
57297                 if (node.typeArguments) {
57298                     error(node, ts.Diagnostics.Untyped_function_calls_may_not_accept_type_arguments);
57299                 }
57300                 return resolveUntypedCall(node);
57301             }
57302             var constructSignatures = getSignaturesOfType(expressionType, 1);
57303             if (constructSignatures.length) {
57304                 if (!isConstructorAccessible(node, constructSignatures[0])) {
57305                     return resolveErrorCall(node);
57306                 }
57307                 var valueDecl = expressionType.symbol && ts.getClassLikeDeclarationOfSymbol(expressionType.symbol);
57308                 if (valueDecl && ts.hasSyntacticModifier(valueDecl, 128)) {
57309                     error(node, ts.Diagnostics.Cannot_create_an_instance_of_an_abstract_class);
57310                     return resolveErrorCall(node);
57311                 }
57312                 return resolveCall(node, constructSignatures, candidatesOutArray, checkMode, 0);
57313             }
57314             var callSignatures = getSignaturesOfType(expressionType, 0);
57315             if (callSignatures.length) {
57316                 var signature = resolveCall(node, callSignatures, candidatesOutArray, checkMode, 0);
57317                 if (!noImplicitAny) {
57318                     if (signature.declaration && !isJSConstructor(signature.declaration) && getReturnTypeOfSignature(signature) !== voidType) {
57319                         error(node, ts.Diagnostics.Only_a_void_function_can_be_called_with_the_new_keyword);
57320                     }
57321                     if (getThisTypeOfSignature(signature) === voidType) {
57322                         error(node, ts.Diagnostics.A_function_that_is_called_with_the_new_keyword_cannot_have_a_this_type_that_is_void);
57323                     }
57324                 }
57325                 return signature;
57326             }
57327             invocationError(node.expression, expressionType, 1);
57328             return resolveErrorCall(node);
57329         }
57330         function typeHasProtectedAccessibleBase(target, type) {
57331             var baseTypes = getBaseTypes(type);
57332             if (!ts.length(baseTypes)) {
57333                 return false;
57334             }
57335             var firstBase = baseTypes[0];
57336             if (firstBase.flags & 2097152) {
57337                 var types = firstBase.types;
57338                 var mixinFlags = findMixins(types);
57339                 var i = 0;
57340                 for (var _i = 0, _a = firstBase.types; _i < _a.length; _i++) {
57341                     var intersectionMember = _a[_i];
57342                     if (!mixinFlags[i]) {
57343                         if (ts.getObjectFlags(intersectionMember) & (1 | 2)) {
57344                             if (intersectionMember.symbol === target) {
57345                                 return true;
57346                             }
57347                             if (typeHasProtectedAccessibleBase(target, intersectionMember)) {
57348                                 return true;
57349                             }
57350                         }
57351                     }
57352                     i++;
57353                 }
57354                 return false;
57355             }
57356             if (firstBase.symbol === target) {
57357                 return true;
57358             }
57359             return typeHasProtectedAccessibleBase(target, firstBase);
57360         }
57361         function isConstructorAccessible(node, signature) {
57362             if (!signature || !signature.declaration) {
57363                 return true;
57364             }
57365             var declaration = signature.declaration;
57366             var modifiers = ts.getSelectedEffectiveModifierFlags(declaration, 24);
57367             if (!modifiers || declaration.kind !== 166) {
57368                 return true;
57369             }
57370             var declaringClassDeclaration = ts.getClassLikeDeclarationOfSymbol(declaration.parent.symbol);
57371             var declaringClass = getDeclaredTypeOfSymbol(declaration.parent.symbol);
57372             if (!isNodeWithinClass(node, declaringClassDeclaration)) {
57373                 var containingClass = ts.getContainingClass(node);
57374                 if (containingClass && modifiers & 16) {
57375                     var containingType = getTypeOfNode(containingClass);
57376                     if (typeHasProtectedAccessibleBase(declaration.parent.symbol, containingType)) {
57377                         return true;
57378                     }
57379                 }
57380                 if (modifiers & 8) {
57381                     error(node, ts.Diagnostics.Constructor_of_class_0_is_private_and_only_accessible_within_the_class_declaration, typeToString(declaringClass));
57382                 }
57383                 if (modifiers & 16) {
57384                     error(node, ts.Diagnostics.Constructor_of_class_0_is_protected_and_only_accessible_within_the_class_declaration, typeToString(declaringClass));
57385                 }
57386                 return false;
57387             }
57388             return true;
57389         }
57390         function invocationErrorDetails(errorTarget, apparentType, kind) {
57391             var errorInfo;
57392             var isCall = kind === 0;
57393             var awaitedType = getAwaitedType(apparentType);
57394             var maybeMissingAwait = awaitedType && getSignaturesOfType(awaitedType, kind).length > 0;
57395             if (apparentType.flags & 1048576) {
57396                 var types = apparentType.types;
57397                 var hasSignatures = false;
57398                 for (var _i = 0, types_19 = types; _i < types_19.length; _i++) {
57399                     var constituent = types_19[_i];
57400                     var signatures = getSignaturesOfType(constituent, kind);
57401                     if (signatures.length !== 0) {
57402                         hasSignatures = true;
57403                         if (errorInfo) {
57404                             break;
57405                         }
57406                     }
57407                     else {
57408                         if (!errorInfo) {
57409                             errorInfo = ts.chainDiagnosticMessages(errorInfo, isCall ?
57410                                 ts.Diagnostics.Type_0_has_no_call_signatures :
57411                                 ts.Diagnostics.Type_0_has_no_construct_signatures, typeToString(constituent));
57412                             errorInfo = ts.chainDiagnosticMessages(errorInfo, isCall ?
57413                                 ts.Diagnostics.Not_all_constituents_of_type_0_are_callable :
57414                                 ts.Diagnostics.Not_all_constituents_of_type_0_are_constructable, typeToString(apparentType));
57415                         }
57416                         if (hasSignatures) {
57417                             break;
57418                         }
57419                     }
57420                 }
57421                 if (!hasSignatures) {
57422                     errorInfo = ts.chainDiagnosticMessages(undefined, isCall ?
57423                         ts.Diagnostics.No_constituent_of_type_0_is_callable :
57424                         ts.Diagnostics.No_constituent_of_type_0_is_constructable, typeToString(apparentType));
57425                 }
57426                 if (!errorInfo) {
57427                     errorInfo = ts.chainDiagnosticMessages(errorInfo, isCall ?
57428                         ts.Diagnostics.Each_member_of_the_union_type_0_has_signatures_but_none_of_those_signatures_are_compatible_with_each_other :
57429                         ts.Diagnostics.Each_member_of_the_union_type_0_has_construct_signatures_but_none_of_those_signatures_are_compatible_with_each_other, typeToString(apparentType));
57430                 }
57431             }
57432             else {
57433                 errorInfo = ts.chainDiagnosticMessages(errorInfo, isCall ?
57434                     ts.Diagnostics.Type_0_has_no_call_signatures :
57435                     ts.Diagnostics.Type_0_has_no_construct_signatures, typeToString(apparentType));
57436             }
57437             var headMessage = isCall ? ts.Diagnostics.This_expression_is_not_callable : ts.Diagnostics.This_expression_is_not_constructable;
57438             if (ts.isCallExpression(errorTarget.parent) && errorTarget.parent.arguments.length === 0) {
57439                 var resolvedSymbol = getNodeLinks(errorTarget).resolvedSymbol;
57440                 if (resolvedSymbol && resolvedSymbol.flags & 32768) {
57441                     headMessage = ts.Diagnostics.This_expression_is_not_callable_because_it_is_a_get_accessor_Did_you_mean_to_use_it_without;
57442                 }
57443             }
57444             return {
57445                 messageChain: ts.chainDiagnosticMessages(errorInfo, headMessage),
57446                 relatedMessage: maybeMissingAwait ? ts.Diagnostics.Did_you_forget_to_use_await : undefined,
57447             };
57448         }
57449         function invocationError(errorTarget, apparentType, kind, relatedInformation) {
57450             var _a = invocationErrorDetails(errorTarget, apparentType, kind), messageChain = _a.messageChain, relatedInfo = _a.relatedMessage;
57451             var diagnostic = ts.createDiagnosticForNodeFromMessageChain(errorTarget, messageChain);
57452             if (relatedInfo) {
57453                 ts.addRelatedInfo(diagnostic, ts.createDiagnosticForNode(errorTarget, relatedInfo));
57454             }
57455             if (ts.isCallExpression(errorTarget.parent)) {
57456                 var _b = getDiagnosticSpanForCallNode(errorTarget.parent, true), start = _b.start, length_7 = _b.length;
57457                 diagnostic.start = start;
57458                 diagnostic.length = length_7;
57459             }
57460             diagnostics.add(diagnostic);
57461             invocationErrorRecovery(apparentType, kind, relatedInformation ? ts.addRelatedInfo(diagnostic, relatedInformation) : diagnostic);
57462         }
57463         function invocationErrorRecovery(apparentType, kind, diagnostic) {
57464             if (!apparentType.symbol) {
57465                 return;
57466             }
57467             var importNode = getSymbolLinks(apparentType.symbol).originatingImport;
57468             if (importNode && !ts.isImportCall(importNode)) {
57469                 var sigs = getSignaturesOfType(getTypeOfSymbol(getSymbolLinks(apparentType.symbol).target), kind);
57470                 if (!sigs || !sigs.length)
57471                     return;
57472                 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));
57473             }
57474         }
57475         function resolveTaggedTemplateExpression(node, candidatesOutArray, checkMode) {
57476             var tagType = checkExpression(node.tag);
57477             var apparentType = getApparentType(tagType);
57478             if (apparentType === errorType) {
57479                 return resolveErrorCall(node);
57480             }
57481             var callSignatures = getSignaturesOfType(apparentType, 0);
57482             var numConstructSignatures = getSignaturesOfType(apparentType, 1).length;
57483             if (isUntypedFunctionCall(tagType, apparentType, callSignatures.length, numConstructSignatures)) {
57484                 return resolveUntypedCall(node);
57485             }
57486             if (!callSignatures.length) {
57487                 if (ts.isArrayLiteralExpression(node.parent)) {
57488                     var diagnostic = ts.createDiagnosticForNode(node.tag, ts.Diagnostics.It_is_likely_that_you_are_missing_a_comma_to_separate_these_two_template_expressions_They_form_a_tagged_template_expression_which_cannot_be_invoked);
57489                     diagnostics.add(diagnostic);
57490                     return resolveErrorCall(node);
57491                 }
57492                 invocationError(node.tag, apparentType, 0);
57493                 return resolveErrorCall(node);
57494             }
57495             return resolveCall(node, callSignatures, candidatesOutArray, checkMode, 0);
57496         }
57497         function getDiagnosticHeadMessageForDecoratorResolution(node) {
57498             switch (node.parent.kind) {
57499                 case 252:
57500                 case 221:
57501                     return ts.Diagnostics.Unable_to_resolve_signature_of_class_decorator_when_called_as_an_expression;
57502                 case 160:
57503                     return ts.Diagnostics.Unable_to_resolve_signature_of_parameter_decorator_when_called_as_an_expression;
57504                 case 163:
57505                     return ts.Diagnostics.Unable_to_resolve_signature_of_property_decorator_when_called_as_an_expression;
57506                 case 165:
57507                 case 167:
57508                 case 168:
57509                     return ts.Diagnostics.Unable_to_resolve_signature_of_method_decorator_when_called_as_an_expression;
57510                 default:
57511                     return ts.Debug.fail();
57512             }
57513         }
57514         function resolveDecorator(node, candidatesOutArray, checkMode) {
57515             var funcType = checkExpression(node.expression);
57516             var apparentType = getApparentType(funcType);
57517             if (apparentType === errorType) {
57518                 return resolveErrorCall(node);
57519             }
57520             var callSignatures = getSignaturesOfType(apparentType, 0);
57521             var numConstructSignatures = getSignaturesOfType(apparentType, 1).length;
57522             if (isUntypedFunctionCall(funcType, apparentType, callSignatures.length, numConstructSignatures)) {
57523                 return resolveUntypedCall(node);
57524             }
57525             if (isPotentiallyUncalledDecorator(node, callSignatures)) {
57526                 var nodeStr = ts.getTextOfNode(node.expression, false);
57527                 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);
57528                 return resolveErrorCall(node);
57529             }
57530             var headMessage = getDiagnosticHeadMessageForDecoratorResolution(node);
57531             if (!callSignatures.length) {
57532                 var errorDetails = invocationErrorDetails(node.expression, apparentType, 0);
57533                 var messageChain = ts.chainDiagnosticMessages(errorDetails.messageChain, headMessage);
57534                 var diag = ts.createDiagnosticForNodeFromMessageChain(node.expression, messageChain);
57535                 if (errorDetails.relatedMessage) {
57536                     ts.addRelatedInfo(diag, ts.createDiagnosticForNode(node.expression, errorDetails.relatedMessage));
57537                 }
57538                 diagnostics.add(diag);
57539                 invocationErrorRecovery(apparentType, 0, diag);
57540                 return resolveErrorCall(node);
57541             }
57542             return resolveCall(node, callSignatures, candidatesOutArray, checkMode, 0, headMessage);
57543         }
57544         function createSignatureForJSXIntrinsic(node, result) {
57545             var namespace = getJsxNamespaceAt(node);
57546             var exports = namespace && getExportsOfSymbol(namespace);
57547             var typeSymbol = exports && getSymbol(exports, JsxNames.Element, 788968);
57548             var returnNode = typeSymbol && nodeBuilder.symbolToEntityName(typeSymbol, 788968, node);
57549             var declaration = ts.factory.createFunctionTypeNode(undefined, [ts.factory.createParameterDeclaration(undefined, undefined, undefined, "props", undefined, nodeBuilder.typeToTypeNode(result, node))], returnNode ? ts.factory.createTypeReferenceNode(returnNode, undefined) : ts.factory.createKeywordTypeNode(128));
57550             var parameterSymbol = createSymbol(1, "props");
57551             parameterSymbol.type = result;
57552             return createSignature(declaration, undefined, undefined, [parameterSymbol], typeSymbol ? getDeclaredTypeOfSymbol(typeSymbol) : errorType, undefined, 1, 0);
57553         }
57554         function resolveJsxOpeningLikeElement(node, candidatesOutArray, checkMode) {
57555             if (isJsxIntrinsicIdentifier(node.tagName)) {
57556                 var result = getIntrinsicAttributesTypeFromJsxOpeningLikeElement(node);
57557                 var fakeSignature = createSignatureForJSXIntrinsic(node, result);
57558                 checkTypeAssignableToAndOptionallyElaborate(checkExpressionWithContextualType(node.attributes, getEffectiveFirstArgumentForJsxSignature(fakeSignature, node), undefined, 0), result, node.tagName, node.attributes);
57559                 if (ts.length(node.typeArguments)) {
57560                     ts.forEach(node.typeArguments, checkSourceElement);
57561                     diagnostics.add(ts.createDiagnosticForNodeArray(ts.getSourceFileOfNode(node), node.typeArguments, ts.Diagnostics.Expected_0_type_arguments_but_got_1, 0, ts.length(node.typeArguments)));
57562                 }
57563                 return fakeSignature;
57564             }
57565             var exprTypes = checkExpression(node.tagName);
57566             var apparentType = getApparentType(exprTypes);
57567             if (apparentType === errorType) {
57568                 return resolveErrorCall(node);
57569             }
57570             var signatures = getUninstantiatedJsxSignaturesOfType(exprTypes, node);
57571             if (isUntypedFunctionCall(exprTypes, apparentType, signatures.length, 0)) {
57572                 return resolveUntypedCall(node);
57573             }
57574             if (signatures.length === 0) {
57575                 error(node.tagName, ts.Diagnostics.JSX_element_type_0_does_not_have_any_construct_or_call_signatures, ts.getTextOfNode(node.tagName));
57576                 return resolveErrorCall(node);
57577             }
57578             return resolveCall(node, signatures, candidatesOutArray, checkMode, 0);
57579         }
57580         function isPotentiallyUncalledDecorator(decorator, signatures) {
57581             return signatures.length && ts.every(signatures, function (signature) {
57582                 return signature.minArgumentCount === 0 &&
57583                     !signatureHasRestParameter(signature) &&
57584                     signature.parameters.length < getDecoratorArgumentCount(decorator, signature);
57585             });
57586         }
57587         function resolveSignature(node, candidatesOutArray, checkMode) {
57588             switch (node.kind) {
57589                 case 203:
57590                     return resolveCallExpression(node, candidatesOutArray, checkMode);
57591                 case 204:
57592                     return resolveNewExpression(node, candidatesOutArray, checkMode);
57593                 case 205:
57594                     return resolveTaggedTemplateExpression(node, candidatesOutArray, checkMode);
57595                 case 161:
57596                     return resolveDecorator(node, candidatesOutArray, checkMode);
57597                 case 275:
57598                 case 274:
57599                     return resolveJsxOpeningLikeElement(node, candidatesOutArray, checkMode);
57600             }
57601             throw ts.Debug.assertNever(node, "Branch in 'resolveSignature' should be unreachable.");
57602         }
57603         function getResolvedSignature(node, candidatesOutArray, checkMode) {
57604             var links = getNodeLinks(node);
57605             var cached = links.resolvedSignature;
57606             if (cached && cached !== resolvingSignature && !candidatesOutArray) {
57607                 return cached;
57608             }
57609             links.resolvedSignature = resolvingSignature;
57610             var result = resolveSignature(node, candidatesOutArray, checkMode || 0);
57611             if (result !== resolvingSignature) {
57612                 links.resolvedSignature = flowLoopStart === flowLoopCount ? result : cached;
57613             }
57614             return result;
57615         }
57616         function isJSConstructor(node) {
57617             var _a;
57618             if (!node || !ts.isInJSFile(node)) {
57619                 return false;
57620             }
57621             var func = ts.isFunctionDeclaration(node) || ts.isFunctionExpression(node) ? node :
57622                 ts.isVariableDeclaration(node) && node.initializer && ts.isFunctionExpression(node.initializer) ? node.initializer :
57623                     undefined;
57624             if (func) {
57625                 if (ts.getJSDocClassTag(node))
57626                     return true;
57627                 var symbol = getSymbolOfNode(func);
57628                 return !!((_a = symbol === null || symbol === void 0 ? void 0 : symbol.members) === null || _a === void 0 ? void 0 : _a.size);
57629             }
57630             return false;
57631         }
57632         function mergeJSSymbols(target, source) {
57633             var _a, _b;
57634             if (source) {
57635                 var links = getSymbolLinks(source);
57636                 if (!links.inferredClassSymbol || !links.inferredClassSymbol.has(getSymbolId(target))) {
57637                     var inferred = ts.isTransientSymbol(target) ? target : cloneSymbol(target);
57638                     inferred.exports = inferred.exports || ts.createSymbolTable();
57639                     inferred.members = inferred.members || ts.createSymbolTable();
57640                     inferred.flags |= source.flags & 32;
57641                     if ((_a = source.exports) === null || _a === void 0 ? void 0 : _a.size) {
57642                         mergeSymbolTable(inferred.exports, source.exports);
57643                     }
57644                     if ((_b = source.members) === null || _b === void 0 ? void 0 : _b.size) {
57645                         mergeSymbolTable(inferred.members, source.members);
57646                     }
57647                     (links.inferredClassSymbol || (links.inferredClassSymbol = new ts.Map())).set(getSymbolId(inferred), inferred);
57648                     return inferred;
57649                 }
57650                 return links.inferredClassSymbol.get(getSymbolId(target));
57651             }
57652         }
57653         function getAssignedClassSymbol(decl) {
57654             var _a;
57655             var assignmentSymbol = decl && getSymbolOfExpando(decl, true);
57656             var prototype = (_a = assignmentSymbol === null || assignmentSymbol === void 0 ? void 0 : assignmentSymbol.exports) === null || _a === void 0 ? void 0 : _a.get("prototype");
57657             var init = (prototype === null || prototype === void 0 ? void 0 : prototype.valueDeclaration) && getAssignedJSPrototype(prototype.valueDeclaration);
57658             return init ? getSymbolOfNode(init) : undefined;
57659         }
57660         function getSymbolOfExpando(node, allowDeclaration) {
57661             if (!node.parent) {
57662                 return undefined;
57663             }
57664             var name;
57665             var decl;
57666             if (ts.isVariableDeclaration(node.parent) && node.parent.initializer === node) {
57667                 if (!ts.isInJSFile(node) && !(ts.isVarConst(node.parent) && ts.isFunctionLikeDeclaration(node))) {
57668                     return undefined;
57669                 }
57670                 name = node.parent.name;
57671                 decl = node.parent;
57672             }
57673             else if (ts.isBinaryExpression(node.parent)) {
57674                 var parentNode = node.parent;
57675                 var parentNodeOperator = node.parent.operatorToken.kind;
57676                 if (parentNodeOperator === 62 && (allowDeclaration || parentNode.right === node)) {
57677                     name = parentNode.left;
57678                     decl = name;
57679                 }
57680                 else if (parentNodeOperator === 56 || parentNodeOperator === 60) {
57681                     if (ts.isVariableDeclaration(parentNode.parent) && parentNode.parent.initializer === parentNode) {
57682                         name = parentNode.parent.name;
57683                         decl = parentNode.parent;
57684                     }
57685                     else if (ts.isBinaryExpression(parentNode.parent) && parentNode.parent.operatorToken.kind === 62 && (allowDeclaration || parentNode.parent.right === parentNode)) {
57686                         name = parentNode.parent.left;
57687                         decl = name;
57688                     }
57689                     if (!name || !ts.isBindableStaticNameExpression(name) || !ts.isSameEntityName(name, parentNode.left)) {
57690                         return undefined;
57691                     }
57692                 }
57693             }
57694             else if (allowDeclaration && ts.isFunctionDeclaration(node)) {
57695                 name = node.name;
57696                 decl = node;
57697             }
57698             if (!decl || !name || (!allowDeclaration && !ts.getExpandoInitializer(node, ts.isPrototypeAccess(name)))) {
57699                 return undefined;
57700             }
57701             return getSymbolOfNode(decl);
57702         }
57703         function getAssignedJSPrototype(node) {
57704             if (!node.parent) {
57705                 return false;
57706             }
57707             var parent = node.parent;
57708             while (parent && parent.kind === 201) {
57709                 parent = parent.parent;
57710             }
57711             if (parent && ts.isBinaryExpression(parent) && ts.isPrototypeAccess(parent.left) && parent.operatorToken.kind === 62) {
57712                 var right = ts.getInitializerOfBinaryExpression(parent);
57713                 return ts.isObjectLiteralExpression(right) && right;
57714             }
57715         }
57716         function checkCallExpression(node, checkMode) {
57717             var _a;
57718             if (!checkGrammarTypeArguments(node, node.typeArguments))
57719                 checkGrammarArguments(node.arguments);
57720             var signature = getResolvedSignature(node, undefined, checkMode);
57721             if (signature === resolvingSignature) {
57722                 return nonInferrableType;
57723             }
57724             checkDeprecatedSignature(signature, node);
57725             if (node.expression.kind === 105) {
57726                 return voidType;
57727             }
57728             if (node.kind === 204) {
57729                 var declaration = signature.declaration;
57730                 if (declaration &&
57731                     declaration.kind !== 166 &&
57732                     declaration.kind !== 170 &&
57733                     declaration.kind !== 175 &&
57734                     !ts.isJSDocConstructSignature(declaration) &&
57735                     !isJSConstructor(declaration)) {
57736                     if (noImplicitAny) {
57737                         error(node, ts.Diagnostics.new_expression_whose_target_lacks_a_construct_signature_implicitly_has_an_any_type);
57738                     }
57739                     return anyType;
57740                 }
57741             }
57742             if (ts.isInJSFile(node) && isCommonJsRequire(node)) {
57743                 return resolveExternalModuleTypeByLiteral(node.arguments[0]);
57744             }
57745             var returnType = getReturnTypeOfSignature(signature);
57746             if (returnType.flags & 12288 && isSymbolOrSymbolForCall(node)) {
57747                 return getESSymbolLikeTypeForNode(ts.walkUpParenthesizedExpressions(node.parent));
57748             }
57749             if (node.kind === 203 && node.parent.kind === 233 &&
57750                 returnType.flags & 16384 && getTypePredicateOfSignature(signature)) {
57751                 if (!ts.isDottedName(node.expression)) {
57752                     error(node.expression, ts.Diagnostics.Assertions_require_the_call_target_to_be_an_identifier_or_qualified_name);
57753                 }
57754                 else if (!getEffectsSignature(node)) {
57755                     var diagnostic = error(node.expression, ts.Diagnostics.Assertions_require_every_name_in_the_call_target_to_be_declared_with_an_explicit_type_annotation);
57756                     getTypeOfDottedName(node.expression, diagnostic);
57757                 }
57758             }
57759             if (ts.isInJSFile(node)) {
57760                 var jsSymbol = getSymbolOfExpando(node, false);
57761                 if ((_a = jsSymbol === null || jsSymbol === void 0 ? void 0 : jsSymbol.exports) === null || _a === void 0 ? void 0 : _a.size) {
57762                     var jsAssignmentType = createAnonymousType(jsSymbol, jsSymbol.exports, ts.emptyArray, ts.emptyArray, undefined, undefined);
57763                     jsAssignmentType.objectFlags |= 16384;
57764                     return getIntersectionType([returnType, jsAssignmentType]);
57765                 }
57766             }
57767             return returnType;
57768         }
57769         function checkDeprecatedSignature(signature, node) {
57770             if (signature.declaration && signature.declaration.flags & 134217728) {
57771                 var suggestionNode = getDeprecatedSuggestionNode(node);
57772                 errorOrSuggestion(false, suggestionNode, ts.Diagnostics._0_is_deprecated, signatureToString(signature));
57773             }
57774         }
57775         function getDeprecatedSuggestionNode(node) {
57776             node = ts.skipParentheses(node);
57777             switch (node.kind) {
57778                 case 203:
57779                 case 161:
57780                 case 204:
57781                     return getDeprecatedSuggestionNode(node.expression);
57782                 case 205:
57783                     return getDeprecatedSuggestionNode(node.tag);
57784                 case 275:
57785                 case 274:
57786                     return getDeprecatedSuggestionNode(node.tagName);
57787                 case 202:
57788                     return node.argumentExpression;
57789                 case 201:
57790                     return node.name;
57791                 case 173:
57792                     var typeReference = node;
57793                     return ts.isQualifiedName(typeReference.typeName) ? typeReference.typeName.right : typeReference;
57794                 default:
57795                     return node;
57796             }
57797         }
57798         function isSymbolOrSymbolForCall(node) {
57799             if (!ts.isCallExpression(node))
57800                 return false;
57801             var left = node.expression;
57802             if (ts.isPropertyAccessExpression(left) && left.name.escapedText === "for") {
57803                 left = left.expression;
57804             }
57805             if (!ts.isIdentifier(left) || left.escapedText !== "Symbol") {
57806                 return false;
57807             }
57808             var globalESSymbol = getGlobalESSymbolConstructorSymbol(false);
57809             if (!globalESSymbol) {
57810                 return false;
57811             }
57812             return globalESSymbol === resolveName(left, "Symbol", 111551, undefined, undefined, false);
57813         }
57814         function checkImportCallExpression(node) {
57815             if (!checkGrammarArguments(node.arguments))
57816                 checkGrammarImportCallExpression(node);
57817             if (node.arguments.length === 0) {
57818                 return createPromiseReturnType(node, anyType);
57819             }
57820             var specifier = node.arguments[0];
57821             var specifierType = checkExpressionCached(specifier);
57822             for (var i = 1; i < node.arguments.length; ++i) {
57823                 checkExpressionCached(node.arguments[i]);
57824             }
57825             if (specifierType.flags & 32768 || specifierType.flags & 65536 || !isTypeAssignableTo(specifierType, stringType)) {
57826                 error(specifier, ts.Diagnostics.Dynamic_import_s_specifier_must_be_of_type_string_but_here_has_type_0, typeToString(specifierType));
57827             }
57828             var moduleSymbol = resolveExternalModuleName(node, specifier);
57829             if (moduleSymbol) {
57830                 var esModuleSymbol = resolveESModuleSymbol(moduleSymbol, specifier, true, false);
57831                 if (esModuleSymbol) {
57832                     return createPromiseReturnType(node, getTypeWithSyntheticDefaultImportType(getTypeOfSymbol(esModuleSymbol), esModuleSymbol, moduleSymbol));
57833                 }
57834             }
57835             return createPromiseReturnType(node, anyType);
57836         }
57837         function getTypeWithSyntheticDefaultImportType(type, symbol, originalSymbol) {
57838             if (allowSyntheticDefaultImports && type && type !== errorType) {
57839                 var synthType = type;
57840                 if (!synthType.syntheticType) {
57841                     var file = ts.find(originalSymbol.declarations, ts.isSourceFile);
57842                     var hasSyntheticDefault = canHaveSyntheticDefault(file, originalSymbol, false);
57843                     if (hasSyntheticDefault) {
57844                         var memberTable = ts.createSymbolTable();
57845                         var newSymbol = createSymbol(2097152, "default");
57846                         newSymbol.parent = originalSymbol;
57847                         newSymbol.nameType = getLiteralType("default");
57848                         newSymbol.target = resolveSymbol(symbol);
57849                         memberTable.set("default", newSymbol);
57850                         var anonymousSymbol = createSymbol(2048, "__type");
57851                         var defaultContainingObject = createAnonymousType(anonymousSymbol, memberTable, ts.emptyArray, ts.emptyArray, undefined, undefined);
57852                         anonymousSymbol.type = defaultContainingObject;
57853                         synthType.syntheticType = isValidSpreadType(type) ? getSpreadType(type, defaultContainingObject, anonymousSymbol, 0, false) : defaultContainingObject;
57854                     }
57855                     else {
57856                         synthType.syntheticType = type;
57857                     }
57858                 }
57859                 return synthType.syntheticType;
57860             }
57861             return type;
57862         }
57863         function isCommonJsRequire(node) {
57864             if (!ts.isRequireCall(node, true)) {
57865                 return false;
57866             }
57867             if (!ts.isIdentifier(node.expression))
57868                 return ts.Debug.fail();
57869             var resolvedRequire = resolveName(node.expression, node.expression.escapedText, 111551, undefined, undefined, true);
57870             if (resolvedRequire === requireSymbol) {
57871                 return true;
57872             }
57873             if (resolvedRequire.flags & 2097152) {
57874                 return false;
57875             }
57876             var targetDeclarationKind = resolvedRequire.flags & 16
57877                 ? 251
57878                 : resolvedRequire.flags & 3
57879                     ? 249
57880                     : 0;
57881             if (targetDeclarationKind !== 0) {
57882                 var decl = ts.getDeclarationOfKind(resolvedRequire, targetDeclarationKind);
57883                 return !!decl && !!(decl.flags & 8388608);
57884             }
57885             return false;
57886         }
57887         function checkTaggedTemplateExpression(node) {
57888             if (!checkGrammarTaggedTemplateChain(node))
57889                 checkGrammarTypeArguments(node, node.typeArguments);
57890             if (languageVersion < 2) {
57891                 checkExternalEmitHelpers(node, 524288);
57892             }
57893             var signature = getResolvedSignature(node);
57894             checkDeprecatedSignature(signature, node);
57895             return getReturnTypeOfSignature(signature);
57896         }
57897         function checkAssertion(node) {
57898             return checkAssertionWorker(node, node.type, node.expression);
57899         }
57900         function isValidConstAssertionArgument(node) {
57901             switch (node.kind) {
57902                 case 10:
57903                 case 14:
57904                 case 8:
57905                 case 9:
57906                 case 109:
57907                 case 94:
57908                 case 199:
57909                 case 200:
57910                 case 218:
57911                     return true;
57912                 case 207:
57913                     return isValidConstAssertionArgument(node.expression);
57914                 case 214:
57915                     var op = node.operator;
57916                     var arg = node.operand;
57917                     return op === 40 && (arg.kind === 8 || arg.kind === 9) ||
57918                         op === 39 && arg.kind === 8;
57919                 case 201:
57920                 case 202:
57921                     var expr = node.expression;
57922                     if (ts.isIdentifier(expr)) {
57923                         var symbol = getSymbolAtLocation(expr);
57924                         if (symbol && symbol.flags & 2097152) {
57925                             symbol = resolveAlias(symbol);
57926                         }
57927                         return !!(symbol && (symbol.flags & 384) && getEnumKind(symbol) === 1);
57928                     }
57929             }
57930             return false;
57931         }
57932         function checkAssertionWorker(errNode, type, expression, checkMode) {
57933             var exprType = checkExpression(expression, checkMode);
57934             if (ts.isConstTypeReference(type)) {
57935                 if (!isValidConstAssertionArgument(expression)) {
57936                     error(expression, ts.Diagnostics.A_const_assertions_can_only_be_applied_to_references_to_enum_members_or_string_number_boolean_array_or_object_literals);
57937                 }
57938                 return getRegularTypeOfLiteralType(exprType);
57939             }
57940             checkSourceElement(type);
57941             exprType = getRegularTypeOfObjectLiteral(getBaseTypeOfLiteralType(exprType));
57942             var targetType = getTypeFromTypeNode(type);
57943             if (produceDiagnostics && targetType !== errorType) {
57944                 var widenedType = getWidenedType(exprType);
57945                 if (!isTypeComparableTo(targetType, widenedType)) {
57946                     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);
57947                 }
57948             }
57949             return targetType;
57950         }
57951         function checkNonNullChain(node) {
57952             var leftType = checkExpression(node.expression);
57953             var nonOptionalType = getOptionalExpressionType(leftType, node.expression);
57954             return propagateOptionalTypeMarker(getNonNullableType(nonOptionalType), node, nonOptionalType !== leftType);
57955         }
57956         function checkNonNullAssertion(node) {
57957             return node.flags & 32 ? checkNonNullChain(node) :
57958                 getNonNullableType(checkExpression(node.expression));
57959         }
57960         function checkMetaProperty(node) {
57961             checkGrammarMetaProperty(node);
57962             if (node.keywordToken === 102) {
57963                 return checkNewTargetMetaProperty(node);
57964             }
57965             if (node.keywordToken === 99) {
57966                 return checkImportMetaProperty(node);
57967             }
57968             return ts.Debug.assertNever(node.keywordToken);
57969         }
57970         function checkNewTargetMetaProperty(node) {
57971             var container = ts.getNewTargetContainer(node);
57972             if (!container) {
57973                 error(node, ts.Diagnostics.Meta_property_0_is_only_allowed_in_the_body_of_a_function_declaration_function_expression_or_constructor, "new.target");
57974                 return errorType;
57975             }
57976             else if (container.kind === 166) {
57977                 var symbol = getSymbolOfNode(container.parent);
57978                 return getTypeOfSymbol(symbol);
57979             }
57980             else {
57981                 var symbol = getSymbolOfNode(container);
57982                 return getTypeOfSymbol(symbol);
57983             }
57984         }
57985         function checkImportMetaProperty(node) {
57986             if (moduleKind !== ts.ModuleKind.ES2020 && moduleKind !== ts.ModuleKind.ESNext && moduleKind !== ts.ModuleKind.System) {
57987                 error(node, ts.Diagnostics.The_import_meta_meta_property_is_only_allowed_when_the_module_option_is_es2020_esnext_or_system);
57988             }
57989             var file = ts.getSourceFileOfNode(node);
57990             ts.Debug.assert(!!(file.flags & 2097152), "Containing file is missing import meta node flag.");
57991             ts.Debug.assert(!!file.externalModuleIndicator, "Containing file should be a module.");
57992             return node.name.escapedText === "meta" ? getGlobalImportMetaType() : errorType;
57993         }
57994         function getTypeOfParameter(symbol) {
57995             var type = getTypeOfSymbol(symbol);
57996             if (strictNullChecks) {
57997                 var declaration = symbol.valueDeclaration;
57998                 if (declaration && ts.hasInitializer(declaration)) {
57999                     return getOptionalType(type);
58000                 }
58001             }
58002             return type;
58003         }
58004         function getTupleElementLabel(d) {
58005             ts.Debug.assert(ts.isIdentifier(d.name));
58006             return d.name.escapedText;
58007         }
58008         function getParameterNameAtPosition(signature, pos, overrideRestType) {
58009             var paramCount = signature.parameters.length - (signatureHasRestParameter(signature) ? 1 : 0);
58010             if (pos < paramCount) {
58011                 return signature.parameters[pos].escapedName;
58012             }
58013             var restParameter = signature.parameters[paramCount] || unknownSymbol;
58014             var restType = overrideRestType || getTypeOfSymbol(restParameter);
58015             if (isTupleType(restType)) {
58016                 var associatedNames = restType.target.labeledElementDeclarations;
58017                 var index = pos - paramCount;
58018                 return associatedNames && getTupleElementLabel(associatedNames[index]) || restParameter.escapedName + "_" + index;
58019             }
58020             return restParameter.escapedName;
58021         }
58022         function isValidDeclarationForTupleLabel(d) {
58023             return d.kind === 192 || (ts.isParameter(d) && d.name && ts.isIdentifier(d.name));
58024         }
58025         function getNameableDeclarationAtPosition(signature, pos) {
58026             var paramCount = signature.parameters.length - (signatureHasRestParameter(signature) ? 1 : 0);
58027             if (pos < paramCount) {
58028                 var decl = signature.parameters[pos].valueDeclaration;
58029                 return decl && isValidDeclarationForTupleLabel(decl) ? decl : undefined;
58030             }
58031             var restParameter = signature.parameters[paramCount] || unknownSymbol;
58032             var restType = getTypeOfSymbol(restParameter);
58033             if (isTupleType(restType)) {
58034                 var associatedNames = restType.target.labeledElementDeclarations;
58035                 var index = pos - paramCount;
58036                 return associatedNames && associatedNames[index];
58037             }
58038             return restParameter.valueDeclaration && isValidDeclarationForTupleLabel(restParameter.valueDeclaration) ? restParameter.valueDeclaration : undefined;
58039         }
58040         function getTypeAtPosition(signature, pos) {
58041             return tryGetTypeAtPosition(signature, pos) || anyType;
58042         }
58043         function tryGetTypeAtPosition(signature, pos) {
58044             var paramCount = signature.parameters.length - (signatureHasRestParameter(signature) ? 1 : 0);
58045             if (pos < paramCount) {
58046                 return getTypeOfParameter(signature.parameters[pos]);
58047             }
58048             if (signatureHasRestParameter(signature)) {
58049                 var restType = getTypeOfSymbol(signature.parameters[paramCount]);
58050                 var index = pos - paramCount;
58051                 if (!isTupleType(restType) || restType.target.hasRestElement || index < restType.target.fixedLength) {
58052                     return getIndexedAccessType(restType, getLiteralType(index));
58053                 }
58054             }
58055             return undefined;
58056         }
58057         function getRestTypeAtPosition(source, pos) {
58058             var parameterCount = getParameterCount(source);
58059             var minArgumentCount = getMinArgumentCount(source);
58060             var restType = getEffectiveRestType(source);
58061             if (restType && pos >= parameterCount - 1) {
58062                 return pos === parameterCount - 1 ? restType : createArrayType(getIndexedAccessType(restType, numberType));
58063             }
58064             var types = [];
58065             var flags = [];
58066             var names = [];
58067             for (var i = pos; i < parameterCount; i++) {
58068                 if (!restType || i < parameterCount - 1) {
58069                     types.push(getTypeAtPosition(source, i));
58070                     flags.push(i < minArgumentCount ? 1 : 2);
58071                 }
58072                 else {
58073                     types.push(restType);
58074                     flags.push(8);
58075                 }
58076                 var name = getNameableDeclarationAtPosition(source, i);
58077                 if (name) {
58078                     names.push(name);
58079                 }
58080             }
58081             return createTupleType(types, flags, false, ts.length(names) === ts.length(types) ? names : undefined);
58082         }
58083         function getParameterCount(signature) {
58084             var length = signature.parameters.length;
58085             if (signatureHasRestParameter(signature)) {
58086                 var restType = getTypeOfSymbol(signature.parameters[length - 1]);
58087                 if (isTupleType(restType)) {
58088                     return length + restType.target.fixedLength - (restType.target.hasRestElement ? 0 : 1);
58089                 }
58090             }
58091             return length;
58092         }
58093         function getMinArgumentCount(signature, flags) {
58094             var strongArityForUntypedJS = flags & 1;
58095             var voidIsNonOptional = flags & 2;
58096             if (voidIsNonOptional || signature.resolvedMinArgumentCount === undefined) {
58097                 var minArgumentCount = void 0;
58098                 if (signatureHasRestParameter(signature)) {
58099                     var restType = getTypeOfSymbol(signature.parameters[signature.parameters.length - 1]);
58100                     if (isTupleType(restType)) {
58101                         var firstOptionalIndex = ts.findIndex(restType.target.elementFlags, function (f) { return !(f & 1); });
58102                         var requiredCount = firstOptionalIndex < 0 ? restType.target.fixedLength : firstOptionalIndex;
58103                         if (requiredCount > 0) {
58104                             minArgumentCount = signature.parameters.length - 1 + requiredCount;
58105                         }
58106                     }
58107                 }
58108                 if (minArgumentCount === undefined) {
58109                     if (!strongArityForUntypedJS && signature.flags & 16) {
58110                         return 0;
58111                     }
58112                     minArgumentCount = signature.minArgumentCount;
58113                 }
58114                 if (voidIsNonOptional) {
58115                     return minArgumentCount;
58116                 }
58117                 for (var i = minArgumentCount - 1; i >= 0; i--) {
58118                     var type = getTypeAtPosition(signature, i);
58119                     if (filterType(type, acceptsVoid).flags & 131072) {
58120                         break;
58121                     }
58122                     minArgumentCount = i;
58123                 }
58124                 signature.resolvedMinArgumentCount = minArgumentCount;
58125             }
58126             return signature.resolvedMinArgumentCount;
58127         }
58128         function hasEffectiveRestParameter(signature) {
58129             if (signatureHasRestParameter(signature)) {
58130                 var restType = getTypeOfSymbol(signature.parameters[signature.parameters.length - 1]);
58131                 return !isTupleType(restType) || restType.target.hasRestElement;
58132             }
58133             return false;
58134         }
58135         function getEffectiveRestType(signature) {
58136             if (signatureHasRestParameter(signature)) {
58137                 var restType = getTypeOfSymbol(signature.parameters[signature.parameters.length - 1]);
58138                 if (!isTupleType(restType)) {
58139                     return restType;
58140                 }
58141                 if (restType.target.hasRestElement) {
58142                     return sliceTupleType(restType, restType.target.fixedLength);
58143                 }
58144             }
58145             return undefined;
58146         }
58147         function getNonArrayRestType(signature) {
58148             var restType = getEffectiveRestType(signature);
58149             return restType && !isArrayType(restType) && !isTypeAny(restType) && (getReducedType(restType).flags & 131072) === 0 ? restType : undefined;
58150         }
58151         function getTypeOfFirstParameterOfSignature(signature) {
58152             return getTypeOfFirstParameterOfSignatureWithFallback(signature, neverType);
58153         }
58154         function getTypeOfFirstParameterOfSignatureWithFallback(signature, fallbackType) {
58155             return signature.parameters.length > 0 ? getTypeAtPosition(signature, 0) : fallbackType;
58156         }
58157         function inferFromAnnotatedParameters(signature, context, inferenceContext) {
58158             var len = signature.parameters.length - (signatureHasRestParameter(signature) ? 1 : 0);
58159             for (var i = 0; i < len; i++) {
58160                 var declaration = signature.parameters[i].valueDeclaration;
58161                 if (declaration.type) {
58162                     var typeNode = ts.getEffectiveTypeAnnotationNode(declaration);
58163                     if (typeNode) {
58164                         inferTypes(inferenceContext.inferences, getTypeFromTypeNode(typeNode), getTypeAtPosition(context, i));
58165                     }
58166                 }
58167             }
58168             var restType = getEffectiveRestType(context);
58169             if (restType && restType.flags & 262144) {
58170                 var instantiatedContext = instantiateSignature(context, inferenceContext.nonFixingMapper);
58171                 assignContextualParameterTypes(signature, instantiatedContext);
58172                 var restPos = getParameterCount(context) - 1;
58173                 inferTypes(inferenceContext.inferences, getRestTypeAtPosition(signature, restPos), restType);
58174             }
58175         }
58176         function assignContextualParameterTypes(signature, context) {
58177             signature.typeParameters = context.typeParameters;
58178             if (context.thisParameter) {
58179                 var parameter = signature.thisParameter;
58180                 if (!parameter || parameter.valueDeclaration && !parameter.valueDeclaration.type) {
58181                     if (!parameter) {
58182                         signature.thisParameter = createSymbolWithType(context.thisParameter, undefined);
58183                     }
58184                     assignParameterType(signature.thisParameter, getTypeOfSymbol(context.thisParameter));
58185                 }
58186             }
58187             var len = signature.parameters.length - (signatureHasRestParameter(signature) ? 1 : 0);
58188             for (var i = 0; i < len; i++) {
58189                 var parameter = signature.parameters[i];
58190                 if (!ts.getEffectiveTypeAnnotationNode(parameter.valueDeclaration)) {
58191                     var contextualParameterType = tryGetTypeAtPosition(context, i);
58192                     assignParameterType(parameter, contextualParameterType);
58193                 }
58194             }
58195             if (signatureHasRestParameter(signature)) {
58196                 var parameter = ts.last(signature.parameters);
58197                 if (ts.isTransientSymbol(parameter) || !ts.getEffectiveTypeAnnotationNode(parameter.valueDeclaration)) {
58198                     var contextualParameterType = getRestTypeAtPosition(context, len);
58199                     assignParameterType(parameter, contextualParameterType);
58200                 }
58201             }
58202         }
58203         function assignNonContextualParameterTypes(signature) {
58204             if (signature.thisParameter) {
58205                 assignParameterType(signature.thisParameter);
58206             }
58207             for (var _i = 0, _a = signature.parameters; _i < _a.length; _i++) {
58208                 var parameter = _a[_i];
58209                 assignParameterType(parameter);
58210             }
58211         }
58212         function assignParameterType(parameter, type) {
58213             var links = getSymbolLinks(parameter);
58214             if (!links.type) {
58215                 var declaration = parameter.valueDeclaration;
58216                 links.type = type || getWidenedTypeForVariableLikeDeclaration(declaration, true);
58217                 if (declaration.name.kind !== 78) {
58218                     if (links.type === unknownType) {
58219                         links.type = getTypeFromBindingPattern(declaration.name);
58220                     }
58221                     assignBindingElementTypes(declaration.name);
58222                 }
58223             }
58224         }
58225         function assignBindingElementTypes(pattern) {
58226             for (var _i = 0, _a = pattern.elements; _i < _a.length; _i++) {
58227                 var element = _a[_i];
58228                 if (!ts.isOmittedExpression(element)) {
58229                     if (element.name.kind === 78) {
58230                         getSymbolLinks(getSymbolOfNode(element)).type = getTypeForBindingElement(element);
58231                     }
58232                     else {
58233                         assignBindingElementTypes(element.name);
58234                     }
58235                 }
58236             }
58237         }
58238         function createPromiseType(promisedType) {
58239             var globalPromiseType = getGlobalPromiseType(true);
58240             if (globalPromiseType !== emptyGenericType) {
58241                 promisedType = getAwaitedType(promisedType) || unknownType;
58242                 return createTypeReference(globalPromiseType, [promisedType]);
58243             }
58244             return unknownType;
58245         }
58246         function createPromiseLikeType(promisedType) {
58247             var globalPromiseLikeType = getGlobalPromiseLikeType(true);
58248             if (globalPromiseLikeType !== emptyGenericType) {
58249                 promisedType = getAwaitedType(promisedType) || unknownType;
58250                 return createTypeReference(globalPromiseLikeType, [promisedType]);
58251             }
58252             return unknownType;
58253         }
58254         function createPromiseReturnType(func, promisedType) {
58255             var promiseType = createPromiseType(promisedType);
58256             if (promiseType === unknownType) {
58257                 error(func, ts.isImportCall(func) ?
58258                     ts.Diagnostics.A_dynamic_import_call_returns_a_Promise_Make_sure_you_have_a_declaration_for_Promise_or_include_ES2015_in_your_lib_option :
58259                     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);
58260                 return errorType;
58261             }
58262             else if (!getGlobalPromiseConstructorSymbol(true)) {
58263                 error(func, ts.isImportCall(func) ?
58264                     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 :
58265                     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);
58266             }
58267             return promiseType;
58268         }
58269         function getReturnTypeFromBody(func, checkMode) {
58270             if (!func.body) {
58271                 return errorType;
58272             }
58273             var functionFlags = ts.getFunctionFlags(func);
58274             var isAsync = (functionFlags & 2) !== 0;
58275             var isGenerator = (functionFlags & 1) !== 0;
58276             var returnType;
58277             var yieldType;
58278             var nextType;
58279             var fallbackReturnType = voidType;
58280             if (func.body.kind !== 230) {
58281                 returnType = checkExpressionCached(func.body, checkMode && checkMode & ~8);
58282                 if (isAsync) {
58283                     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);
58284                 }
58285             }
58286             else if (isGenerator) {
58287                 var returnTypes = checkAndAggregateReturnExpressionTypes(func, checkMode);
58288                 if (!returnTypes) {
58289                     fallbackReturnType = neverType;
58290                 }
58291                 else if (returnTypes.length > 0) {
58292                     returnType = getUnionType(returnTypes, 2);
58293                 }
58294                 var _a = checkAndAggregateYieldOperandTypes(func, checkMode), yieldTypes = _a.yieldTypes, nextTypes = _a.nextTypes;
58295                 yieldType = ts.some(yieldTypes) ? getUnionType(yieldTypes, 2) : undefined;
58296                 nextType = ts.some(nextTypes) ? getIntersectionType(nextTypes) : undefined;
58297             }
58298             else {
58299                 var types = checkAndAggregateReturnExpressionTypes(func, checkMode);
58300                 if (!types) {
58301                     return functionFlags & 2
58302                         ? createPromiseReturnType(func, neverType)
58303                         : neverType;
58304                 }
58305                 if (types.length === 0) {
58306                     return functionFlags & 2
58307                         ? createPromiseReturnType(func, voidType)
58308                         : voidType;
58309                 }
58310                 returnType = getUnionType(types, 2);
58311             }
58312             if (returnType || yieldType || nextType) {
58313                 if (yieldType)
58314                     reportErrorsFromWidening(func, yieldType, 3);
58315                 if (returnType)
58316                     reportErrorsFromWidening(func, returnType, 1);
58317                 if (nextType)
58318                     reportErrorsFromWidening(func, nextType, 2);
58319                 if (returnType && isUnitType(returnType) ||
58320                     yieldType && isUnitType(yieldType) ||
58321                     nextType && isUnitType(nextType)) {
58322                     var contextualSignature = getContextualSignatureForFunctionLikeDeclaration(func);
58323                     var contextualType = !contextualSignature ? undefined :
58324                         contextualSignature === getSignatureFromDeclaration(func) ? isGenerator ? undefined : returnType :
58325                             instantiateContextualType(getReturnTypeOfSignature(contextualSignature), func);
58326                     if (isGenerator) {
58327                         yieldType = getWidenedLiteralLikeTypeForContextualIterationTypeIfNeeded(yieldType, contextualType, 0, isAsync);
58328                         returnType = getWidenedLiteralLikeTypeForContextualIterationTypeIfNeeded(returnType, contextualType, 1, isAsync);
58329                         nextType = getWidenedLiteralLikeTypeForContextualIterationTypeIfNeeded(nextType, contextualType, 2, isAsync);
58330                     }
58331                     else {
58332                         returnType = getWidenedLiteralLikeTypeForContextualReturnTypeIfNeeded(returnType, contextualType, isAsync);
58333                     }
58334                 }
58335                 if (yieldType)
58336                     yieldType = getWidenedType(yieldType);
58337                 if (returnType)
58338                     returnType = getWidenedType(returnType);
58339                 if (nextType)
58340                     nextType = getWidenedType(nextType);
58341             }
58342             if (isGenerator) {
58343                 return createGeneratorReturnType(yieldType || neverType, returnType || fallbackReturnType, nextType || getContextualIterationType(2, func) || unknownType, isAsync);
58344             }
58345             else {
58346                 return isAsync
58347                     ? createPromiseType(returnType || fallbackReturnType)
58348                     : returnType || fallbackReturnType;
58349             }
58350         }
58351         function createGeneratorReturnType(yieldType, returnType, nextType, isAsyncGenerator) {
58352             var resolver = isAsyncGenerator ? asyncIterationTypesResolver : syncIterationTypesResolver;
58353             var globalGeneratorType = resolver.getGlobalGeneratorType(false);
58354             yieldType = resolver.resolveIterationType(yieldType, undefined) || unknownType;
58355             returnType = resolver.resolveIterationType(returnType, undefined) || unknownType;
58356             nextType = resolver.resolveIterationType(nextType, undefined) || unknownType;
58357             if (globalGeneratorType === emptyGenericType) {
58358                 var globalType = resolver.getGlobalIterableIteratorType(false);
58359                 var iterationTypes = globalType !== emptyGenericType ? getIterationTypesOfGlobalIterableType(globalType, resolver) : undefined;
58360                 var iterableIteratorReturnType = iterationTypes ? iterationTypes.returnType : anyType;
58361                 var iterableIteratorNextType = iterationTypes ? iterationTypes.nextType : undefinedType;
58362                 if (isTypeAssignableTo(returnType, iterableIteratorReturnType) &&
58363                     isTypeAssignableTo(iterableIteratorNextType, nextType)) {
58364                     if (globalType !== emptyGenericType) {
58365                         return createTypeFromGenericGlobalType(globalType, [yieldType]);
58366                     }
58367                     resolver.getGlobalIterableIteratorType(true);
58368                     return emptyObjectType;
58369                 }
58370                 resolver.getGlobalGeneratorType(true);
58371                 return emptyObjectType;
58372             }
58373             return createTypeFromGenericGlobalType(globalGeneratorType, [yieldType, returnType, nextType]);
58374         }
58375         function checkAndAggregateYieldOperandTypes(func, checkMode) {
58376             var yieldTypes = [];
58377             var nextTypes = [];
58378             var isAsync = (ts.getFunctionFlags(func) & 2) !== 0;
58379             ts.forEachYieldExpression(func.body, function (yieldExpression) {
58380                 var yieldExpressionType = yieldExpression.expression ? checkExpression(yieldExpression.expression, checkMode) : undefinedWideningType;
58381                 ts.pushIfUnique(yieldTypes, getYieldedTypeOfYieldExpression(yieldExpression, yieldExpressionType, anyType, isAsync));
58382                 var nextType;
58383                 if (yieldExpression.asteriskToken) {
58384                     var iterationTypes = getIterationTypesOfIterable(yieldExpressionType, isAsync ? 19 : 17, yieldExpression.expression);
58385                     nextType = iterationTypes && iterationTypes.nextType;
58386                 }
58387                 else {
58388                     nextType = getContextualType(yieldExpression);
58389                 }
58390                 if (nextType)
58391                     ts.pushIfUnique(nextTypes, nextType);
58392             });
58393             return { yieldTypes: yieldTypes, nextTypes: nextTypes };
58394         }
58395         function getYieldedTypeOfYieldExpression(node, expressionType, sentType, isAsync) {
58396             var errorNode = node.expression || node;
58397             var yieldedType = node.asteriskToken ? checkIteratedTypeOrElementType(isAsync ? 19 : 17, expressionType, sentType, errorNode) : expressionType;
58398             return !isAsync ? yieldedType : getAwaitedType(yieldedType, errorNode, node.asteriskToken
58399                 ? 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
58400                 : ts.Diagnostics.Type_of_yield_operand_in_an_async_generator_must_either_be_a_valid_promise_or_must_not_contain_a_callable_then_member);
58401         }
58402         function getFactsFromTypeofSwitch(start, end, witnesses, hasDefault) {
58403             var facts = 0;
58404             if (hasDefault) {
58405                 for (var i = end; i < witnesses.length; i++) {
58406                     facts |= typeofNEFacts.get(witnesses[i]) || 32768;
58407                 }
58408                 for (var i = start; i < end; i++) {
58409                     facts &= ~(typeofNEFacts.get(witnesses[i]) || 0);
58410                 }
58411                 for (var i = 0; i < start; i++) {
58412                     facts |= typeofNEFacts.get(witnesses[i]) || 32768;
58413                 }
58414             }
58415             else {
58416                 for (var i = start; i < end; i++) {
58417                     facts |= typeofEQFacts.get(witnesses[i]) || 128;
58418                 }
58419                 for (var i = 0; i < start; i++) {
58420                     facts &= ~(typeofEQFacts.get(witnesses[i]) || 0);
58421                 }
58422             }
58423             return facts;
58424         }
58425         function isExhaustiveSwitchStatement(node) {
58426             var links = getNodeLinks(node);
58427             return links.isExhaustive !== undefined ? links.isExhaustive : (links.isExhaustive = computeExhaustiveSwitchStatement(node));
58428         }
58429         function computeExhaustiveSwitchStatement(node) {
58430             if (node.expression.kind === 211) {
58431                 var operandType = getTypeOfExpression(node.expression.expression);
58432                 var witnesses = getSwitchClauseTypeOfWitnesses(node, false);
58433                 var notEqualFacts_1 = getFactsFromTypeofSwitch(0, 0, witnesses, true);
58434                 var type_4 = getBaseConstraintOfType(operandType) || operandType;
58435                 if (type_4.flags & 3) {
58436                     return (556800 & notEqualFacts_1) === 556800;
58437                 }
58438                 return !!(filterType(type_4, function (t) { return (getTypeFacts(t) & notEqualFacts_1) === notEqualFacts_1; }).flags & 131072);
58439             }
58440             var type = getTypeOfExpression(node.expression);
58441             if (!isLiteralType(type)) {
58442                 return false;
58443             }
58444             var switchTypes = getSwitchClauseTypes(node);
58445             if (!switchTypes.length || ts.some(switchTypes, isNeitherUnitTypeNorNever)) {
58446                 return false;
58447             }
58448             return eachTypeContainedIn(mapType(type, getRegularTypeOfLiteralType), switchTypes);
58449         }
58450         function functionHasImplicitReturn(func) {
58451             return func.endFlowNode && isReachableFlowNode(func.endFlowNode);
58452         }
58453         function checkAndAggregateReturnExpressionTypes(func, checkMode) {
58454             var functionFlags = ts.getFunctionFlags(func);
58455             var aggregatedTypes = [];
58456             var hasReturnWithNoExpression = functionHasImplicitReturn(func);
58457             var hasReturnOfTypeNever = false;
58458             ts.forEachReturnStatement(func.body, function (returnStatement) {
58459                 var expr = returnStatement.expression;
58460                 if (expr) {
58461                     var type = checkExpressionCached(expr, checkMode && checkMode & ~8);
58462                     if (functionFlags & 2) {
58463                         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);
58464                     }
58465                     if (type.flags & 131072) {
58466                         hasReturnOfTypeNever = true;
58467                     }
58468                     ts.pushIfUnique(aggregatedTypes, type);
58469                 }
58470                 else {
58471                     hasReturnWithNoExpression = true;
58472                 }
58473             });
58474             if (aggregatedTypes.length === 0 && !hasReturnWithNoExpression && (hasReturnOfTypeNever || mayReturnNever(func))) {
58475                 return undefined;
58476             }
58477             if (strictNullChecks && aggregatedTypes.length && hasReturnWithNoExpression &&
58478                 !(isJSConstructor(func) && aggregatedTypes.some(function (t) { return t.symbol === func.symbol; }))) {
58479                 ts.pushIfUnique(aggregatedTypes, undefinedType);
58480             }
58481             return aggregatedTypes;
58482         }
58483         function mayReturnNever(func) {
58484             switch (func.kind) {
58485                 case 208:
58486                 case 209:
58487                     return true;
58488                 case 165:
58489                     return func.parent.kind === 200;
58490                 default:
58491                     return false;
58492             }
58493         }
58494         function checkAllCodePathsInNonVoidFunctionReturnOrThrow(func, returnType) {
58495             if (!produceDiagnostics) {
58496                 return;
58497             }
58498             var functionFlags = ts.getFunctionFlags(func);
58499             var type = returnType && unwrapReturnType(returnType, functionFlags);
58500             if (type && maybeTypeOfKind(type, 1 | 16384)) {
58501                 return;
58502             }
58503             if (func.kind === 164 || ts.nodeIsMissing(func.body) || func.body.kind !== 230 || !functionHasImplicitReturn(func)) {
58504                 return;
58505             }
58506             var hasExplicitReturn = func.flags & 512;
58507             if (type && type.flags & 131072) {
58508                 error(ts.getEffectiveReturnTypeNode(func), ts.Diagnostics.A_function_returning_never_cannot_have_a_reachable_end_point);
58509             }
58510             else if (type && !hasExplicitReturn) {
58511                 error(ts.getEffectiveReturnTypeNode(func), ts.Diagnostics.A_function_whose_declared_type_is_neither_void_nor_any_must_return_a_value);
58512             }
58513             else if (type && strictNullChecks && !isTypeAssignableTo(undefinedType, type)) {
58514                 error(ts.getEffectiveReturnTypeNode(func) || func, ts.Diagnostics.Function_lacks_ending_return_statement_and_return_type_does_not_include_undefined);
58515             }
58516             else if (compilerOptions.noImplicitReturns) {
58517                 if (!type) {
58518                     if (!hasExplicitReturn) {
58519                         return;
58520                     }
58521                     var inferredReturnType = getReturnTypeOfSignature(getSignatureFromDeclaration(func));
58522                     if (isUnwrappedReturnTypeVoidOrAny(func, inferredReturnType)) {
58523                         return;
58524                     }
58525                 }
58526                 error(ts.getEffectiveReturnTypeNode(func) || func, ts.Diagnostics.Not_all_code_paths_return_a_value);
58527             }
58528         }
58529         function checkFunctionExpressionOrObjectLiteralMethod(node, checkMode) {
58530             ts.Debug.assert(node.kind !== 165 || ts.isObjectLiteralMethod(node));
58531             checkNodeDeferred(node);
58532             if (checkMode && checkMode & 4 && isContextSensitive(node)) {
58533                 if (!ts.getEffectiveReturnTypeNode(node) && !hasContextSensitiveParameters(node)) {
58534                     var contextualSignature = getContextualSignature(node);
58535                     if (contextualSignature && couldContainTypeVariables(getReturnTypeOfSignature(contextualSignature))) {
58536                         var links = getNodeLinks(node);
58537                         if (links.contextFreeType) {
58538                             return links.contextFreeType;
58539                         }
58540                         var returnType = getReturnTypeFromBody(node, checkMode);
58541                         var returnOnlySignature = createSignature(undefined, undefined, undefined, ts.emptyArray, returnType, undefined, 0, 0);
58542                         var returnOnlyType = createAnonymousType(node.symbol, emptySymbols, [returnOnlySignature], ts.emptyArray, undefined, undefined);
58543                         returnOnlyType.objectFlags |= 2097152;
58544                         return links.contextFreeType = returnOnlyType;
58545                     }
58546                 }
58547                 return anyFunctionType;
58548             }
58549             var hasGrammarError = checkGrammarFunctionLikeDeclaration(node);
58550             if (!hasGrammarError && node.kind === 208) {
58551                 checkGrammarForGenerator(node);
58552             }
58553             contextuallyCheckFunctionExpressionOrObjectLiteralMethod(node, checkMode);
58554             return getTypeOfSymbol(getSymbolOfNode(node));
58555         }
58556         function contextuallyCheckFunctionExpressionOrObjectLiteralMethod(node, checkMode) {
58557             var links = getNodeLinks(node);
58558             if (!(links.flags & 1024)) {
58559                 var contextualSignature = getContextualSignature(node);
58560                 if (!(links.flags & 1024)) {
58561                     links.flags |= 1024;
58562                     var signature = ts.firstOrUndefined(getSignaturesOfType(getTypeOfSymbol(getSymbolOfNode(node)), 0));
58563                     if (!signature) {
58564                         return;
58565                     }
58566                     if (isContextSensitive(node)) {
58567                         if (contextualSignature) {
58568                             var inferenceContext = getInferenceContext(node);
58569                             if (checkMode && checkMode & 2) {
58570                                 inferFromAnnotatedParameters(signature, contextualSignature, inferenceContext);
58571                             }
58572                             var instantiatedContextualSignature = inferenceContext ?
58573                                 instantiateSignature(contextualSignature, inferenceContext.mapper) : contextualSignature;
58574                             assignContextualParameterTypes(signature, instantiatedContextualSignature);
58575                         }
58576                         else {
58577                             assignNonContextualParameterTypes(signature);
58578                         }
58579                     }
58580                     if (contextualSignature && !getReturnTypeFromAnnotation(node) && !signature.resolvedReturnType) {
58581                         var returnType = getReturnTypeFromBody(node, checkMode);
58582                         if (!signature.resolvedReturnType) {
58583                             signature.resolvedReturnType = returnType;
58584                         }
58585                     }
58586                     checkSignatureDeclaration(node);
58587                 }
58588             }
58589         }
58590         function checkFunctionExpressionOrObjectLiteralMethodDeferred(node) {
58591             ts.Debug.assert(node.kind !== 165 || ts.isObjectLiteralMethod(node));
58592             var functionFlags = ts.getFunctionFlags(node);
58593             var returnType = getReturnTypeFromAnnotation(node);
58594             checkAllCodePathsInNonVoidFunctionReturnOrThrow(node, returnType);
58595             if (node.body) {
58596                 if (!ts.getEffectiveReturnTypeNode(node)) {
58597                     getReturnTypeOfSignature(getSignatureFromDeclaration(node));
58598                 }
58599                 if (node.body.kind === 230) {
58600                     checkSourceElement(node.body);
58601                 }
58602                 else {
58603                     var exprType = checkExpression(node.body);
58604                     var returnOrPromisedType = returnType && unwrapReturnType(returnType, functionFlags);
58605                     if (returnOrPromisedType) {
58606                         if ((functionFlags & 3) === 2) {
58607                             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);
58608                             checkTypeAssignableToAndOptionallyElaborate(awaitedType, returnOrPromisedType, node.body, node.body);
58609                         }
58610                         else {
58611                             checkTypeAssignableToAndOptionallyElaborate(exprType, returnOrPromisedType, node.body, node.body);
58612                         }
58613                     }
58614                 }
58615             }
58616         }
58617         function checkArithmeticOperandType(operand, type, diagnostic, isAwaitValid) {
58618             if (isAwaitValid === void 0) { isAwaitValid = false; }
58619             if (!isTypeAssignableTo(type, numberOrBigIntType)) {
58620                 var awaitedType = isAwaitValid && getAwaitedTypeOfPromise(type);
58621                 errorAndMaybeSuggestAwait(operand, !!awaitedType && isTypeAssignableTo(awaitedType, numberOrBigIntType), diagnostic);
58622                 return false;
58623             }
58624             return true;
58625         }
58626         function isReadonlyAssignmentDeclaration(d) {
58627             if (!ts.isCallExpression(d)) {
58628                 return false;
58629             }
58630             if (!ts.isBindableObjectDefinePropertyCall(d)) {
58631                 return false;
58632             }
58633             var objectLitType = checkExpressionCached(d.arguments[2]);
58634             var valueType = getTypeOfPropertyOfType(objectLitType, "value");
58635             if (valueType) {
58636                 var writableProp = getPropertyOfType(objectLitType, "writable");
58637                 var writableType = writableProp && getTypeOfSymbol(writableProp);
58638                 if (!writableType || writableType === falseType || writableType === regularFalseType) {
58639                     return true;
58640                 }
58641                 if (writableProp && writableProp.valueDeclaration && ts.isPropertyAssignment(writableProp.valueDeclaration)) {
58642                     var initializer = writableProp.valueDeclaration.initializer;
58643                     var rawOriginalType = checkExpression(initializer);
58644                     if (rawOriginalType === falseType || rawOriginalType === regularFalseType) {
58645                         return true;
58646                     }
58647                 }
58648                 return false;
58649             }
58650             var setProp = getPropertyOfType(objectLitType, "set");
58651             return !setProp;
58652         }
58653         function isReadonlySymbol(symbol) {
58654             return !!(ts.getCheckFlags(symbol) & 8 ||
58655                 symbol.flags & 4 && ts.getDeclarationModifierFlagsFromSymbol(symbol) & 64 ||
58656                 symbol.flags & 3 && getDeclarationNodeFlagsFromSymbol(symbol) & 2 ||
58657                 symbol.flags & 98304 && !(symbol.flags & 65536) ||
58658                 symbol.flags & 8 ||
58659                 ts.some(symbol.declarations, isReadonlyAssignmentDeclaration));
58660         }
58661         function isAssignmentToReadonlyEntity(expr, symbol, assignmentKind) {
58662             var _a, _b;
58663             if (assignmentKind === 0) {
58664                 return false;
58665             }
58666             if (isReadonlySymbol(symbol)) {
58667                 if (symbol.flags & 4 &&
58668                     ts.isAccessExpression(expr) &&
58669                     expr.expression.kind === 107) {
58670                     var ctor = ts.getContainingFunction(expr);
58671                     if (!(ctor && (ctor.kind === 166 || isJSConstructor(ctor)))) {
58672                         return true;
58673                     }
58674                     if (symbol.valueDeclaration) {
58675                         var isAssignmentDeclaration_1 = ts.isBinaryExpression(symbol.valueDeclaration);
58676                         var isLocalPropertyDeclaration = ctor.parent === symbol.valueDeclaration.parent;
58677                         var isLocalParameterProperty = ctor === symbol.valueDeclaration.parent;
58678                         var isLocalThisPropertyAssignment = isAssignmentDeclaration_1 && ((_a = symbol.parent) === null || _a === void 0 ? void 0 : _a.valueDeclaration) === ctor.parent;
58679                         var isLocalThisPropertyAssignmentConstructorFunction = isAssignmentDeclaration_1 && ((_b = symbol.parent) === null || _b === void 0 ? void 0 : _b.valueDeclaration) === ctor;
58680                         var isWriteableSymbol = isLocalPropertyDeclaration
58681                             || isLocalParameterProperty
58682                             || isLocalThisPropertyAssignment
58683                             || isLocalThisPropertyAssignmentConstructorFunction;
58684                         return !isWriteableSymbol;
58685                     }
58686                 }
58687                 return true;
58688             }
58689             if (ts.isAccessExpression(expr)) {
58690                 var node = ts.skipParentheses(expr.expression);
58691                 if (node.kind === 78) {
58692                     var symbol_2 = getNodeLinks(node).resolvedSymbol;
58693                     if (symbol_2.flags & 2097152) {
58694                         var declaration = getDeclarationOfAliasSymbol(symbol_2);
58695                         return !!declaration && declaration.kind === 263;
58696                     }
58697                 }
58698             }
58699             return false;
58700         }
58701         function checkReferenceExpression(expr, invalidReferenceMessage, invalidOptionalChainMessage) {
58702             var node = ts.skipOuterExpressions(expr, 6 | 1);
58703             if (node.kind !== 78 && !ts.isAccessExpression(node)) {
58704                 error(expr, invalidReferenceMessage);
58705                 return false;
58706             }
58707             if (node.flags & 32) {
58708                 error(expr, invalidOptionalChainMessage);
58709                 return false;
58710             }
58711             return true;
58712         }
58713         function checkDeleteExpression(node) {
58714             checkExpression(node.expression);
58715             var expr = ts.skipParentheses(node.expression);
58716             if (!ts.isAccessExpression(expr)) {
58717                 error(expr, ts.Diagnostics.The_operand_of_a_delete_operator_must_be_a_property_reference);
58718                 return booleanType;
58719             }
58720             if (ts.isPropertyAccessExpression(expr) && ts.isPrivateIdentifier(expr.name)) {
58721                 error(expr, ts.Diagnostics.The_operand_of_a_delete_operator_cannot_be_a_private_identifier);
58722             }
58723             var links = getNodeLinks(expr);
58724             var symbol = getExportSymbolOfValueSymbolIfExported(links.resolvedSymbol);
58725             if (symbol) {
58726                 if (isReadonlySymbol(symbol)) {
58727                     error(expr, ts.Diagnostics.The_operand_of_a_delete_operator_cannot_be_a_read_only_property);
58728                 }
58729                 checkDeleteExpressionMustBeOptional(expr, getTypeOfSymbol(symbol));
58730             }
58731             return booleanType;
58732         }
58733         function checkDeleteExpressionMustBeOptional(expr, type) {
58734             var AnyOrUnknownOrNeverFlags = 3 | 131072;
58735             if (strictNullChecks && !(type.flags & AnyOrUnknownOrNeverFlags) && !(getFalsyFlags(type) & 32768)) {
58736                 error(expr, ts.Diagnostics.The_operand_of_a_delete_operator_must_be_optional);
58737             }
58738         }
58739         function checkTypeOfExpression(node) {
58740             checkExpression(node.expression);
58741             return typeofType;
58742         }
58743         function checkVoidExpression(node) {
58744             checkExpression(node.expression);
58745             return undefinedWideningType;
58746         }
58747         function checkAwaitExpression(node) {
58748             if (produceDiagnostics) {
58749                 if (!(node.flags & 32768)) {
58750                     if (ts.isInTopLevelContext(node)) {
58751                         var sourceFile = ts.getSourceFileOfNode(node);
58752                         if (!hasParseDiagnostics(sourceFile)) {
58753                             var span = void 0;
58754                             if (!ts.isEffectiveExternalModule(sourceFile, compilerOptions)) {
58755                                 if (!span)
58756                                     span = ts.getSpanOfTokenAtPosition(sourceFile, node.pos);
58757                                 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);
58758                                 diagnostics.add(diagnostic);
58759                             }
58760                             if ((moduleKind !== ts.ModuleKind.ESNext && moduleKind !== ts.ModuleKind.System) || languageVersion < 4) {
58761                                 span = ts.getSpanOfTokenAtPosition(sourceFile, node.pos);
58762                                 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);
58763                                 diagnostics.add(diagnostic);
58764                             }
58765                         }
58766                     }
58767                     else {
58768                         var sourceFile = ts.getSourceFileOfNode(node);
58769                         if (!hasParseDiagnostics(sourceFile)) {
58770                             var span = ts.getSpanOfTokenAtPosition(sourceFile, node.pos);
58771                             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);
58772                             var func = ts.getContainingFunction(node);
58773                             if (func && func.kind !== 166 && (ts.getFunctionFlags(func) & 2) === 0) {
58774                                 var relatedInfo = ts.createDiagnosticForNode(func, ts.Diagnostics.Did_you_mean_to_mark_this_function_as_async);
58775                                 ts.addRelatedInfo(diagnostic, relatedInfo);
58776                             }
58777                             diagnostics.add(diagnostic);
58778                         }
58779                     }
58780                 }
58781                 if (isInParameterInitializerBeforeContainingFunction(node)) {
58782                     error(node, ts.Diagnostics.await_expressions_cannot_be_used_in_a_parameter_initializer);
58783                 }
58784             }
58785             var operandType = checkExpression(node.expression);
58786             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);
58787             if (awaitedType === operandType && awaitedType !== errorType && !(operandType.flags & 3)) {
58788                 addErrorOrSuggestion(false, ts.createDiagnosticForNode(node, ts.Diagnostics.await_has_no_effect_on_the_type_of_this_expression));
58789             }
58790             return awaitedType;
58791         }
58792         function checkPrefixUnaryExpression(node) {
58793             var operandType = checkExpression(node.operand);
58794             if (operandType === silentNeverType) {
58795                 return silentNeverType;
58796             }
58797             switch (node.operand.kind) {
58798                 case 8:
58799                     switch (node.operator) {
58800                         case 40:
58801                             return getFreshTypeOfLiteralType(getLiteralType(-node.operand.text));
58802                         case 39:
58803                             return getFreshTypeOfLiteralType(getLiteralType(+node.operand.text));
58804                     }
58805                     break;
58806                 case 9:
58807                     if (node.operator === 40) {
58808                         return getFreshTypeOfLiteralType(getLiteralType({
58809                             negative: true,
58810                             base10Value: ts.parsePseudoBigInt(node.operand.text)
58811                         }));
58812                     }
58813             }
58814             switch (node.operator) {
58815                 case 39:
58816                 case 40:
58817                 case 54:
58818                     checkNonNullType(operandType, node.operand);
58819                     if (maybeTypeOfKind(operandType, 12288)) {
58820                         error(node.operand, ts.Diagnostics.The_0_operator_cannot_be_applied_to_type_symbol, ts.tokenToString(node.operator));
58821                     }
58822                     if (node.operator === 39) {
58823                         if (maybeTypeOfKind(operandType, 2112)) {
58824                             error(node.operand, ts.Diagnostics.Operator_0_cannot_be_applied_to_type_1, ts.tokenToString(node.operator), typeToString(getBaseTypeOfLiteralType(operandType)));
58825                         }
58826                         return numberType;
58827                     }
58828                     return getUnaryResultType(operandType);
58829                 case 53:
58830                     checkTruthinessExpression(node.operand);
58831                     var facts = getTypeFacts(operandType) & (4194304 | 8388608);
58832                     return facts === 4194304 ? falseType :
58833                         facts === 8388608 ? trueType :
58834                             booleanType;
58835                 case 45:
58836                 case 46:
58837                     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);
58838                     if (ok) {
58839                         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);
58840                     }
58841                     return getUnaryResultType(operandType);
58842             }
58843             return errorType;
58844         }
58845         function checkPostfixUnaryExpression(node) {
58846             var operandType = checkExpression(node.operand);
58847             if (operandType === silentNeverType) {
58848                 return silentNeverType;
58849             }
58850             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);
58851             if (ok) {
58852                 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);
58853             }
58854             return getUnaryResultType(operandType);
58855         }
58856         function getUnaryResultType(operandType) {
58857             if (maybeTypeOfKind(operandType, 2112)) {
58858                 return isTypeAssignableToKind(operandType, 3) || maybeTypeOfKind(operandType, 296)
58859                     ? numberOrBigIntType
58860                     : bigintType;
58861             }
58862             return numberType;
58863         }
58864         function maybeTypeOfKind(type, kind) {
58865             if (type.flags & kind) {
58866                 return true;
58867             }
58868             if (type.flags & 3145728) {
58869                 var types = type.types;
58870                 for (var _i = 0, types_20 = types; _i < types_20.length; _i++) {
58871                     var t = types_20[_i];
58872                     if (maybeTypeOfKind(t, kind)) {
58873                         return true;
58874                     }
58875                 }
58876             }
58877             return false;
58878         }
58879         function isTypeAssignableToKind(source, kind, strict) {
58880             if (source.flags & kind) {
58881                 return true;
58882             }
58883             if (strict && source.flags & (3 | 16384 | 32768 | 65536)) {
58884                 return false;
58885             }
58886             return !!(kind & 296) && isTypeAssignableTo(source, numberType) ||
58887                 !!(kind & 2112) && isTypeAssignableTo(source, bigintType) ||
58888                 !!(kind & 402653316) && isTypeAssignableTo(source, stringType) ||
58889                 !!(kind & 528) && isTypeAssignableTo(source, booleanType) ||
58890                 !!(kind & 16384) && isTypeAssignableTo(source, voidType) ||
58891                 !!(kind & 131072) && isTypeAssignableTo(source, neverType) ||
58892                 !!(kind & 65536) && isTypeAssignableTo(source, nullType) ||
58893                 !!(kind & 32768) && isTypeAssignableTo(source, undefinedType) ||
58894                 !!(kind & 4096) && isTypeAssignableTo(source, esSymbolType) ||
58895                 !!(kind & 67108864) && isTypeAssignableTo(source, nonPrimitiveType);
58896         }
58897         function allTypesAssignableToKind(source, kind, strict) {
58898             return source.flags & 1048576 ?
58899                 ts.every(source.types, function (subType) { return allTypesAssignableToKind(subType, kind, strict); }) :
58900                 isTypeAssignableToKind(source, kind, strict);
58901         }
58902         function isConstEnumObjectType(type) {
58903             return !!(ts.getObjectFlags(type) & 16) && !!type.symbol && isConstEnumSymbol(type.symbol);
58904         }
58905         function isConstEnumSymbol(symbol) {
58906             return (symbol.flags & 128) !== 0;
58907         }
58908         function checkInstanceOfExpression(left, right, leftType, rightType) {
58909             if (leftType === silentNeverType || rightType === silentNeverType) {
58910                 return silentNeverType;
58911             }
58912             if (!isTypeAny(leftType) &&
58913                 allTypesAssignableToKind(leftType, 131068)) {
58914                 error(left, ts.Diagnostics.The_left_hand_side_of_an_instanceof_expression_must_be_of_type_any_an_object_type_or_a_type_parameter);
58915             }
58916             if (!(isTypeAny(rightType) || typeHasCallOrConstructSignatures(rightType) || isTypeSubtypeOf(rightType, globalFunctionType))) {
58917                 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);
58918             }
58919             return booleanType;
58920         }
58921         function checkInExpression(left, right, leftType, rightType) {
58922             if (leftType === silentNeverType || rightType === silentNeverType) {
58923                 return silentNeverType;
58924             }
58925             leftType = checkNonNullType(leftType, left);
58926             rightType = checkNonNullType(rightType, right);
58927             if (!(allTypesAssignableToKind(leftType, 402653316 | 296 | 12288) ||
58928                 isTypeAssignableToKind(leftType, 4194304 | 134217728 | 268435456 | 262144))) {
58929                 error(left, ts.Diagnostics.The_left_hand_side_of_an_in_expression_must_be_of_type_any_string_number_or_symbol);
58930             }
58931             if (!allTypesAssignableToKind(rightType, 67108864 | 58982400)) {
58932                 error(right, ts.Diagnostics.The_right_hand_side_of_an_in_expression_must_be_of_type_any_an_object_type_or_a_type_parameter);
58933             }
58934             return booleanType;
58935         }
58936         function checkObjectLiteralAssignment(node, sourceType, rightIsThis) {
58937             var properties = node.properties;
58938             if (strictNullChecks && properties.length === 0) {
58939                 return checkNonNullType(sourceType, node);
58940             }
58941             for (var i = 0; i < properties.length; i++) {
58942                 checkObjectLiteralDestructuringPropertyAssignment(node, sourceType, i, properties, rightIsThis);
58943             }
58944             return sourceType;
58945         }
58946         function checkObjectLiteralDestructuringPropertyAssignment(node, objectLiteralType, propertyIndex, allProperties, rightIsThis) {
58947             if (rightIsThis === void 0) { rightIsThis = false; }
58948             var properties = node.properties;
58949             var property = properties[propertyIndex];
58950             if (property.kind === 288 || property.kind === 289) {
58951                 var name = property.name;
58952                 var exprType = getLiteralTypeFromPropertyName(name);
58953                 if (isTypeUsableAsPropertyName(exprType)) {
58954                     var text = getPropertyNameFromType(exprType);
58955                     var prop = getPropertyOfType(objectLiteralType, text);
58956                     if (prop) {
58957                         markPropertyAsReferenced(prop, property, rightIsThis);
58958                         checkPropertyAccessibility(property, false, objectLiteralType, prop);
58959                     }
58960                 }
58961                 var elementType = getIndexedAccessType(objectLiteralType, exprType, undefined, name, undefined, undefined, 16);
58962                 var type = getFlowTypeOfDestructuring(property, elementType);
58963                 return checkDestructuringAssignment(property.kind === 289 ? property : property.initializer, type);
58964             }
58965             else if (property.kind === 290) {
58966                 if (propertyIndex < properties.length - 1) {
58967                     error(property, ts.Diagnostics.A_rest_element_must_be_last_in_a_destructuring_pattern);
58968                 }
58969                 else {
58970                     if (languageVersion < 99) {
58971                         checkExternalEmitHelpers(property, 4);
58972                     }
58973                     var nonRestNames = [];
58974                     if (allProperties) {
58975                         for (var _i = 0, allProperties_1 = allProperties; _i < allProperties_1.length; _i++) {
58976                             var otherProperty = allProperties_1[_i];
58977                             if (!ts.isSpreadAssignment(otherProperty)) {
58978                                 nonRestNames.push(otherProperty.name);
58979                             }
58980                         }
58981                     }
58982                     var type = getRestType(objectLiteralType, nonRestNames, objectLiteralType.symbol);
58983                     checkGrammarForDisallowedTrailingComma(allProperties, ts.Diagnostics.A_rest_parameter_or_binding_pattern_may_not_have_a_trailing_comma);
58984                     return checkDestructuringAssignment(property.expression, type);
58985                 }
58986             }
58987             else {
58988                 error(property, ts.Diagnostics.Property_assignment_expected);
58989             }
58990         }
58991         function checkArrayLiteralAssignment(node, sourceType, checkMode) {
58992             var elements = node.elements;
58993             if (languageVersion < 2 && compilerOptions.downlevelIteration) {
58994                 checkExternalEmitHelpers(node, 512);
58995             }
58996             var possiblyOutOfBoundsType = checkIteratedTypeOrElementType(65 | 128, sourceType, undefinedType, node) || errorType;
58997             var inBoundsType = compilerOptions.noUncheckedIndexedAccess ? undefined : possiblyOutOfBoundsType;
58998             for (var i = 0; i < elements.length; i++) {
58999                 var type = possiblyOutOfBoundsType;
59000                 if (node.elements[i].kind === 220) {
59001                     type = inBoundsType = inBoundsType !== null && inBoundsType !== void 0 ? inBoundsType : (checkIteratedTypeOrElementType(65, sourceType, undefinedType, node) || errorType);
59002                 }
59003                 checkArrayLiteralDestructuringElementAssignment(node, sourceType, i, type, checkMode);
59004             }
59005             return sourceType;
59006         }
59007         function checkArrayLiteralDestructuringElementAssignment(node, sourceType, elementIndex, elementType, checkMode) {
59008             var elements = node.elements;
59009             var element = elements[elementIndex];
59010             if (element.kind !== 222) {
59011                 if (element.kind !== 220) {
59012                     var indexType = getLiteralType(elementIndex);
59013                     if (isArrayLikeType(sourceType)) {
59014                         var accessFlags = 16 | (hasDefaultValue(element) ? 8 : 0);
59015                         var elementType_2 = getIndexedAccessTypeOrUndefined(sourceType, indexType, undefined, createSyntheticExpression(element, indexType), accessFlags) || errorType;
59016                         var assignedType = hasDefaultValue(element) ? getTypeWithFacts(elementType_2, 524288) : elementType_2;
59017                         var type = getFlowTypeOfDestructuring(element, assignedType);
59018                         return checkDestructuringAssignment(element, type, checkMode);
59019                     }
59020                     return checkDestructuringAssignment(element, elementType, checkMode);
59021                 }
59022                 if (elementIndex < elements.length - 1) {
59023                     error(element, ts.Diagnostics.A_rest_element_must_be_last_in_a_destructuring_pattern);
59024                 }
59025                 else {
59026                     var restExpression = element.expression;
59027                     if (restExpression.kind === 216 && restExpression.operatorToken.kind === 62) {
59028                         error(restExpression.operatorToken, ts.Diagnostics.A_rest_element_cannot_have_an_initializer);
59029                     }
59030                     else {
59031                         checkGrammarForDisallowedTrailingComma(node.elements, ts.Diagnostics.A_rest_parameter_or_binding_pattern_may_not_have_a_trailing_comma);
59032                         var type = everyType(sourceType, isTupleType) ?
59033                             mapType(sourceType, function (t) { return sliceTupleType(t, elementIndex); }) :
59034                             createArrayType(elementType);
59035                         return checkDestructuringAssignment(restExpression, type, checkMode);
59036                     }
59037                 }
59038             }
59039             return undefined;
59040         }
59041         function checkDestructuringAssignment(exprOrAssignment, sourceType, checkMode, rightIsThis) {
59042             var target;
59043             if (exprOrAssignment.kind === 289) {
59044                 var prop = exprOrAssignment;
59045                 if (prop.objectAssignmentInitializer) {
59046                     if (strictNullChecks &&
59047                         !(getFalsyFlags(checkExpression(prop.objectAssignmentInitializer)) & 32768)) {
59048                         sourceType = getTypeWithFacts(sourceType, 524288);
59049                     }
59050                     checkBinaryLikeExpression(prop.name, prop.equalsToken, prop.objectAssignmentInitializer, checkMode);
59051                 }
59052                 target = exprOrAssignment.name;
59053             }
59054             else {
59055                 target = exprOrAssignment;
59056             }
59057             if (target.kind === 216 && target.operatorToken.kind === 62) {
59058                 checkBinaryExpression(target, checkMode);
59059                 target = target.left;
59060             }
59061             if (target.kind === 200) {
59062                 return checkObjectLiteralAssignment(target, sourceType, rightIsThis);
59063             }
59064             if (target.kind === 199) {
59065                 return checkArrayLiteralAssignment(target, sourceType, checkMode);
59066             }
59067             return checkReferenceAssignment(target, sourceType, checkMode);
59068         }
59069         function checkReferenceAssignment(target, sourceType, checkMode) {
59070             var targetType = checkExpression(target, checkMode);
59071             var error = target.parent.kind === 290 ?
59072                 ts.Diagnostics.The_target_of_an_object_rest_assignment_must_be_a_variable_or_a_property_access :
59073                 ts.Diagnostics.The_left_hand_side_of_an_assignment_expression_must_be_a_variable_or_a_property_access;
59074             var optionalError = target.parent.kind === 290 ?
59075                 ts.Diagnostics.The_target_of_an_object_rest_assignment_may_not_be_an_optional_property_access :
59076                 ts.Diagnostics.The_left_hand_side_of_an_assignment_expression_may_not_be_an_optional_property_access;
59077             if (checkReferenceExpression(target, error, optionalError)) {
59078                 checkTypeAssignableToAndOptionallyElaborate(sourceType, targetType, target, target);
59079             }
59080             if (ts.isPrivateIdentifierPropertyAccessExpression(target)) {
59081                 checkExternalEmitHelpers(target.parent, 2097152);
59082             }
59083             return sourceType;
59084         }
59085         function isSideEffectFree(node) {
59086             node = ts.skipParentheses(node);
59087             switch (node.kind) {
59088                 case 78:
59089                 case 10:
59090                 case 13:
59091                 case 205:
59092                 case 218:
59093                 case 14:
59094                 case 8:
59095                 case 9:
59096                 case 109:
59097                 case 94:
59098                 case 103:
59099                 case 150:
59100                 case 208:
59101                 case 221:
59102                 case 209:
59103                 case 199:
59104                 case 200:
59105                 case 211:
59106                 case 225:
59107                 case 274:
59108                 case 273:
59109                     return true;
59110                 case 217:
59111                     return isSideEffectFree(node.whenTrue) &&
59112                         isSideEffectFree(node.whenFalse);
59113                 case 216:
59114                     if (ts.isAssignmentOperator(node.operatorToken.kind)) {
59115                         return false;
59116                     }
59117                     return isSideEffectFree(node.left) &&
59118                         isSideEffectFree(node.right);
59119                 case 214:
59120                 case 215:
59121                     switch (node.operator) {
59122                         case 53:
59123                         case 39:
59124                         case 40:
59125                         case 54:
59126                             return true;
59127                     }
59128                     return false;
59129                 case 212:
59130                 case 206:
59131                 case 224:
59132                 default:
59133                     return false;
59134             }
59135         }
59136         function isTypeEqualityComparableTo(source, target) {
59137             return (target.flags & 98304) !== 0 || isTypeComparableTo(source, target);
59138         }
59139         function checkBinaryExpression(node, checkMode) {
59140             var workStacks = {
59141                 expr: [node],
59142                 state: [0],
59143                 leftType: [undefined]
59144             };
59145             var stackIndex = 0;
59146             var lastResult;
59147             while (stackIndex >= 0) {
59148                 node = workStacks.expr[stackIndex];
59149                 switch (workStacks.state[stackIndex]) {
59150                     case 0: {
59151                         if (ts.isInJSFile(node) && ts.getAssignedExpandoInitializer(node)) {
59152                             finishInvocation(checkExpression(node.right, checkMode));
59153                             break;
59154                         }
59155                         checkGrammarNullishCoalesceWithLogicalExpression(node);
59156                         var operator = node.operatorToken.kind;
59157                         if (operator === 62 && (node.left.kind === 200 || node.left.kind === 199)) {
59158                             finishInvocation(checkDestructuringAssignment(node.left, checkExpression(node.right, checkMode), checkMode, node.right.kind === 107));
59159                             break;
59160                         }
59161                         advanceState(1);
59162                         maybeCheckExpression(node.left);
59163                         break;
59164                     }
59165                     case 1: {
59166                         var leftType = lastResult;
59167                         workStacks.leftType[stackIndex] = leftType;
59168                         var operator = node.operatorToken.kind;
59169                         if (operator === 55 || operator === 56 || operator === 60) {
59170                             checkTruthinessOfType(leftType, node.left);
59171                         }
59172                         advanceState(2);
59173                         maybeCheckExpression(node.right);
59174                         break;
59175                     }
59176                     case 2: {
59177                         var leftType = workStacks.leftType[stackIndex];
59178                         var rightType = lastResult;
59179                         finishInvocation(checkBinaryLikeExpressionWorker(node.left, node.operatorToken, node.right, leftType, rightType, node));
59180                         break;
59181                     }
59182                     default: return ts.Debug.fail("Invalid state " + workStacks.state[stackIndex] + " for checkBinaryExpression");
59183                 }
59184             }
59185             return lastResult;
59186             function finishInvocation(result) {
59187                 lastResult = result;
59188                 stackIndex--;
59189             }
59190             function advanceState(nextState) {
59191                 workStacks.state[stackIndex] = nextState;
59192             }
59193             function maybeCheckExpression(node) {
59194                 if (ts.isBinaryExpression(node)) {
59195                     stackIndex++;
59196                     workStacks.expr[stackIndex] = node;
59197                     workStacks.state[stackIndex] = 0;
59198                     workStacks.leftType[stackIndex] = undefined;
59199                 }
59200                 else {
59201                     lastResult = checkExpression(node, checkMode);
59202                 }
59203             }
59204         }
59205         function checkGrammarNullishCoalesceWithLogicalExpression(node) {
59206             var left = node.left, operatorToken = node.operatorToken, right = node.right;
59207             if (operatorToken.kind === 60) {
59208                 if (ts.isBinaryExpression(left) && (left.operatorToken.kind === 56 || left.operatorToken.kind === 55)) {
59209                     grammarErrorOnNode(left, ts.Diagnostics._0_and_1_operations_cannot_be_mixed_without_parentheses, ts.tokenToString(left.operatorToken.kind), ts.tokenToString(operatorToken.kind));
59210                 }
59211                 if (ts.isBinaryExpression(right) && (right.operatorToken.kind === 56 || right.operatorToken.kind === 55)) {
59212                     grammarErrorOnNode(right, ts.Diagnostics._0_and_1_operations_cannot_be_mixed_without_parentheses, ts.tokenToString(right.operatorToken.kind), ts.tokenToString(operatorToken.kind));
59213                 }
59214             }
59215         }
59216         function checkBinaryLikeExpression(left, operatorToken, right, checkMode, errorNode) {
59217             var operator = operatorToken.kind;
59218             if (operator === 62 && (left.kind === 200 || left.kind === 199)) {
59219                 return checkDestructuringAssignment(left, checkExpression(right, checkMode), checkMode, right.kind === 107);
59220             }
59221             var leftType;
59222             if (operator === 55 || operator === 56 || operator === 60) {
59223                 leftType = checkTruthinessExpression(left, checkMode);
59224             }
59225             else {
59226                 leftType = checkExpression(left, checkMode);
59227             }
59228             var rightType = checkExpression(right, checkMode);
59229             return checkBinaryLikeExpressionWorker(left, operatorToken, right, leftType, rightType, errorNode);
59230         }
59231         function checkBinaryLikeExpressionWorker(left, operatorToken, right, leftType, rightType, errorNode) {
59232             var operator = operatorToken.kind;
59233             switch (operator) {
59234                 case 41:
59235                 case 42:
59236                 case 65:
59237                 case 66:
59238                 case 43:
59239                 case 67:
59240                 case 44:
59241                 case 68:
59242                 case 40:
59243                 case 64:
59244                 case 47:
59245                 case 69:
59246                 case 48:
59247                 case 70:
59248                 case 49:
59249                 case 71:
59250                 case 51:
59251                 case 73:
59252                 case 52:
59253                 case 77:
59254                 case 50:
59255                 case 72:
59256                     if (leftType === silentNeverType || rightType === silentNeverType) {
59257                         return silentNeverType;
59258                     }
59259                     leftType = checkNonNullType(leftType, left);
59260                     rightType = checkNonNullType(rightType, right);
59261                     var suggestedOperator = void 0;
59262                     if ((leftType.flags & 528) &&
59263                         (rightType.flags & 528) &&
59264                         (suggestedOperator = getSuggestedBooleanOperator(operatorToken.kind)) !== undefined) {
59265                         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));
59266                         return numberType;
59267                     }
59268                     else {
59269                         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);
59270                         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);
59271                         var resultType_1;
59272                         if ((isTypeAssignableToKind(leftType, 3) && isTypeAssignableToKind(rightType, 3)) ||
59273                             !(maybeTypeOfKind(leftType, 2112) || maybeTypeOfKind(rightType, 2112))) {
59274                             resultType_1 = numberType;
59275                         }
59276                         else if (bothAreBigIntLike(leftType, rightType)) {
59277                             switch (operator) {
59278                                 case 49:
59279                                 case 71:
59280                                     reportOperatorError();
59281                                     break;
59282                                 case 42:
59283                                 case 66:
59284                                     if (languageVersion < 3) {
59285                                         error(errorNode, ts.Diagnostics.Exponentiation_cannot_be_performed_on_bigint_values_unless_the_target_option_is_set_to_es2016_or_later);
59286                                     }
59287                             }
59288                             resultType_1 = bigintType;
59289                         }
59290                         else {
59291                             reportOperatorError(bothAreBigIntLike);
59292                             resultType_1 = errorType;
59293                         }
59294                         if (leftOk && rightOk) {
59295                             checkAssignmentOperator(resultType_1);
59296                         }
59297                         return resultType_1;
59298                     }
59299                 case 39:
59300                 case 63:
59301                     if (leftType === silentNeverType || rightType === silentNeverType) {
59302                         return silentNeverType;
59303                     }
59304                     if (!isTypeAssignableToKind(leftType, 402653316) && !isTypeAssignableToKind(rightType, 402653316)) {
59305                         leftType = checkNonNullType(leftType, left);
59306                         rightType = checkNonNullType(rightType, right);
59307                     }
59308                     var resultType = void 0;
59309                     if (isTypeAssignableToKind(leftType, 296, true) && isTypeAssignableToKind(rightType, 296, true)) {
59310                         resultType = numberType;
59311                     }
59312                     else if (isTypeAssignableToKind(leftType, 2112, true) && isTypeAssignableToKind(rightType, 2112, true)) {
59313                         resultType = bigintType;
59314                     }
59315                     else if (isTypeAssignableToKind(leftType, 402653316, true) || isTypeAssignableToKind(rightType, 402653316, true)) {
59316                         resultType = stringType;
59317                     }
59318                     else if (isTypeAny(leftType) || isTypeAny(rightType)) {
59319                         resultType = leftType === errorType || rightType === errorType ? errorType : anyType;
59320                     }
59321                     if (resultType && !checkForDisallowedESSymbolOperand(operator)) {
59322                         return resultType;
59323                     }
59324                     if (!resultType) {
59325                         var closeEnoughKind_1 = 296 | 2112 | 402653316 | 3;
59326                         reportOperatorError(function (left, right) {
59327                             return isTypeAssignableToKind(left, closeEnoughKind_1) &&
59328                                 isTypeAssignableToKind(right, closeEnoughKind_1);
59329                         });
59330                         return anyType;
59331                     }
59332                     if (operator === 63) {
59333                         checkAssignmentOperator(resultType);
59334                     }
59335                     return resultType;
59336                 case 29:
59337                 case 31:
59338                 case 32:
59339                 case 33:
59340                     if (checkForDisallowedESSymbolOperand(operator)) {
59341                         leftType = getBaseTypeOfLiteralType(checkNonNullType(leftType, left));
59342                         rightType = getBaseTypeOfLiteralType(checkNonNullType(rightType, right));
59343                         reportOperatorErrorUnless(function (left, right) {
59344                             return isTypeComparableTo(left, right) || isTypeComparableTo(right, left) || (isTypeAssignableTo(left, numberOrBigIntType) && isTypeAssignableTo(right, numberOrBigIntType));
59345                         });
59346                     }
59347                     return booleanType;
59348                 case 34:
59349                 case 35:
59350                 case 36:
59351                 case 37:
59352                     reportOperatorErrorUnless(function (left, right) { return isTypeEqualityComparableTo(left, right) || isTypeEqualityComparableTo(right, left); });
59353                     return booleanType;
59354                 case 101:
59355                     return checkInstanceOfExpression(left, right, leftType, rightType);
59356                 case 100:
59357                     return checkInExpression(left, right, leftType, rightType);
59358                 case 55:
59359                 case 75: {
59360                     var resultType_2 = getTypeFacts(leftType) & 4194304 ?
59361                         getUnionType([extractDefinitelyFalsyTypes(strictNullChecks ? leftType : getBaseTypeOfLiteralType(rightType)), rightType]) :
59362                         leftType;
59363                     if (operator === 75) {
59364                         checkAssignmentOperator(rightType);
59365                     }
59366                     return resultType_2;
59367                 }
59368                 case 56:
59369                 case 74: {
59370                     var resultType_3 = getTypeFacts(leftType) & 8388608 ?
59371                         getUnionType([removeDefinitelyFalsyTypes(leftType), rightType], 2) :
59372                         leftType;
59373                     if (operator === 74) {
59374                         checkAssignmentOperator(rightType);
59375                     }
59376                     return resultType_3;
59377                 }
59378                 case 60:
59379                 case 76: {
59380                     var resultType_4 = getTypeFacts(leftType) & 262144 ?
59381                         getUnionType([getNonNullableType(leftType), rightType], 2) :
59382                         leftType;
59383                     if (operator === 76) {
59384                         checkAssignmentOperator(rightType);
59385                     }
59386                     return resultType_4;
59387                 }
59388                 case 62:
59389                     var declKind = ts.isBinaryExpression(left.parent) ? ts.getAssignmentDeclarationKind(left.parent) : 0;
59390                     checkAssignmentDeclaration(declKind, rightType);
59391                     if (isAssignmentDeclaration(declKind)) {
59392                         if (!(rightType.flags & 524288) ||
59393                             declKind !== 2 &&
59394                                 declKind !== 6 &&
59395                                 !isEmptyObjectType(rightType) &&
59396                                 !isFunctionObjectType(rightType) &&
59397                                 !(ts.getObjectFlags(rightType) & 1)) {
59398                             checkAssignmentOperator(rightType);
59399                         }
59400                         return leftType;
59401                     }
59402                     else {
59403                         checkAssignmentOperator(rightType);
59404                         return getRegularTypeOfObjectLiteral(rightType);
59405                     }
59406                 case 27:
59407                     if (!compilerOptions.allowUnreachableCode && isSideEffectFree(left) && !isEvalNode(right)) {
59408                         var sf = ts.getSourceFileOfNode(left);
59409                         var sourceText = sf.text;
59410                         var start_3 = ts.skipTrivia(sourceText, left.pos);
59411                         var isInDiag2657 = sf.parseDiagnostics.some(function (diag) {
59412                             if (diag.code !== ts.Diagnostics.JSX_expressions_must_have_one_parent_element.code)
59413                                 return false;
59414                             return ts.textSpanContainsPosition(diag, start_3);
59415                         });
59416                         if (!isInDiag2657)
59417                             error(left, ts.Diagnostics.Left_side_of_comma_operator_is_unused_and_has_no_side_effects);
59418                     }
59419                     return rightType;
59420                 default:
59421                     return ts.Debug.fail();
59422             }
59423             function bothAreBigIntLike(left, right) {
59424                 return isTypeAssignableToKind(left, 2112) && isTypeAssignableToKind(right, 2112);
59425             }
59426             function checkAssignmentDeclaration(kind, rightType) {
59427                 if (kind === 2) {
59428                     for (var _i = 0, _a = getPropertiesOfObjectType(rightType); _i < _a.length; _i++) {
59429                         var prop = _a[_i];
59430                         var propType = getTypeOfSymbol(prop);
59431                         if (propType.symbol && propType.symbol.flags & 32) {
59432                             var name = prop.escapedName;
59433                             var symbol = resolveName(prop.valueDeclaration, name, 788968, undefined, name, false);
59434                             if (symbol && symbol.declarations.some(ts.isJSDocTypedefTag)) {
59435                                 addDuplicateDeclarationErrorsForSymbols(symbol, ts.Diagnostics.Duplicate_identifier_0, ts.unescapeLeadingUnderscores(name), prop);
59436                                 addDuplicateDeclarationErrorsForSymbols(prop, ts.Diagnostics.Duplicate_identifier_0, ts.unescapeLeadingUnderscores(name), symbol);
59437                             }
59438                         }
59439                     }
59440                 }
59441             }
59442             function isEvalNode(node) {
59443                 return node.kind === 78 && node.escapedText === "eval";
59444             }
59445             function checkForDisallowedESSymbolOperand(operator) {
59446                 var offendingSymbolOperand = maybeTypeOfKind(leftType, 12288) ? left :
59447                     maybeTypeOfKind(rightType, 12288) ? right :
59448                         undefined;
59449                 if (offendingSymbolOperand) {
59450                     error(offendingSymbolOperand, ts.Diagnostics.The_0_operator_cannot_be_applied_to_type_symbol, ts.tokenToString(operator));
59451                     return false;
59452                 }
59453                 return true;
59454             }
59455             function getSuggestedBooleanOperator(operator) {
59456                 switch (operator) {
59457                     case 51:
59458                     case 73:
59459                         return 56;
59460                     case 52:
59461                     case 77:
59462                         return 37;
59463                     case 50:
59464                     case 72:
59465                         return 55;
59466                     default:
59467                         return undefined;
59468                 }
59469             }
59470             function checkAssignmentOperator(valueType) {
59471                 if (produceDiagnostics && ts.isAssignmentOperator(operator)) {
59472                     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)
59473                         && (!ts.isIdentifier(left) || ts.unescapeLeadingUnderscores(left.escapedText) !== "exports")) {
59474                         checkTypeAssignableToAndOptionallyElaborate(valueType, leftType, left, right);
59475                     }
59476                 }
59477             }
59478             function isAssignmentDeclaration(kind) {
59479                 var _a;
59480                 switch (kind) {
59481                     case 2:
59482                         return true;
59483                     case 1:
59484                     case 5:
59485                     case 6:
59486                     case 3:
59487                     case 4:
59488                         var symbol = getSymbolOfNode(left);
59489                         var init = ts.getAssignedExpandoInitializer(right);
59490                         return !!init && ts.isObjectLiteralExpression(init) &&
59491                             !!((_a = symbol === null || symbol === void 0 ? void 0 : symbol.exports) === null || _a === void 0 ? void 0 : _a.size);
59492                     default:
59493                         return false;
59494                 }
59495             }
59496             function reportOperatorErrorUnless(typesAreCompatible) {
59497                 if (!typesAreCompatible(leftType, rightType)) {
59498                     reportOperatorError(typesAreCompatible);
59499                     return true;
59500                 }
59501                 return false;
59502             }
59503             function reportOperatorError(isRelated) {
59504                 var _a;
59505                 var wouldWorkWithAwait = false;
59506                 var errNode = errorNode || operatorToken;
59507                 if (isRelated) {
59508                     var awaitedLeftType = getAwaitedType(leftType);
59509                     var awaitedRightType = getAwaitedType(rightType);
59510                     wouldWorkWithAwait = !(awaitedLeftType === leftType && awaitedRightType === rightType)
59511                         && !!(awaitedLeftType && awaitedRightType)
59512                         && isRelated(awaitedLeftType, awaitedRightType);
59513                 }
59514                 var effectiveLeft = leftType;
59515                 var effectiveRight = rightType;
59516                 if (!wouldWorkWithAwait && isRelated) {
59517                     _a = getBaseTypesIfUnrelated(leftType, rightType, isRelated), effectiveLeft = _a[0], effectiveRight = _a[1];
59518                 }
59519                 var _b = getTypeNamesForErrorDisplay(effectiveLeft, effectiveRight), leftStr = _b[0], rightStr = _b[1];
59520                 if (!tryGiveBetterPrimaryError(errNode, wouldWorkWithAwait, leftStr, rightStr)) {
59521                     errorAndMaybeSuggestAwait(errNode, wouldWorkWithAwait, ts.Diagnostics.Operator_0_cannot_be_applied_to_types_1_and_2, ts.tokenToString(operatorToken.kind), leftStr, rightStr);
59522                 }
59523             }
59524             function tryGiveBetterPrimaryError(errNode, maybeMissingAwait, leftStr, rightStr) {
59525                 var typeName;
59526                 switch (operatorToken.kind) {
59527                     case 36:
59528                     case 34:
59529                         typeName = "false";
59530                         break;
59531                     case 37:
59532                     case 35:
59533                         typeName = "true";
59534                 }
59535                 if (typeName) {
59536                     return errorAndMaybeSuggestAwait(errNode, maybeMissingAwait, ts.Diagnostics.This_condition_will_always_return_0_since_the_types_1_and_2_have_no_overlap, typeName, leftStr, rightStr);
59537                 }
59538                 return undefined;
59539             }
59540         }
59541         function getBaseTypesIfUnrelated(leftType, rightType, isRelated) {
59542             var effectiveLeft = leftType;
59543             var effectiveRight = rightType;
59544             var leftBase = getBaseTypeOfLiteralType(leftType);
59545             var rightBase = getBaseTypeOfLiteralType(rightType);
59546             if (!isRelated(leftBase, rightBase)) {
59547                 effectiveLeft = leftBase;
59548                 effectiveRight = rightBase;
59549             }
59550             return [effectiveLeft, effectiveRight];
59551         }
59552         function checkYieldExpression(node) {
59553             if (produceDiagnostics) {
59554                 if (!(node.flags & 8192)) {
59555                     grammarErrorOnFirstToken(node, ts.Diagnostics.A_yield_expression_is_only_allowed_in_a_generator_body);
59556                 }
59557                 if (isInParameterInitializerBeforeContainingFunction(node)) {
59558                     error(node, ts.Diagnostics.yield_expressions_cannot_be_used_in_a_parameter_initializer);
59559                 }
59560             }
59561             var func = ts.getContainingFunction(node);
59562             if (!func)
59563                 return anyType;
59564             var functionFlags = ts.getFunctionFlags(func);
59565             if (!(functionFlags & 1)) {
59566                 return anyType;
59567             }
59568             var isAsync = (functionFlags & 2) !== 0;
59569             if (node.asteriskToken) {
59570                 if (isAsync && languageVersion < 99) {
59571                     checkExternalEmitHelpers(node, 53248);
59572                 }
59573                 if (!isAsync && languageVersion < 2 && compilerOptions.downlevelIteration) {
59574                     checkExternalEmitHelpers(node, 256);
59575                 }
59576             }
59577             var returnType = getReturnTypeFromAnnotation(func);
59578             var iterationTypes = returnType && getIterationTypesOfGeneratorFunctionReturnType(returnType, isAsync);
59579             var signatureYieldType = iterationTypes && iterationTypes.yieldType || anyType;
59580             var signatureNextType = iterationTypes && iterationTypes.nextType || anyType;
59581             var resolvedSignatureNextType = isAsync ? getAwaitedType(signatureNextType) || anyType : signatureNextType;
59582             var yieldExpressionType = node.expression ? checkExpression(node.expression) : undefinedWideningType;
59583             var yieldedType = getYieldedTypeOfYieldExpression(node, yieldExpressionType, resolvedSignatureNextType, isAsync);
59584             if (returnType && yieldedType) {
59585                 checkTypeAssignableToAndOptionallyElaborate(yieldedType, signatureYieldType, node.expression || node, node.expression);
59586             }
59587             if (node.asteriskToken) {
59588                 var use = isAsync ? 19 : 17;
59589                 return getIterationTypeOfIterable(use, 1, yieldExpressionType, node.expression)
59590                     || anyType;
59591             }
59592             else if (returnType) {
59593                 return getIterationTypeOfGeneratorFunctionReturnType(2, returnType, isAsync)
59594                     || anyType;
59595             }
59596             return getContextualIterationType(2, func) || anyType;
59597         }
59598         function checkConditionalExpression(node, checkMode) {
59599             var type = checkTruthinessExpression(node.condition);
59600             checkTestingKnownTruthyCallableType(node.condition, node.whenTrue, type);
59601             var type1 = checkExpression(node.whenTrue, checkMode);
59602             var type2 = checkExpression(node.whenFalse, checkMode);
59603             return getUnionType([type1, type2], 2);
59604         }
59605         function checkTemplateExpression(node) {
59606             var texts = [node.head.text];
59607             var types = [];
59608             for (var _i = 0, _a = node.templateSpans; _i < _a.length; _i++) {
59609                 var span = _a[_i];
59610                 var type = checkExpression(span.expression);
59611                 if (maybeTypeOfKind(type, 12288)) {
59612                     error(span.expression, ts.Diagnostics.Implicit_conversion_of_a_symbol_to_a_string_will_fail_at_runtime_Consider_wrapping_this_expression_in_String);
59613                 }
59614                 texts.push(span.literal.text);
59615                 types.push(isTypeAssignableTo(type, templateConstraintType) ? type : stringType);
59616             }
59617             return isConstContext(node) ? getTemplateLiteralType(texts, types) : stringType;
59618         }
59619         function getContextNode(node) {
59620             if (node.kind === 281 && !ts.isJsxSelfClosingElement(node.parent)) {
59621                 return node.parent.parent;
59622             }
59623             return node;
59624         }
59625         function checkExpressionWithContextualType(node, contextualType, inferenceContext, checkMode) {
59626             var context = getContextNode(node);
59627             var saveContextualType = context.contextualType;
59628             var saveInferenceContext = context.inferenceContext;
59629             try {
59630                 context.contextualType = contextualType;
59631                 context.inferenceContext = inferenceContext;
59632                 var type = checkExpression(node, checkMode | 1 | (inferenceContext ? 2 : 0));
59633                 var result = maybeTypeOfKind(type, 2944) && isLiteralOfContextualType(type, instantiateContextualType(contextualType, node)) ?
59634                     getRegularTypeOfLiteralType(type) : type;
59635                 return result;
59636             }
59637             finally {
59638                 context.contextualType = saveContextualType;
59639                 context.inferenceContext = saveInferenceContext;
59640             }
59641         }
59642         function checkExpressionCached(node, checkMode) {
59643             var links = getNodeLinks(node);
59644             if (!links.resolvedType) {
59645                 if (checkMode && checkMode !== 0) {
59646                     return checkExpression(node, checkMode);
59647                 }
59648                 var saveFlowLoopStart = flowLoopStart;
59649                 var saveFlowTypeCache = flowTypeCache;
59650                 flowLoopStart = flowLoopCount;
59651                 flowTypeCache = undefined;
59652                 links.resolvedType = checkExpression(node, checkMode);
59653                 flowTypeCache = saveFlowTypeCache;
59654                 flowLoopStart = saveFlowLoopStart;
59655             }
59656             return links.resolvedType;
59657         }
59658         function isTypeAssertion(node) {
59659             node = ts.skipParentheses(node);
59660             return node.kind === 206 || node.kind === 224;
59661         }
59662         function checkDeclarationInitializer(declaration, contextualType) {
59663             var initializer = ts.getEffectiveInitializer(declaration);
59664             var type = getQuickTypeOfExpression(initializer) ||
59665                 (contextualType ? checkExpressionWithContextualType(initializer, contextualType, undefined, 0) : checkExpressionCached(initializer));
59666             return ts.isParameter(declaration) && declaration.name.kind === 197 &&
59667                 isTupleType(type) && !type.target.hasRestElement && getTypeReferenceArity(type) < declaration.name.elements.length ?
59668                 padTupleType(type, declaration.name) : type;
59669         }
59670         function padTupleType(type, pattern) {
59671             var patternElements = pattern.elements;
59672             var elementTypes = getTypeArguments(type).slice();
59673             var elementFlags = type.target.elementFlags.slice();
59674             for (var i = getTypeReferenceArity(type); i < patternElements.length; i++) {
59675                 var e = patternElements[i];
59676                 if (i < patternElements.length - 1 || !(e.kind === 198 && e.dotDotDotToken)) {
59677                     elementTypes.push(!ts.isOmittedExpression(e) && hasDefaultValue(e) ? getTypeFromBindingElement(e, false, false) : anyType);
59678                     elementFlags.push(2);
59679                     if (!ts.isOmittedExpression(e) && !hasDefaultValue(e)) {
59680                         reportImplicitAny(e, anyType);
59681                     }
59682                 }
59683             }
59684             return createTupleType(elementTypes, elementFlags, type.target.readonly);
59685         }
59686         function widenTypeInferredFromInitializer(declaration, type) {
59687             var widened = ts.getCombinedNodeFlags(declaration) & 2 || ts.isDeclarationReadonly(declaration) ? type : getWidenedLiteralType(type);
59688             if (ts.isInJSFile(declaration)) {
59689                 if (widened.flags & 98304) {
59690                     reportImplicitAny(declaration, anyType);
59691                     return anyType;
59692                 }
59693                 else if (isEmptyArrayLiteralType(widened)) {
59694                     reportImplicitAny(declaration, anyArrayType);
59695                     return anyArrayType;
59696                 }
59697             }
59698             return widened;
59699         }
59700         function isLiteralOfContextualType(candidateType, contextualType) {
59701             if (contextualType) {
59702                 if (contextualType.flags & 3145728) {
59703                     var types = contextualType.types;
59704                     return ts.some(types, function (t) { return isLiteralOfContextualType(candidateType, t); });
59705                 }
59706                 if (contextualType.flags & 58982400) {
59707                     var constraint = getBaseConstraintOfType(contextualType) || unknownType;
59708                     return maybeTypeOfKind(constraint, 4) && maybeTypeOfKind(candidateType, 128) ||
59709                         maybeTypeOfKind(constraint, 8) && maybeTypeOfKind(candidateType, 256) ||
59710                         maybeTypeOfKind(constraint, 64) && maybeTypeOfKind(candidateType, 2048) ||
59711                         maybeTypeOfKind(constraint, 4096) && maybeTypeOfKind(candidateType, 8192) ||
59712                         isLiteralOfContextualType(candidateType, constraint);
59713                 }
59714                 return !!(contextualType.flags & (128 | 4194304 | 134217728 | 268435456) && maybeTypeOfKind(candidateType, 128) ||
59715                     contextualType.flags & 256 && maybeTypeOfKind(candidateType, 256) ||
59716                     contextualType.flags & 2048 && maybeTypeOfKind(candidateType, 2048) ||
59717                     contextualType.flags & 512 && maybeTypeOfKind(candidateType, 512) ||
59718                     contextualType.flags & 8192 && maybeTypeOfKind(candidateType, 8192));
59719             }
59720             return false;
59721         }
59722         function isConstContext(node) {
59723             var parent = node.parent;
59724             return ts.isAssertionExpression(parent) && ts.isConstTypeReference(parent.type) ||
59725                 (ts.isParenthesizedExpression(parent) || ts.isArrayLiteralExpression(parent) || ts.isSpreadElement(parent)) && isConstContext(parent) ||
59726                 (ts.isPropertyAssignment(parent) || ts.isShorthandPropertyAssignment(parent) || ts.isTemplateSpan(parent)) && isConstContext(parent.parent);
59727         }
59728         function checkExpressionForMutableLocation(node, checkMode, contextualType, forceTuple) {
59729             var type = checkExpression(node, checkMode, forceTuple);
59730             return isConstContext(node) ? getRegularTypeOfLiteralType(type) :
59731                 isTypeAssertion(node) ? type :
59732                     getWidenedLiteralLikeTypeForContextualType(type, instantiateContextualType(arguments.length === 2 ? getContextualType(node) : contextualType, node));
59733         }
59734         function checkPropertyAssignment(node, checkMode) {
59735             if (node.name.kind === 158) {
59736                 checkComputedPropertyName(node.name);
59737             }
59738             return checkExpressionForMutableLocation(node.initializer, checkMode);
59739         }
59740         function checkObjectLiteralMethod(node, checkMode) {
59741             checkGrammarMethod(node);
59742             if (node.name.kind === 158) {
59743                 checkComputedPropertyName(node.name);
59744             }
59745             var uninstantiatedType = checkFunctionExpressionOrObjectLiteralMethod(node, checkMode);
59746             return instantiateTypeWithSingleGenericCallSignature(node, uninstantiatedType, checkMode);
59747         }
59748         function instantiateTypeWithSingleGenericCallSignature(node, type, checkMode) {
59749             if (checkMode && checkMode & (2 | 8)) {
59750                 var callSignature = getSingleSignature(type, 0, true);
59751                 var constructSignature = getSingleSignature(type, 1, true);
59752                 var signature = callSignature || constructSignature;
59753                 if (signature && signature.typeParameters) {
59754                     var contextualType = getApparentTypeOfContextualType(node, 2);
59755                     if (contextualType) {
59756                         var contextualSignature = getSingleSignature(getNonNullableType(contextualType), callSignature ? 0 : 1, false);
59757                         if (contextualSignature && !contextualSignature.typeParameters) {
59758                             if (checkMode & 8) {
59759                                 skippedGenericFunction(node, checkMode);
59760                                 return anyFunctionType;
59761                             }
59762                             var context = getInferenceContext(node);
59763                             var returnType = context.signature && getReturnTypeOfSignature(context.signature);
59764                             var returnSignature = returnType && getSingleCallOrConstructSignature(returnType);
59765                             if (returnSignature && !returnSignature.typeParameters && !ts.every(context.inferences, hasInferenceCandidates)) {
59766                                 var uniqueTypeParameters = getUniqueTypeParameters(context, signature.typeParameters);
59767                                 var instantiatedSignature = getSignatureInstantiationWithoutFillingInTypeArguments(signature, uniqueTypeParameters);
59768                                 var inferences_3 = ts.map(context.inferences, function (info) { return createInferenceInfo(info.typeParameter); });
59769                                 applyToParameterTypes(instantiatedSignature, contextualSignature, function (source, target) {
59770                                     inferTypes(inferences_3, source, target, 0, true);
59771                                 });
59772                                 if (ts.some(inferences_3, hasInferenceCandidates)) {
59773                                     applyToReturnTypes(instantiatedSignature, contextualSignature, function (source, target) {
59774                                         inferTypes(inferences_3, source, target);
59775                                     });
59776                                     if (!hasOverlappingInferences(context.inferences, inferences_3)) {
59777                                         mergeInferences(context.inferences, inferences_3);
59778                                         context.inferredTypeParameters = ts.concatenate(context.inferredTypeParameters, uniqueTypeParameters);
59779                                         return getOrCreateTypeFromSignature(instantiatedSignature);
59780                                     }
59781                                 }
59782                             }
59783                             return getOrCreateTypeFromSignature(instantiateSignatureInContextOf(signature, contextualSignature, context));
59784                         }
59785                     }
59786                 }
59787             }
59788             return type;
59789         }
59790         function skippedGenericFunction(node, checkMode) {
59791             if (checkMode & 2) {
59792                 var context = getInferenceContext(node);
59793                 context.flags |= 4;
59794             }
59795         }
59796         function hasInferenceCandidates(info) {
59797             return !!(info.candidates || info.contraCandidates);
59798         }
59799         function hasOverlappingInferences(a, b) {
59800             for (var i = 0; i < a.length; i++) {
59801                 if (hasInferenceCandidates(a[i]) && hasInferenceCandidates(b[i])) {
59802                     return true;
59803                 }
59804             }
59805             return false;
59806         }
59807         function mergeInferences(target, source) {
59808             for (var i = 0; i < target.length; i++) {
59809                 if (!hasInferenceCandidates(target[i]) && hasInferenceCandidates(source[i])) {
59810                     target[i] = source[i];
59811                 }
59812             }
59813         }
59814         function getUniqueTypeParameters(context, typeParameters) {
59815             var result = [];
59816             var oldTypeParameters;
59817             var newTypeParameters;
59818             for (var _i = 0, typeParameters_2 = typeParameters; _i < typeParameters_2.length; _i++) {
59819                 var tp = typeParameters_2[_i];
59820                 var name = tp.symbol.escapedName;
59821                 if (hasTypeParameterByName(context.inferredTypeParameters, name) || hasTypeParameterByName(result, name)) {
59822                     var newName = getUniqueTypeParameterName(ts.concatenate(context.inferredTypeParameters, result), name);
59823                     var symbol = createSymbol(262144, newName);
59824                     var newTypeParameter = createTypeParameter(symbol);
59825                     newTypeParameter.target = tp;
59826                     oldTypeParameters = ts.append(oldTypeParameters, tp);
59827                     newTypeParameters = ts.append(newTypeParameters, newTypeParameter);
59828                     result.push(newTypeParameter);
59829                 }
59830                 else {
59831                     result.push(tp);
59832                 }
59833             }
59834             if (newTypeParameters) {
59835                 var mapper = createTypeMapper(oldTypeParameters, newTypeParameters);
59836                 for (var _a = 0, newTypeParameters_1 = newTypeParameters; _a < newTypeParameters_1.length; _a++) {
59837                     var tp = newTypeParameters_1[_a];
59838                     tp.mapper = mapper;
59839                 }
59840             }
59841             return result;
59842         }
59843         function hasTypeParameterByName(typeParameters, name) {
59844             return ts.some(typeParameters, function (tp) { return tp.symbol.escapedName === name; });
59845         }
59846         function getUniqueTypeParameterName(typeParameters, baseName) {
59847             var len = baseName.length;
59848             while (len > 1 && baseName.charCodeAt(len - 1) >= 48 && baseName.charCodeAt(len - 1) <= 57)
59849                 len--;
59850             var s = baseName.slice(0, len);
59851             for (var index = 1; true; index++) {
59852                 var augmentedName = (s + index);
59853                 if (!hasTypeParameterByName(typeParameters, augmentedName)) {
59854                     return augmentedName;
59855                 }
59856             }
59857         }
59858         function getReturnTypeOfSingleNonGenericCallSignature(funcType) {
59859             var signature = getSingleCallSignature(funcType);
59860             if (signature && !signature.typeParameters) {
59861                 return getReturnTypeOfSignature(signature);
59862             }
59863         }
59864         function getReturnTypeOfSingleNonGenericSignatureOfCallChain(expr) {
59865             var funcType = checkExpression(expr.expression);
59866             var nonOptionalType = getOptionalExpressionType(funcType, expr.expression);
59867             var returnType = getReturnTypeOfSingleNonGenericCallSignature(funcType);
59868             return returnType && propagateOptionalTypeMarker(returnType, expr, nonOptionalType !== funcType);
59869         }
59870         function getTypeOfExpression(node) {
59871             var quickType = getQuickTypeOfExpression(node);
59872             if (quickType) {
59873                 return quickType;
59874             }
59875             if (node.flags & 67108864 && flowTypeCache) {
59876                 var cachedType = flowTypeCache[getNodeId(node)];
59877                 if (cachedType) {
59878                     return cachedType;
59879                 }
59880             }
59881             var startInvocationCount = flowInvocationCount;
59882             var type = checkExpression(node);
59883             if (flowInvocationCount !== startInvocationCount) {
59884                 var cache = flowTypeCache || (flowTypeCache = []);
59885                 cache[getNodeId(node)] = type;
59886                 ts.setNodeFlags(node, node.flags | 67108864);
59887             }
59888             return type;
59889         }
59890         function getQuickTypeOfExpression(node) {
59891             var expr = ts.skipParentheses(node);
59892             if (ts.isCallExpression(expr) && expr.expression.kind !== 105 && !ts.isRequireCall(expr, true) && !isSymbolOrSymbolForCall(expr)) {
59893                 var type = ts.isCallChain(expr) ? getReturnTypeOfSingleNonGenericSignatureOfCallChain(expr) :
59894                     getReturnTypeOfSingleNonGenericCallSignature(checkNonNullExpression(expr.expression));
59895                 if (type) {
59896                     return type;
59897                 }
59898             }
59899             else if (ts.isAssertionExpression(expr) && !ts.isConstTypeReference(expr.type)) {
59900                 return getTypeFromTypeNode(expr.type);
59901             }
59902             else if (node.kind === 8 || node.kind === 10 ||
59903                 node.kind === 109 || node.kind === 94) {
59904                 return checkExpression(node);
59905             }
59906             return undefined;
59907         }
59908         function getContextFreeTypeOfExpression(node) {
59909             var links = getNodeLinks(node);
59910             if (links.contextFreeType) {
59911                 return links.contextFreeType;
59912             }
59913             var saveContextualType = node.contextualType;
59914             node.contextualType = anyType;
59915             try {
59916                 var type = links.contextFreeType = checkExpression(node, 4);
59917                 return type;
59918             }
59919             finally {
59920                 node.contextualType = saveContextualType;
59921             }
59922         }
59923         function checkExpression(node, checkMode, forceTuple) {
59924             ts.tracing.push("check", "checkExpression", { kind: node.kind, pos: node.pos, end: node.end });
59925             var saveCurrentNode = currentNode;
59926             currentNode = node;
59927             instantiationCount = 0;
59928             var uninstantiatedType = checkExpressionWorker(node, checkMode, forceTuple);
59929             var type = instantiateTypeWithSingleGenericCallSignature(node, uninstantiatedType, checkMode);
59930             if (isConstEnumObjectType(type)) {
59931                 checkConstEnumAccess(node, type);
59932             }
59933             currentNode = saveCurrentNode;
59934             ts.tracing.pop();
59935             return type;
59936         }
59937         function checkConstEnumAccess(node, type) {
59938             var ok = (node.parent.kind === 201 && node.parent.expression === node) ||
59939                 (node.parent.kind === 202 && node.parent.expression === node) ||
59940                 ((node.kind === 78 || node.kind === 157) && isInRightSideOfImportOrExportAssignment(node) ||
59941                     (node.parent.kind === 176 && node.parent.exprName === node)) ||
59942                 (node.parent.kind === 270);
59943             if (!ok) {
59944                 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);
59945             }
59946             if (compilerOptions.isolatedModules) {
59947                 ts.Debug.assert(!!(type.symbol.flags & 128));
59948                 var constEnumDeclaration = type.symbol.valueDeclaration;
59949                 if (constEnumDeclaration.flags & 8388608) {
59950                     error(node, ts.Diagnostics.Cannot_access_ambient_const_enums_when_the_isolatedModules_flag_is_provided);
59951                 }
59952             }
59953         }
59954         function checkParenthesizedExpression(node, checkMode) {
59955             var tag = ts.isInJSFile(node) ? ts.getJSDocTypeTag(node) : undefined;
59956             if (tag) {
59957                 return checkAssertionWorker(tag, tag.typeExpression.type, node.expression, checkMode);
59958             }
59959             return checkExpression(node.expression, checkMode);
59960         }
59961         function checkExpressionWorker(node, checkMode, forceTuple) {
59962             var kind = node.kind;
59963             if (cancellationToken) {
59964                 switch (kind) {
59965                     case 221:
59966                     case 208:
59967                     case 209:
59968                         cancellationToken.throwIfCancellationRequested();
59969                 }
59970             }
59971             switch (kind) {
59972                 case 78:
59973                     return checkIdentifier(node);
59974                 case 107:
59975                     return checkThisExpression(node);
59976                 case 105:
59977                     return checkSuperExpression(node);
59978                 case 103:
59979                     return nullWideningType;
59980                 case 14:
59981                 case 10:
59982                     return getFreshTypeOfLiteralType(getLiteralType(node.text));
59983                 case 8:
59984                     checkGrammarNumericLiteral(node);
59985                     return getFreshTypeOfLiteralType(getLiteralType(+node.text));
59986                 case 9:
59987                     checkGrammarBigIntLiteral(node);
59988                     return getFreshTypeOfLiteralType(getBigIntLiteralType(node));
59989                 case 109:
59990                     return trueType;
59991                 case 94:
59992                     return falseType;
59993                 case 218:
59994                     return checkTemplateExpression(node);
59995                 case 13:
59996                     return globalRegExpType;
59997                 case 199:
59998                     return checkArrayLiteral(node, checkMode, forceTuple);
59999                 case 200:
60000                     return checkObjectLiteral(node, checkMode);
60001                 case 201:
60002                     return checkPropertyAccessExpression(node);
60003                 case 157:
60004                     return checkQualifiedName(node);
60005                 case 202:
60006                     return checkIndexedAccess(node);
60007                 case 203:
60008                     if (node.expression.kind === 99) {
60009                         return checkImportCallExpression(node);
60010                     }
60011                 case 204:
60012                     return checkCallExpression(node, checkMode);
60013                 case 205:
60014                     return checkTaggedTemplateExpression(node);
60015                 case 207:
60016                     return checkParenthesizedExpression(node, checkMode);
60017                 case 221:
60018                     return checkClassExpression(node);
60019                 case 208:
60020                 case 209:
60021                     return checkFunctionExpressionOrObjectLiteralMethod(node, checkMode);
60022                 case 211:
60023                     return checkTypeOfExpression(node);
60024                 case 206:
60025                 case 224:
60026                     return checkAssertion(node);
60027                 case 225:
60028                     return checkNonNullAssertion(node);
60029                 case 226:
60030                     return checkMetaProperty(node);
60031                 case 210:
60032                     return checkDeleteExpression(node);
60033                 case 212:
60034                     return checkVoidExpression(node);
60035                 case 213:
60036                     return checkAwaitExpression(node);
60037                 case 214:
60038                     return checkPrefixUnaryExpression(node);
60039                 case 215:
60040                     return checkPostfixUnaryExpression(node);
60041                 case 216:
60042                     return checkBinaryExpression(node, checkMode);
60043                 case 217:
60044                     return checkConditionalExpression(node, checkMode);
60045                 case 220:
60046                     return checkSpreadExpression(node, checkMode);
60047                 case 222:
60048                     return undefinedWideningType;
60049                 case 219:
60050                     return checkYieldExpression(node);
60051                 case 227:
60052                     return checkSyntheticExpression(node);
60053                 case 283:
60054                     return checkJsxExpression(node, checkMode);
60055                 case 273:
60056                     return checkJsxElement(node, checkMode);
60057                 case 274:
60058                     return checkJsxSelfClosingElement(node, checkMode);
60059                 case 277:
60060                     return checkJsxFragment(node);
60061                 case 281:
60062                     return checkJsxAttributes(node, checkMode);
60063                 case 275:
60064                     ts.Debug.fail("Shouldn't ever directly check a JsxOpeningElement");
60065             }
60066             return errorType;
60067         }
60068         function checkTypeParameter(node) {
60069             if (node.expression) {
60070                 grammarErrorOnFirstToken(node.expression, ts.Diagnostics.Type_expected);
60071             }
60072             checkSourceElement(node.constraint);
60073             checkSourceElement(node.default);
60074             var typeParameter = getDeclaredTypeOfTypeParameter(getSymbolOfNode(node));
60075             getBaseConstraintOfType(typeParameter);
60076             if (!hasNonCircularTypeParameterDefault(typeParameter)) {
60077                 error(node.default, ts.Diagnostics.Type_parameter_0_has_a_circular_default, typeToString(typeParameter));
60078             }
60079             var constraintType = getConstraintOfTypeParameter(typeParameter);
60080             var defaultType = getDefaultFromTypeParameter(typeParameter);
60081             if (constraintType && defaultType) {
60082                 checkTypeAssignableTo(defaultType, getTypeWithThisArgument(instantiateType(constraintType, makeUnaryTypeMapper(typeParameter, defaultType)), defaultType), node.default, ts.Diagnostics.Type_0_does_not_satisfy_the_constraint_1);
60083             }
60084             if (produceDiagnostics) {
60085                 checkTypeNameIsReserved(node.name, ts.Diagnostics.Type_parameter_name_cannot_be_0);
60086             }
60087         }
60088         function checkParameter(node) {
60089             checkGrammarDecoratorsAndModifiers(node);
60090             checkVariableLikeDeclaration(node);
60091             var func = ts.getContainingFunction(node);
60092             if (ts.hasSyntacticModifier(node, 92)) {
60093                 if (!(func.kind === 166 && ts.nodeIsPresent(func.body))) {
60094                     error(node, ts.Diagnostics.A_parameter_property_is_only_allowed_in_a_constructor_implementation);
60095                 }
60096                 if (func.kind === 166 && ts.isIdentifier(node.name) && node.name.escapedText === "constructor") {
60097                     error(node.name, ts.Diagnostics.constructor_cannot_be_used_as_a_parameter_property_name);
60098                 }
60099             }
60100             if (node.questionToken && ts.isBindingPattern(node.name) && func.body) {
60101                 error(node, ts.Diagnostics.A_binding_pattern_parameter_cannot_be_optional_in_an_implementation_signature);
60102             }
60103             if (node.name && ts.isIdentifier(node.name) && (node.name.escapedText === "this" || node.name.escapedText === "new")) {
60104                 if (func.parameters.indexOf(node) !== 0) {
60105                     error(node, ts.Diagnostics.A_0_parameter_must_be_the_first_parameter, node.name.escapedText);
60106                 }
60107                 if (func.kind === 166 || func.kind === 170 || func.kind === 175) {
60108                     error(node, ts.Diagnostics.A_constructor_cannot_have_a_this_parameter);
60109                 }
60110                 if (func.kind === 209) {
60111                     error(node, ts.Diagnostics.An_arrow_function_cannot_have_a_this_parameter);
60112                 }
60113                 if (func.kind === 167 || func.kind === 168) {
60114                     error(node, ts.Diagnostics.get_and_set_accessors_cannot_declare_this_parameters);
60115                 }
60116             }
60117             if (node.dotDotDotToken && !ts.isBindingPattern(node.name) && !isTypeAssignableTo(getReducedType(getTypeOfSymbol(node.symbol)), anyReadonlyArrayType)) {
60118                 error(node, ts.Diagnostics.A_rest_parameter_must_be_of_an_array_type);
60119             }
60120         }
60121         function checkTypePredicate(node) {
60122             var parent = getTypePredicateParent(node);
60123             if (!parent) {
60124                 error(node, ts.Diagnostics.A_type_predicate_is_only_allowed_in_return_type_position_for_functions_and_methods);
60125                 return;
60126             }
60127             var signature = getSignatureFromDeclaration(parent);
60128             var typePredicate = getTypePredicateOfSignature(signature);
60129             if (!typePredicate) {
60130                 return;
60131             }
60132             checkSourceElement(node.type);
60133             var parameterName = node.parameterName;
60134             if (typePredicate.kind === 0 || typePredicate.kind === 2) {
60135                 getTypeFromThisTypeNode(parameterName);
60136             }
60137             else {
60138                 if (typePredicate.parameterIndex >= 0) {
60139                     if (signatureHasRestParameter(signature) && typePredicate.parameterIndex === signature.parameters.length - 1) {
60140                         error(parameterName, ts.Diagnostics.A_type_predicate_cannot_reference_a_rest_parameter);
60141                     }
60142                     else {
60143                         if (typePredicate.type) {
60144                             var leadingError = function () { return ts.chainDiagnosticMessages(undefined, ts.Diagnostics.A_type_predicate_s_type_must_be_assignable_to_its_parameter_s_type); };
60145                             checkTypeAssignableTo(typePredicate.type, getTypeOfSymbol(signature.parameters[typePredicate.parameterIndex]), node.type, undefined, leadingError);
60146                         }
60147                     }
60148                 }
60149                 else if (parameterName) {
60150                     var hasReportedError = false;
60151                     for (var _i = 0, _a = parent.parameters; _i < _a.length; _i++) {
60152                         var name = _a[_i].name;
60153                         if (ts.isBindingPattern(name) &&
60154                             checkIfTypePredicateVariableIsDeclaredInBindingPattern(name, parameterName, typePredicate.parameterName)) {
60155                             hasReportedError = true;
60156                             break;
60157                         }
60158                     }
60159                     if (!hasReportedError) {
60160                         error(node.parameterName, ts.Diagnostics.Cannot_find_parameter_0, typePredicate.parameterName);
60161                     }
60162                 }
60163             }
60164         }
60165         function getTypePredicateParent(node) {
60166             switch (node.parent.kind) {
60167                 case 209:
60168                 case 169:
60169                 case 251:
60170                 case 208:
60171                 case 174:
60172                 case 165:
60173                 case 164:
60174                     var parent = node.parent;
60175                     if (node === parent.type) {
60176                         return parent;
60177                     }
60178             }
60179         }
60180         function checkIfTypePredicateVariableIsDeclaredInBindingPattern(pattern, predicateVariableNode, predicateVariableName) {
60181             for (var _i = 0, _a = pattern.elements; _i < _a.length; _i++) {
60182                 var element = _a[_i];
60183                 if (ts.isOmittedExpression(element)) {
60184                     continue;
60185                 }
60186                 var name = element.name;
60187                 if (name.kind === 78 && name.escapedText === predicateVariableName) {
60188                     error(predicateVariableNode, ts.Diagnostics.A_type_predicate_cannot_reference_element_0_in_a_binding_pattern, predicateVariableName);
60189                     return true;
60190                 }
60191                 else if (name.kind === 197 || name.kind === 196) {
60192                     if (checkIfTypePredicateVariableIsDeclaredInBindingPattern(name, predicateVariableNode, predicateVariableName)) {
60193                         return true;
60194                     }
60195                 }
60196             }
60197         }
60198         function checkSignatureDeclaration(node) {
60199             if (node.kind === 171) {
60200                 checkGrammarIndexSignature(node);
60201             }
60202             else if (node.kind === 174 || node.kind === 251 || node.kind === 175 ||
60203                 node.kind === 169 || node.kind === 166 ||
60204                 node.kind === 170) {
60205                 checkGrammarFunctionLikeDeclaration(node);
60206             }
60207             var functionFlags = ts.getFunctionFlags(node);
60208             if (!(functionFlags & 4)) {
60209                 if ((functionFlags & 3) === 3 && languageVersion < 99) {
60210                     checkExternalEmitHelpers(node, 12288);
60211                 }
60212                 if ((functionFlags & 3) === 2 && languageVersion < 4) {
60213                     checkExternalEmitHelpers(node, 64);
60214                 }
60215                 if ((functionFlags & 3) !== 0 && languageVersion < 2) {
60216                     checkExternalEmitHelpers(node, 128);
60217                 }
60218             }
60219             checkTypeParameters(node.typeParameters);
60220             ts.forEach(node.parameters, checkParameter);
60221             if (node.type) {
60222                 checkSourceElement(node.type);
60223             }
60224             if (produceDiagnostics) {
60225                 checkCollisionWithArgumentsInGeneratedCode(node);
60226                 var returnTypeNode = ts.getEffectiveReturnTypeNode(node);
60227                 if (noImplicitAny && !returnTypeNode) {
60228                     switch (node.kind) {
60229                         case 170:
60230                             error(node, ts.Diagnostics.Construct_signature_which_lacks_return_type_annotation_implicitly_has_an_any_return_type);
60231                             break;
60232                         case 169:
60233                             error(node, ts.Diagnostics.Call_signature_which_lacks_return_type_annotation_implicitly_has_an_any_return_type);
60234                             break;
60235                     }
60236                 }
60237                 if (returnTypeNode) {
60238                     var functionFlags_1 = ts.getFunctionFlags(node);
60239                     if ((functionFlags_1 & (4 | 1)) === 1) {
60240                         var returnType = getTypeFromTypeNode(returnTypeNode);
60241                         if (returnType === voidType) {
60242                             error(returnTypeNode, ts.Diagnostics.A_generator_cannot_have_a_void_type_annotation);
60243                         }
60244                         else {
60245                             var generatorYieldType = getIterationTypeOfGeneratorFunctionReturnType(0, returnType, (functionFlags_1 & 2) !== 0) || anyType;
60246                             var generatorReturnType = getIterationTypeOfGeneratorFunctionReturnType(1, returnType, (functionFlags_1 & 2) !== 0) || generatorYieldType;
60247                             var generatorNextType = getIterationTypeOfGeneratorFunctionReturnType(2, returnType, (functionFlags_1 & 2) !== 0) || unknownType;
60248                             var generatorInstantiation = createGeneratorReturnType(generatorYieldType, generatorReturnType, generatorNextType, !!(functionFlags_1 & 2));
60249                             checkTypeAssignableTo(generatorInstantiation, returnType, returnTypeNode);
60250                         }
60251                     }
60252                     else if ((functionFlags_1 & 3) === 2) {
60253                         checkAsyncFunctionReturnType(node, returnTypeNode);
60254                     }
60255                 }
60256                 if (node.kind !== 171 && node.kind !== 308) {
60257                     registerForUnusedIdentifiersCheck(node);
60258                 }
60259             }
60260         }
60261         function checkClassForDuplicateDeclarations(node) {
60262             var instanceNames = new ts.Map();
60263             var staticNames = new ts.Map();
60264             var privateIdentifiers = new ts.Map();
60265             for (var _i = 0, _a = node.members; _i < _a.length; _i++) {
60266                 var member = _a[_i];
60267                 if (member.kind === 166) {
60268                     for (var _b = 0, _c = member.parameters; _b < _c.length; _b++) {
60269                         var param = _c[_b];
60270                         if (ts.isParameterPropertyDeclaration(param, member) && !ts.isBindingPattern(param.name)) {
60271                             addName(instanceNames, param.name, param.name.escapedText, 3);
60272                         }
60273                     }
60274                 }
60275                 else {
60276                     var isStatic = ts.hasSyntacticModifier(member, 32);
60277                     var name = member.name;
60278                     if (!name) {
60279                         return;
60280                     }
60281                     var names = ts.isPrivateIdentifier(name) ? privateIdentifiers :
60282                         isStatic ? staticNames :
60283                             instanceNames;
60284                     var memberName = name && ts.getPropertyNameForPropertyNameNode(name);
60285                     if (memberName) {
60286                         switch (member.kind) {
60287                             case 167:
60288                                 addName(names, name, memberName, 1);
60289                                 break;
60290                             case 168:
60291                                 addName(names, name, memberName, 2);
60292                                 break;
60293                             case 163:
60294                                 addName(names, name, memberName, 3);
60295                                 break;
60296                             case 165:
60297                                 addName(names, name, memberName, 8);
60298                                 break;
60299                         }
60300                     }
60301                 }
60302             }
60303             function addName(names, location, name, meaning) {
60304                 var prev = names.get(name);
60305                 if (prev) {
60306                     if (prev & 8) {
60307                         if (meaning !== 8) {
60308                             error(location, ts.Diagnostics.Duplicate_identifier_0, ts.getTextOfNode(location));
60309                         }
60310                     }
60311                     else if (prev & meaning) {
60312                         error(location, ts.Diagnostics.Duplicate_identifier_0, ts.getTextOfNode(location));
60313                     }
60314                     else {
60315                         names.set(name, prev | meaning);
60316                     }
60317                 }
60318                 else {
60319                     names.set(name, meaning);
60320                 }
60321             }
60322         }
60323         function checkClassForStaticPropertyNameConflicts(node) {
60324             for (var _i = 0, _a = node.members; _i < _a.length; _i++) {
60325                 var member = _a[_i];
60326                 var memberNameNode = member.name;
60327                 var isStatic = ts.hasSyntacticModifier(member, 32);
60328                 if (isStatic && memberNameNode) {
60329                     var memberName = ts.getPropertyNameForPropertyNameNode(memberNameNode);
60330                     switch (memberName) {
60331                         case "name":
60332                         case "length":
60333                         case "caller":
60334                         case "arguments":
60335                         case "prototype":
60336                             var message = ts.Diagnostics.Static_property_0_conflicts_with_built_in_property_Function_0_of_constructor_function_1;
60337                             var className = getNameOfSymbolAsWritten(getSymbolOfNode(node));
60338                             error(memberNameNode, message, memberName, className);
60339                             break;
60340                     }
60341                 }
60342             }
60343         }
60344         function checkObjectTypeForDuplicateDeclarations(node) {
60345             var names = new ts.Map();
60346             for (var _i = 0, _a = node.members; _i < _a.length; _i++) {
60347                 var member = _a[_i];
60348                 if (member.kind === 162) {
60349                     var memberName = void 0;
60350                     var name = member.name;
60351                     switch (name.kind) {
60352                         case 10:
60353                         case 8:
60354                             memberName = name.text;
60355                             break;
60356                         case 78:
60357                             memberName = ts.idText(name);
60358                             break;
60359                         default:
60360                             continue;
60361                     }
60362                     if (names.get(memberName)) {
60363                         error(ts.getNameOfDeclaration(member.symbol.valueDeclaration), ts.Diagnostics.Duplicate_identifier_0, memberName);
60364                         error(member.name, ts.Diagnostics.Duplicate_identifier_0, memberName);
60365                     }
60366                     else {
60367                         names.set(memberName, true);
60368                     }
60369                 }
60370             }
60371         }
60372         function checkTypeForDuplicateIndexSignatures(node) {
60373             if (node.kind === 253) {
60374                 var nodeSymbol = getSymbolOfNode(node);
60375                 if (nodeSymbol.declarations.length > 0 && nodeSymbol.declarations[0] !== node) {
60376                     return;
60377                 }
60378             }
60379             var indexSymbol = getIndexSymbol(getSymbolOfNode(node));
60380             if (indexSymbol) {
60381                 var seenNumericIndexer = false;
60382                 var seenStringIndexer = false;
60383                 for (var _i = 0, _a = indexSymbol.declarations; _i < _a.length; _i++) {
60384                     var decl = _a[_i];
60385                     var declaration = decl;
60386                     if (declaration.parameters.length === 1 && declaration.parameters[0].type) {
60387                         switch (declaration.parameters[0].type.kind) {
60388                             case 147:
60389                                 if (!seenStringIndexer) {
60390                                     seenStringIndexer = true;
60391                                 }
60392                                 else {
60393                                     error(declaration, ts.Diagnostics.Duplicate_string_index_signature);
60394                                 }
60395                                 break;
60396                             case 144:
60397                                 if (!seenNumericIndexer) {
60398                                     seenNumericIndexer = true;
60399                                 }
60400                                 else {
60401                                     error(declaration, ts.Diagnostics.Duplicate_number_index_signature);
60402                                 }
60403                                 break;
60404                         }
60405                     }
60406                 }
60407             }
60408         }
60409         function checkPropertyDeclaration(node) {
60410             if (!checkGrammarDecoratorsAndModifiers(node) && !checkGrammarProperty(node))
60411                 checkGrammarComputedPropertyName(node.name);
60412             checkVariableLikeDeclaration(node);
60413             if (ts.isPrivateIdentifier(node.name) && languageVersion < 99) {
60414                 for (var lexicalScope = ts.getEnclosingBlockScopeContainer(node); !!lexicalScope; lexicalScope = ts.getEnclosingBlockScopeContainer(lexicalScope)) {
60415                     getNodeLinks(lexicalScope).flags |= 67108864;
60416                 }
60417             }
60418         }
60419         function checkPropertySignature(node) {
60420             if (ts.isPrivateIdentifier(node.name)) {
60421                 error(node, ts.Diagnostics.Private_identifiers_are_not_allowed_outside_class_bodies);
60422             }
60423             return checkPropertyDeclaration(node);
60424         }
60425         function checkMethodDeclaration(node) {
60426             if (!checkGrammarMethod(node))
60427                 checkGrammarComputedPropertyName(node.name);
60428             if (ts.isPrivateIdentifier(node.name)) {
60429                 error(node, ts.Diagnostics.A_method_cannot_be_named_with_a_private_identifier);
60430             }
60431             checkFunctionOrMethodDeclaration(node);
60432             if (ts.hasSyntacticModifier(node, 128) && node.kind === 165 && node.body) {
60433                 error(node, ts.Diagnostics.Method_0_cannot_have_an_implementation_because_it_is_marked_abstract, ts.declarationNameToString(node.name));
60434             }
60435         }
60436         function checkConstructorDeclaration(node) {
60437             checkSignatureDeclaration(node);
60438             if (!checkGrammarConstructorTypeParameters(node))
60439                 checkGrammarConstructorTypeAnnotation(node);
60440             checkSourceElement(node.body);
60441             var symbol = getSymbolOfNode(node);
60442             var firstDeclaration = ts.getDeclarationOfKind(symbol, node.kind);
60443             if (node === firstDeclaration) {
60444                 checkFunctionOrConstructorSymbol(symbol);
60445             }
60446             if (ts.nodeIsMissing(node.body)) {
60447                 return;
60448             }
60449             if (!produceDiagnostics) {
60450                 return;
60451             }
60452             function isInstancePropertyWithInitializerOrPrivateIdentifierProperty(n) {
60453                 if (ts.isPrivateIdentifierPropertyDeclaration(n)) {
60454                     return true;
60455                 }
60456                 return n.kind === 163 &&
60457                     !ts.hasSyntacticModifier(n, 32) &&
60458                     !!n.initializer;
60459             }
60460             var containingClassDecl = node.parent;
60461             if (ts.getClassExtendsHeritageElement(containingClassDecl)) {
60462                 captureLexicalThis(node.parent, containingClassDecl);
60463                 var classExtendsNull = classDeclarationExtendsNull(containingClassDecl);
60464                 var superCall = findFirstSuperCall(node.body);
60465                 if (superCall) {
60466                     if (classExtendsNull) {
60467                         error(superCall, ts.Diagnostics.A_constructor_cannot_contain_a_super_call_when_its_class_extends_null);
60468                     }
60469                     var superCallShouldBeFirst = (compilerOptions.target !== 99 || !compilerOptions.useDefineForClassFields) &&
60470                         (ts.some(node.parent.members, isInstancePropertyWithInitializerOrPrivateIdentifierProperty) ||
60471                             ts.some(node.parameters, function (p) { return ts.hasSyntacticModifier(p, 92); }));
60472                     if (superCallShouldBeFirst) {
60473                         var statements = node.body.statements;
60474                         var superCallStatement = void 0;
60475                         for (var _i = 0, statements_4 = statements; _i < statements_4.length; _i++) {
60476                             var statement = statements_4[_i];
60477                             if (statement.kind === 233 && ts.isSuperCall(statement.expression)) {
60478                                 superCallStatement = statement;
60479                                 break;
60480                             }
60481                             if (!ts.isPrologueDirective(statement)) {
60482                                 break;
60483                             }
60484                         }
60485                         if (!superCallStatement) {
60486                             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);
60487                         }
60488                     }
60489                 }
60490                 else if (!classExtendsNull) {
60491                     error(node, ts.Diagnostics.Constructors_for_derived_classes_must_contain_a_super_call);
60492                 }
60493             }
60494         }
60495         function checkAccessorDeclaration(node) {
60496             if (produceDiagnostics) {
60497                 if (!checkGrammarFunctionLikeDeclaration(node) && !checkGrammarAccessor(node))
60498                     checkGrammarComputedPropertyName(node.name);
60499                 checkDecorators(node);
60500                 checkSignatureDeclaration(node);
60501                 if (node.kind === 167) {
60502                     if (!(node.flags & 8388608) && ts.nodeIsPresent(node.body) && (node.flags & 256)) {
60503                         if (!(node.flags & 512)) {
60504                             error(node.name, ts.Diagnostics.A_get_accessor_must_return_a_value);
60505                         }
60506                     }
60507                 }
60508                 if (node.name.kind === 158) {
60509                     checkComputedPropertyName(node.name);
60510                 }
60511                 if (ts.isPrivateIdentifier(node.name)) {
60512                     error(node.name, ts.Diagnostics.An_accessor_cannot_be_named_with_a_private_identifier);
60513                 }
60514                 if (!hasNonBindableDynamicName(node)) {
60515                     var otherKind = node.kind === 167 ? 168 : 167;
60516                     var otherAccessor = ts.getDeclarationOfKind(getSymbolOfNode(node), otherKind);
60517                     if (otherAccessor) {
60518                         var nodeFlags = ts.getEffectiveModifierFlags(node);
60519                         var otherFlags = ts.getEffectiveModifierFlags(otherAccessor);
60520                         if ((nodeFlags & 28) !== (otherFlags & 28)) {
60521                             error(node.name, ts.Diagnostics.Getter_and_setter_accessors_do_not_agree_in_visibility);
60522                         }
60523                         if ((nodeFlags & 128) !== (otherFlags & 128)) {
60524                             error(node.name, ts.Diagnostics.Accessors_must_both_be_abstract_or_non_abstract);
60525                         }
60526                         checkAccessorDeclarationTypesIdentical(node, otherAccessor, getAnnotatedAccessorType, ts.Diagnostics.get_and_set_accessor_must_have_the_same_type);
60527                         checkAccessorDeclarationTypesIdentical(node, otherAccessor, getThisTypeOfDeclaration, ts.Diagnostics.get_and_set_accessor_must_have_the_same_this_type);
60528                     }
60529                 }
60530                 var returnType = getTypeOfAccessors(getSymbolOfNode(node));
60531                 if (node.kind === 167) {
60532                     checkAllCodePathsInNonVoidFunctionReturnOrThrow(node, returnType);
60533                 }
60534             }
60535             checkSourceElement(node.body);
60536         }
60537         function checkAccessorDeclarationTypesIdentical(first, second, getAnnotatedType, message) {
60538             var firstType = getAnnotatedType(first);
60539             var secondType = getAnnotatedType(second);
60540             if (firstType && secondType && !isTypeIdenticalTo(firstType, secondType)) {
60541                 error(first, message);
60542             }
60543         }
60544         function checkMissingDeclaration(node) {
60545             checkDecorators(node);
60546         }
60547         function getEffectiveTypeArguments(node, typeParameters) {
60548             return fillMissingTypeArguments(ts.map(node.typeArguments, getTypeFromTypeNode), typeParameters, getMinTypeArgumentCount(typeParameters), ts.isInJSFile(node));
60549         }
60550         function checkTypeArgumentConstraints(node, typeParameters) {
60551             var typeArguments;
60552             var mapper;
60553             var result = true;
60554             for (var i = 0; i < typeParameters.length; i++) {
60555                 var constraint = getConstraintOfTypeParameter(typeParameters[i]);
60556                 if (constraint) {
60557                     if (!typeArguments) {
60558                         typeArguments = getEffectiveTypeArguments(node, typeParameters);
60559                         mapper = createTypeMapper(typeParameters, typeArguments);
60560                     }
60561                     result = result && checkTypeAssignableTo(typeArguments[i], instantiateType(constraint, mapper), node.typeArguments[i], ts.Diagnostics.Type_0_does_not_satisfy_the_constraint_1);
60562                 }
60563             }
60564             return result;
60565         }
60566         function getTypeParametersForTypeReference(node) {
60567             var type = getTypeFromTypeReference(node);
60568             if (type !== errorType) {
60569                 var symbol = getNodeLinks(node).resolvedSymbol;
60570                 if (symbol) {
60571                     return symbol.flags & 524288 && getSymbolLinks(symbol).typeParameters ||
60572                         (ts.getObjectFlags(type) & 4 ? type.target.localTypeParameters : undefined);
60573                 }
60574             }
60575             return undefined;
60576         }
60577         function checkTypeReferenceNode(node) {
60578             checkGrammarTypeArguments(node, node.typeArguments);
60579             if (node.kind === 173 && node.typeName.jsdocDotPos !== undefined && !ts.isInJSFile(node) && !ts.isInJSDoc(node)) {
60580                 grammarErrorAtPos(node, node.typeName.jsdocDotPos, 1, ts.Diagnostics.JSDoc_types_can_only_be_used_inside_documentation_comments);
60581             }
60582             ts.forEach(node.typeArguments, checkSourceElement);
60583             var type = getTypeFromTypeReference(node);
60584             if (type !== errorType) {
60585                 if (node.typeArguments && produceDiagnostics) {
60586                     var typeParameters = getTypeParametersForTypeReference(node);
60587                     if (typeParameters) {
60588                         checkTypeArgumentConstraints(node, typeParameters);
60589                     }
60590                 }
60591                 var symbol = getNodeLinks(node).resolvedSymbol;
60592                 if (symbol) {
60593                     if (ts.some(symbol.declarations, function (d) { return isTypeDeclaration(d) && !!(d.flags & 134217728); })) {
60594                         errorOrSuggestion(false, getDeprecatedSuggestionNode(node), ts.Diagnostics._0_is_deprecated, symbol.escapedName);
60595                     }
60596                     if (type.flags & 32 && symbol.flags & 8) {
60597                         error(node, ts.Diagnostics.Enum_type_0_has_members_with_initializers_that_are_not_literals, typeToString(type));
60598                     }
60599                 }
60600             }
60601         }
60602         function getTypeArgumentConstraint(node) {
60603             var typeReferenceNode = ts.tryCast(node.parent, ts.isTypeReferenceType);
60604             if (!typeReferenceNode)
60605                 return undefined;
60606             var typeParameters = getTypeParametersForTypeReference(typeReferenceNode);
60607             var constraint = getConstraintOfTypeParameter(typeParameters[typeReferenceNode.typeArguments.indexOf(node)]);
60608             return constraint && instantiateType(constraint, createTypeMapper(typeParameters, getEffectiveTypeArguments(typeReferenceNode, typeParameters)));
60609         }
60610         function checkTypeQuery(node) {
60611             getTypeFromTypeQueryNode(node);
60612         }
60613         function checkTypeLiteral(node) {
60614             ts.forEach(node.members, checkSourceElement);
60615             if (produceDiagnostics) {
60616                 var type = getTypeFromTypeLiteralOrFunctionOrConstructorTypeNode(node);
60617                 checkIndexConstraints(type);
60618                 checkTypeForDuplicateIndexSignatures(node);
60619                 checkObjectTypeForDuplicateDeclarations(node);
60620             }
60621         }
60622         function checkArrayType(node) {
60623             checkSourceElement(node.elementType);
60624         }
60625         function checkTupleType(node) {
60626             var elementTypes = node.elements;
60627             var seenOptionalElement = false;
60628             var seenRestElement = false;
60629             var hasNamedElement = ts.some(elementTypes, ts.isNamedTupleMember);
60630             for (var i = 0; i < elementTypes.length; i++) {
60631                 var e = elementTypes[i];
60632                 if (e.kind !== 192 && hasNamedElement) {
60633                     grammarErrorOnNode(e, ts.Diagnostics.Tuple_members_must_all_have_names_or_all_not_have_names);
60634                     break;
60635                 }
60636                 var flags = getTupleElementFlags(e);
60637                 if (flags & 8) {
60638                     var type = getTypeFromTypeNode(e.type);
60639                     if (!isArrayLikeType(type)) {
60640                         error(e, ts.Diagnostics.A_rest_element_type_must_be_an_array_type);
60641                         break;
60642                     }
60643                     if (isArrayType(type) || isTupleType(type) && type.target.combinedFlags & 4) {
60644                         seenRestElement = true;
60645                     }
60646                 }
60647                 else if (flags & 4) {
60648                     seenRestElement = true;
60649                 }
60650                 else if (flags & 2) {
60651                     seenOptionalElement = true;
60652                 }
60653                 else if (seenOptionalElement) {
60654                     grammarErrorOnNode(e, ts.Diagnostics.A_required_element_cannot_follow_an_optional_element);
60655                     break;
60656                 }
60657                 if (seenRestElement && i !== elementTypes.length - 1) {
60658                     grammarErrorOnNode(e, ts.Diagnostics.A_rest_element_must_be_last_in_a_tuple_type);
60659                     break;
60660                 }
60661             }
60662             ts.forEach(node.elements, checkSourceElement);
60663             getTypeFromTypeNode(node);
60664         }
60665         function checkUnionOrIntersectionType(node) {
60666             ts.forEach(node.types, checkSourceElement);
60667             getTypeFromTypeNode(node);
60668         }
60669         function checkIndexedAccessIndexType(type, accessNode) {
60670             if (!(type.flags & 8388608)) {
60671                 return type;
60672             }
60673             var objectType = type.objectType;
60674             var indexType = type.indexType;
60675             if (isTypeAssignableTo(indexType, getIndexType(objectType, false))) {
60676                 if (accessNode.kind === 202 && ts.isAssignmentTarget(accessNode) &&
60677                     ts.getObjectFlags(objectType) & 32 && getMappedTypeModifiers(objectType) & 1) {
60678                     error(accessNode, ts.Diagnostics.Index_signature_in_type_0_only_permits_reading, typeToString(objectType));
60679                 }
60680                 return type;
60681             }
60682             var apparentObjectType = getApparentType(objectType);
60683             if (getIndexInfoOfType(apparentObjectType, 1) && isTypeAssignableToKind(indexType, 296)) {
60684                 return type;
60685             }
60686             if (isGenericObjectType(objectType)) {
60687                 var propertyName_1 = getPropertyNameFromIndex(indexType, accessNode);
60688                 if (propertyName_1) {
60689                     var propertySymbol = forEachType(apparentObjectType, function (t) { return getPropertyOfType(t, propertyName_1); });
60690                     if (propertySymbol && ts.getDeclarationModifierFlagsFromSymbol(propertySymbol) & 24) {
60691                         error(accessNode, ts.Diagnostics.Private_or_protected_member_0_cannot_be_accessed_on_a_type_parameter, ts.unescapeLeadingUnderscores(propertyName_1));
60692                         return errorType;
60693                     }
60694                 }
60695             }
60696             error(accessNode, ts.Diagnostics.Type_0_cannot_be_used_to_index_type_1, typeToString(indexType), typeToString(objectType));
60697             return errorType;
60698         }
60699         function checkIndexedAccessType(node) {
60700             checkSourceElement(node.objectType);
60701             checkSourceElement(node.indexType);
60702             checkIndexedAccessIndexType(getTypeFromIndexedAccessTypeNode(node), node);
60703         }
60704         function checkMappedType(node) {
60705             checkSourceElement(node.typeParameter);
60706             checkSourceElement(node.nameType);
60707             checkSourceElement(node.type);
60708             if (!node.type) {
60709                 reportImplicitAny(node, anyType);
60710             }
60711             var type = getTypeFromMappedTypeNode(node);
60712             var nameType = getNameTypeFromMappedType(type);
60713             if (nameType) {
60714                 checkTypeAssignableTo(nameType, keyofConstraintType, node.nameType);
60715             }
60716             else {
60717                 var constraintType = getConstraintTypeFromMappedType(type);
60718                 checkTypeAssignableTo(constraintType, keyofConstraintType, ts.getEffectiveConstraintOfTypeParameter(node.typeParameter));
60719             }
60720         }
60721         function checkThisType(node) {
60722             getTypeFromThisTypeNode(node);
60723         }
60724         function checkTypeOperator(node) {
60725             checkGrammarTypeOperatorNode(node);
60726             checkSourceElement(node.type);
60727         }
60728         function checkConditionalType(node) {
60729             ts.forEachChild(node, checkSourceElement);
60730         }
60731         function checkInferType(node) {
60732             if (!ts.findAncestor(node, function (n) { return n.parent && n.parent.kind === 184 && n.parent.extendsType === n; })) {
60733                 grammarErrorOnNode(node, ts.Diagnostics.infer_declarations_are_only_permitted_in_the_extends_clause_of_a_conditional_type);
60734             }
60735             checkSourceElement(node.typeParameter);
60736             registerForUnusedIdentifiersCheck(node);
60737         }
60738         function checkTemplateLiteralType(node) {
60739             for (var _i = 0, _a = node.templateSpans; _i < _a.length; _i++) {
60740                 var span = _a[_i];
60741                 checkSourceElement(span.type);
60742                 var type = getTypeFromTypeNode(span.type);
60743                 checkTypeAssignableTo(type, templateConstraintType, span.type);
60744             }
60745             getTypeFromTypeNode(node);
60746         }
60747         function checkImportType(node) {
60748             checkSourceElement(node.argument);
60749             getTypeFromTypeNode(node);
60750         }
60751         function checkNamedTupleMember(node) {
60752             if (node.dotDotDotToken && node.questionToken) {
60753                 grammarErrorOnNode(node, ts.Diagnostics.A_tuple_member_cannot_be_both_optional_and_rest);
60754             }
60755             if (node.type.kind === 180) {
60756                 grammarErrorOnNode(node.type, ts.Diagnostics.A_labeled_tuple_element_is_declared_as_optional_with_a_question_mark_after_the_name_and_before_the_colon_rather_than_after_the_type);
60757             }
60758             if (node.type.kind === 181) {
60759                 grammarErrorOnNode(node.type, ts.Diagnostics.A_labeled_tuple_element_is_declared_as_rest_with_a_before_the_name_rather_than_before_the_type);
60760             }
60761             checkSourceElement(node.type);
60762             getTypeFromTypeNode(node);
60763         }
60764         function isPrivateWithinAmbient(node) {
60765             return (ts.hasEffectiveModifier(node, 8) || ts.isPrivateIdentifierPropertyDeclaration(node)) && !!(node.flags & 8388608);
60766         }
60767         function getEffectiveDeclarationFlags(n, flagsToCheck) {
60768             var flags = ts.getCombinedModifierFlags(n);
60769             if (n.parent.kind !== 253 &&
60770                 n.parent.kind !== 252 &&
60771                 n.parent.kind !== 221 &&
60772                 n.flags & 8388608) {
60773                 if (!(flags & 2) && !(ts.isModuleBlock(n.parent) && ts.isModuleDeclaration(n.parent.parent) && ts.isGlobalScopeAugmentation(n.parent.parent))) {
60774                     flags |= 1;
60775                 }
60776                 flags |= 2;
60777             }
60778             return flags & flagsToCheck;
60779         }
60780         function checkFunctionOrConstructorSymbol(symbol) {
60781             if (!produceDiagnostics) {
60782                 return;
60783             }
60784             function getCanonicalOverload(overloads, implementation) {
60785                 var implementationSharesContainerWithFirstOverload = implementation !== undefined && implementation.parent === overloads[0].parent;
60786                 return implementationSharesContainerWithFirstOverload ? implementation : overloads[0];
60787             }
60788             function checkFlagAgreementBetweenOverloads(overloads, implementation, flagsToCheck, someOverloadFlags, allOverloadFlags) {
60789                 var someButNotAllOverloadFlags = someOverloadFlags ^ allOverloadFlags;
60790                 if (someButNotAllOverloadFlags !== 0) {
60791                     var canonicalFlags_1 = getEffectiveDeclarationFlags(getCanonicalOverload(overloads, implementation), flagsToCheck);
60792                     ts.forEach(overloads, function (o) {
60793                         var deviation = getEffectiveDeclarationFlags(o, flagsToCheck) ^ canonicalFlags_1;
60794                         if (deviation & 1) {
60795                             error(ts.getNameOfDeclaration(o), ts.Diagnostics.Overload_signatures_must_all_be_exported_or_non_exported);
60796                         }
60797                         else if (deviation & 2) {
60798                             error(ts.getNameOfDeclaration(o), ts.Diagnostics.Overload_signatures_must_all_be_ambient_or_non_ambient);
60799                         }
60800                         else if (deviation & (8 | 16)) {
60801                             error(ts.getNameOfDeclaration(o) || o, ts.Diagnostics.Overload_signatures_must_all_be_public_private_or_protected);
60802                         }
60803                         else if (deviation & 128) {
60804                             error(ts.getNameOfDeclaration(o), ts.Diagnostics.Overload_signatures_must_all_be_abstract_or_non_abstract);
60805                         }
60806                     });
60807                 }
60808             }
60809             function checkQuestionTokenAgreementBetweenOverloads(overloads, implementation, someHaveQuestionToken, allHaveQuestionToken) {
60810                 if (someHaveQuestionToken !== allHaveQuestionToken) {
60811                     var canonicalHasQuestionToken_1 = ts.hasQuestionToken(getCanonicalOverload(overloads, implementation));
60812                     ts.forEach(overloads, function (o) {
60813                         var deviation = ts.hasQuestionToken(o) !== canonicalHasQuestionToken_1;
60814                         if (deviation) {
60815                             error(ts.getNameOfDeclaration(o), ts.Diagnostics.Overload_signatures_must_all_be_optional_or_required);
60816                         }
60817                     });
60818                 }
60819             }
60820             var flagsToCheck = 1 | 2 | 8 | 16 | 128;
60821             var someNodeFlags = 0;
60822             var allNodeFlags = flagsToCheck;
60823             var someHaveQuestionToken = false;
60824             var allHaveQuestionToken = true;
60825             var hasOverloads = false;
60826             var bodyDeclaration;
60827             var lastSeenNonAmbientDeclaration;
60828             var previousDeclaration;
60829             var declarations = symbol.declarations;
60830             var isConstructor = (symbol.flags & 16384) !== 0;
60831             function reportImplementationExpectedError(node) {
60832                 if (node.name && ts.nodeIsMissing(node.name)) {
60833                     return;
60834                 }
60835                 var seen = false;
60836                 var subsequentNode = ts.forEachChild(node.parent, function (c) {
60837                     if (seen) {
60838                         return c;
60839                     }
60840                     else {
60841                         seen = c === node;
60842                     }
60843                 });
60844                 if (subsequentNode && subsequentNode.pos === node.end) {
60845                     if (subsequentNode.kind === node.kind) {
60846                         var errorNode_1 = subsequentNode.name || subsequentNode;
60847                         var subsequentName = subsequentNode.name;
60848                         if (node.name && subsequentName && (ts.isPrivateIdentifier(node.name) && ts.isPrivateIdentifier(subsequentName) && node.name.escapedText === subsequentName.escapedText ||
60849                             ts.isComputedPropertyName(node.name) && ts.isComputedPropertyName(subsequentName) ||
60850                             ts.isPropertyNameLiteral(node.name) && ts.isPropertyNameLiteral(subsequentName) &&
60851                                 ts.getEscapedTextOfIdentifierOrLiteral(node.name) === ts.getEscapedTextOfIdentifierOrLiteral(subsequentName))) {
60852                             var reportError = (node.kind === 165 || node.kind === 164) &&
60853                                 ts.hasSyntacticModifier(node, 32) !== ts.hasSyntacticModifier(subsequentNode, 32);
60854                             if (reportError) {
60855                                 var diagnostic = ts.hasSyntacticModifier(node, 32) ? ts.Diagnostics.Function_overload_must_be_static : ts.Diagnostics.Function_overload_must_not_be_static;
60856                                 error(errorNode_1, diagnostic);
60857                             }
60858                             return;
60859                         }
60860                         if (ts.nodeIsPresent(subsequentNode.body)) {
60861                             error(errorNode_1, ts.Diagnostics.Function_implementation_name_must_be_0, ts.declarationNameToString(node.name));
60862                             return;
60863                         }
60864                     }
60865                 }
60866                 var errorNode = node.name || node;
60867                 if (isConstructor) {
60868                     error(errorNode, ts.Diagnostics.Constructor_implementation_is_missing);
60869                 }
60870                 else {
60871                     if (ts.hasSyntacticModifier(node, 128)) {
60872                         error(errorNode, ts.Diagnostics.All_declarations_of_an_abstract_method_must_be_consecutive);
60873                     }
60874                     else {
60875                         error(errorNode, ts.Diagnostics.Function_implementation_is_missing_or_not_immediately_following_the_declaration);
60876                     }
60877                 }
60878             }
60879             var duplicateFunctionDeclaration = false;
60880             var multipleConstructorImplementation = false;
60881             var hasNonAmbientClass = false;
60882             var functionDeclarations = [];
60883             for (var _i = 0, declarations_4 = declarations; _i < declarations_4.length; _i++) {
60884                 var current = declarations_4[_i];
60885                 var node = current;
60886                 var inAmbientContext = node.flags & 8388608;
60887                 var inAmbientContextOrInterface = node.parent && (node.parent.kind === 253 || node.parent.kind === 177) || inAmbientContext;
60888                 if (inAmbientContextOrInterface) {
60889                     previousDeclaration = undefined;
60890                 }
60891                 if ((node.kind === 252 || node.kind === 221) && !inAmbientContext) {
60892                     hasNonAmbientClass = true;
60893                 }
60894                 if (node.kind === 251 || node.kind === 165 || node.kind === 164 || node.kind === 166) {
60895                     functionDeclarations.push(node);
60896                     var currentNodeFlags = getEffectiveDeclarationFlags(node, flagsToCheck);
60897                     someNodeFlags |= currentNodeFlags;
60898                     allNodeFlags &= currentNodeFlags;
60899                     someHaveQuestionToken = someHaveQuestionToken || ts.hasQuestionToken(node);
60900                     allHaveQuestionToken = allHaveQuestionToken && ts.hasQuestionToken(node);
60901                     var bodyIsPresent = ts.nodeIsPresent(node.body);
60902                     if (bodyIsPresent && bodyDeclaration) {
60903                         if (isConstructor) {
60904                             multipleConstructorImplementation = true;
60905                         }
60906                         else {
60907                             duplicateFunctionDeclaration = true;
60908                         }
60909                     }
60910                     else if ((previousDeclaration === null || previousDeclaration === void 0 ? void 0 : previousDeclaration.parent) === node.parent && previousDeclaration.end !== node.pos) {
60911                         reportImplementationExpectedError(previousDeclaration);
60912                     }
60913                     if (bodyIsPresent) {
60914                         if (!bodyDeclaration) {
60915                             bodyDeclaration = node;
60916                         }
60917                     }
60918                     else {
60919                         hasOverloads = true;
60920                     }
60921                     previousDeclaration = node;
60922                     if (!inAmbientContextOrInterface) {
60923                         lastSeenNonAmbientDeclaration = node;
60924                     }
60925                 }
60926             }
60927             if (multipleConstructorImplementation) {
60928                 ts.forEach(functionDeclarations, function (declaration) {
60929                     error(declaration, ts.Diagnostics.Multiple_constructor_implementations_are_not_allowed);
60930                 });
60931             }
60932             if (duplicateFunctionDeclaration) {
60933                 ts.forEach(functionDeclarations, function (declaration) {
60934                     error(ts.getNameOfDeclaration(declaration) || declaration, ts.Diagnostics.Duplicate_function_implementation);
60935                 });
60936             }
60937             if (hasNonAmbientClass && !isConstructor && symbol.flags & 16) {
60938                 ts.forEach(declarations, function (declaration) {
60939                     addDuplicateDeclarationError(declaration, ts.Diagnostics.Duplicate_identifier_0, ts.symbolName(symbol), declarations);
60940                 });
60941             }
60942             if (lastSeenNonAmbientDeclaration && !lastSeenNonAmbientDeclaration.body &&
60943                 !ts.hasSyntacticModifier(lastSeenNonAmbientDeclaration, 128) && !lastSeenNonAmbientDeclaration.questionToken) {
60944                 reportImplementationExpectedError(lastSeenNonAmbientDeclaration);
60945             }
60946             if (hasOverloads) {
60947                 checkFlagAgreementBetweenOverloads(declarations, bodyDeclaration, flagsToCheck, someNodeFlags, allNodeFlags);
60948                 checkQuestionTokenAgreementBetweenOverloads(declarations, bodyDeclaration, someHaveQuestionToken, allHaveQuestionToken);
60949                 if (bodyDeclaration) {
60950                     var signatures = getSignaturesOfSymbol(symbol);
60951                     var bodySignature = getSignatureFromDeclaration(bodyDeclaration);
60952                     for (var _a = 0, signatures_10 = signatures; _a < signatures_10.length; _a++) {
60953                         var signature = signatures_10[_a];
60954                         if (!isImplementationCompatibleWithOverload(bodySignature, signature)) {
60955                             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));
60956                             break;
60957                         }
60958                     }
60959                 }
60960             }
60961         }
60962         function checkExportsOnMergedDeclarations(node) {
60963             if (!produceDiagnostics) {
60964                 return;
60965             }
60966             var symbol = node.localSymbol;
60967             if (!symbol) {
60968                 symbol = getSymbolOfNode(node);
60969                 if (!symbol.exportSymbol) {
60970                     return;
60971                 }
60972             }
60973             if (ts.getDeclarationOfKind(symbol, node.kind) !== node) {
60974                 return;
60975             }
60976             var exportedDeclarationSpaces = 0;
60977             var nonExportedDeclarationSpaces = 0;
60978             var defaultExportedDeclarationSpaces = 0;
60979             for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) {
60980                 var d = _a[_i];
60981                 var declarationSpaces = getDeclarationSpaces(d);
60982                 var effectiveDeclarationFlags = getEffectiveDeclarationFlags(d, 1 | 512);
60983                 if (effectiveDeclarationFlags & 1) {
60984                     if (effectiveDeclarationFlags & 512) {
60985                         defaultExportedDeclarationSpaces |= declarationSpaces;
60986                     }
60987                     else {
60988                         exportedDeclarationSpaces |= declarationSpaces;
60989                     }
60990                 }
60991                 else {
60992                     nonExportedDeclarationSpaces |= declarationSpaces;
60993                 }
60994             }
60995             var nonDefaultExportedDeclarationSpaces = exportedDeclarationSpaces | nonExportedDeclarationSpaces;
60996             var commonDeclarationSpacesForExportsAndLocals = exportedDeclarationSpaces & nonExportedDeclarationSpaces;
60997             var commonDeclarationSpacesForDefaultAndNonDefault = defaultExportedDeclarationSpaces & nonDefaultExportedDeclarationSpaces;
60998             if (commonDeclarationSpacesForExportsAndLocals || commonDeclarationSpacesForDefaultAndNonDefault) {
60999                 for (var _b = 0, _c = symbol.declarations; _b < _c.length; _b++) {
61000                     var d = _c[_b];
61001                     var declarationSpaces = getDeclarationSpaces(d);
61002                     var name = ts.getNameOfDeclaration(d);
61003                     if (declarationSpaces & commonDeclarationSpacesForDefaultAndNonDefault) {
61004                         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));
61005                     }
61006                     else if (declarationSpaces & commonDeclarationSpacesForExportsAndLocals) {
61007                         error(name, ts.Diagnostics.Individual_declarations_in_merged_declaration_0_must_be_all_exported_or_all_local, ts.declarationNameToString(name));
61008                     }
61009                 }
61010             }
61011             function getDeclarationSpaces(decl) {
61012                 var d = decl;
61013                 switch (d.kind) {
61014                     case 253:
61015                     case 254:
61016                     case 331:
61017                     case 324:
61018                     case 325:
61019                         return 2;
61020                     case 256:
61021                         return ts.isAmbientModule(d) || ts.getModuleInstanceState(d) !== 0
61022                             ? 4 | 1
61023                             : 4;
61024                     case 252:
61025                     case 255:
61026                     case 291:
61027                         return 2 | 1;
61028                     case 297:
61029                         return 2 | 1 | 4;
61030                     case 266:
61031                         if (!ts.isEntityNameExpression(d.expression)) {
61032                             return 1;
61033                         }
61034                         d = d.expression;
61035                     case 260:
61036                     case 263:
61037                     case 262:
61038                         var result_12 = 0;
61039                         var target = resolveAlias(getSymbolOfNode(d));
61040                         ts.forEach(target.declarations, function (d) { result_12 |= getDeclarationSpaces(d); });
61041                         return result_12;
61042                     case 249:
61043                     case 198:
61044                     case 251:
61045                     case 265:
61046                     case 78:
61047                         return 1;
61048                     default:
61049                         return ts.Debug.failBadSyntaxKind(d);
61050                 }
61051             }
61052         }
61053         function getAwaitedTypeOfPromise(type, errorNode, diagnosticMessage, arg0) {
61054             var promisedType = getPromisedTypeOfPromise(type, errorNode);
61055             return promisedType && getAwaitedType(promisedType, errorNode, diagnosticMessage, arg0);
61056         }
61057         function getPromisedTypeOfPromise(type, errorNode) {
61058             if (isTypeAny(type)) {
61059                 return undefined;
61060             }
61061             var typeAsPromise = type;
61062             if (typeAsPromise.promisedTypeOfPromise) {
61063                 return typeAsPromise.promisedTypeOfPromise;
61064             }
61065             if (isReferenceToType(type, getGlobalPromiseType(false))) {
61066                 return typeAsPromise.promisedTypeOfPromise = getTypeArguments(type)[0];
61067             }
61068             var thenFunction = getTypeOfPropertyOfType(type, "then");
61069             if (isTypeAny(thenFunction)) {
61070                 return undefined;
61071             }
61072             var thenSignatures = thenFunction ? getSignaturesOfType(thenFunction, 0) : ts.emptyArray;
61073             if (thenSignatures.length === 0) {
61074                 if (errorNode) {
61075                     error(errorNode, ts.Diagnostics.A_promise_must_have_a_then_method);
61076                 }
61077                 return undefined;
61078             }
61079             var onfulfilledParameterType = getTypeWithFacts(getUnionType(ts.map(thenSignatures, getTypeOfFirstParameterOfSignature)), 2097152);
61080             if (isTypeAny(onfulfilledParameterType)) {
61081                 return undefined;
61082             }
61083             var onfulfilledParameterSignatures = getSignaturesOfType(onfulfilledParameterType, 0);
61084             if (onfulfilledParameterSignatures.length === 0) {
61085                 if (errorNode) {
61086                     error(errorNode, ts.Diagnostics.The_first_parameter_of_the_then_method_of_a_promise_must_be_a_callback);
61087                 }
61088                 return undefined;
61089             }
61090             return typeAsPromise.promisedTypeOfPromise = getUnionType(ts.map(onfulfilledParameterSignatures, getTypeOfFirstParameterOfSignature), 2);
61091         }
61092         function checkAwaitedType(type, errorNode, diagnosticMessage, arg0) {
61093             var awaitedType = getAwaitedType(type, errorNode, diagnosticMessage, arg0);
61094             return awaitedType || errorType;
61095         }
61096         function isThenableType(type) {
61097             var thenFunction = getTypeOfPropertyOfType(type, "then");
61098             return !!thenFunction && getSignaturesOfType(getTypeWithFacts(thenFunction, 2097152), 0).length > 0;
61099         }
61100         function getAwaitedType(type, errorNode, diagnosticMessage, arg0) {
61101             if (isTypeAny(type)) {
61102                 return type;
61103             }
61104             var typeAsAwaitable = type;
61105             if (typeAsAwaitable.awaitedTypeOfType) {
61106                 return typeAsAwaitable.awaitedTypeOfType;
61107             }
61108             return typeAsAwaitable.awaitedTypeOfType =
61109                 mapType(type, errorNode ? function (constituentType) { return getAwaitedTypeWorker(constituentType, errorNode, diagnosticMessage, arg0); } : getAwaitedTypeWorker);
61110         }
61111         function getAwaitedTypeWorker(type, errorNode, diagnosticMessage, arg0) {
61112             var typeAsAwaitable = type;
61113             if (typeAsAwaitable.awaitedTypeOfType) {
61114                 return typeAsAwaitable.awaitedTypeOfType;
61115             }
61116             var promisedType = getPromisedTypeOfPromise(type);
61117             if (promisedType) {
61118                 if (type.id === promisedType.id || awaitedTypeStack.lastIndexOf(promisedType.id) >= 0) {
61119                     if (errorNode) {
61120                         error(errorNode, ts.Diagnostics.Type_is_referenced_directly_or_indirectly_in_the_fulfillment_callback_of_its_own_then_method);
61121                     }
61122                     return undefined;
61123                 }
61124                 awaitedTypeStack.push(type.id);
61125                 var awaitedType = getAwaitedType(promisedType, errorNode, diagnosticMessage, arg0);
61126                 awaitedTypeStack.pop();
61127                 if (!awaitedType) {
61128                     return undefined;
61129                 }
61130                 return typeAsAwaitable.awaitedTypeOfType = awaitedType;
61131             }
61132             if (isThenableType(type)) {
61133                 if (errorNode) {
61134                     if (!diagnosticMessage)
61135                         return ts.Debug.fail();
61136                     error(errorNode, diagnosticMessage, arg0);
61137                 }
61138                 return undefined;
61139             }
61140             return typeAsAwaitable.awaitedTypeOfType = type;
61141         }
61142         function checkAsyncFunctionReturnType(node, returnTypeNode) {
61143             var returnType = getTypeFromTypeNode(returnTypeNode);
61144             if (languageVersion >= 2) {
61145                 if (returnType === errorType) {
61146                     return;
61147                 }
61148                 var globalPromiseType = getGlobalPromiseType(true);
61149                 if (globalPromiseType !== emptyGenericType && !isReferenceToType(returnType, globalPromiseType)) {
61150                     error(returnTypeNode, ts.Diagnostics.The_return_type_of_an_async_function_or_method_must_be_the_global_Promise_T_type_Did_you_mean_to_write_Promise_0, typeToString(getAwaitedType(returnType) || voidType));
61151                     return;
61152                 }
61153             }
61154             else {
61155                 markTypeNodeAsReferenced(returnTypeNode);
61156                 if (returnType === errorType) {
61157                     return;
61158                 }
61159                 var promiseConstructorName = ts.getEntityNameFromTypeNode(returnTypeNode);
61160                 if (promiseConstructorName === undefined) {
61161                     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));
61162                     return;
61163                 }
61164                 var promiseConstructorSymbol = resolveEntityName(promiseConstructorName, 111551, true);
61165                 var promiseConstructorType = promiseConstructorSymbol ? getTypeOfSymbol(promiseConstructorSymbol) : errorType;
61166                 if (promiseConstructorType === errorType) {
61167                     if (promiseConstructorName.kind === 78 && promiseConstructorName.escapedText === "Promise" && getTargetType(returnType) === getGlobalPromiseType(false)) {
61168                         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);
61169                     }
61170                     else {
61171                         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));
61172                     }
61173                     return;
61174                 }
61175                 var globalPromiseConstructorLikeType = getGlobalPromiseConstructorLikeType(true);
61176                 if (globalPromiseConstructorLikeType === emptyObjectType) {
61177                     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));
61178                     return;
61179                 }
61180                 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)) {
61181                     return;
61182                 }
61183                 var rootName = promiseConstructorName && ts.getFirstIdentifier(promiseConstructorName);
61184                 var collidingSymbol = getSymbol(node.locals, rootName.escapedText, 111551);
61185                 if (collidingSymbol) {
61186                     error(collidingSymbol.valueDeclaration, ts.Diagnostics.Duplicate_identifier_0_Compiler_uses_declaration_1_to_support_async_functions, ts.idText(rootName), ts.entityNameToString(promiseConstructorName));
61187                     return;
61188                 }
61189             }
61190             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);
61191         }
61192         function checkDecorator(node) {
61193             var signature = getResolvedSignature(node);
61194             checkDeprecatedSignature(signature, node);
61195             var returnType = getReturnTypeOfSignature(signature);
61196             if (returnType.flags & 1) {
61197                 return;
61198             }
61199             var expectedReturnType;
61200             var headMessage = getDiagnosticHeadMessageForDecoratorResolution(node);
61201             var errorInfo;
61202             switch (node.parent.kind) {
61203                 case 252:
61204                     var classSymbol = getSymbolOfNode(node.parent);
61205                     var classConstructorType = getTypeOfSymbol(classSymbol);
61206                     expectedReturnType = getUnionType([classConstructorType, voidType]);
61207                     break;
61208                 case 160:
61209                     expectedReturnType = voidType;
61210                     errorInfo = ts.chainDiagnosticMessages(undefined, ts.Diagnostics.The_return_type_of_a_parameter_decorator_function_must_be_either_void_or_any);
61211                     break;
61212                 case 163:
61213                     expectedReturnType = voidType;
61214                     errorInfo = ts.chainDiagnosticMessages(undefined, ts.Diagnostics.The_return_type_of_a_property_decorator_function_must_be_either_void_or_any);
61215                     break;
61216                 case 165:
61217                 case 167:
61218                 case 168:
61219                     var methodType = getTypeOfNode(node.parent);
61220                     var descriptorType = createTypedPropertyDescriptorType(methodType);
61221                     expectedReturnType = getUnionType([descriptorType, voidType]);
61222                     break;
61223                 default:
61224                     return ts.Debug.fail();
61225             }
61226             checkTypeAssignableTo(returnType, expectedReturnType, node, headMessage, function () { return errorInfo; });
61227         }
61228         function markTypeNodeAsReferenced(node) {
61229             markEntityNameOrEntityExpressionAsReference(node && ts.getEntityNameFromTypeNode(node));
61230         }
61231         function markEntityNameOrEntityExpressionAsReference(typeName) {
61232             if (!typeName)
61233                 return;
61234             var rootName = ts.getFirstIdentifier(typeName);
61235             var meaning = (typeName.kind === 78 ? 788968 : 1920) | 2097152;
61236             var rootSymbol = resolveName(rootName, rootName.escapedText, meaning, undefined, undefined, true);
61237             if (rootSymbol
61238                 && rootSymbol.flags & 2097152
61239                 && symbolIsValue(rootSymbol)
61240                 && !isConstEnumOrConstEnumOnlyModule(resolveAlias(rootSymbol))
61241                 && !getTypeOnlyAliasDeclaration(rootSymbol)) {
61242                 markAliasSymbolAsReferenced(rootSymbol);
61243             }
61244         }
61245         function markDecoratorMedataDataTypeNodeAsReferenced(node) {
61246             var entityName = getEntityNameForDecoratorMetadata(node);
61247             if (entityName && ts.isEntityName(entityName)) {
61248                 markEntityNameOrEntityExpressionAsReference(entityName);
61249             }
61250         }
61251         function getEntityNameForDecoratorMetadata(node) {
61252             if (node) {
61253                 switch (node.kind) {
61254                     case 183:
61255                     case 182:
61256                         return getEntityNameForDecoratorMetadataFromTypeList(node.types);
61257                     case 184:
61258                         return getEntityNameForDecoratorMetadataFromTypeList([node.trueType, node.falseType]);
61259                     case 186:
61260                     case 192:
61261                         return getEntityNameForDecoratorMetadata(node.type);
61262                     case 173:
61263                         return node.typeName;
61264                 }
61265             }
61266         }
61267         function getEntityNameForDecoratorMetadataFromTypeList(types) {
61268             var commonEntityName;
61269             for (var _i = 0, types_21 = types; _i < types_21.length; _i++) {
61270                 var typeNode = types_21[_i];
61271                 while (typeNode.kind === 186 || typeNode.kind === 192) {
61272                     typeNode = typeNode.type;
61273                 }
61274                 if (typeNode.kind === 141) {
61275                     continue;
61276                 }
61277                 if (!strictNullChecks && (typeNode.kind === 191 && typeNode.literal.kind === 103 || typeNode.kind === 150)) {
61278                     continue;
61279                 }
61280                 var individualEntityName = getEntityNameForDecoratorMetadata(typeNode);
61281                 if (!individualEntityName) {
61282                     return undefined;
61283                 }
61284                 if (commonEntityName) {
61285                     if (!ts.isIdentifier(commonEntityName) ||
61286                         !ts.isIdentifier(individualEntityName) ||
61287                         commonEntityName.escapedText !== individualEntityName.escapedText) {
61288                         return undefined;
61289                     }
61290                 }
61291                 else {
61292                     commonEntityName = individualEntityName;
61293                 }
61294             }
61295             return commonEntityName;
61296         }
61297         function getParameterTypeNodeForDecoratorCheck(node) {
61298             var typeNode = ts.getEffectiveTypeAnnotationNode(node);
61299             return ts.isRestParameter(node) ? ts.getRestParameterElementType(typeNode) : typeNode;
61300         }
61301         function checkDecorators(node) {
61302             if (!node.decorators) {
61303                 return;
61304             }
61305             if (!ts.nodeCanBeDecorated(node, node.parent, node.parent.parent)) {
61306                 return;
61307             }
61308             if (!compilerOptions.experimentalDecorators) {
61309                 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);
61310             }
61311             var firstDecorator = node.decorators[0];
61312             checkExternalEmitHelpers(firstDecorator, 8);
61313             if (node.kind === 160) {
61314                 checkExternalEmitHelpers(firstDecorator, 32);
61315             }
61316             if (compilerOptions.emitDecoratorMetadata) {
61317                 checkExternalEmitHelpers(firstDecorator, 16);
61318                 switch (node.kind) {
61319                     case 252:
61320                         var constructor = ts.getFirstConstructorWithBody(node);
61321                         if (constructor) {
61322                             for (var _i = 0, _a = constructor.parameters; _i < _a.length; _i++) {
61323                                 var parameter = _a[_i];
61324                                 markDecoratorMedataDataTypeNodeAsReferenced(getParameterTypeNodeForDecoratorCheck(parameter));
61325                             }
61326                         }
61327                         break;
61328                     case 167:
61329                     case 168:
61330                         var otherKind = node.kind === 167 ? 168 : 167;
61331                         var otherAccessor = ts.getDeclarationOfKind(getSymbolOfNode(node), otherKind);
61332                         markDecoratorMedataDataTypeNodeAsReferenced(getAnnotatedAccessorTypeNode(node) || otherAccessor && getAnnotatedAccessorTypeNode(otherAccessor));
61333                         break;
61334                     case 165:
61335                         for (var _b = 0, _c = node.parameters; _b < _c.length; _b++) {
61336                             var parameter = _c[_b];
61337                             markDecoratorMedataDataTypeNodeAsReferenced(getParameterTypeNodeForDecoratorCheck(parameter));
61338                         }
61339                         markDecoratorMedataDataTypeNodeAsReferenced(ts.getEffectiveReturnTypeNode(node));
61340                         break;
61341                     case 163:
61342                         markDecoratorMedataDataTypeNodeAsReferenced(ts.getEffectiveTypeAnnotationNode(node));
61343                         break;
61344                     case 160:
61345                         markDecoratorMedataDataTypeNodeAsReferenced(getParameterTypeNodeForDecoratorCheck(node));
61346                         var containingSignature = node.parent;
61347                         for (var _d = 0, _e = containingSignature.parameters; _d < _e.length; _d++) {
61348                             var parameter = _e[_d];
61349                             markDecoratorMedataDataTypeNodeAsReferenced(getParameterTypeNodeForDecoratorCheck(parameter));
61350                         }
61351                         break;
61352                 }
61353             }
61354             ts.forEach(node.decorators, checkDecorator);
61355         }
61356         function checkFunctionDeclaration(node) {
61357             if (produceDiagnostics) {
61358                 checkFunctionOrMethodDeclaration(node);
61359                 checkGrammarForGenerator(node);
61360                 checkCollisionWithRequireExportsInGeneratedCode(node, node.name);
61361                 checkCollisionWithGlobalPromiseInGeneratedCode(node, node.name);
61362             }
61363         }
61364         function checkJSDocTypeAliasTag(node) {
61365             if (!node.typeExpression) {
61366                 error(node.name, ts.Diagnostics.JSDoc_typedef_tag_should_either_have_a_type_annotation_or_be_followed_by_property_or_member_tags);
61367             }
61368             if (node.name) {
61369                 checkTypeNameIsReserved(node.name, ts.Diagnostics.Type_alias_name_cannot_be_0);
61370             }
61371             checkSourceElement(node.typeExpression);
61372         }
61373         function checkJSDocTemplateTag(node) {
61374             checkSourceElement(node.constraint);
61375             for (var _i = 0, _a = node.typeParameters; _i < _a.length; _i++) {
61376                 var tp = _a[_i];
61377                 checkSourceElement(tp);
61378             }
61379         }
61380         function checkJSDocTypeTag(node) {
61381             checkSourceElement(node.typeExpression);
61382         }
61383         function checkJSDocParameterTag(node) {
61384             checkSourceElement(node.typeExpression);
61385             if (!ts.getParameterSymbolFromJSDoc(node)) {
61386                 var decl = ts.getHostSignatureFromJSDoc(node);
61387                 if (decl) {
61388                     var i = ts.getJSDocTags(decl).filter(ts.isJSDocParameterTag).indexOf(node);
61389                     if (i > -1 && i < decl.parameters.length && ts.isBindingPattern(decl.parameters[i].name)) {
61390                         return;
61391                     }
61392                     if (!containsArgumentsReference(decl)) {
61393                         if (ts.isQualifiedName(node.name)) {
61394                             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));
61395                         }
61396                         else {
61397                             error(node.name, ts.Diagnostics.JSDoc_param_tag_has_name_0_but_there_is_no_parameter_with_that_name, ts.idText(node.name));
61398                         }
61399                     }
61400                     else if (ts.findLast(ts.getJSDocTags(decl), ts.isJSDocParameterTag) === node &&
61401                         node.typeExpression && node.typeExpression.type &&
61402                         !isArrayType(getTypeFromTypeNode(node.typeExpression.type))) {
61403                         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 === 157 ? node.name.right : node.name));
61404                     }
61405                 }
61406             }
61407         }
61408         function checkJSDocPropertyTag(node) {
61409             checkSourceElement(node.typeExpression);
61410         }
61411         function checkJSDocFunctionType(node) {
61412             if (produceDiagnostics && !node.type && !ts.isJSDocConstructSignature(node)) {
61413                 reportImplicitAny(node, anyType);
61414             }
61415             checkSignatureDeclaration(node);
61416         }
61417         function checkJSDocImplementsTag(node) {
61418             var classLike = ts.getEffectiveJSDocHost(node);
61419             if (!classLike || !ts.isClassDeclaration(classLike) && !ts.isClassExpression(classLike)) {
61420                 error(classLike, ts.Diagnostics.JSDoc_0_is_not_attached_to_a_class, ts.idText(node.tagName));
61421             }
61422         }
61423         function checkJSDocAugmentsTag(node) {
61424             var classLike = ts.getEffectiveJSDocHost(node);
61425             if (!classLike || !ts.isClassDeclaration(classLike) && !ts.isClassExpression(classLike)) {
61426                 error(classLike, ts.Diagnostics.JSDoc_0_is_not_attached_to_a_class, ts.idText(node.tagName));
61427                 return;
61428             }
61429             var augmentsTags = ts.getJSDocTags(classLike).filter(ts.isJSDocAugmentsTag);
61430             ts.Debug.assert(augmentsTags.length > 0);
61431             if (augmentsTags.length > 1) {
61432                 error(augmentsTags[1], ts.Diagnostics.Class_declarations_cannot_have_more_than_one_augments_or_extends_tag);
61433             }
61434             var name = getIdentifierFromEntityNameExpression(node.class.expression);
61435             var extend = ts.getClassExtendsHeritageElement(classLike);
61436             if (extend) {
61437                 var className = getIdentifierFromEntityNameExpression(extend.expression);
61438                 if (className && name.escapedText !== className.escapedText) {
61439                     error(name, ts.Diagnostics.JSDoc_0_1_does_not_match_the_extends_2_clause, ts.idText(node.tagName), ts.idText(name), ts.idText(className));
61440                 }
61441             }
61442         }
61443         function getIdentifierFromEntityNameExpression(node) {
61444             switch (node.kind) {
61445                 case 78:
61446                     return node;
61447                 case 201:
61448                     return node.name;
61449                 default:
61450                     return undefined;
61451             }
61452         }
61453         function checkFunctionOrMethodDeclaration(node) {
61454             checkDecorators(node);
61455             checkSignatureDeclaration(node);
61456             var functionFlags = ts.getFunctionFlags(node);
61457             if (node.name && node.name.kind === 158) {
61458                 checkComputedPropertyName(node.name);
61459             }
61460             if (!hasNonBindableDynamicName(node)) {
61461                 var symbol = getSymbolOfNode(node);
61462                 var localSymbol = node.localSymbol || symbol;
61463                 var firstDeclaration = ts.find(localSymbol.declarations, function (declaration) { return declaration.kind === node.kind && !(declaration.flags & 131072); });
61464                 if (node === firstDeclaration) {
61465                     checkFunctionOrConstructorSymbol(localSymbol);
61466                 }
61467                 if (symbol.parent) {
61468                     checkFunctionOrConstructorSymbol(symbol);
61469                 }
61470             }
61471             var body = node.kind === 164 ? undefined : node.body;
61472             checkSourceElement(body);
61473             checkAllCodePathsInNonVoidFunctionReturnOrThrow(node, getReturnTypeFromAnnotation(node));
61474             if (produceDiagnostics && !ts.getEffectiveReturnTypeNode(node)) {
61475                 if (ts.nodeIsMissing(body) && !isPrivateWithinAmbient(node)) {
61476                     reportImplicitAny(node, anyType);
61477                 }
61478                 if (functionFlags & 1 && ts.nodeIsPresent(body)) {
61479                     getReturnTypeOfSignature(getSignatureFromDeclaration(node));
61480                 }
61481             }
61482             if (ts.isInJSFile(node)) {
61483                 var typeTag = ts.getJSDocTypeTag(node);
61484                 if (typeTag && typeTag.typeExpression && !getContextualCallSignature(getTypeFromTypeNode(typeTag.typeExpression), node)) {
61485                     error(typeTag, ts.Diagnostics.The_type_of_a_function_declaration_must_match_the_function_s_signature);
61486                 }
61487             }
61488         }
61489         function registerForUnusedIdentifiersCheck(node) {
61490             if (produceDiagnostics) {
61491                 var sourceFile = ts.getSourceFileOfNode(node);
61492                 var potentiallyUnusedIdentifiers = allPotentiallyUnusedIdentifiers.get(sourceFile.path);
61493                 if (!potentiallyUnusedIdentifiers) {
61494                     potentiallyUnusedIdentifiers = [];
61495                     allPotentiallyUnusedIdentifiers.set(sourceFile.path, potentiallyUnusedIdentifiers);
61496                 }
61497                 potentiallyUnusedIdentifiers.push(node);
61498             }
61499         }
61500         function checkUnusedIdentifiers(potentiallyUnusedIdentifiers, addDiagnostic) {
61501             for (var _i = 0, potentiallyUnusedIdentifiers_1 = potentiallyUnusedIdentifiers; _i < potentiallyUnusedIdentifiers_1.length; _i++) {
61502                 var node = potentiallyUnusedIdentifiers_1[_i];
61503                 switch (node.kind) {
61504                     case 252:
61505                     case 221:
61506                         checkUnusedClassMembers(node, addDiagnostic);
61507                         checkUnusedTypeParameters(node, addDiagnostic);
61508                         break;
61509                     case 297:
61510                     case 256:
61511                     case 230:
61512                     case 258:
61513                     case 237:
61514                     case 238:
61515                     case 239:
61516                         checkUnusedLocalsAndParameters(node, addDiagnostic);
61517                         break;
61518                     case 166:
61519                     case 208:
61520                     case 251:
61521                     case 209:
61522                     case 165:
61523                     case 167:
61524                     case 168:
61525                         if (node.body) {
61526                             checkUnusedLocalsAndParameters(node, addDiagnostic);
61527                         }
61528                         checkUnusedTypeParameters(node, addDiagnostic);
61529                         break;
61530                     case 164:
61531                     case 169:
61532                     case 170:
61533                     case 174:
61534                     case 175:
61535                     case 254:
61536                     case 253:
61537                         checkUnusedTypeParameters(node, addDiagnostic);
61538                         break;
61539                     case 185:
61540                         checkUnusedInferTypeParameter(node, addDiagnostic);
61541                         break;
61542                     default:
61543                         ts.Debug.assertNever(node, "Node should not have been registered for unused identifiers check");
61544                 }
61545             }
61546         }
61547         function errorUnusedLocal(declaration, name, addDiagnostic) {
61548             var node = ts.getNameOfDeclaration(declaration) || declaration;
61549             var message = isTypeDeclaration(declaration) ? ts.Diagnostics._0_is_declared_but_never_used : ts.Diagnostics._0_is_declared_but_its_value_is_never_read;
61550             addDiagnostic(declaration, 0, ts.createDiagnosticForNode(node, message, name));
61551         }
61552         function isIdentifierThatStartsWithUnderscore(node) {
61553             return ts.isIdentifier(node) && ts.idText(node).charCodeAt(0) === 95;
61554         }
61555         function checkUnusedClassMembers(node, addDiagnostic) {
61556             for (var _i = 0, _a = node.members; _i < _a.length; _i++) {
61557                 var member = _a[_i];
61558                 switch (member.kind) {
61559                     case 165:
61560                     case 163:
61561                     case 167:
61562                     case 168:
61563                         if (member.kind === 168 && member.symbol.flags & 32768) {
61564                             break;
61565                         }
61566                         var symbol = getSymbolOfNode(member);
61567                         if (!symbol.isReferenced
61568                             && (ts.hasEffectiveModifier(member, 8) || ts.isNamedDeclaration(member) && ts.isPrivateIdentifier(member.name))
61569                             && !(member.flags & 8388608)) {
61570                             addDiagnostic(member, 0, ts.createDiagnosticForNode(member.name, ts.Diagnostics._0_is_declared_but_its_value_is_never_read, symbolToString(symbol)));
61571                         }
61572                         break;
61573                     case 166:
61574                         for (var _b = 0, _c = member.parameters; _b < _c.length; _b++) {
61575                             var parameter = _c[_b];
61576                             if (!parameter.symbol.isReferenced && ts.hasSyntacticModifier(parameter, 8)) {
61577                                 addDiagnostic(parameter, 0, ts.createDiagnosticForNode(parameter.name, ts.Diagnostics.Property_0_is_declared_but_its_value_is_never_read, ts.symbolName(parameter.symbol)));
61578                             }
61579                         }
61580                         break;
61581                     case 171:
61582                     case 229:
61583                         break;
61584                     default:
61585                         ts.Debug.fail();
61586                 }
61587             }
61588         }
61589         function checkUnusedInferTypeParameter(node, addDiagnostic) {
61590             var typeParameter = node.typeParameter;
61591             if (isTypeParameterUnused(typeParameter)) {
61592                 addDiagnostic(node, 1, ts.createDiagnosticForNode(node, ts.Diagnostics._0_is_declared_but_its_value_is_never_read, ts.idText(typeParameter.name)));
61593             }
61594         }
61595         function checkUnusedTypeParameters(node, addDiagnostic) {
61596             if (ts.last(getSymbolOfNode(node).declarations) !== node)
61597                 return;
61598             var typeParameters = ts.getEffectiveTypeParameterDeclarations(node);
61599             var seenParentsWithEveryUnused = new ts.Set();
61600             for (var _i = 0, typeParameters_3 = typeParameters; _i < typeParameters_3.length; _i++) {
61601                 var typeParameter = typeParameters_3[_i];
61602                 if (!isTypeParameterUnused(typeParameter))
61603                     continue;
61604                 var name = ts.idText(typeParameter.name);
61605                 var parent = typeParameter.parent;
61606                 if (parent.kind !== 185 && parent.typeParameters.every(isTypeParameterUnused)) {
61607                     if (ts.tryAddToSet(seenParentsWithEveryUnused, parent)) {
61608                         var range = ts.isJSDocTemplateTag(parent)
61609                             ? ts.rangeOfNode(parent)
61610                             : ts.rangeOfTypeParameters(parent.typeParameters);
61611                         var only = parent.typeParameters.length === 1;
61612                         var message = only ? ts.Diagnostics._0_is_declared_but_its_value_is_never_read : ts.Diagnostics.All_type_parameters_are_unused;
61613                         var arg0 = only ? name : undefined;
61614                         addDiagnostic(typeParameter, 1, ts.createFileDiagnostic(ts.getSourceFileOfNode(parent), range.pos, range.end - range.pos, message, arg0));
61615                     }
61616                 }
61617                 else {
61618                     addDiagnostic(typeParameter, 1, ts.createDiagnosticForNode(typeParameter, ts.Diagnostics._0_is_declared_but_its_value_is_never_read, name));
61619                 }
61620             }
61621         }
61622         function isTypeParameterUnused(typeParameter) {
61623             return !(getMergedSymbol(typeParameter.symbol).isReferenced & 262144) && !isIdentifierThatStartsWithUnderscore(typeParameter.name);
61624         }
61625         function addToGroup(map, key, value, getKey) {
61626             var keyString = String(getKey(key));
61627             var group = map.get(keyString);
61628             if (group) {
61629                 group[1].push(value);
61630             }
61631             else {
61632                 map.set(keyString, [key, [value]]);
61633             }
61634         }
61635         function tryGetRootParameterDeclaration(node) {
61636             return ts.tryCast(ts.getRootDeclaration(node), ts.isParameter);
61637         }
61638         function isValidUnusedLocalDeclaration(declaration) {
61639             if (ts.isBindingElement(declaration) && isIdentifierThatStartsWithUnderscore(declaration.name)) {
61640                 return !!ts.findAncestor(declaration.parent, function (ancestor) {
61641                     return ts.isArrayBindingPattern(ancestor) || ts.isVariableDeclaration(ancestor) || ts.isVariableDeclarationList(ancestor) ? false :
61642                         ts.isForOfStatement(ancestor) ? true : "quit";
61643                 });
61644             }
61645             return ts.isAmbientModule(declaration) ||
61646                 (ts.isVariableDeclaration(declaration) && ts.isForInOrOfStatement(declaration.parent.parent) || isImportedDeclaration(declaration)) && isIdentifierThatStartsWithUnderscore(declaration.name);
61647         }
61648         function checkUnusedLocalsAndParameters(nodeWithLocals, addDiagnostic) {
61649             var unusedImports = new ts.Map();
61650             var unusedDestructures = new ts.Map();
61651             var unusedVariables = new ts.Map();
61652             nodeWithLocals.locals.forEach(function (local) {
61653                 if (local.flags & 262144 ? !(local.flags & 3 && !(local.isReferenced & 3)) : local.isReferenced || local.exportSymbol) {
61654                     return;
61655                 }
61656                 for (var _i = 0, _a = local.declarations; _i < _a.length; _i++) {
61657                     var declaration = _a[_i];
61658                     if (isValidUnusedLocalDeclaration(declaration)) {
61659                         continue;
61660                     }
61661                     if (isImportedDeclaration(declaration)) {
61662                         addToGroup(unusedImports, importClauseFromImported(declaration), declaration, getNodeId);
61663                     }
61664                     else if (ts.isBindingElement(declaration) && ts.isObjectBindingPattern(declaration.parent)) {
61665                         var lastElement = ts.last(declaration.parent.elements);
61666                         if (declaration === lastElement || !ts.last(declaration.parent.elements).dotDotDotToken) {
61667                             addToGroup(unusedDestructures, declaration.parent, declaration, getNodeId);
61668                         }
61669                     }
61670                     else if (ts.isVariableDeclaration(declaration)) {
61671                         addToGroup(unusedVariables, declaration.parent, declaration, getNodeId);
61672                     }
61673                     else {
61674                         var parameter = local.valueDeclaration && tryGetRootParameterDeclaration(local.valueDeclaration);
61675                         var name = local.valueDeclaration && ts.getNameOfDeclaration(local.valueDeclaration);
61676                         if (parameter && name) {
61677                             if (!ts.isParameterPropertyDeclaration(parameter, parameter.parent) && !ts.parameterIsThisKeyword(parameter) && !isIdentifierThatStartsWithUnderscore(name)) {
61678                                 addDiagnostic(parameter, 1, ts.createDiagnosticForNode(name, ts.Diagnostics._0_is_declared_but_its_value_is_never_read, ts.symbolName(local)));
61679                             }
61680                         }
61681                         else {
61682                             errorUnusedLocal(declaration, ts.symbolName(local), addDiagnostic);
61683                         }
61684                     }
61685                 }
61686             });
61687             unusedImports.forEach(function (_a) {
61688                 var importClause = _a[0], unuseds = _a[1];
61689                 var importDecl = importClause.parent;
61690                 var nDeclarations = (importClause.name ? 1 : 0) +
61691                     (importClause.namedBindings ?
61692                         (importClause.namedBindings.kind === 263 ? 1 : importClause.namedBindings.elements.length)
61693                         : 0);
61694                 if (nDeclarations === unuseds.length) {
61695                     addDiagnostic(importDecl, 0, unuseds.length === 1
61696                         ? ts.createDiagnosticForNode(importDecl, ts.Diagnostics._0_is_declared_but_its_value_is_never_read, ts.idText(ts.first(unuseds).name))
61697                         : ts.createDiagnosticForNode(importDecl, ts.Diagnostics.All_imports_in_import_declaration_are_unused));
61698                 }
61699                 else {
61700                     for (var _i = 0, unuseds_1 = unuseds; _i < unuseds_1.length; _i++) {
61701                         var unused = unuseds_1[_i];
61702                         errorUnusedLocal(unused, ts.idText(unused.name), addDiagnostic);
61703                     }
61704                 }
61705             });
61706             unusedDestructures.forEach(function (_a) {
61707                 var bindingPattern = _a[0], bindingElements = _a[1];
61708                 var kind = tryGetRootParameterDeclaration(bindingPattern.parent) ? 1 : 0;
61709                 if (bindingPattern.elements.length === bindingElements.length) {
61710                     if (bindingElements.length === 1 && bindingPattern.parent.kind === 249 && bindingPattern.parent.parent.kind === 250) {
61711                         addToGroup(unusedVariables, bindingPattern.parent.parent, bindingPattern.parent, getNodeId);
61712                     }
61713                     else {
61714                         addDiagnostic(bindingPattern, kind, bindingElements.length === 1
61715                             ? ts.createDiagnosticForNode(bindingPattern, ts.Diagnostics._0_is_declared_but_its_value_is_never_read, bindingNameText(ts.first(bindingElements).name))
61716                             : ts.createDiagnosticForNode(bindingPattern, ts.Diagnostics.All_destructured_elements_are_unused));
61717                     }
61718                 }
61719                 else {
61720                     for (var _i = 0, bindingElements_1 = bindingElements; _i < bindingElements_1.length; _i++) {
61721                         var e = bindingElements_1[_i];
61722                         addDiagnostic(e, kind, ts.createDiagnosticForNode(e, ts.Diagnostics._0_is_declared_but_its_value_is_never_read, bindingNameText(e.name)));
61723                     }
61724                 }
61725             });
61726             unusedVariables.forEach(function (_a) {
61727                 var declarationList = _a[0], declarations = _a[1];
61728                 if (declarationList.declarations.length === declarations.length) {
61729                     addDiagnostic(declarationList, 0, declarations.length === 1
61730                         ? ts.createDiagnosticForNode(ts.first(declarations).name, ts.Diagnostics._0_is_declared_but_its_value_is_never_read, bindingNameText(ts.first(declarations).name))
61731                         : ts.createDiagnosticForNode(declarationList.parent.kind === 232 ? declarationList.parent : declarationList, ts.Diagnostics.All_variables_are_unused));
61732                 }
61733                 else {
61734                     for (var _i = 0, declarations_5 = declarations; _i < declarations_5.length; _i++) {
61735                         var decl = declarations_5[_i];
61736                         addDiagnostic(decl, 0, ts.createDiagnosticForNode(decl, ts.Diagnostics._0_is_declared_but_its_value_is_never_read, bindingNameText(decl.name)));
61737                     }
61738                 }
61739             });
61740         }
61741         function bindingNameText(name) {
61742             switch (name.kind) {
61743                 case 78:
61744                     return ts.idText(name);
61745                 case 197:
61746                 case 196:
61747                     return bindingNameText(ts.cast(ts.first(name.elements), ts.isBindingElement).name);
61748                 default:
61749                     return ts.Debug.assertNever(name);
61750             }
61751         }
61752         function isImportedDeclaration(node) {
61753             return node.kind === 262 || node.kind === 265 || node.kind === 263;
61754         }
61755         function importClauseFromImported(decl) {
61756             return decl.kind === 262 ? decl : decl.kind === 263 ? decl.parent : decl.parent.parent;
61757         }
61758         function checkBlock(node) {
61759             if (node.kind === 230) {
61760                 checkGrammarStatementInAmbientContext(node);
61761             }
61762             if (ts.isFunctionOrModuleBlock(node)) {
61763                 var saveFlowAnalysisDisabled = flowAnalysisDisabled;
61764                 ts.forEach(node.statements, checkSourceElement);
61765                 flowAnalysisDisabled = saveFlowAnalysisDisabled;
61766             }
61767             else {
61768                 ts.forEach(node.statements, checkSourceElement);
61769             }
61770             if (node.locals) {
61771                 registerForUnusedIdentifiersCheck(node);
61772             }
61773         }
61774         function checkCollisionWithArgumentsInGeneratedCode(node) {
61775             if (languageVersion >= 2 || !ts.hasRestParameter(node) || node.flags & 8388608 || ts.nodeIsMissing(node.body)) {
61776                 return;
61777             }
61778             ts.forEach(node.parameters, function (p) {
61779                 if (p.name && !ts.isBindingPattern(p.name) && p.name.escapedText === argumentsSymbol.escapedName) {
61780                     errorSkippedOn("noEmit", p, ts.Diagnostics.Duplicate_identifier_arguments_Compiler_uses_arguments_to_initialize_rest_parameters);
61781                 }
61782             });
61783         }
61784         function needCollisionCheckForIdentifier(node, identifier, name) {
61785             if (!(identifier && identifier.escapedText === name)) {
61786                 return false;
61787             }
61788             if (node.kind === 163 ||
61789                 node.kind === 162 ||
61790                 node.kind === 165 ||
61791                 node.kind === 164 ||
61792                 node.kind === 167 ||
61793                 node.kind === 168) {
61794                 return false;
61795             }
61796             if (node.flags & 8388608) {
61797                 return false;
61798             }
61799             var root = ts.getRootDeclaration(node);
61800             if (root.kind === 160 && ts.nodeIsMissing(root.parent.body)) {
61801                 return false;
61802             }
61803             return true;
61804         }
61805         function checkIfThisIsCapturedInEnclosingScope(node) {
61806             ts.findAncestor(node, function (current) {
61807                 if (getNodeCheckFlags(current) & 4) {
61808                     var isDeclaration_1 = node.kind !== 78;
61809                     if (isDeclaration_1) {
61810                         error(ts.getNameOfDeclaration(node), ts.Diagnostics.Duplicate_identifier_this_Compiler_uses_variable_declaration_this_to_capture_this_reference);
61811                     }
61812                     else {
61813                         error(node, ts.Diagnostics.Expression_resolves_to_variable_declaration_this_that_compiler_uses_to_capture_this_reference);
61814                     }
61815                     return true;
61816                 }
61817                 return false;
61818             });
61819         }
61820         function checkIfNewTargetIsCapturedInEnclosingScope(node) {
61821             ts.findAncestor(node, function (current) {
61822                 if (getNodeCheckFlags(current) & 8) {
61823                     var isDeclaration_2 = node.kind !== 78;
61824                     if (isDeclaration_2) {
61825                         error(ts.getNameOfDeclaration(node), ts.Diagnostics.Duplicate_identifier_newTarget_Compiler_uses_variable_declaration_newTarget_to_capture_new_target_meta_property_reference);
61826                     }
61827                     else {
61828                         error(node, ts.Diagnostics.Expression_resolves_to_variable_declaration_newTarget_that_compiler_uses_to_capture_new_target_meta_property_reference);
61829                     }
61830                     return true;
61831                 }
61832                 return false;
61833             });
61834         }
61835         function checkWeakMapCollision(node) {
61836             var enclosingBlockScope = ts.getEnclosingBlockScopeContainer(node);
61837             if (getNodeCheckFlags(enclosingBlockScope) & 67108864) {
61838                 errorSkippedOn("noEmit", node, ts.Diagnostics.Compiler_reserves_name_0_when_emitting_private_identifier_downlevel, "WeakMap");
61839             }
61840         }
61841         function checkCollisionWithRequireExportsInGeneratedCode(node, name) {
61842             if (moduleKind >= ts.ModuleKind.ES2015) {
61843                 return;
61844             }
61845             if (!needCollisionCheckForIdentifier(node, name, "require") && !needCollisionCheckForIdentifier(node, name, "exports")) {
61846                 return;
61847             }
61848             if (ts.isModuleDeclaration(node) && ts.getModuleInstanceState(node) !== 1) {
61849                 return;
61850             }
61851             var parent = getDeclarationContainer(node);
61852             if (parent.kind === 297 && ts.isExternalOrCommonJsModule(parent)) {
61853                 errorSkippedOn("noEmit", name, ts.Diagnostics.Duplicate_identifier_0_Compiler_reserves_name_1_in_top_level_scope_of_a_module, ts.declarationNameToString(name), ts.declarationNameToString(name));
61854             }
61855         }
61856         function checkCollisionWithGlobalPromiseInGeneratedCode(node, name) {
61857             if (languageVersion >= 4 || !needCollisionCheckForIdentifier(node, name, "Promise")) {
61858                 return;
61859             }
61860             if (ts.isModuleDeclaration(node) && ts.getModuleInstanceState(node) !== 1) {
61861                 return;
61862             }
61863             var parent = getDeclarationContainer(node);
61864             if (parent.kind === 297 && ts.isExternalOrCommonJsModule(parent) && parent.flags & 2048) {
61865                 errorSkippedOn("noEmit", 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));
61866             }
61867         }
61868         function checkVarDeclaredNamesNotShadowed(node) {
61869             if ((ts.getCombinedNodeFlags(node) & 3) !== 0 || ts.isParameterDeclaration(node)) {
61870                 return;
61871             }
61872             if (node.kind === 249 && !node.initializer) {
61873                 return;
61874             }
61875             var symbol = getSymbolOfNode(node);
61876             if (symbol.flags & 1) {
61877                 if (!ts.isIdentifier(node.name))
61878                     return ts.Debug.fail();
61879                 var localDeclarationSymbol = resolveName(node, node.name.escapedText, 3, undefined, undefined, false);
61880                 if (localDeclarationSymbol &&
61881                     localDeclarationSymbol !== symbol &&
61882                     localDeclarationSymbol.flags & 2) {
61883                     if (getDeclarationNodeFlagsFromSymbol(localDeclarationSymbol) & 3) {
61884                         var varDeclList = ts.getAncestor(localDeclarationSymbol.valueDeclaration, 250);
61885                         var container = varDeclList.parent.kind === 232 && varDeclList.parent.parent
61886                             ? varDeclList.parent.parent
61887                             : undefined;
61888                         var namesShareScope = container &&
61889                             (container.kind === 230 && ts.isFunctionLike(container.parent) ||
61890                                 container.kind === 257 ||
61891                                 container.kind === 256 ||
61892                                 container.kind === 297);
61893                         if (!namesShareScope) {
61894                             var name = symbolToString(localDeclarationSymbol);
61895                             error(node, ts.Diagnostics.Cannot_initialize_outer_scoped_variable_0_in_the_same_scope_as_block_scoped_declaration_1, name, name);
61896                         }
61897                     }
61898                 }
61899             }
61900         }
61901         function convertAutoToAny(type) {
61902             return type === autoType ? anyType : type === autoArrayType ? anyArrayType : type;
61903         }
61904         function checkVariableLikeDeclaration(node) {
61905             var _a;
61906             checkDecorators(node);
61907             if (!ts.isBindingElement(node)) {
61908                 checkSourceElement(node.type);
61909             }
61910             if (!node.name) {
61911                 return;
61912             }
61913             if (node.name.kind === 158) {
61914                 checkComputedPropertyName(node.name);
61915                 if (node.initializer) {
61916                     checkExpressionCached(node.initializer);
61917                 }
61918             }
61919             if (node.kind === 198) {
61920                 if (node.parent.kind === 196 && languageVersion < 99) {
61921                     checkExternalEmitHelpers(node, 4);
61922                 }
61923                 if (node.propertyName && node.propertyName.kind === 158) {
61924                     checkComputedPropertyName(node.propertyName);
61925                 }
61926                 var parent = node.parent.parent;
61927                 var parentType = getTypeForBindingElementParent(parent);
61928                 var name = node.propertyName || node.name;
61929                 if (parentType && !ts.isBindingPattern(name)) {
61930                     var exprType = getLiteralTypeFromPropertyName(name);
61931                     if (isTypeUsableAsPropertyName(exprType)) {
61932                         var nameText = getPropertyNameFromType(exprType);
61933                         var property = getPropertyOfType(parentType, nameText);
61934                         if (property) {
61935                             markPropertyAsReferenced(property, undefined, false);
61936                             checkPropertyAccessibility(parent, !!parent.initializer && parent.initializer.kind === 105, parentType, property);
61937                         }
61938                     }
61939                 }
61940             }
61941             if (ts.isBindingPattern(node.name)) {
61942                 if (node.name.kind === 197 && languageVersion < 2 && compilerOptions.downlevelIteration) {
61943                     checkExternalEmitHelpers(node, 512);
61944                 }
61945                 ts.forEach(node.name.elements, checkSourceElement);
61946             }
61947             if (node.initializer && ts.isParameterDeclaration(node) && ts.nodeIsMissing(ts.getContainingFunction(node).body)) {
61948                 error(node, ts.Diagnostics.A_parameter_initializer_is_only_allowed_in_a_function_or_constructor_implementation);
61949                 return;
61950             }
61951             if (ts.isBindingPattern(node.name)) {
61952                 var needCheckInitializer = node.initializer && node.parent.parent.kind !== 238;
61953                 var needCheckWidenedType = node.name.elements.length === 0;
61954                 if (needCheckInitializer || needCheckWidenedType) {
61955                     var widenedType = getWidenedTypeForVariableLikeDeclaration(node);
61956                     if (needCheckInitializer) {
61957                         var initializerType = checkExpressionCached(node.initializer);
61958                         if (strictNullChecks && needCheckWidenedType) {
61959                             checkNonNullNonVoidType(initializerType, node);
61960                         }
61961                         else {
61962                             checkTypeAssignableToAndOptionallyElaborate(initializerType, getWidenedTypeForVariableLikeDeclaration(node), node, node.initializer);
61963                         }
61964                     }
61965                     if (needCheckWidenedType) {
61966                         if (ts.isArrayBindingPattern(node.name)) {
61967                             checkIteratedTypeOrElementType(65, widenedType, undefinedType, node);
61968                         }
61969                         else if (strictNullChecks) {
61970                             checkNonNullNonVoidType(widenedType, node);
61971                         }
61972                     }
61973                 }
61974                 return;
61975             }
61976             var symbol = getSymbolOfNode(node);
61977             if (symbol.flags & 2097152 && ts.isRequireVariableDeclaration(node, true)) {
61978                 checkAliasSymbol(node);
61979                 return;
61980             }
61981             var type = convertAutoToAny(getTypeOfSymbol(symbol));
61982             if (node === symbol.valueDeclaration) {
61983                 var initializer = ts.getEffectiveInitializer(node);
61984                 if (initializer) {
61985                     var isJSObjectLiteralInitializer = ts.isInJSFile(node) &&
61986                         ts.isObjectLiteralExpression(initializer) &&
61987                         (initializer.properties.length === 0 || ts.isPrototypeAccess(node.name)) &&
61988                         !!((_a = symbol.exports) === null || _a === void 0 ? void 0 : _a.size);
61989                     if (!isJSObjectLiteralInitializer && node.parent.parent.kind !== 238) {
61990                         checkTypeAssignableToAndOptionallyElaborate(checkExpressionCached(initializer), type, node, initializer, undefined);
61991                     }
61992                 }
61993                 if (symbol.declarations.length > 1) {
61994                     if (ts.some(symbol.declarations, function (d) { return d !== node && ts.isVariableLike(d) && !areDeclarationFlagsIdentical(d, node); })) {
61995                         error(node.name, ts.Diagnostics.All_declarations_of_0_must_have_identical_modifiers, ts.declarationNameToString(node.name));
61996                     }
61997                 }
61998             }
61999             else {
62000                 var declarationType = convertAutoToAny(getWidenedTypeForVariableLikeDeclaration(node));
62001                 if (type !== errorType && declarationType !== errorType &&
62002                     !isTypeIdenticalTo(type, declarationType) &&
62003                     !(symbol.flags & 67108864)) {
62004                     errorNextVariableOrPropertyDeclarationMustHaveSameType(symbol.valueDeclaration, type, node, declarationType);
62005                 }
62006                 if (node.initializer) {
62007                     checkTypeAssignableToAndOptionallyElaborate(checkExpressionCached(node.initializer), declarationType, node, node.initializer, undefined);
62008                 }
62009                 if (!areDeclarationFlagsIdentical(node, symbol.valueDeclaration)) {
62010                     error(node.name, ts.Diagnostics.All_declarations_of_0_must_have_identical_modifiers, ts.declarationNameToString(node.name));
62011                 }
62012             }
62013             if (node.kind !== 163 && node.kind !== 162) {
62014                 checkExportsOnMergedDeclarations(node);
62015                 if (node.kind === 249 || node.kind === 198) {
62016                     checkVarDeclaredNamesNotShadowed(node);
62017                 }
62018                 checkCollisionWithRequireExportsInGeneratedCode(node, node.name);
62019                 checkCollisionWithGlobalPromiseInGeneratedCode(node, node.name);
62020                 if (languageVersion < 99 && needCollisionCheckForIdentifier(node, node.name, "WeakMap")) {
62021                     potentialWeakMapCollisions.push(node);
62022                 }
62023             }
62024         }
62025         function errorNextVariableOrPropertyDeclarationMustHaveSameType(firstDeclaration, firstType, nextDeclaration, nextType) {
62026             var nextDeclarationName = ts.getNameOfDeclaration(nextDeclaration);
62027             var message = nextDeclaration.kind === 163 || nextDeclaration.kind === 162
62028                 ? ts.Diagnostics.Subsequent_property_declarations_must_have_the_same_type_Property_0_must_be_of_type_1_but_here_has_type_2
62029                 : ts.Diagnostics.Subsequent_variable_declarations_must_have_the_same_type_Variable_0_must_be_of_type_1_but_here_has_type_2;
62030             var declName = ts.declarationNameToString(nextDeclarationName);
62031             var err = error(nextDeclarationName, message, declName, typeToString(firstType), typeToString(nextType));
62032             if (firstDeclaration) {
62033                 ts.addRelatedInfo(err, ts.createDiagnosticForNode(firstDeclaration, ts.Diagnostics._0_was_also_declared_here, declName));
62034             }
62035         }
62036         function areDeclarationFlagsIdentical(left, right) {
62037             if ((left.kind === 160 && right.kind === 249) ||
62038                 (left.kind === 249 && right.kind === 160)) {
62039                 return true;
62040             }
62041             if (ts.hasQuestionToken(left) !== ts.hasQuestionToken(right)) {
62042                 return false;
62043             }
62044             var interestingFlags = 8 |
62045                 16 |
62046                 256 |
62047                 128 |
62048                 64 |
62049                 32;
62050             return ts.getSelectedEffectiveModifierFlags(left, interestingFlags) === ts.getSelectedEffectiveModifierFlags(right, interestingFlags);
62051         }
62052         function checkVariableDeclaration(node) {
62053             ts.tracing.push("check", "checkVariableDeclaration", { kind: node.kind, pos: node.pos, end: node.end });
62054             checkGrammarVariableDeclaration(node);
62055             checkVariableLikeDeclaration(node);
62056             ts.tracing.pop();
62057         }
62058         function checkBindingElement(node) {
62059             checkGrammarBindingElement(node);
62060             return checkVariableLikeDeclaration(node);
62061         }
62062         function checkVariableStatement(node) {
62063             if (!checkGrammarDecoratorsAndModifiers(node) && !checkGrammarVariableDeclarationList(node.declarationList))
62064                 checkGrammarForDisallowedLetOrConstStatement(node);
62065             ts.forEach(node.declarationList.declarations, checkSourceElement);
62066         }
62067         function checkExpressionStatement(node) {
62068             checkGrammarStatementInAmbientContext(node);
62069             checkExpression(node.expression);
62070         }
62071         function checkIfStatement(node) {
62072             checkGrammarStatementInAmbientContext(node);
62073             var type = checkTruthinessExpression(node.expression);
62074             checkTestingKnownTruthyCallableType(node.expression, node.thenStatement, type);
62075             checkSourceElement(node.thenStatement);
62076             if (node.thenStatement.kind === 231) {
62077                 error(node.thenStatement, ts.Diagnostics.The_body_of_an_if_statement_cannot_be_the_empty_statement);
62078             }
62079             checkSourceElement(node.elseStatement);
62080         }
62081         function checkTestingKnownTruthyCallableType(condExpr, body, type) {
62082             if (!strictNullChecks) {
62083                 return;
62084             }
62085             var testedNode = ts.isIdentifier(condExpr)
62086                 ? condExpr
62087                 : ts.isPropertyAccessExpression(condExpr)
62088                     ? condExpr.name
62089                     : undefined;
62090             if (!testedNode) {
62091                 return;
62092             }
62093             var possiblyFalsy = getFalsyFlags(type);
62094             if (possiblyFalsy) {
62095                 return;
62096             }
62097             var callSignatures = getSignaturesOfType(type, 0);
62098             if (callSignatures.length === 0) {
62099                 return;
62100             }
62101             var testedFunctionSymbol = getSymbolAtLocation(testedNode);
62102             if (!testedFunctionSymbol) {
62103                 return;
62104             }
62105             var functionIsUsedInBody = ts.forEachChild(body, function check(childNode) {
62106                 if (ts.isIdentifier(childNode)) {
62107                     var childSymbol = getSymbolAtLocation(childNode);
62108                     if (childSymbol && childSymbol === testedFunctionSymbol) {
62109                         if (ts.isIdentifier(condExpr)) {
62110                             return true;
62111                         }
62112                         var testedExpression = testedNode.parent;
62113                         var childExpression = childNode.parent;
62114                         while (testedExpression && childExpression) {
62115                             if (ts.isIdentifier(testedExpression) && ts.isIdentifier(childExpression) ||
62116                                 testedExpression.kind === 107 && childExpression.kind === 107) {
62117                                 return getSymbolAtLocation(testedExpression) === getSymbolAtLocation(childExpression);
62118                             }
62119                             if (ts.isPropertyAccessExpression(testedExpression) && ts.isPropertyAccessExpression(childExpression)) {
62120                                 if (getSymbolAtLocation(testedExpression.name) !== getSymbolAtLocation(childExpression.name)) {
62121                                     return false;
62122                                 }
62123                                 childExpression = childExpression.expression;
62124                                 testedExpression = testedExpression.expression;
62125                             }
62126                             else {
62127                                 return false;
62128                             }
62129                         }
62130                     }
62131                 }
62132                 return ts.forEachChild(childNode, check);
62133             });
62134             if (!functionIsUsedInBody) {
62135                 error(condExpr, ts.Diagnostics.This_condition_will_always_return_true_since_the_function_is_always_defined_Did_you_mean_to_call_it_instead);
62136             }
62137         }
62138         function checkDoStatement(node) {
62139             checkGrammarStatementInAmbientContext(node);
62140             checkSourceElement(node.statement);
62141             checkTruthinessExpression(node.expression);
62142         }
62143         function checkWhileStatement(node) {
62144             checkGrammarStatementInAmbientContext(node);
62145             checkTruthinessExpression(node.expression);
62146             checkSourceElement(node.statement);
62147         }
62148         function checkTruthinessOfType(type, node) {
62149             if (type.flags & 16384) {
62150                 error(node, ts.Diagnostics.An_expression_of_type_void_cannot_be_tested_for_truthiness);
62151             }
62152             return type;
62153         }
62154         function checkTruthinessExpression(node, checkMode) {
62155             return checkTruthinessOfType(checkExpression(node, checkMode), node);
62156         }
62157         function checkForStatement(node) {
62158             if (!checkGrammarStatementInAmbientContext(node)) {
62159                 if (node.initializer && node.initializer.kind === 250) {
62160                     checkGrammarVariableDeclarationList(node.initializer);
62161                 }
62162             }
62163             if (node.initializer) {
62164                 if (node.initializer.kind === 250) {
62165                     ts.forEach(node.initializer.declarations, checkVariableDeclaration);
62166                 }
62167                 else {
62168                     checkExpression(node.initializer);
62169                 }
62170             }
62171             if (node.condition)
62172                 checkTruthinessExpression(node.condition);
62173             if (node.incrementor)
62174                 checkExpression(node.incrementor);
62175             checkSourceElement(node.statement);
62176             if (node.locals) {
62177                 registerForUnusedIdentifiersCheck(node);
62178             }
62179         }
62180         function checkForOfStatement(node) {
62181             checkGrammarForInOrForOfStatement(node);
62182             if (node.awaitModifier) {
62183                 var functionFlags = ts.getFunctionFlags(ts.getContainingFunction(node));
62184                 if ((functionFlags & (4 | 2)) === 2 && languageVersion < 99) {
62185                     checkExternalEmitHelpers(node, 32768);
62186                 }
62187             }
62188             else if (compilerOptions.downlevelIteration && languageVersion < 2) {
62189                 checkExternalEmitHelpers(node, 256);
62190             }
62191             if (node.initializer.kind === 250) {
62192                 checkForInOrForOfVariableDeclaration(node);
62193             }
62194             else {
62195                 var varExpr = node.initializer;
62196                 var iteratedType = checkRightHandSideOfForOf(node);
62197                 if (varExpr.kind === 199 || varExpr.kind === 200) {
62198                     checkDestructuringAssignment(varExpr, iteratedType || errorType);
62199                 }
62200                 else {
62201                     var leftType = checkExpression(varExpr);
62202                     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);
62203                     if (iteratedType) {
62204                         checkTypeAssignableToAndOptionallyElaborate(iteratedType, leftType, varExpr, node.expression);
62205                     }
62206                 }
62207             }
62208             checkSourceElement(node.statement);
62209             if (node.locals) {
62210                 registerForUnusedIdentifiersCheck(node);
62211             }
62212         }
62213         function checkForInStatement(node) {
62214             checkGrammarForInOrForOfStatement(node);
62215             var rightType = getNonNullableTypeIfNeeded(checkExpression(node.expression));
62216             if (node.initializer.kind === 250) {
62217                 var variable = node.initializer.declarations[0];
62218                 if (variable && ts.isBindingPattern(variable.name)) {
62219                     error(variable.name, ts.Diagnostics.The_left_hand_side_of_a_for_in_statement_cannot_be_a_destructuring_pattern);
62220                 }
62221                 checkForInOrForOfVariableDeclaration(node);
62222             }
62223             else {
62224                 var varExpr = node.initializer;
62225                 var leftType = checkExpression(varExpr);
62226                 if (varExpr.kind === 199 || varExpr.kind === 200) {
62227                     error(varExpr, ts.Diagnostics.The_left_hand_side_of_a_for_in_statement_cannot_be_a_destructuring_pattern);
62228                 }
62229                 else if (!isTypeAssignableTo(getIndexTypeOrString(rightType), leftType)) {
62230                     error(varExpr, ts.Diagnostics.The_left_hand_side_of_a_for_in_statement_must_be_of_type_string_or_any);
62231                 }
62232                 else {
62233                     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);
62234                 }
62235             }
62236             if (rightType === neverType || !isTypeAssignableToKind(rightType, 67108864 | 58982400)) {
62237                 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));
62238             }
62239             checkSourceElement(node.statement);
62240             if (node.locals) {
62241                 registerForUnusedIdentifiersCheck(node);
62242             }
62243         }
62244         function checkForInOrForOfVariableDeclaration(iterationStatement) {
62245             var variableDeclarationList = iterationStatement.initializer;
62246             if (variableDeclarationList.declarations.length >= 1) {
62247                 var decl = variableDeclarationList.declarations[0];
62248                 checkVariableDeclaration(decl);
62249             }
62250         }
62251         function checkRightHandSideOfForOf(statement) {
62252             var use = statement.awaitModifier ? 15 : 13;
62253             return checkIteratedTypeOrElementType(use, checkNonNullExpression(statement.expression), undefinedType, statement.expression);
62254         }
62255         function checkIteratedTypeOrElementType(use, inputType, sentType, errorNode) {
62256             if (isTypeAny(inputType)) {
62257                 return inputType;
62258             }
62259             return getIteratedTypeOrElementType(use, inputType, sentType, errorNode, true) || anyType;
62260         }
62261         function getIteratedTypeOrElementType(use, inputType, sentType, errorNode, checkAssignability) {
62262             var allowAsyncIterables = (use & 2) !== 0;
62263             if (inputType === neverType) {
62264                 reportTypeNotIterableError(errorNode, inputType, allowAsyncIterables);
62265                 return undefined;
62266             }
62267             var uplevelIteration = languageVersion >= 2;
62268             var downlevelIteration = !uplevelIteration && compilerOptions.downlevelIteration;
62269             var possibleOutOfBounds = compilerOptions.noUncheckedIndexedAccess && !!(use & 128);
62270             if (uplevelIteration || downlevelIteration || allowAsyncIterables) {
62271                 var iterationTypes = getIterationTypesOfIterable(inputType, use, uplevelIteration ? errorNode : undefined);
62272                 if (checkAssignability) {
62273                     if (iterationTypes) {
62274                         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 :
62275                             use & 32 ? ts.Diagnostics.Cannot_iterate_value_because_the_next_method_of_its_iterator_expects_type_1_but_array_spread_will_always_send_0 :
62276                                 use & 64 ? ts.Diagnostics.Cannot_iterate_value_because_the_next_method_of_its_iterator_expects_type_1_but_array_destructuring_will_always_send_0 :
62277                                     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 :
62278                                         undefined;
62279                         if (diagnostic) {
62280                             checkTypeAssignableTo(sentType, iterationTypes.nextType, errorNode, diagnostic);
62281                         }
62282                     }
62283                 }
62284                 if (iterationTypes || uplevelIteration) {
62285                     return possibleOutOfBounds ? includeUndefinedInIndexSignature(iterationTypes && iterationTypes.yieldType) : (iterationTypes && iterationTypes.yieldType);
62286                 }
62287             }
62288             var arrayType = inputType;
62289             var reportedError = false;
62290             var hasStringConstituent = false;
62291             if (use & 4) {
62292                 if (arrayType.flags & 1048576) {
62293                     var arrayTypes = inputType.types;
62294                     var filteredTypes = ts.filter(arrayTypes, function (t) { return !(t.flags & 402653316); });
62295                     if (filteredTypes !== arrayTypes) {
62296                         arrayType = getUnionType(filteredTypes, 2);
62297                     }
62298                 }
62299                 else if (arrayType.flags & 402653316) {
62300                     arrayType = neverType;
62301                 }
62302                 hasStringConstituent = arrayType !== inputType;
62303                 if (hasStringConstituent) {
62304                     if (languageVersion < 1) {
62305                         if (errorNode) {
62306                             error(errorNode, ts.Diagnostics.Using_a_string_in_a_for_of_statement_is_only_supported_in_ECMAScript_5_and_higher);
62307                             reportedError = true;
62308                         }
62309                     }
62310                     if (arrayType.flags & 131072) {
62311                         return possibleOutOfBounds ? includeUndefinedInIndexSignature(stringType) : stringType;
62312                     }
62313                 }
62314             }
62315             if (!isArrayLikeType(arrayType)) {
62316                 if (errorNode && !reportedError) {
62317                     var yieldType = getIterationTypeOfIterable(use, 0, inputType, undefined);
62318                     var _a = !(use & 4) || hasStringConstituent
62319                         ? downlevelIteration
62320                             ? [ts.Diagnostics.Type_0_is_not_an_array_type_or_does_not_have_a_Symbol_iterator_method_that_returns_an_iterator, true]
62321                             : yieldType
62322                                 ? [ts.Diagnostics.Type_0_is_not_an_array_type_or_a_string_type_Use_compiler_option_downlevelIteration_to_allow_iterating_of_iterators, false]
62323                                 : [ts.Diagnostics.Type_0_is_not_an_array_type, true]
62324                         : downlevelIteration
62325                             ? [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]
62326                             : yieldType
62327                                 ? [ts.Diagnostics.Type_0_is_not_an_array_type_or_a_string_type_Use_compiler_option_downlevelIteration_to_allow_iterating_of_iterators, false]
62328                                 : [ts.Diagnostics.Type_0_is_not_an_array_type_or_a_string_type, true], defaultDiagnostic = _a[0], maybeMissingAwait = _a[1];
62329                     errorAndMaybeSuggestAwait(errorNode, maybeMissingAwait && !!getAwaitedTypeOfPromise(arrayType), defaultDiagnostic, typeToString(arrayType));
62330                 }
62331                 return hasStringConstituent ? possibleOutOfBounds ? includeUndefinedInIndexSignature(stringType) : stringType : undefined;
62332             }
62333             var arrayElementType = getIndexTypeOfType(arrayType, 1);
62334             if (hasStringConstituent && arrayElementType) {
62335                 if (arrayElementType.flags & 402653316 && !compilerOptions.noUncheckedIndexedAccess) {
62336                     return stringType;
62337                 }
62338                 return getUnionType(possibleOutOfBounds ? [arrayElementType, stringType, undefinedType] : [arrayElementType, stringType], 2);
62339             }
62340             return (use & 128) ? includeUndefinedInIndexSignature(arrayElementType) : arrayElementType;
62341         }
62342         function getIterationTypeOfIterable(use, typeKind, inputType, errorNode) {
62343             if (isTypeAny(inputType)) {
62344                 return undefined;
62345             }
62346             var iterationTypes = getIterationTypesOfIterable(inputType, use, errorNode);
62347             return iterationTypes && iterationTypes[getIterationTypesKeyFromIterationTypeKind(typeKind)];
62348         }
62349         function createIterationTypes(yieldType, returnType, nextType) {
62350             if (yieldType === void 0) { yieldType = neverType; }
62351             if (returnType === void 0) { returnType = neverType; }
62352             if (nextType === void 0) { nextType = unknownType; }
62353             if (yieldType.flags & 67359327 &&
62354                 returnType.flags & (1 | 131072 | 2 | 16384 | 32768) &&
62355                 nextType.flags & (1 | 131072 | 2 | 16384 | 32768)) {
62356                 var id = getTypeListId([yieldType, returnType, nextType]);
62357                 var iterationTypes = iterationTypesCache.get(id);
62358                 if (!iterationTypes) {
62359                     iterationTypes = { yieldType: yieldType, returnType: returnType, nextType: nextType };
62360                     iterationTypesCache.set(id, iterationTypes);
62361                 }
62362                 return iterationTypes;
62363             }
62364             return { yieldType: yieldType, returnType: returnType, nextType: nextType };
62365         }
62366         function combineIterationTypes(array) {
62367             var yieldTypes;
62368             var returnTypes;
62369             var nextTypes;
62370             for (var _i = 0, array_10 = array; _i < array_10.length; _i++) {
62371                 var iterationTypes = array_10[_i];
62372                 if (iterationTypes === undefined || iterationTypes === noIterationTypes) {
62373                     continue;
62374                 }
62375                 if (iterationTypes === anyIterationTypes) {
62376                     return anyIterationTypes;
62377                 }
62378                 yieldTypes = ts.append(yieldTypes, iterationTypes.yieldType);
62379                 returnTypes = ts.append(returnTypes, iterationTypes.returnType);
62380                 nextTypes = ts.append(nextTypes, iterationTypes.nextType);
62381             }
62382             if (yieldTypes || returnTypes || nextTypes) {
62383                 return createIterationTypes(yieldTypes && getUnionType(yieldTypes), returnTypes && getUnionType(returnTypes), nextTypes && getIntersectionType(nextTypes));
62384             }
62385             return noIterationTypes;
62386         }
62387         function getCachedIterationTypes(type, cacheKey) {
62388             return type[cacheKey];
62389         }
62390         function setCachedIterationTypes(type, cacheKey, cachedTypes) {
62391             return type[cacheKey] = cachedTypes;
62392         }
62393         function getIterationTypesOfIterable(type, use, errorNode) {
62394             if (isTypeAny(type)) {
62395                 return anyIterationTypes;
62396             }
62397             if (!(type.flags & 1048576)) {
62398                 var iterationTypes_1 = getIterationTypesOfIterableWorker(type, use, errorNode);
62399                 if (iterationTypes_1 === noIterationTypes) {
62400                     if (errorNode) {
62401                         reportTypeNotIterableError(errorNode, type, !!(use & 2));
62402                     }
62403                     return undefined;
62404                 }
62405                 return iterationTypes_1;
62406             }
62407             var cacheKey = use & 2 ? "iterationTypesOfAsyncIterable" : "iterationTypesOfIterable";
62408             var cachedTypes = getCachedIterationTypes(type, cacheKey);
62409             if (cachedTypes)
62410                 return cachedTypes === noIterationTypes ? undefined : cachedTypes;
62411             var allIterationTypes;
62412             for (var _i = 0, _a = type.types; _i < _a.length; _i++) {
62413                 var constituent = _a[_i];
62414                 var iterationTypes_2 = getIterationTypesOfIterableWorker(constituent, use, errorNode);
62415                 if (iterationTypes_2 === noIterationTypes) {
62416                     if (errorNode) {
62417                         reportTypeNotIterableError(errorNode, type, !!(use & 2));
62418                     }
62419                     setCachedIterationTypes(type, cacheKey, noIterationTypes);
62420                     return undefined;
62421                 }
62422                 else {
62423                     allIterationTypes = ts.append(allIterationTypes, iterationTypes_2);
62424                 }
62425             }
62426             var iterationTypes = allIterationTypes ? combineIterationTypes(allIterationTypes) : noIterationTypes;
62427             setCachedIterationTypes(type, cacheKey, iterationTypes);
62428             return iterationTypes === noIterationTypes ? undefined : iterationTypes;
62429         }
62430         function getAsyncFromSyncIterationTypes(iterationTypes, errorNode) {
62431             if (iterationTypes === noIterationTypes)
62432                 return noIterationTypes;
62433             if (iterationTypes === anyIterationTypes)
62434                 return anyIterationTypes;
62435             var yieldType = iterationTypes.yieldType, returnType = iterationTypes.returnType, nextType = iterationTypes.nextType;
62436             return createIterationTypes(getAwaitedType(yieldType, errorNode) || anyType, getAwaitedType(returnType, errorNode) || anyType, nextType);
62437         }
62438         function getIterationTypesOfIterableWorker(type, use, errorNode) {
62439             if (isTypeAny(type)) {
62440                 return anyIterationTypes;
62441             }
62442             if (use & 2) {
62443                 var iterationTypes = getIterationTypesOfIterableCached(type, asyncIterationTypesResolver) ||
62444                     getIterationTypesOfIterableFast(type, asyncIterationTypesResolver);
62445                 if (iterationTypes) {
62446                     return iterationTypes;
62447                 }
62448             }
62449             if (use & 1) {
62450                 var iterationTypes = getIterationTypesOfIterableCached(type, syncIterationTypesResolver) ||
62451                     getIterationTypesOfIterableFast(type, syncIterationTypesResolver);
62452                 if (iterationTypes) {
62453                     if (use & 2) {
62454                         if (iterationTypes !== noIterationTypes) {
62455                             return setCachedIterationTypes(type, "iterationTypesOfAsyncIterable", getAsyncFromSyncIterationTypes(iterationTypes, errorNode));
62456                         }
62457                     }
62458                     else {
62459                         return iterationTypes;
62460                     }
62461                 }
62462             }
62463             if (use & 2) {
62464                 var iterationTypes = getIterationTypesOfIterableSlow(type, asyncIterationTypesResolver, errorNode);
62465                 if (iterationTypes !== noIterationTypes) {
62466                     return iterationTypes;
62467                 }
62468             }
62469             if (use & 1) {
62470                 var iterationTypes = getIterationTypesOfIterableSlow(type, syncIterationTypesResolver, errorNode);
62471                 if (iterationTypes !== noIterationTypes) {
62472                     if (use & 2) {
62473                         return setCachedIterationTypes(type, "iterationTypesOfAsyncIterable", iterationTypes
62474                             ? getAsyncFromSyncIterationTypes(iterationTypes, errorNode)
62475                             : noIterationTypes);
62476                     }
62477                     else {
62478                         return iterationTypes;
62479                     }
62480                 }
62481             }
62482             return noIterationTypes;
62483         }
62484         function getIterationTypesOfIterableCached(type, resolver) {
62485             return getCachedIterationTypes(type, resolver.iterableCacheKey);
62486         }
62487         function getIterationTypesOfGlobalIterableType(globalType, resolver) {
62488             var globalIterationTypes = getIterationTypesOfIterableCached(globalType, resolver) ||
62489                 getIterationTypesOfIterableSlow(globalType, resolver, undefined);
62490             return globalIterationTypes === noIterationTypes ? defaultIterationTypes : globalIterationTypes;
62491         }
62492         function getIterationTypesOfIterableFast(type, resolver) {
62493             var globalType;
62494             if (isReferenceToType(type, globalType = resolver.getGlobalIterableType(false)) ||
62495                 isReferenceToType(type, globalType = resolver.getGlobalIterableIteratorType(false))) {
62496                 var yieldType = getTypeArguments(type)[0];
62497                 var _a = getIterationTypesOfGlobalIterableType(globalType, resolver), returnType = _a.returnType, nextType = _a.nextType;
62498                 return setCachedIterationTypes(type, resolver.iterableCacheKey, createIterationTypes(yieldType, returnType, nextType));
62499             }
62500             if (isReferenceToType(type, resolver.getGlobalGeneratorType(false))) {
62501                 var _b = getTypeArguments(type), yieldType = _b[0], returnType = _b[1], nextType = _b[2];
62502                 return setCachedIterationTypes(type, resolver.iterableCacheKey, createIterationTypes(yieldType, returnType, nextType));
62503             }
62504         }
62505         function getIterationTypesOfIterableSlow(type, resolver, errorNode) {
62506             var _a;
62507             var method = getPropertyOfType(type, ts.getPropertyNameForKnownSymbolName(resolver.iteratorSymbolName));
62508             var methodType = method && !(method.flags & 16777216) ? getTypeOfSymbol(method) : undefined;
62509             if (isTypeAny(methodType)) {
62510                 return setCachedIterationTypes(type, resolver.iterableCacheKey, anyIterationTypes);
62511             }
62512             var signatures = methodType ? getSignaturesOfType(methodType, 0) : undefined;
62513             if (!ts.some(signatures)) {
62514                 return setCachedIterationTypes(type, resolver.iterableCacheKey, noIterationTypes);
62515             }
62516             var iteratorType = getIntersectionType(ts.map(signatures, getReturnTypeOfSignature));
62517             var iterationTypes = (_a = getIterationTypesOfIterator(iteratorType, resolver, errorNode)) !== null && _a !== void 0 ? _a : noIterationTypes;
62518             return setCachedIterationTypes(type, resolver.iterableCacheKey, iterationTypes);
62519         }
62520         function reportTypeNotIterableError(errorNode, type, allowAsyncIterables) {
62521             var message = allowAsyncIterables
62522                 ? ts.Diagnostics.Type_0_must_have_a_Symbol_asyncIterator_method_that_returns_an_async_iterator
62523                 : ts.Diagnostics.Type_0_must_have_a_Symbol_iterator_method_that_returns_an_iterator;
62524             errorAndMaybeSuggestAwait(errorNode, !!getAwaitedTypeOfPromise(type), message, typeToString(type));
62525         }
62526         function getIterationTypesOfIterator(type, resolver, errorNode) {
62527             if (isTypeAny(type)) {
62528                 return anyIterationTypes;
62529             }
62530             var iterationTypes = getIterationTypesOfIteratorCached(type, resolver) ||
62531                 getIterationTypesOfIteratorFast(type, resolver) ||
62532                 getIterationTypesOfIteratorSlow(type, resolver, errorNode);
62533             return iterationTypes === noIterationTypes ? undefined : iterationTypes;
62534         }
62535         function getIterationTypesOfIteratorCached(type, resolver) {
62536             return getCachedIterationTypes(type, resolver.iteratorCacheKey);
62537         }
62538         function getIterationTypesOfIteratorFast(type, resolver) {
62539             var globalType = resolver.getGlobalIterableIteratorType(false);
62540             if (isReferenceToType(type, globalType)) {
62541                 var yieldType = getTypeArguments(type)[0];
62542                 var globalIterationTypes = getIterationTypesOfIteratorCached(globalType, resolver) ||
62543                     getIterationTypesOfIteratorSlow(globalType, resolver, undefined);
62544                 var _a = globalIterationTypes === noIterationTypes ? defaultIterationTypes : globalIterationTypes, returnType = _a.returnType, nextType = _a.nextType;
62545                 return setCachedIterationTypes(type, resolver.iteratorCacheKey, createIterationTypes(yieldType, returnType, nextType));
62546             }
62547             if (isReferenceToType(type, resolver.getGlobalIteratorType(false)) ||
62548                 isReferenceToType(type, resolver.getGlobalGeneratorType(false))) {
62549                 var _b = getTypeArguments(type), yieldType = _b[0], returnType = _b[1], nextType = _b[2];
62550                 return setCachedIterationTypes(type, resolver.iteratorCacheKey, createIterationTypes(yieldType, returnType, nextType));
62551             }
62552         }
62553         function isIteratorResult(type, kind) {
62554             var doneType = getTypeOfPropertyOfType(type, "done") || falseType;
62555             return isTypeAssignableTo(kind === 0 ? falseType : trueType, doneType);
62556         }
62557         function isYieldIteratorResult(type) {
62558             return isIteratorResult(type, 0);
62559         }
62560         function isReturnIteratorResult(type) {
62561             return isIteratorResult(type, 1);
62562         }
62563         function getIterationTypesOfIteratorResult(type) {
62564             if (isTypeAny(type)) {
62565                 return anyIterationTypes;
62566             }
62567             var cachedTypes = getCachedIterationTypes(type, "iterationTypesOfIteratorResult");
62568             if (cachedTypes) {
62569                 return cachedTypes;
62570             }
62571             if (isReferenceToType(type, getGlobalIteratorYieldResultType(false))) {
62572                 var yieldType_1 = getTypeArguments(type)[0];
62573                 return setCachedIterationTypes(type, "iterationTypesOfIteratorResult", createIterationTypes(yieldType_1, undefined, undefined));
62574             }
62575             if (isReferenceToType(type, getGlobalIteratorReturnResultType(false))) {
62576                 var returnType_1 = getTypeArguments(type)[0];
62577                 return setCachedIterationTypes(type, "iterationTypesOfIteratorResult", createIterationTypes(undefined, returnType_1, undefined));
62578             }
62579             var yieldIteratorResult = filterType(type, isYieldIteratorResult);
62580             var yieldType = yieldIteratorResult !== neverType ? getTypeOfPropertyOfType(yieldIteratorResult, "value") : undefined;
62581             var returnIteratorResult = filterType(type, isReturnIteratorResult);
62582             var returnType = returnIteratorResult !== neverType ? getTypeOfPropertyOfType(returnIteratorResult, "value") : undefined;
62583             if (!yieldType && !returnType) {
62584                 return setCachedIterationTypes(type, "iterationTypesOfIteratorResult", noIterationTypes);
62585             }
62586             return setCachedIterationTypes(type, "iterationTypesOfIteratorResult", createIterationTypes(yieldType, returnType || voidType, undefined));
62587         }
62588         function getIterationTypesOfMethod(type, resolver, methodName, errorNode) {
62589             var _a, _b, _c, _d;
62590             var method = getPropertyOfType(type, methodName);
62591             if (!method && methodName !== "next") {
62592                 return undefined;
62593             }
62594             var methodType = method && !(methodName === "next" && (method.flags & 16777216))
62595                 ? methodName === "next" ? getTypeOfSymbol(method) : getTypeWithFacts(getTypeOfSymbol(method), 2097152)
62596                 : undefined;
62597             if (isTypeAny(methodType)) {
62598                 return methodName === "next" ? anyIterationTypes : anyIterationTypesExceptNext;
62599             }
62600             var methodSignatures = methodType ? getSignaturesOfType(methodType, 0) : ts.emptyArray;
62601             if (methodSignatures.length === 0) {
62602                 if (errorNode) {
62603                     var diagnostic = methodName === "next"
62604                         ? resolver.mustHaveANextMethodDiagnostic
62605                         : resolver.mustBeAMethodDiagnostic;
62606                     error(errorNode, diagnostic, methodName);
62607                 }
62608                 return methodName === "next" ? anyIterationTypes : undefined;
62609             }
62610             if ((methodType === null || methodType === void 0 ? void 0 : methodType.symbol) && methodSignatures.length === 1) {
62611                 var globalGeneratorType = resolver.getGlobalGeneratorType(false);
62612                 var globalIteratorType = resolver.getGlobalIteratorType(false);
62613                 var isGeneratorMethod = ((_b = (_a = globalGeneratorType.symbol) === null || _a === void 0 ? void 0 : _a.members) === null || _b === void 0 ? void 0 : _b.get(methodName)) === methodType.symbol;
62614                 var isIteratorMethod = !isGeneratorMethod && ((_d = (_c = globalIteratorType.symbol) === null || _c === void 0 ? void 0 : _c.members) === null || _d === void 0 ? void 0 : _d.get(methodName)) === methodType.symbol;
62615                 if (isGeneratorMethod || isIteratorMethod) {
62616                     var globalType = isGeneratorMethod ? globalGeneratorType : globalIteratorType;
62617                     var mapper = methodType.mapper;
62618                     return createIterationTypes(getMappedType(globalType.typeParameters[0], mapper), getMappedType(globalType.typeParameters[1], mapper), methodName === "next" ? getMappedType(globalType.typeParameters[2], mapper) : undefined);
62619                 }
62620             }
62621             var methodParameterTypes;
62622             var methodReturnTypes;
62623             for (var _i = 0, methodSignatures_1 = methodSignatures; _i < methodSignatures_1.length; _i++) {
62624                 var signature = methodSignatures_1[_i];
62625                 if (methodName !== "throw" && ts.some(signature.parameters)) {
62626                     methodParameterTypes = ts.append(methodParameterTypes, getTypeAtPosition(signature, 0));
62627                 }
62628                 methodReturnTypes = ts.append(methodReturnTypes, getReturnTypeOfSignature(signature));
62629             }
62630             var returnTypes;
62631             var nextType;
62632             if (methodName !== "throw") {
62633                 var methodParameterType = methodParameterTypes ? getUnionType(methodParameterTypes) : unknownType;
62634                 if (methodName === "next") {
62635                     nextType = methodParameterType;
62636                 }
62637                 else if (methodName === "return") {
62638                     var resolvedMethodParameterType = resolver.resolveIterationType(methodParameterType, errorNode) || anyType;
62639                     returnTypes = ts.append(returnTypes, resolvedMethodParameterType);
62640                 }
62641             }
62642             var yieldType;
62643             var methodReturnType = methodReturnTypes ? getIntersectionType(methodReturnTypes) : neverType;
62644             var resolvedMethodReturnType = resolver.resolveIterationType(methodReturnType, errorNode) || anyType;
62645             var iterationTypes = getIterationTypesOfIteratorResult(resolvedMethodReturnType);
62646             if (iterationTypes === noIterationTypes) {
62647                 if (errorNode) {
62648                     error(errorNode, resolver.mustHaveAValueDiagnostic, methodName);
62649                 }
62650                 yieldType = anyType;
62651                 returnTypes = ts.append(returnTypes, anyType);
62652             }
62653             else {
62654                 yieldType = iterationTypes.yieldType;
62655                 returnTypes = ts.append(returnTypes, iterationTypes.returnType);
62656             }
62657             return createIterationTypes(yieldType, getUnionType(returnTypes), nextType);
62658         }
62659         function getIterationTypesOfIteratorSlow(type, resolver, errorNode) {
62660             var iterationTypes = combineIterationTypes([
62661                 getIterationTypesOfMethod(type, resolver, "next", errorNode),
62662                 getIterationTypesOfMethod(type, resolver, "return", errorNode),
62663                 getIterationTypesOfMethod(type, resolver, "throw", errorNode),
62664             ]);
62665             return setCachedIterationTypes(type, resolver.iteratorCacheKey, iterationTypes);
62666         }
62667         function getIterationTypeOfGeneratorFunctionReturnType(kind, returnType, isAsyncGenerator) {
62668             if (isTypeAny(returnType)) {
62669                 return undefined;
62670             }
62671             var iterationTypes = getIterationTypesOfGeneratorFunctionReturnType(returnType, isAsyncGenerator);
62672             return iterationTypes && iterationTypes[getIterationTypesKeyFromIterationTypeKind(kind)];
62673         }
62674         function getIterationTypesOfGeneratorFunctionReturnType(type, isAsyncGenerator) {
62675             if (isTypeAny(type)) {
62676                 return anyIterationTypes;
62677             }
62678             var use = isAsyncGenerator ? 2 : 1;
62679             var resolver = isAsyncGenerator ? asyncIterationTypesResolver : syncIterationTypesResolver;
62680             return getIterationTypesOfIterable(type, use, undefined) ||
62681                 getIterationTypesOfIterator(type, resolver, undefined);
62682         }
62683         function checkBreakOrContinueStatement(node) {
62684             if (!checkGrammarStatementInAmbientContext(node))
62685                 checkGrammarBreakOrContinueStatement(node);
62686         }
62687         function unwrapReturnType(returnType, functionFlags) {
62688             var _a, _b;
62689             var isGenerator = !!(functionFlags & 1);
62690             var isAsync = !!(functionFlags & 2);
62691             return isGenerator ? (_a = getIterationTypeOfGeneratorFunctionReturnType(1, returnType, isAsync)) !== null && _a !== void 0 ? _a : errorType :
62692                 isAsync ? (_b = getAwaitedType(returnType)) !== null && _b !== void 0 ? _b : errorType :
62693                     returnType;
62694         }
62695         function isUnwrappedReturnTypeVoidOrAny(func, returnType) {
62696             var unwrappedReturnType = unwrapReturnType(returnType, ts.getFunctionFlags(func));
62697             return !!unwrappedReturnType && maybeTypeOfKind(unwrappedReturnType, 16384 | 3);
62698         }
62699         function checkReturnStatement(node) {
62700             var _a;
62701             if (checkGrammarStatementInAmbientContext(node)) {
62702                 return;
62703             }
62704             var func = ts.getContainingFunction(node);
62705             if (!func) {
62706                 grammarErrorOnFirstToken(node, ts.Diagnostics.A_return_statement_can_only_be_used_within_a_function_body);
62707                 return;
62708             }
62709             var signature = getSignatureFromDeclaration(func);
62710             var returnType = getReturnTypeOfSignature(signature);
62711             var functionFlags = ts.getFunctionFlags(func);
62712             if (strictNullChecks || node.expression || returnType.flags & 131072) {
62713                 var exprType = node.expression ? checkExpressionCached(node.expression) : undefinedType;
62714                 if (func.kind === 168) {
62715                     if (node.expression) {
62716                         error(node, ts.Diagnostics.Setters_cannot_return_a_value);
62717                     }
62718                 }
62719                 else if (func.kind === 166) {
62720                     if (node.expression && !checkTypeAssignableToAndOptionallyElaborate(exprType, returnType, node, node.expression)) {
62721                         error(node, ts.Diagnostics.Return_type_of_constructor_signature_must_be_assignable_to_the_instance_type_of_the_class);
62722                     }
62723                 }
62724                 else if (getReturnTypeFromAnnotation(func)) {
62725                     var unwrappedReturnType = (_a = unwrapReturnType(returnType, functionFlags)) !== null && _a !== void 0 ? _a : returnType;
62726                     var unwrappedExprType = functionFlags & 2
62727                         ? 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)
62728                         : exprType;
62729                     if (unwrappedReturnType) {
62730                         checkTypeAssignableToAndOptionallyElaborate(unwrappedExprType, unwrappedReturnType, node, node.expression);
62731                     }
62732                 }
62733             }
62734             else if (func.kind !== 166 && compilerOptions.noImplicitReturns && !isUnwrappedReturnTypeVoidOrAny(func, returnType)) {
62735                 error(node, ts.Diagnostics.Not_all_code_paths_return_a_value);
62736             }
62737         }
62738         function checkWithStatement(node) {
62739             if (!checkGrammarStatementInAmbientContext(node)) {
62740                 if (node.flags & 32768) {
62741                     grammarErrorOnFirstToken(node, ts.Diagnostics.with_statements_are_not_allowed_in_an_async_function_block);
62742                 }
62743             }
62744             checkExpression(node.expression);
62745             var sourceFile = ts.getSourceFileOfNode(node);
62746             if (!hasParseDiagnostics(sourceFile)) {
62747                 var start = ts.getSpanOfTokenAtPosition(sourceFile, node.pos).start;
62748                 var end = node.statement.pos;
62749                 grammarErrorAtPos(sourceFile, start, end - start, ts.Diagnostics.The_with_statement_is_not_supported_All_symbols_in_a_with_block_will_have_type_any);
62750             }
62751         }
62752         function checkSwitchStatement(node) {
62753             checkGrammarStatementInAmbientContext(node);
62754             var firstDefaultClause;
62755             var hasDuplicateDefaultClause = false;
62756             var expressionType = checkExpression(node.expression);
62757             var expressionIsLiteral = isLiteralType(expressionType);
62758             ts.forEach(node.caseBlock.clauses, function (clause) {
62759                 if (clause.kind === 285 && !hasDuplicateDefaultClause) {
62760                     if (firstDefaultClause === undefined) {
62761                         firstDefaultClause = clause;
62762                     }
62763                     else {
62764                         grammarErrorOnNode(clause, ts.Diagnostics.A_default_clause_cannot_appear_more_than_once_in_a_switch_statement);
62765                         hasDuplicateDefaultClause = true;
62766                     }
62767                 }
62768                 if (produceDiagnostics && clause.kind === 284) {
62769                     var caseType = checkExpression(clause.expression);
62770                     var caseIsLiteral = isLiteralType(caseType);
62771                     var comparedExpressionType = expressionType;
62772                     if (!caseIsLiteral || !expressionIsLiteral) {
62773                         caseType = caseIsLiteral ? getBaseTypeOfLiteralType(caseType) : caseType;
62774                         comparedExpressionType = getBaseTypeOfLiteralType(expressionType);
62775                     }
62776                     if (!isTypeEqualityComparableTo(comparedExpressionType, caseType)) {
62777                         checkTypeComparableTo(caseType, comparedExpressionType, clause.expression, undefined);
62778                     }
62779                 }
62780                 ts.forEach(clause.statements, checkSourceElement);
62781                 if (compilerOptions.noFallthroughCasesInSwitch && clause.fallthroughFlowNode && isReachableFlowNode(clause.fallthroughFlowNode)) {
62782                     error(clause, ts.Diagnostics.Fallthrough_case_in_switch);
62783                 }
62784             });
62785             if (node.caseBlock.locals) {
62786                 registerForUnusedIdentifiersCheck(node.caseBlock);
62787             }
62788         }
62789         function checkLabeledStatement(node) {
62790             if (!checkGrammarStatementInAmbientContext(node)) {
62791                 ts.findAncestor(node.parent, function (current) {
62792                     if (ts.isFunctionLike(current)) {
62793                         return "quit";
62794                     }
62795                     if (current.kind === 245 && current.label.escapedText === node.label.escapedText) {
62796                         grammarErrorOnNode(node.label, ts.Diagnostics.Duplicate_label_0, ts.getTextOfNode(node.label));
62797                         return true;
62798                     }
62799                     return false;
62800                 });
62801             }
62802             checkSourceElement(node.statement);
62803         }
62804         function checkThrowStatement(node) {
62805             if (!checkGrammarStatementInAmbientContext(node)) {
62806                 if (ts.isIdentifier(node.expression) && !node.expression.escapedText) {
62807                     grammarErrorAfterFirstToken(node, ts.Diagnostics.Line_break_not_permitted_here);
62808                 }
62809             }
62810             if (node.expression) {
62811                 checkExpression(node.expression);
62812             }
62813         }
62814         function checkTryStatement(node) {
62815             checkGrammarStatementInAmbientContext(node);
62816             checkBlock(node.tryBlock);
62817             var catchClause = node.catchClause;
62818             if (catchClause) {
62819                 if (catchClause.variableDeclaration) {
62820                     var declaration = catchClause.variableDeclaration;
62821                     if (declaration.type) {
62822                         var type = getTypeForVariableLikeDeclaration(declaration, false);
62823                         if (type && !(type.flags & 3)) {
62824                             grammarErrorOnFirstToken(declaration.type, ts.Diagnostics.Catch_clause_variable_type_annotation_must_be_any_or_unknown_if_specified);
62825                         }
62826                     }
62827                     else if (declaration.initializer) {
62828                         grammarErrorOnFirstToken(declaration.initializer, ts.Diagnostics.Catch_clause_variable_cannot_have_an_initializer);
62829                     }
62830                     else {
62831                         var blockLocals_1 = catchClause.block.locals;
62832                         if (blockLocals_1) {
62833                             ts.forEachKey(catchClause.locals, function (caughtName) {
62834                                 var blockLocal = blockLocals_1.get(caughtName);
62835                                 if (blockLocal && (blockLocal.flags & 2) !== 0) {
62836                                     grammarErrorOnNode(blockLocal.valueDeclaration, ts.Diagnostics.Cannot_redeclare_identifier_0_in_catch_clause, caughtName);
62837                                 }
62838                             });
62839                         }
62840                     }
62841                 }
62842                 checkBlock(catchClause.block);
62843             }
62844             if (node.finallyBlock) {
62845                 checkBlock(node.finallyBlock);
62846             }
62847         }
62848         function checkIndexConstraints(type) {
62849             var declaredNumberIndexer = getIndexDeclarationOfSymbol(type.symbol, 1);
62850             var declaredStringIndexer = getIndexDeclarationOfSymbol(type.symbol, 0);
62851             var stringIndexType = getIndexTypeOfType(type, 0);
62852             var numberIndexType = getIndexTypeOfType(type, 1);
62853             if (stringIndexType || numberIndexType) {
62854                 ts.forEach(getPropertiesOfObjectType(type), function (prop) {
62855                     var propType = getTypeOfSymbol(prop);
62856                     checkIndexConstraintForProperty(prop, propType, type, declaredStringIndexer, stringIndexType, 0);
62857                     checkIndexConstraintForProperty(prop, propType, type, declaredNumberIndexer, numberIndexType, 1);
62858                 });
62859                 var classDeclaration = type.symbol.valueDeclaration;
62860                 if (ts.getObjectFlags(type) & 1 && ts.isClassLike(classDeclaration)) {
62861                     for (var _i = 0, _a = classDeclaration.members; _i < _a.length; _i++) {
62862                         var member = _a[_i];
62863                         if (!ts.hasSyntacticModifier(member, 32) && hasNonBindableDynamicName(member)) {
62864                             var symbol = getSymbolOfNode(member);
62865                             var propType = getTypeOfSymbol(symbol);
62866                             checkIndexConstraintForProperty(symbol, propType, type, declaredStringIndexer, stringIndexType, 0);
62867                             checkIndexConstraintForProperty(symbol, propType, type, declaredNumberIndexer, numberIndexType, 1);
62868                         }
62869                     }
62870                 }
62871             }
62872             var errorNode;
62873             if (stringIndexType && numberIndexType) {
62874                 errorNode = declaredNumberIndexer || declaredStringIndexer;
62875                 if (!errorNode && (ts.getObjectFlags(type) & 2)) {
62876                     var someBaseTypeHasBothIndexers = ts.forEach(getBaseTypes(type), function (base) { return getIndexTypeOfType(base, 0) && getIndexTypeOfType(base, 1); });
62877                     errorNode = someBaseTypeHasBothIndexers ? undefined : type.symbol.declarations[0];
62878                 }
62879             }
62880             if (errorNode && !isTypeAssignableTo(numberIndexType, stringIndexType)) {
62881                 error(errorNode, ts.Diagnostics.Numeric_index_type_0_is_not_assignable_to_string_index_type_1, typeToString(numberIndexType), typeToString(stringIndexType));
62882             }
62883             function checkIndexConstraintForProperty(prop, propertyType, containingType, indexDeclaration, indexType, indexKind) {
62884                 if (!indexType || ts.isKnownSymbol(prop)) {
62885                     return;
62886                 }
62887                 var propDeclaration = prop.valueDeclaration;
62888                 var name = propDeclaration && ts.getNameOfDeclaration(propDeclaration);
62889                 if (name && ts.isPrivateIdentifier(name)) {
62890                     return;
62891                 }
62892                 if (indexKind === 1 && !(name ? isNumericName(name) : isNumericLiteralName(prop.escapedName))) {
62893                     return;
62894                 }
62895                 var errorNode;
62896                 if (propDeclaration && name &&
62897                     (propDeclaration.kind === 216 ||
62898                         name.kind === 158 ||
62899                         prop.parent === containingType.symbol)) {
62900                     errorNode = propDeclaration;
62901                 }
62902                 else if (indexDeclaration) {
62903                     errorNode = indexDeclaration;
62904                 }
62905                 else if (ts.getObjectFlags(containingType) & 2) {
62906                     var someBaseClassHasBothPropertyAndIndexer = ts.forEach(getBaseTypes(containingType), function (base) { return getPropertyOfObjectType(base, prop.escapedName) && getIndexTypeOfType(base, indexKind); });
62907                     errorNode = someBaseClassHasBothPropertyAndIndexer ? undefined : containingType.symbol.declarations[0];
62908                 }
62909                 if (errorNode && !isTypeAssignableTo(propertyType, indexType)) {
62910                     var errorMessage = indexKind === 0
62911                         ? ts.Diagnostics.Property_0_of_type_1_is_not_assignable_to_string_index_type_2
62912                         : ts.Diagnostics.Property_0_of_type_1_is_not_assignable_to_numeric_index_type_2;
62913                     error(errorNode, errorMessage, symbolToString(prop), typeToString(propertyType), typeToString(indexType));
62914                 }
62915             }
62916         }
62917         function checkTypeNameIsReserved(name, message) {
62918             switch (name.escapedText) {
62919                 case "any":
62920                 case "unknown":
62921                 case "number":
62922                 case "bigint":
62923                 case "boolean":
62924                 case "string":
62925                 case "symbol":
62926                 case "void":
62927                 case "object":
62928                     error(name, message, name.escapedText);
62929             }
62930         }
62931         function checkClassNameCollisionWithObject(name) {
62932             if (languageVersion === 1 && name.escapedText === "Object"
62933                 && moduleKind < ts.ModuleKind.ES2015) {
62934                 error(name, ts.Diagnostics.Class_name_cannot_be_Object_when_targeting_ES5_with_module_0, ts.ModuleKind[moduleKind]);
62935             }
62936         }
62937         function checkTypeParameters(typeParameterDeclarations) {
62938             if (typeParameterDeclarations) {
62939                 var seenDefault = false;
62940                 for (var i = 0; i < typeParameterDeclarations.length; i++) {
62941                     var node = typeParameterDeclarations[i];
62942                     checkTypeParameter(node);
62943                     if (produceDiagnostics) {
62944                         if (node.default) {
62945                             seenDefault = true;
62946                             checkTypeParametersNotReferenced(node.default, typeParameterDeclarations, i);
62947                         }
62948                         else if (seenDefault) {
62949                             error(node, ts.Diagnostics.Required_type_parameters_may_not_follow_optional_type_parameters);
62950                         }
62951                         for (var j = 0; j < i; j++) {
62952                             if (typeParameterDeclarations[j].symbol === node.symbol) {
62953                                 error(node.name, ts.Diagnostics.Duplicate_identifier_0, ts.declarationNameToString(node.name));
62954                             }
62955                         }
62956                     }
62957                 }
62958             }
62959         }
62960         function checkTypeParametersNotReferenced(root, typeParameters, index) {
62961             visit(root);
62962             function visit(node) {
62963                 if (node.kind === 173) {
62964                     var type = getTypeFromTypeReference(node);
62965                     if (type.flags & 262144) {
62966                         for (var i = index; i < typeParameters.length; i++) {
62967                             if (type.symbol === getSymbolOfNode(typeParameters[i])) {
62968                                 error(node, ts.Diagnostics.Type_parameter_defaults_can_only_reference_previously_declared_type_parameters);
62969                             }
62970                         }
62971                     }
62972                 }
62973                 ts.forEachChild(node, visit);
62974             }
62975         }
62976         function checkTypeParameterListsIdentical(symbol) {
62977             if (symbol.declarations.length === 1) {
62978                 return;
62979             }
62980             var links = getSymbolLinks(symbol);
62981             if (!links.typeParametersChecked) {
62982                 links.typeParametersChecked = true;
62983                 var declarations = getClassOrInterfaceDeclarationsOfSymbol(symbol);
62984                 if (declarations.length <= 1) {
62985                     return;
62986                 }
62987                 var type = getDeclaredTypeOfSymbol(symbol);
62988                 if (!areTypeParametersIdentical(declarations, type.localTypeParameters)) {
62989                     var name = symbolToString(symbol);
62990                     for (var _i = 0, declarations_6 = declarations; _i < declarations_6.length; _i++) {
62991                         var declaration = declarations_6[_i];
62992                         error(declaration.name, ts.Diagnostics.All_declarations_of_0_must_have_identical_type_parameters, name);
62993                     }
62994                 }
62995             }
62996         }
62997         function areTypeParametersIdentical(declarations, targetParameters) {
62998             var maxTypeArgumentCount = ts.length(targetParameters);
62999             var minTypeArgumentCount = getMinTypeArgumentCount(targetParameters);
63000             for (var _i = 0, declarations_7 = declarations; _i < declarations_7.length; _i++) {
63001                 var declaration = declarations_7[_i];
63002                 var sourceParameters = ts.getEffectiveTypeParameterDeclarations(declaration);
63003                 var numTypeParameters = sourceParameters.length;
63004                 if (numTypeParameters < minTypeArgumentCount || numTypeParameters > maxTypeArgumentCount) {
63005                     return false;
63006                 }
63007                 for (var i = 0; i < numTypeParameters; i++) {
63008                     var source = sourceParameters[i];
63009                     var target = targetParameters[i];
63010                     if (source.name.escapedText !== target.symbol.escapedName) {
63011                         return false;
63012                     }
63013                     var constraint = ts.getEffectiveConstraintOfTypeParameter(source);
63014                     var sourceConstraint = constraint && getTypeFromTypeNode(constraint);
63015                     var targetConstraint = getConstraintOfTypeParameter(target);
63016                     if (sourceConstraint && targetConstraint && !isTypeIdenticalTo(sourceConstraint, targetConstraint)) {
63017                         return false;
63018                     }
63019                     var sourceDefault = source.default && getTypeFromTypeNode(source.default);
63020                     var targetDefault = getDefaultFromTypeParameter(target);
63021                     if (sourceDefault && targetDefault && !isTypeIdenticalTo(sourceDefault, targetDefault)) {
63022                         return false;
63023                     }
63024                 }
63025             }
63026             return true;
63027         }
63028         function checkClassExpression(node) {
63029             checkClassLikeDeclaration(node);
63030             checkNodeDeferred(node);
63031             return getTypeOfSymbol(getSymbolOfNode(node));
63032         }
63033         function checkClassExpressionDeferred(node) {
63034             ts.forEach(node.members, checkSourceElement);
63035             registerForUnusedIdentifiersCheck(node);
63036         }
63037         function checkClassDeclaration(node) {
63038             if (!node.name && !ts.hasSyntacticModifier(node, 512)) {
63039                 grammarErrorOnFirstToken(node, ts.Diagnostics.A_class_declaration_without_the_default_modifier_must_have_a_name);
63040             }
63041             checkClassLikeDeclaration(node);
63042             ts.forEach(node.members, checkSourceElement);
63043             registerForUnusedIdentifiersCheck(node);
63044         }
63045         function checkClassLikeDeclaration(node) {
63046             checkGrammarClassLikeDeclaration(node);
63047             checkDecorators(node);
63048             if (node.name) {
63049                 checkTypeNameIsReserved(node.name, ts.Diagnostics.Class_name_cannot_be_0);
63050                 checkCollisionWithRequireExportsInGeneratedCode(node, node.name);
63051                 checkCollisionWithGlobalPromiseInGeneratedCode(node, node.name);
63052                 if (!(node.flags & 8388608)) {
63053                     checkClassNameCollisionWithObject(node.name);
63054                 }
63055             }
63056             checkTypeParameters(ts.getEffectiveTypeParameterDeclarations(node));
63057             checkExportsOnMergedDeclarations(node);
63058             var symbol = getSymbolOfNode(node);
63059             var type = getDeclaredTypeOfSymbol(symbol);
63060             var typeWithThis = getTypeWithThisArgument(type);
63061             var staticType = getTypeOfSymbol(symbol);
63062             checkTypeParameterListsIdentical(symbol);
63063             checkFunctionOrConstructorSymbol(symbol);
63064             checkClassForDuplicateDeclarations(node);
63065             if (!(node.flags & 8388608)) {
63066                 checkClassForStaticPropertyNameConflicts(node);
63067             }
63068             var baseTypeNode = ts.getEffectiveBaseTypeNode(node);
63069             if (baseTypeNode) {
63070                 ts.forEach(baseTypeNode.typeArguments, checkSourceElement);
63071                 if (languageVersion < 2) {
63072                     checkExternalEmitHelpers(baseTypeNode.parent, 1);
63073                 }
63074                 var extendsNode = ts.getClassExtendsHeritageElement(node);
63075                 if (extendsNode && extendsNode !== baseTypeNode) {
63076                     checkExpression(extendsNode.expression);
63077                 }
63078                 var baseTypes = getBaseTypes(type);
63079                 if (baseTypes.length && produceDiagnostics) {
63080                     var baseType_1 = baseTypes[0];
63081                     var baseConstructorType = getBaseConstructorTypeOfClass(type);
63082                     var staticBaseType = getApparentType(baseConstructorType);
63083                     checkBaseTypeAccessibility(staticBaseType, baseTypeNode);
63084                     checkSourceElement(baseTypeNode.expression);
63085                     if (ts.some(baseTypeNode.typeArguments)) {
63086                         ts.forEach(baseTypeNode.typeArguments, checkSourceElement);
63087                         for (var _i = 0, _a = getConstructorsForTypeArguments(staticBaseType, baseTypeNode.typeArguments, baseTypeNode); _i < _a.length; _i++) {
63088                             var constructor = _a[_i];
63089                             if (!checkTypeArgumentConstraints(baseTypeNode, constructor.typeParameters)) {
63090                                 break;
63091                             }
63092                         }
63093                     }
63094                     var baseWithThis = getTypeWithThisArgument(baseType_1, type.thisType);
63095                     if (!checkTypeAssignableTo(typeWithThis, baseWithThis, undefined)) {
63096                         issueMemberSpecificError(node, typeWithThis, baseWithThis, ts.Diagnostics.Class_0_incorrectly_extends_base_class_1);
63097                     }
63098                     else {
63099                         checkTypeAssignableTo(staticType, getTypeWithoutSignatures(staticBaseType), node.name || node, ts.Diagnostics.Class_static_side_0_incorrectly_extends_base_class_static_side_1);
63100                     }
63101                     if (baseConstructorType.flags & 8650752 && !isMixinConstructorType(staticType)) {
63102                         error(node.name || node, ts.Diagnostics.A_mixin_class_must_have_a_constructor_with_a_single_rest_parameter_of_type_any);
63103                     }
63104                     if (!(staticBaseType.symbol && staticBaseType.symbol.flags & 32) && !(baseConstructorType.flags & 8650752)) {
63105                         var constructors = getInstantiatedConstructorsForTypeArguments(staticBaseType, baseTypeNode.typeArguments, baseTypeNode);
63106                         if (ts.forEach(constructors, function (sig) { return !isJSConstructor(sig.declaration) && !isTypeIdenticalTo(getReturnTypeOfSignature(sig), baseType_1); })) {
63107                             error(baseTypeNode.expression, ts.Diagnostics.Base_constructors_must_all_have_the_same_return_type);
63108                         }
63109                     }
63110                     checkKindsOfPropertyMemberOverrides(type, baseType_1);
63111                 }
63112             }
63113             var implementedTypeNodes = ts.getEffectiveImplementsTypeNodes(node);
63114             if (implementedTypeNodes) {
63115                 for (var _b = 0, implementedTypeNodes_1 = implementedTypeNodes; _b < implementedTypeNodes_1.length; _b++) {
63116                     var typeRefNode = implementedTypeNodes_1[_b];
63117                     if (!ts.isEntityNameExpression(typeRefNode.expression)) {
63118                         error(typeRefNode.expression, ts.Diagnostics.A_class_can_only_implement_an_identifier_Slashqualified_name_with_optional_type_arguments);
63119                     }
63120                     checkTypeReferenceNode(typeRefNode);
63121                     if (produceDiagnostics) {
63122                         var t = getReducedType(getTypeFromTypeNode(typeRefNode));
63123                         if (t !== errorType) {
63124                             if (isValidBaseType(t)) {
63125                                 var genericDiag = t.symbol && t.symbol.flags & 32 ?
63126                                     ts.Diagnostics.Class_0_incorrectly_implements_class_1_Did_you_mean_to_extend_1_and_inherit_its_members_as_a_subclass :
63127                                     ts.Diagnostics.Class_0_incorrectly_implements_interface_1;
63128                                 var baseWithThis = getTypeWithThisArgument(t, type.thisType);
63129                                 if (!checkTypeAssignableTo(typeWithThis, baseWithThis, undefined)) {
63130                                     issueMemberSpecificError(node, typeWithThis, baseWithThis, genericDiag);
63131                                 }
63132                             }
63133                             else {
63134                                 error(typeRefNode, ts.Diagnostics.A_class_can_only_implement_an_object_type_or_intersection_of_object_types_with_statically_known_members);
63135                             }
63136                         }
63137                     }
63138                 }
63139             }
63140             if (produceDiagnostics) {
63141                 checkIndexConstraints(type);
63142                 checkTypeForDuplicateIndexSignatures(node);
63143                 checkPropertyInitialization(node);
63144             }
63145         }
63146         function issueMemberSpecificError(node, typeWithThis, baseWithThis, broadDiag) {
63147             var issuedMemberError = false;
63148             var _loop_23 = function (member) {
63149                 if (ts.hasStaticModifier(member)) {
63150                     return "continue";
63151                 }
63152                 var declaredProp = member.name && getSymbolAtLocation(member.name) || getSymbolAtLocation(member);
63153                 if (declaredProp) {
63154                     var prop = getPropertyOfType(typeWithThis, declaredProp.escapedName);
63155                     var baseProp = getPropertyOfType(baseWithThis, declaredProp.escapedName);
63156                     if (prop && baseProp) {
63157                         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)); };
63158                         if (!checkTypeAssignableTo(getTypeOfSymbol(prop), getTypeOfSymbol(baseProp), member.name || member, undefined, rootChain)) {
63159                             issuedMemberError = true;
63160                         }
63161                     }
63162                 }
63163             };
63164             for (var _i = 0, _a = node.members; _i < _a.length; _i++) {
63165                 var member = _a[_i];
63166                 _loop_23(member);
63167             }
63168             if (!issuedMemberError) {
63169                 checkTypeAssignableTo(typeWithThis, baseWithThis, node.name || node, broadDiag);
63170             }
63171         }
63172         function checkBaseTypeAccessibility(type, node) {
63173             var signatures = getSignaturesOfType(type, 1);
63174             if (signatures.length) {
63175                 var declaration = signatures[0].declaration;
63176                 if (declaration && ts.hasEffectiveModifier(declaration, 8)) {
63177                     var typeClassDeclaration = ts.getClassLikeDeclarationOfSymbol(type.symbol);
63178                     if (!isNodeWithinClass(node, typeClassDeclaration)) {
63179                         error(node, ts.Diagnostics.Cannot_extend_a_class_0_Class_constructor_is_marked_as_private, getFullyQualifiedName(type.symbol));
63180                     }
63181                 }
63182             }
63183         }
63184         function getTargetSymbol(s) {
63185             return ts.getCheckFlags(s) & 1 ? s.target : s;
63186         }
63187         function getClassOrInterfaceDeclarationsOfSymbol(symbol) {
63188             return ts.filter(symbol.declarations, function (d) {
63189                 return d.kind === 252 || d.kind === 253;
63190             });
63191         }
63192         function checkKindsOfPropertyMemberOverrides(type, baseType) {
63193             var baseProperties = getPropertiesOfType(baseType);
63194             basePropertyCheck: for (var _i = 0, baseProperties_1 = baseProperties; _i < baseProperties_1.length; _i++) {
63195                 var baseProperty = baseProperties_1[_i];
63196                 var base = getTargetSymbol(baseProperty);
63197                 if (base.flags & 4194304) {
63198                     continue;
63199                 }
63200                 var baseSymbol = getPropertyOfObjectType(type, base.escapedName);
63201                 if (!baseSymbol) {
63202                     continue;
63203                 }
63204                 var derived = getTargetSymbol(baseSymbol);
63205                 var baseDeclarationFlags = ts.getDeclarationModifierFlagsFromSymbol(base);
63206                 ts.Debug.assert(!!derived, "derived should point to something, even if it is the base class' declaration.");
63207                 if (derived === base) {
63208                     var derivedClassDecl = ts.getClassLikeDeclarationOfSymbol(type.symbol);
63209                     if (baseDeclarationFlags & 128 && (!derivedClassDecl || !ts.hasSyntacticModifier(derivedClassDecl, 128))) {
63210                         for (var _a = 0, _b = getBaseTypes(type); _a < _b.length; _a++) {
63211                             var otherBaseType = _b[_a];
63212                             if (otherBaseType === baseType)
63213                                 continue;
63214                             var baseSymbol_1 = getPropertyOfObjectType(otherBaseType, base.escapedName);
63215                             var derivedElsewhere = baseSymbol_1 && getTargetSymbol(baseSymbol_1);
63216                             if (derivedElsewhere && derivedElsewhere !== base) {
63217                                 continue basePropertyCheck;
63218                             }
63219                         }
63220                         if (derivedClassDecl.kind === 221) {
63221                             error(derivedClassDecl, ts.Diagnostics.Non_abstract_class_expression_does_not_implement_inherited_abstract_member_0_from_class_1, symbolToString(baseProperty), typeToString(baseType));
63222                         }
63223                         else {
63224                             error(derivedClassDecl, ts.Diagnostics.Non_abstract_class_0_does_not_implement_inherited_abstract_member_1_from_class_2, typeToString(type), symbolToString(baseProperty), typeToString(baseType));
63225                         }
63226                     }
63227                 }
63228                 else {
63229                     var derivedDeclarationFlags = ts.getDeclarationModifierFlagsFromSymbol(derived);
63230                     if (baseDeclarationFlags & 8 || derivedDeclarationFlags & 8) {
63231                         continue;
63232                     }
63233                     var errorMessage = void 0;
63234                     var basePropertyFlags = base.flags & 98308;
63235                     var derivedPropertyFlags = derived.flags & 98308;
63236                     if (basePropertyFlags && derivedPropertyFlags) {
63237                         if (baseDeclarationFlags & 128 && !(base.valueDeclaration && ts.isPropertyDeclaration(base.valueDeclaration) && base.valueDeclaration.initializer)
63238                             || base.valueDeclaration && base.valueDeclaration.parent.kind === 253
63239                             || derived.valueDeclaration && ts.isBinaryExpression(derived.valueDeclaration)) {
63240                             continue;
63241                         }
63242                         var overriddenInstanceProperty = basePropertyFlags !== 4 && derivedPropertyFlags === 4;
63243                         var overriddenInstanceAccessor = basePropertyFlags === 4 && derivedPropertyFlags !== 4;
63244                         if (overriddenInstanceProperty || overriddenInstanceAccessor) {
63245                             var errorMessage_1 = overriddenInstanceProperty ?
63246                                 ts.Diagnostics._0_is_defined_as_an_accessor_in_class_1_but_is_overridden_here_in_2_as_an_instance_property :
63247                                 ts.Diagnostics._0_is_defined_as_a_property_in_class_1_but_is_overridden_here_in_2_as_an_accessor;
63248                             error(ts.getNameOfDeclaration(derived.valueDeclaration) || derived.valueDeclaration, errorMessage_1, symbolToString(base), typeToString(baseType), typeToString(type));
63249                         }
63250                         else if (compilerOptions.useDefineForClassFields) {
63251                             var uninitialized = ts.find(derived.declarations, function (d) { return d.kind === 163 && !d.initializer; });
63252                             if (uninitialized
63253                                 && !(derived.flags & 33554432)
63254                                 && !(baseDeclarationFlags & 128)
63255                                 && !(derivedDeclarationFlags & 128)
63256                                 && !derived.declarations.some(function (d) { return !!(d.flags & 8388608); })) {
63257                                 var constructor = findConstructorDeclaration(ts.getClassLikeDeclarationOfSymbol(type.symbol));
63258                                 var propName = uninitialized.name;
63259                                 if (uninitialized.exclamationToken
63260                                     || !constructor
63261                                     || !ts.isIdentifier(propName)
63262                                     || !strictNullChecks
63263                                     || !isPropertyInitializedInConstructor(propName, type, constructor)) {
63264                                     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;
63265                                     error(ts.getNameOfDeclaration(derived.valueDeclaration) || derived.valueDeclaration, errorMessage_2, symbolToString(base), typeToString(baseType));
63266                                 }
63267                             }
63268                         }
63269                         continue;
63270                     }
63271                     else if (isPrototypeProperty(base)) {
63272                         if (isPrototypeProperty(derived) || derived.flags & 4) {
63273                             continue;
63274                         }
63275                         else {
63276                             ts.Debug.assert(!!(derived.flags & 98304));
63277                             errorMessage = ts.Diagnostics.Class_0_defines_instance_member_function_1_but_extended_class_2_defines_it_as_instance_member_accessor;
63278                         }
63279                     }
63280                     else if (base.flags & 98304) {
63281                         errorMessage = ts.Diagnostics.Class_0_defines_instance_member_accessor_1_but_extended_class_2_defines_it_as_instance_member_function;
63282                     }
63283                     else {
63284                         errorMessage = ts.Diagnostics.Class_0_defines_instance_member_property_1_but_extended_class_2_defines_it_as_instance_member_function;
63285                     }
63286                     error(ts.getNameOfDeclaration(derived.valueDeclaration) || derived.valueDeclaration, errorMessage, typeToString(baseType), symbolToString(base), typeToString(type));
63287                 }
63288             }
63289         }
63290         function getNonInterhitedProperties(type, baseTypes, properties) {
63291             if (!ts.length(baseTypes)) {
63292                 return properties;
63293             }
63294             var seen = new ts.Map();
63295             ts.forEach(properties, function (p) { seen.set(p.escapedName, p); });
63296             for (var _i = 0, baseTypes_2 = baseTypes; _i < baseTypes_2.length; _i++) {
63297                 var base = baseTypes_2[_i];
63298                 var properties_5 = getPropertiesOfType(getTypeWithThisArgument(base, type.thisType));
63299                 for (var _a = 0, properties_4 = properties_5; _a < properties_4.length; _a++) {
63300                     var prop = properties_4[_a];
63301                     var existing = seen.get(prop.escapedName);
63302                     if (existing && !isPropertyIdenticalTo(existing, prop)) {
63303                         seen.delete(prop.escapedName);
63304                     }
63305                 }
63306             }
63307             return ts.arrayFrom(seen.values());
63308         }
63309         function checkInheritedPropertiesAreIdentical(type, typeNode) {
63310             var baseTypes = getBaseTypes(type);
63311             if (baseTypes.length < 2) {
63312                 return true;
63313             }
63314             var seen = new ts.Map();
63315             ts.forEach(resolveDeclaredMembers(type).declaredProperties, function (p) { seen.set(p.escapedName, { prop: p, containingType: type }); });
63316             var ok = true;
63317             for (var _i = 0, baseTypes_3 = baseTypes; _i < baseTypes_3.length; _i++) {
63318                 var base = baseTypes_3[_i];
63319                 var properties = getPropertiesOfType(getTypeWithThisArgument(base, type.thisType));
63320                 for (var _a = 0, properties_6 = properties; _a < properties_6.length; _a++) {
63321                     var prop = properties_6[_a];
63322                     var existing = seen.get(prop.escapedName);
63323                     if (!existing) {
63324                         seen.set(prop.escapedName, { prop: prop, containingType: base });
63325                     }
63326                     else {
63327                         var isInheritedProperty = existing.containingType !== type;
63328                         if (isInheritedProperty && !isPropertyIdenticalTo(existing.prop, prop)) {
63329                             ok = false;
63330                             var typeName1 = typeToString(existing.containingType);
63331                             var typeName2 = typeToString(base);
63332                             var errorInfo = ts.chainDiagnosticMessages(undefined, ts.Diagnostics.Named_property_0_of_types_1_and_2_are_not_identical, symbolToString(prop), typeName1, typeName2);
63333                             errorInfo = ts.chainDiagnosticMessages(errorInfo, ts.Diagnostics.Interface_0_cannot_simultaneously_extend_types_1_and_2, typeToString(type), typeName1, typeName2);
63334                             diagnostics.add(ts.createDiagnosticForNodeFromMessageChain(typeNode, errorInfo));
63335                         }
63336                     }
63337                 }
63338             }
63339             return ok;
63340         }
63341         function checkPropertyInitialization(node) {
63342             if (!strictNullChecks || !strictPropertyInitialization || node.flags & 8388608) {
63343                 return;
63344             }
63345             var constructor = findConstructorDeclaration(node);
63346             for (var _i = 0, _a = node.members; _i < _a.length; _i++) {
63347                 var member = _a[_i];
63348                 if (ts.getEffectiveModifierFlags(member) & 2) {
63349                     continue;
63350                 }
63351                 if (isInstancePropertyWithoutInitializer(member)) {
63352                     var propName = member.name;
63353                     if (ts.isIdentifier(propName) || ts.isPrivateIdentifier(propName)) {
63354                         var type = getTypeOfSymbol(getSymbolOfNode(member));
63355                         if (!(type.flags & 3 || getFalsyFlags(type) & 32768)) {
63356                             if (!constructor || !isPropertyInitializedInConstructor(propName, type, constructor)) {
63357                                 error(member.name, ts.Diagnostics.Property_0_has_no_initializer_and_is_not_definitely_assigned_in_the_constructor, ts.declarationNameToString(propName));
63358                             }
63359                         }
63360                     }
63361                 }
63362             }
63363         }
63364         function isInstancePropertyWithoutInitializer(node) {
63365             return node.kind === 163 &&
63366                 !ts.hasSyntacticModifier(node, 32 | 128) &&
63367                 !node.exclamationToken &&
63368                 !node.initializer;
63369         }
63370         function isPropertyInitializedInConstructor(propName, propType, constructor) {
63371             var reference = ts.factory.createPropertyAccessExpression(ts.factory.createThis(), propName);
63372             ts.setParent(reference.expression, reference);
63373             ts.setParent(reference, constructor);
63374             reference.flowNode = constructor.returnFlowNode;
63375             var flowType = getFlowTypeOfReference(reference, propType, getOptionalType(propType));
63376             return !(getFalsyFlags(flowType) & 32768);
63377         }
63378         function checkInterfaceDeclaration(node) {
63379             if (!checkGrammarDecoratorsAndModifiers(node))
63380                 checkGrammarInterfaceDeclaration(node);
63381             checkTypeParameters(node.typeParameters);
63382             if (produceDiagnostics) {
63383                 checkTypeNameIsReserved(node.name, ts.Diagnostics.Interface_name_cannot_be_0);
63384                 checkExportsOnMergedDeclarations(node);
63385                 var symbol = getSymbolOfNode(node);
63386                 checkTypeParameterListsIdentical(symbol);
63387                 var firstInterfaceDecl = ts.getDeclarationOfKind(symbol, 253);
63388                 if (node === firstInterfaceDecl) {
63389                     var type = getDeclaredTypeOfSymbol(symbol);
63390                     var typeWithThis = getTypeWithThisArgument(type);
63391                     if (checkInheritedPropertiesAreIdentical(type, node.name)) {
63392                         for (var _i = 0, _a = getBaseTypes(type); _i < _a.length; _i++) {
63393                             var baseType = _a[_i];
63394                             checkTypeAssignableTo(typeWithThis, getTypeWithThisArgument(baseType, type.thisType), node.name, ts.Diagnostics.Interface_0_incorrectly_extends_interface_1);
63395                         }
63396                         checkIndexConstraints(type);
63397                     }
63398                 }
63399                 checkObjectTypeForDuplicateDeclarations(node);
63400             }
63401             ts.forEach(ts.getInterfaceBaseTypeNodes(node), function (heritageElement) {
63402                 if (!ts.isEntityNameExpression(heritageElement.expression)) {
63403                     error(heritageElement.expression, ts.Diagnostics.An_interface_can_only_extend_an_identifier_Slashqualified_name_with_optional_type_arguments);
63404                 }
63405                 checkTypeReferenceNode(heritageElement);
63406             });
63407             ts.forEach(node.members, checkSourceElement);
63408             if (produceDiagnostics) {
63409                 checkTypeForDuplicateIndexSignatures(node);
63410                 registerForUnusedIdentifiersCheck(node);
63411             }
63412         }
63413         function checkTypeAliasDeclaration(node) {
63414             checkGrammarDecoratorsAndModifiers(node);
63415             checkTypeNameIsReserved(node.name, ts.Diagnostics.Type_alias_name_cannot_be_0);
63416             checkExportsOnMergedDeclarations(node);
63417             checkTypeParameters(node.typeParameters);
63418             if (node.type.kind === 136) {
63419                 if (!intrinsicTypeKinds.has(node.name.escapedText) || ts.length(node.typeParameters) !== 1) {
63420                     error(node.type, ts.Diagnostics.The_intrinsic_keyword_can_only_be_used_to_declare_compiler_provided_intrinsic_types);
63421                 }
63422             }
63423             else {
63424                 checkSourceElement(node.type);
63425                 registerForUnusedIdentifiersCheck(node);
63426             }
63427         }
63428         function computeEnumMemberValues(node) {
63429             var nodeLinks = getNodeLinks(node);
63430             if (!(nodeLinks.flags & 16384)) {
63431                 nodeLinks.flags |= 16384;
63432                 var autoValue = 0;
63433                 for (var _i = 0, _a = node.members; _i < _a.length; _i++) {
63434                     var member = _a[_i];
63435                     var value = computeMemberValue(member, autoValue);
63436                     getNodeLinks(member).enumMemberValue = value;
63437                     autoValue = typeof value === "number" ? value + 1 : undefined;
63438                 }
63439             }
63440         }
63441         function computeMemberValue(member, autoValue) {
63442             if (ts.isComputedNonLiteralName(member.name)) {
63443                 error(member.name, ts.Diagnostics.Computed_property_names_are_not_allowed_in_enums);
63444             }
63445             else {
63446                 var text = ts.getTextOfPropertyName(member.name);
63447                 if (isNumericLiteralName(text) && !isInfinityOrNaNString(text)) {
63448                     error(member.name, ts.Diagnostics.An_enum_member_cannot_have_a_numeric_name);
63449                 }
63450             }
63451             if (member.initializer) {
63452                 return computeConstantValue(member);
63453             }
63454             if (member.parent.flags & 8388608 && !ts.isEnumConst(member.parent) && getEnumKind(getSymbolOfNode(member.parent)) === 0) {
63455                 return undefined;
63456             }
63457             if (autoValue !== undefined) {
63458                 return autoValue;
63459             }
63460             error(member.name, ts.Diagnostics.Enum_member_must_have_initializer);
63461             return undefined;
63462         }
63463         function computeConstantValue(member) {
63464             var enumKind = getEnumKind(getSymbolOfNode(member.parent));
63465             var isConstEnum = ts.isEnumConst(member.parent);
63466             var initializer = member.initializer;
63467             var value = enumKind === 1 && !isLiteralEnumMember(member) ? undefined : evaluate(initializer);
63468             if (value !== undefined) {
63469                 if (isConstEnum && typeof value === "number" && !isFinite(value)) {
63470                     error(initializer, isNaN(value) ?
63471                         ts.Diagnostics.const_enum_member_initializer_was_evaluated_to_disallowed_value_NaN :
63472                         ts.Diagnostics.const_enum_member_initializer_was_evaluated_to_a_non_finite_value);
63473                 }
63474             }
63475             else if (enumKind === 1) {
63476                 error(initializer, ts.Diagnostics.Computed_values_are_not_permitted_in_an_enum_with_string_valued_members);
63477                 return 0;
63478             }
63479             else if (isConstEnum) {
63480                 error(initializer, ts.Diagnostics.const_enum_member_initializers_can_only_contain_literal_values_and_other_computed_enum_values);
63481             }
63482             else if (member.parent.flags & 8388608) {
63483                 error(initializer, ts.Diagnostics.In_ambient_enum_declarations_member_initializer_must_be_constant_expression);
63484             }
63485             else {
63486                 var source = checkExpression(initializer);
63487                 if (!isTypeAssignableToKind(source, 296)) {
63488                     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));
63489                 }
63490                 else {
63491                     checkTypeAssignableTo(source, getDeclaredTypeOfSymbol(getSymbolOfNode(member.parent)), initializer, undefined);
63492                 }
63493             }
63494             return value;
63495             function evaluate(expr) {
63496                 switch (expr.kind) {
63497                     case 214:
63498                         var value_2 = evaluate(expr.operand);
63499                         if (typeof value_2 === "number") {
63500                             switch (expr.operator) {
63501                                 case 39: return value_2;
63502                                 case 40: return -value_2;
63503                                 case 54: return ~value_2;
63504                             }
63505                         }
63506                         break;
63507                     case 216:
63508                         var left = evaluate(expr.left);
63509                         var right = evaluate(expr.right);
63510                         if (typeof left === "number" && typeof right === "number") {
63511                             switch (expr.operatorToken.kind) {
63512                                 case 51: return left | right;
63513                                 case 50: return left & right;
63514                                 case 48: return left >> right;
63515                                 case 49: return left >>> right;
63516                                 case 47: return left << right;
63517                                 case 52: return left ^ right;
63518                                 case 41: return left * right;
63519                                 case 43: return left / right;
63520                                 case 39: return left + right;
63521                                 case 40: return left - right;
63522                                 case 44: return left % right;
63523                                 case 42: return Math.pow(left, right);
63524                             }
63525                         }
63526                         else if (typeof left === "string" && typeof right === "string" && expr.operatorToken.kind === 39) {
63527                             return left + right;
63528                         }
63529                         break;
63530                     case 10:
63531                     case 14:
63532                         return expr.text;
63533                     case 8:
63534                         checkGrammarNumericLiteral(expr);
63535                         return +expr.text;
63536                     case 207:
63537                         return evaluate(expr.expression);
63538                     case 78:
63539                         var identifier = expr;
63540                         if (isInfinityOrNaNString(identifier.escapedText)) {
63541                             return +(identifier.escapedText);
63542                         }
63543                         return ts.nodeIsMissing(expr) ? 0 : evaluateEnumMember(expr, getSymbolOfNode(member.parent), identifier.escapedText);
63544                     case 202:
63545                     case 201:
63546                         var ex = expr;
63547                         if (isConstantMemberAccess(ex)) {
63548                             var type = getTypeOfExpression(ex.expression);
63549                             if (type.symbol && type.symbol.flags & 384) {
63550                                 var name = void 0;
63551                                 if (ex.kind === 201) {
63552                                     name = ex.name.escapedText;
63553                                 }
63554                                 else {
63555                                     name = ts.escapeLeadingUnderscores(ts.cast(ex.argumentExpression, ts.isLiteralExpression).text);
63556                                 }
63557                                 return evaluateEnumMember(expr, type.symbol, name);
63558                             }
63559                         }
63560                         break;
63561                 }
63562                 return undefined;
63563             }
63564             function evaluateEnumMember(expr, enumSymbol, name) {
63565                 var memberSymbol = enumSymbol.exports.get(name);
63566                 if (memberSymbol) {
63567                     var declaration = memberSymbol.valueDeclaration;
63568                     if (declaration !== member) {
63569                         if (isBlockScopedNameDeclaredBeforeUse(declaration, member)) {
63570                             return getEnumMemberValue(declaration);
63571                         }
63572                         error(expr, ts.Diagnostics.A_member_initializer_in_a_enum_declaration_cannot_reference_members_declared_after_it_including_members_defined_in_other_enums);
63573                         return 0;
63574                     }
63575                     else {
63576                         error(expr, ts.Diagnostics.Property_0_is_used_before_being_assigned, symbolToString(memberSymbol));
63577                     }
63578                 }
63579                 return undefined;
63580             }
63581         }
63582         function isConstantMemberAccess(node) {
63583             return node.kind === 78 ||
63584                 node.kind === 201 && isConstantMemberAccess(node.expression) ||
63585                 node.kind === 202 && isConstantMemberAccess(node.expression) &&
63586                     ts.isStringLiteralLike(node.argumentExpression);
63587         }
63588         function checkEnumDeclaration(node) {
63589             if (!produceDiagnostics) {
63590                 return;
63591             }
63592             checkGrammarDecoratorsAndModifiers(node);
63593             checkTypeNameIsReserved(node.name, ts.Diagnostics.Enum_name_cannot_be_0);
63594             checkCollisionWithRequireExportsInGeneratedCode(node, node.name);
63595             checkCollisionWithGlobalPromiseInGeneratedCode(node, node.name);
63596             checkExportsOnMergedDeclarations(node);
63597             node.members.forEach(checkEnumMember);
63598             computeEnumMemberValues(node);
63599             var enumSymbol = getSymbolOfNode(node);
63600             var firstDeclaration = ts.getDeclarationOfKind(enumSymbol, node.kind);
63601             if (node === firstDeclaration) {
63602                 if (enumSymbol.declarations.length > 1) {
63603                     var enumIsConst_1 = ts.isEnumConst(node);
63604                     ts.forEach(enumSymbol.declarations, function (decl) {
63605                         if (ts.isEnumDeclaration(decl) && ts.isEnumConst(decl) !== enumIsConst_1) {
63606                             error(ts.getNameOfDeclaration(decl), ts.Diagnostics.Enum_declarations_must_all_be_const_or_non_const);
63607                         }
63608                     });
63609                 }
63610                 var seenEnumMissingInitialInitializer_1 = false;
63611                 ts.forEach(enumSymbol.declarations, function (declaration) {
63612                     if (declaration.kind !== 255) {
63613                         return false;
63614                     }
63615                     var enumDeclaration = declaration;
63616                     if (!enumDeclaration.members.length) {
63617                         return false;
63618                     }
63619                     var firstEnumMember = enumDeclaration.members[0];
63620                     if (!firstEnumMember.initializer) {
63621                         if (seenEnumMissingInitialInitializer_1) {
63622                             error(firstEnumMember.name, ts.Diagnostics.In_an_enum_with_multiple_declarations_only_one_declaration_can_omit_an_initializer_for_its_first_enum_element);
63623                         }
63624                         else {
63625                             seenEnumMissingInitialInitializer_1 = true;
63626                         }
63627                     }
63628                 });
63629             }
63630         }
63631         function checkEnumMember(node) {
63632             if (ts.isPrivateIdentifier(node.name)) {
63633                 error(node, ts.Diagnostics.An_enum_member_cannot_be_named_with_a_private_identifier);
63634             }
63635         }
63636         function getFirstNonAmbientClassOrFunctionDeclaration(symbol) {
63637             var declarations = symbol.declarations;
63638             for (var _i = 0, declarations_8 = declarations; _i < declarations_8.length; _i++) {
63639                 var declaration = declarations_8[_i];
63640                 if ((declaration.kind === 252 ||
63641                     (declaration.kind === 251 && ts.nodeIsPresent(declaration.body))) &&
63642                     !(declaration.flags & 8388608)) {
63643                     return declaration;
63644                 }
63645             }
63646             return undefined;
63647         }
63648         function inSameLexicalScope(node1, node2) {
63649             var container1 = ts.getEnclosingBlockScopeContainer(node1);
63650             var container2 = ts.getEnclosingBlockScopeContainer(node2);
63651             if (isGlobalSourceFile(container1)) {
63652                 return isGlobalSourceFile(container2);
63653             }
63654             else if (isGlobalSourceFile(container2)) {
63655                 return false;
63656             }
63657             else {
63658                 return container1 === container2;
63659             }
63660         }
63661         function checkModuleDeclaration(node) {
63662             if (produceDiagnostics) {
63663                 var isGlobalAugmentation = ts.isGlobalScopeAugmentation(node);
63664                 var inAmbientContext = node.flags & 8388608;
63665                 if (isGlobalAugmentation && !inAmbientContext) {
63666                     error(node.name, ts.Diagnostics.Augmentations_for_the_global_scope_should_have_declare_modifier_unless_they_appear_in_already_ambient_context);
63667                 }
63668                 var isAmbientExternalModule = ts.isAmbientModule(node);
63669                 var contextErrorMessage = isAmbientExternalModule
63670                     ? ts.Diagnostics.An_ambient_module_declaration_is_only_allowed_at_the_top_level_in_a_file
63671                     : ts.Diagnostics.A_namespace_declaration_is_only_allowed_in_a_namespace_or_module;
63672                 if (checkGrammarModuleElementContext(node, contextErrorMessage)) {
63673                     return;
63674                 }
63675                 if (!checkGrammarDecoratorsAndModifiers(node)) {
63676                     if (!inAmbientContext && node.name.kind === 10) {
63677                         grammarErrorOnNode(node.name, ts.Diagnostics.Only_ambient_modules_can_use_quoted_names);
63678                     }
63679                 }
63680                 if (ts.isIdentifier(node.name)) {
63681                     checkCollisionWithRequireExportsInGeneratedCode(node, node.name);
63682                     checkCollisionWithGlobalPromiseInGeneratedCode(node, node.name);
63683                 }
63684                 checkExportsOnMergedDeclarations(node);
63685                 var symbol = getSymbolOfNode(node);
63686                 if (symbol.flags & 512
63687                     && !inAmbientContext
63688                     && symbol.declarations.length > 1
63689                     && isInstantiatedModule(node, !!compilerOptions.preserveConstEnums || !!compilerOptions.isolatedModules)) {
63690                     var firstNonAmbientClassOrFunc = getFirstNonAmbientClassOrFunctionDeclaration(symbol);
63691                     if (firstNonAmbientClassOrFunc) {
63692                         if (ts.getSourceFileOfNode(node) !== ts.getSourceFileOfNode(firstNonAmbientClassOrFunc)) {
63693                             error(node.name, ts.Diagnostics.A_namespace_declaration_cannot_be_in_a_different_file_from_a_class_or_function_with_which_it_is_merged);
63694                         }
63695                         else if (node.pos < firstNonAmbientClassOrFunc.pos) {
63696                             error(node.name, ts.Diagnostics.A_namespace_declaration_cannot_be_located_prior_to_a_class_or_function_with_which_it_is_merged);
63697                         }
63698                     }
63699                     var mergedClass = ts.getDeclarationOfKind(symbol, 252);
63700                     if (mergedClass &&
63701                         inSameLexicalScope(node, mergedClass)) {
63702                         getNodeLinks(node).flags |= 32768;
63703                     }
63704                 }
63705                 if (isAmbientExternalModule) {
63706                     if (ts.isExternalModuleAugmentation(node)) {
63707                         var checkBody = isGlobalAugmentation || (getSymbolOfNode(node).flags & 33554432);
63708                         if (checkBody && node.body) {
63709                             for (var _i = 0, _a = node.body.statements; _i < _a.length; _i++) {
63710                                 var statement = _a[_i];
63711                                 checkModuleAugmentationElement(statement, isGlobalAugmentation);
63712                             }
63713                         }
63714                     }
63715                     else if (isGlobalSourceFile(node.parent)) {
63716                         if (isGlobalAugmentation) {
63717                             error(node.name, ts.Diagnostics.Augmentations_for_the_global_scope_can_only_be_directly_nested_in_external_modules_or_ambient_module_declarations);
63718                         }
63719                         else if (ts.isExternalModuleNameRelative(ts.getTextOfIdentifierOrLiteral(node.name))) {
63720                             error(node.name, ts.Diagnostics.Ambient_module_declaration_cannot_specify_relative_module_name);
63721                         }
63722                     }
63723                     else {
63724                         if (isGlobalAugmentation) {
63725                             error(node.name, ts.Diagnostics.Augmentations_for_the_global_scope_can_only_be_directly_nested_in_external_modules_or_ambient_module_declarations);
63726                         }
63727                         else {
63728                             error(node.name, ts.Diagnostics.Ambient_modules_cannot_be_nested_in_other_modules_or_namespaces);
63729                         }
63730                     }
63731                 }
63732             }
63733             if (node.body) {
63734                 checkSourceElement(node.body);
63735                 if (!ts.isGlobalScopeAugmentation(node)) {
63736                     registerForUnusedIdentifiersCheck(node);
63737                 }
63738             }
63739         }
63740         function checkModuleAugmentationElement(node, isGlobalAugmentation) {
63741             switch (node.kind) {
63742                 case 232:
63743                     for (var _i = 0, _a = node.declarationList.declarations; _i < _a.length; _i++) {
63744                         var decl = _a[_i];
63745                         checkModuleAugmentationElement(decl, isGlobalAugmentation);
63746                     }
63747                     break;
63748                 case 266:
63749                 case 267:
63750                     grammarErrorOnFirstToken(node, ts.Diagnostics.Exports_and_export_assignments_are_not_permitted_in_module_augmentations);
63751                     break;
63752                 case 260:
63753                 case 261:
63754                     grammarErrorOnFirstToken(node, ts.Diagnostics.Imports_are_not_permitted_in_module_augmentations_Consider_moving_them_to_the_enclosing_external_module);
63755                     break;
63756                 case 198:
63757                 case 249:
63758                     var name = node.name;
63759                     if (ts.isBindingPattern(name)) {
63760                         for (var _b = 0, _c = name.elements; _b < _c.length; _b++) {
63761                             var el = _c[_b];
63762                             checkModuleAugmentationElement(el, isGlobalAugmentation);
63763                         }
63764                         break;
63765                     }
63766                 case 252:
63767                 case 255:
63768                 case 251:
63769                 case 253:
63770                 case 256:
63771                 case 254:
63772                     if (isGlobalAugmentation) {
63773                         return;
63774                     }
63775                     var symbol = getSymbolOfNode(node);
63776                     if (symbol) {
63777                         var reportError = !(symbol.flags & 33554432);
63778                         if (!reportError) {
63779                             reportError = !!symbol.parent && ts.isExternalModuleAugmentation(symbol.parent.declarations[0]);
63780                         }
63781                     }
63782                     break;
63783             }
63784         }
63785         function getFirstNonModuleExportsIdentifier(node) {
63786             switch (node.kind) {
63787                 case 78:
63788                     return node;
63789                 case 157:
63790                     do {
63791                         node = node.left;
63792                     } while (node.kind !== 78);
63793                     return node;
63794                 case 201:
63795                     do {
63796                         if (ts.isModuleExportsAccessExpression(node.expression) && !ts.isPrivateIdentifier(node.name)) {
63797                             return node.name;
63798                         }
63799                         node = node.expression;
63800                     } while (node.kind !== 78);
63801                     return node;
63802             }
63803         }
63804         function checkExternalImportOrExportDeclaration(node) {
63805             var moduleName = ts.getExternalModuleName(node);
63806             if (!moduleName || ts.nodeIsMissing(moduleName)) {
63807                 return false;
63808             }
63809             if (!ts.isStringLiteral(moduleName)) {
63810                 error(moduleName, ts.Diagnostics.String_literal_expected);
63811                 return false;
63812             }
63813             var inAmbientExternalModule = node.parent.kind === 257 && ts.isAmbientModule(node.parent.parent);
63814             if (node.parent.kind !== 297 && !inAmbientExternalModule) {
63815                 error(moduleName, node.kind === 267 ?
63816                     ts.Diagnostics.Export_declarations_are_not_permitted_in_a_namespace :
63817                     ts.Diagnostics.Import_declarations_in_a_namespace_cannot_reference_a_module);
63818                 return false;
63819             }
63820             if (inAmbientExternalModule && ts.isExternalModuleNameRelative(moduleName.text)) {
63821                 if (!isTopLevelInExternalModuleAugmentation(node)) {
63822                     error(node, ts.Diagnostics.Import_or_export_declaration_in_an_ambient_module_declaration_cannot_reference_module_through_relative_module_name);
63823                     return false;
63824                 }
63825             }
63826             return true;
63827         }
63828         function checkAliasSymbol(node) {
63829             var symbol = getSymbolOfNode(node);
63830             var target = resolveAlias(symbol);
63831             if (target !== unknownSymbol) {
63832                 symbol = getMergedSymbol(symbol.exportSymbol || symbol);
63833                 var excludedMeanings = (symbol.flags & (111551 | 1048576) ? 111551 : 0) |
63834                     (symbol.flags & 788968 ? 788968 : 0) |
63835                     (symbol.flags & 1920 ? 1920 : 0);
63836                 if (target.flags & excludedMeanings) {
63837                     var message = node.kind === 270 ?
63838                         ts.Diagnostics.Export_declaration_conflicts_with_exported_declaration_of_0 :
63839                         ts.Diagnostics.Import_declaration_conflicts_with_local_declaration_of_0;
63840                     error(node, message, symbolToString(symbol));
63841                 }
63842                 if (compilerOptions.isolatedModules
63843                     && node.kind === 270
63844                     && !node.parent.parent.isTypeOnly
63845                     && !(target.flags & 111551)
63846                     && !(node.flags & 8388608)) {
63847                     error(node, ts.Diagnostics.Re_exporting_a_type_when_the_isolatedModules_flag_is_provided_requires_using_export_type);
63848                 }
63849                 if (ts.isImportSpecifier(node) && ts.every(target.declarations, function (d) { return !!(ts.getCombinedNodeFlags(d) & 134217728); })) {
63850                     errorOrSuggestion(false, node.name, ts.Diagnostics._0_is_deprecated, symbol.escapedName);
63851                 }
63852             }
63853         }
63854         function checkImportBinding(node) {
63855             checkCollisionWithRequireExportsInGeneratedCode(node, node.name);
63856             checkCollisionWithGlobalPromiseInGeneratedCode(node, node.name);
63857             checkAliasSymbol(node);
63858             if (node.kind === 265 &&
63859                 ts.idText(node.propertyName || node.name) === "default" &&
63860                 compilerOptions.esModuleInterop &&
63861                 moduleKind !== ts.ModuleKind.System && moduleKind < ts.ModuleKind.ES2015) {
63862                 checkExternalEmitHelpers(node, 262144);
63863             }
63864         }
63865         function checkImportDeclaration(node) {
63866             if (checkGrammarModuleElementContext(node, ts.Diagnostics.An_import_declaration_can_only_be_used_in_a_namespace_or_module)) {
63867                 return;
63868             }
63869             if (!checkGrammarDecoratorsAndModifiers(node) && ts.hasEffectiveModifiers(node)) {
63870                 grammarErrorOnFirstToken(node, ts.Diagnostics.An_import_declaration_cannot_have_modifiers);
63871             }
63872             if (checkExternalImportOrExportDeclaration(node)) {
63873                 var importClause = node.importClause;
63874                 if (importClause && !checkGrammarImportClause(importClause)) {
63875                     if (importClause.name) {
63876                         checkImportBinding(importClause);
63877                     }
63878                     if (importClause.namedBindings) {
63879                         if (importClause.namedBindings.kind === 263) {
63880                             checkImportBinding(importClause.namedBindings);
63881                             if (moduleKind !== ts.ModuleKind.System && moduleKind < ts.ModuleKind.ES2015 && compilerOptions.esModuleInterop) {
63882                                 checkExternalEmitHelpers(node, 131072);
63883                             }
63884                         }
63885                         else {
63886                             var moduleExisted = resolveExternalModuleName(node, node.moduleSpecifier);
63887                             if (moduleExisted) {
63888                                 ts.forEach(importClause.namedBindings.elements, checkImportBinding);
63889                             }
63890                         }
63891                     }
63892                 }
63893             }
63894         }
63895         function checkImportEqualsDeclaration(node) {
63896             if (checkGrammarModuleElementContext(node, ts.Diagnostics.An_import_declaration_can_only_be_used_in_a_namespace_or_module)) {
63897                 return;
63898             }
63899             checkGrammarDecoratorsAndModifiers(node);
63900             if (ts.isInternalModuleImportEqualsDeclaration(node) || checkExternalImportOrExportDeclaration(node)) {
63901                 checkImportBinding(node);
63902                 if (ts.hasSyntacticModifier(node, 1)) {
63903                     markExportAsReferenced(node);
63904                 }
63905                 if (node.moduleReference.kind !== 272) {
63906                     var target = resolveAlias(getSymbolOfNode(node));
63907                     if (target !== unknownSymbol) {
63908                         if (target.flags & 111551) {
63909                             var moduleName = ts.getFirstIdentifier(node.moduleReference);
63910                             if (!(resolveEntityName(moduleName, 111551 | 1920).flags & 1920)) {
63911                                 error(moduleName, ts.Diagnostics.Module_0_is_hidden_by_a_local_declaration_with_the_same_name, ts.declarationNameToString(moduleName));
63912                             }
63913                         }
63914                         if (target.flags & 788968) {
63915                             checkTypeNameIsReserved(node.name, ts.Diagnostics.Import_name_cannot_be_0);
63916                         }
63917                     }
63918                 }
63919                 else {
63920                     if (moduleKind >= ts.ModuleKind.ES2015 && !(node.flags & 8388608)) {
63921                         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);
63922                     }
63923                 }
63924             }
63925         }
63926         function checkExportDeclaration(node) {
63927             if (checkGrammarModuleElementContext(node, ts.Diagnostics.An_export_declaration_can_only_be_used_in_a_module)) {
63928                 return;
63929             }
63930             if (!checkGrammarDecoratorsAndModifiers(node) && ts.hasEffectiveModifiers(node)) {
63931                 grammarErrorOnFirstToken(node, ts.Diagnostics.An_export_declaration_cannot_have_modifiers);
63932             }
63933             if (node.moduleSpecifier && node.exportClause && ts.isNamedExports(node.exportClause) && ts.length(node.exportClause.elements) && languageVersion === 0) {
63934                 checkExternalEmitHelpers(node, 4194304);
63935             }
63936             checkGrammarExportDeclaration(node);
63937             if (!node.moduleSpecifier || checkExternalImportOrExportDeclaration(node)) {
63938                 if (node.exportClause && !ts.isNamespaceExport(node.exportClause)) {
63939                     ts.forEach(node.exportClause.elements, checkExportSpecifier);
63940                     var inAmbientExternalModule = node.parent.kind === 257 && ts.isAmbientModule(node.parent.parent);
63941                     var inAmbientNamespaceDeclaration = !inAmbientExternalModule && node.parent.kind === 257 &&
63942                         !node.moduleSpecifier && node.flags & 8388608;
63943                     if (node.parent.kind !== 297 && !inAmbientExternalModule && !inAmbientNamespaceDeclaration) {
63944                         error(node, ts.Diagnostics.Export_declarations_are_not_permitted_in_a_namespace);
63945                     }
63946                 }
63947                 else {
63948                     var moduleSymbol = resolveExternalModuleName(node, node.moduleSpecifier);
63949                     if (moduleSymbol && hasExportAssignmentSymbol(moduleSymbol)) {
63950                         error(node.moduleSpecifier, ts.Diagnostics.Module_0_uses_export_and_cannot_be_used_with_export_Asterisk, symbolToString(moduleSymbol));
63951                     }
63952                     else if (node.exportClause) {
63953                         checkAliasSymbol(node.exportClause);
63954                     }
63955                     if (moduleKind !== ts.ModuleKind.System && moduleKind < ts.ModuleKind.ES2015) {
63956                         if (node.exportClause) {
63957                             if (compilerOptions.esModuleInterop) {
63958                                 checkExternalEmitHelpers(node, 131072);
63959                             }
63960                         }
63961                         else {
63962                             checkExternalEmitHelpers(node, 65536);
63963                         }
63964                     }
63965                 }
63966             }
63967         }
63968         function checkGrammarExportDeclaration(node) {
63969             var _a;
63970             var isTypeOnlyExportStar = node.isTypeOnly && ((_a = node.exportClause) === null || _a === void 0 ? void 0 : _a.kind) !== 268;
63971             if (isTypeOnlyExportStar) {
63972                 grammarErrorOnNode(node, ts.Diagnostics.Only_named_exports_may_use_export_type);
63973             }
63974             return !isTypeOnlyExportStar;
63975         }
63976         function checkGrammarModuleElementContext(node, errorMessage) {
63977             var isInAppropriateContext = node.parent.kind === 297 || node.parent.kind === 257 || node.parent.kind === 256;
63978             if (!isInAppropriateContext) {
63979                 grammarErrorOnFirstToken(node, errorMessage);
63980             }
63981             return !isInAppropriateContext;
63982         }
63983         function importClauseContainsReferencedImport(importClause) {
63984             return ts.forEachImportClauseDeclaration(importClause, function (declaration) {
63985                 return !!getSymbolOfNode(declaration).isReferenced;
63986             });
63987         }
63988         function importClauseContainsConstEnumUsedAsValue(importClause) {
63989             return ts.forEachImportClauseDeclaration(importClause, function (declaration) {
63990                 return !!getSymbolLinks(getSymbolOfNode(declaration)).constEnumReferenced;
63991             });
63992         }
63993         function checkImportsForTypeOnlyConversion(sourceFile) {
63994             for (var _i = 0, _a = sourceFile.statements; _i < _a.length; _i++) {
63995                 var statement = _a[_i];
63996                 if (ts.isImportDeclaration(statement) &&
63997                     statement.importClause &&
63998                     !statement.importClause.isTypeOnly &&
63999                     importClauseContainsReferencedImport(statement.importClause) &&
64000                     !isReferencedAliasDeclaration(statement.importClause, true) &&
64001                     !importClauseContainsConstEnumUsedAsValue(statement.importClause)) {
64002                     error(statement, ts.Diagnostics.This_import_is_never_used_as_a_value_and_must_use_import_type_because_the_importsNotUsedAsValues_is_set_to_error);
64003                 }
64004             }
64005         }
64006         function checkExportSpecifier(node) {
64007             checkAliasSymbol(node);
64008             if (ts.getEmitDeclarations(compilerOptions)) {
64009                 collectLinkedAliases(node.propertyName || node.name, true);
64010             }
64011             if (!node.parent.parent.moduleSpecifier) {
64012                 var exportedName = node.propertyName || node.name;
64013                 var symbol = resolveName(exportedName, exportedName.escapedText, 111551 | 788968 | 1920 | 2097152, undefined, undefined, true);
64014                 if (symbol && (symbol === undefinedSymbol || symbol === globalThisSymbol || isGlobalSourceFile(getDeclarationContainer(symbol.declarations[0])))) {
64015                     error(exportedName, ts.Diagnostics.Cannot_export_0_Only_local_declarations_can_be_exported_from_a_module, ts.idText(exportedName));
64016                 }
64017                 else {
64018                     markExportAsReferenced(node);
64019                     var target = symbol && (symbol.flags & 2097152 ? resolveAlias(symbol) : symbol);
64020                     if (!target || target === unknownSymbol || target.flags & 111551) {
64021                         checkExpressionCached(node.propertyName || node.name);
64022                     }
64023                 }
64024             }
64025             else {
64026                 if (compilerOptions.esModuleInterop &&
64027                     moduleKind !== ts.ModuleKind.System &&
64028                     moduleKind < ts.ModuleKind.ES2015 &&
64029                     ts.idText(node.propertyName || node.name) === "default") {
64030                     checkExternalEmitHelpers(node, 262144);
64031                 }
64032             }
64033         }
64034         function checkExportAssignment(node) {
64035             if (checkGrammarModuleElementContext(node, ts.Diagnostics.An_export_assignment_can_only_be_used_in_a_module)) {
64036                 return;
64037             }
64038             var container = node.parent.kind === 297 ? node.parent : node.parent.parent;
64039             if (container.kind === 256 && !ts.isAmbientModule(container)) {
64040                 if (node.isExportEquals) {
64041                     error(node, ts.Diagnostics.An_export_assignment_cannot_be_used_in_a_namespace);
64042                 }
64043                 else {
64044                     error(node, ts.Diagnostics.A_default_export_can_only_be_used_in_an_ECMAScript_style_module);
64045                 }
64046                 return;
64047             }
64048             if (!checkGrammarDecoratorsAndModifiers(node) && ts.hasEffectiveModifiers(node)) {
64049                 grammarErrorOnFirstToken(node, ts.Diagnostics.An_export_assignment_cannot_have_modifiers);
64050             }
64051             if (node.expression.kind === 78) {
64052                 var id = node.expression;
64053                 var sym = resolveEntityName(id, 67108863, true, true, node);
64054                 if (sym) {
64055                     markAliasReferenced(sym, id);
64056                     var target = sym.flags & 2097152 ? resolveAlias(sym) : sym;
64057                     if (target === unknownSymbol || target.flags & 111551) {
64058                         checkExpressionCached(node.expression);
64059                     }
64060                 }
64061                 else {
64062                     checkExpressionCached(node.expression);
64063                 }
64064                 if (ts.getEmitDeclarations(compilerOptions)) {
64065                     collectLinkedAliases(node.expression, true);
64066                 }
64067             }
64068             else {
64069                 checkExpressionCached(node.expression);
64070             }
64071             checkExternalModuleExports(container);
64072             if ((node.flags & 8388608) && !ts.isEntityNameExpression(node.expression)) {
64073                 grammarErrorOnNode(node.expression, ts.Diagnostics.The_expression_of_an_export_assignment_must_be_an_identifier_or_qualified_name_in_an_ambient_context);
64074             }
64075             if (node.isExportEquals && !(node.flags & 8388608)) {
64076                 if (moduleKind >= ts.ModuleKind.ES2015) {
64077                     grammarErrorOnNode(node, ts.Diagnostics.Export_assignment_cannot_be_used_when_targeting_ECMAScript_modules_Consider_using_export_default_or_another_module_format_instead);
64078                 }
64079                 else if (moduleKind === ts.ModuleKind.System) {
64080                     grammarErrorOnNode(node, ts.Diagnostics.Export_assignment_is_not_supported_when_module_flag_is_system);
64081                 }
64082             }
64083         }
64084         function hasExportedMembers(moduleSymbol) {
64085             return ts.forEachEntry(moduleSymbol.exports, function (_, id) { return id !== "export="; });
64086         }
64087         function checkExternalModuleExports(node) {
64088             var moduleSymbol = getSymbolOfNode(node);
64089             var links = getSymbolLinks(moduleSymbol);
64090             if (!links.exportsChecked) {
64091                 var exportEqualsSymbol = moduleSymbol.exports.get("export=");
64092                 if (exportEqualsSymbol && hasExportedMembers(moduleSymbol)) {
64093                     var declaration = getDeclarationOfAliasSymbol(exportEqualsSymbol) || exportEqualsSymbol.valueDeclaration;
64094                     if (!isTopLevelInExternalModuleAugmentation(declaration) && !ts.isInJSFile(declaration)) {
64095                         error(declaration, ts.Diagnostics.An_export_assignment_cannot_be_used_in_a_module_with_other_exported_elements);
64096                     }
64097                 }
64098                 var exports_2 = getExportsOfModule(moduleSymbol);
64099                 if (exports_2) {
64100                     exports_2.forEach(function (_a, id) {
64101                         var declarations = _a.declarations, flags = _a.flags;
64102                         if (id === "__export") {
64103                             return;
64104                         }
64105                         if (flags & (1920 | 64 | 384)) {
64106                             return;
64107                         }
64108                         var exportedDeclarationsCount = ts.countWhere(declarations, isNotOverloadAndNotAccessor);
64109                         if (flags & 524288 && exportedDeclarationsCount <= 2) {
64110                             return;
64111                         }
64112                         if (exportedDeclarationsCount > 1) {
64113                             for (var _i = 0, declarations_9 = declarations; _i < declarations_9.length; _i++) {
64114                                 var declaration = declarations_9[_i];
64115                                 if (isNotOverload(declaration)) {
64116                                     diagnostics.add(ts.createDiagnosticForNode(declaration, ts.Diagnostics.Cannot_redeclare_exported_variable_0, ts.unescapeLeadingUnderscores(id)));
64117                                 }
64118                             }
64119                         }
64120                     });
64121                 }
64122                 links.exportsChecked = true;
64123             }
64124         }
64125         function checkSourceElement(node) {
64126             if (node) {
64127                 var saveCurrentNode = currentNode;
64128                 currentNode = node;
64129                 instantiationCount = 0;
64130                 checkSourceElementWorker(node);
64131                 currentNode = saveCurrentNode;
64132             }
64133         }
64134         function checkSourceElementWorker(node) {
64135             if (ts.isInJSFile(node)) {
64136                 ts.forEach(node.jsDoc, function (_a) {
64137                     var tags = _a.tags;
64138                     return ts.forEach(tags, checkSourceElement);
64139                 });
64140             }
64141             var kind = node.kind;
64142             if (cancellationToken) {
64143                 switch (kind) {
64144                     case 256:
64145                     case 252:
64146                     case 253:
64147                     case 251:
64148                         cancellationToken.throwIfCancellationRequested();
64149                 }
64150             }
64151             if (kind >= 232 && kind <= 248 && node.flowNode && !isReachableFlowNode(node.flowNode)) {
64152                 errorOrSuggestion(compilerOptions.allowUnreachableCode === false, node, ts.Diagnostics.Unreachable_code_detected);
64153             }
64154             switch (kind) {
64155                 case 159:
64156                     return checkTypeParameter(node);
64157                 case 160:
64158                     return checkParameter(node);
64159                 case 163:
64160                     return checkPropertyDeclaration(node);
64161                 case 162:
64162                     return checkPropertySignature(node);
64163                 case 174:
64164                 case 175:
64165                 case 169:
64166                 case 170:
64167                 case 171:
64168                     return checkSignatureDeclaration(node);
64169                 case 165:
64170                 case 164:
64171                     return checkMethodDeclaration(node);
64172                 case 166:
64173                     return checkConstructorDeclaration(node);
64174                 case 167:
64175                 case 168:
64176                     return checkAccessorDeclaration(node);
64177                 case 173:
64178                     return checkTypeReferenceNode(node);
64179                 case 172:
64180                     return checkTypePredicate(node);
64181                 case 176:
64182                     return checkTypeQuery(node);
64183                 case 177:
64184                     return checkTypeLiteral(node);
64185                 case 178:
64186                     return checkArrayType(node);
64187                 case 179:
64188                     return checkTupleType(node);
64189                 case 182:
64190                 case 183:
64191                     return checkUnionOrIntersectionType(node);
64192                 case 186:
64193                 case 180:
64194                 case 181:
64195                     return checkSourceElement(node.type);
64196                 case 187:
64197                     return checkThisType(node);
64198                 case 188:
64199                     return checkTypeOperator(node);
64200                 case 184:
64201                     return checkConditionalType(node);
64202                 case 185:
64203                     return checkInferType(node);
64204                 case 193:
64205                     return checkTemplateLiteralType(node);
64206                 case 195:
64207                     return checkImportType(node);
64208                 case 192:
64209                     return checkNamedTupleMember(node);
64210                 case 315:
64211                     return checkJSDocAugmentsTag(node);
64212                 case 316:
64213                     return checkJSDocImplementsTag(node);
64214                 case 331:
64215                 case 324:
64216                 case 325:
64217                     return checkJSDocTypeAliasTag(node);
64218                 case 330:
64219                     return checkJSDocTemplateTag(node);
64220                 case 329:
64221                     return checkJSDocTypeTag(node);
64222                 case 326:
64223                     return checkJSDocParameterTag(node);
64224                 case 333:
64225                     return checkJSDocPropertyTag(node);
64226                 case 308:
64227                     checkJSDocFunctionType(node);
64228                 case 306:
64229                 case 305:
64230                 case 303:
64231                 case 304:
64232                 case 312:
64233                     checkJSDocTypeIsInJsFile(node);
64234                     ts.forEachChild(node, checkSourceElement);
64235                     return;
64236                 case 309:
64237                     checkJSDocVariadicType(node);
64238                     return;
64239                 case 301:
64240                     return checkSourceElement(node.type);
64241                 case 189:
64242                     return checkIndexedAccessType(node);
64243                 case 190:
64244                     return checkMappedType(node);
64245                 case 251:
64246                     return checkFunctionDeclaration(node);
64247                 case 230:
64248                 case 257:
64249                     return checkBlock(node);
64250                 case 232:
64251                     return checkVariableStatement(node);
64252                 case 233:
64253                     return checkExpressionStatement(node);
64254                 case 234:
64255                     return checkIfStatement(node);
64256                 case 235:
64257                     return checkDoStatement(node);
64258                 case 236:
64259                     return checkWhileStatement(node);
64260                 case 237:
64261                     return checkForStatement(node);
64262                 case 238:
64263                     return checkForInStatement(node);
64264                 case 239:
64265                     return checkForOfStatement(node);
64266                 case 240:
64267                 case 241:
64268                     return checkBreakOrContinueStatement(node);
64269                 case 242:
64270                     return checkReturnStatement(node);
64271                 case 243:
64272                     return checkWithStatement(node);
64273                 case 244:
64274                     return checkSwitchStatement(node);
64275                 case 245:
64276                     return checkLabeledStatement(node);
64277                 case 246:
64278                     return checkThrowStatement(node);
64279                 case 247:
64280                     return checkTryStatement(node);
64281                 case 249:
64282                     return checkVariableDeclaration(node);
64283                 case 198:
64284                     return checkBindingElement(node);
64285                 case 252:
64286                     return checkClassDeclaration(node);
64287                 case 253:
64288                     return checkInterfaceDeclaration(node);
64289                 case 254:
64290                     return checkTypeAliasDeclaration(node);
64291                 case 255:
64292                     return checkEnumDeclaration(node);
64293                 case 256:
64294                     return checkModuleDeclaration(node);
64295                 case 261:
64296                     return checkImportDeclaration(node);
64297                 case 260:
64298                     return checkImportEqualsDeclaration(node);
64299                 case 267:
64300                     return checkExportDeclaration(node);
64301                 case 266:
64302                     return checkExportAssignment(node);
64303                 case 231:
64304                 case 248:
64305                     checkGrammarStatementInAmbientContext(node);
64306                     return;
64307                 case 271:
64308                     return checkMissingDeclaration(node);
64309             }
64310         }
64311         function checkJSDocTypeIsInJsFile(node) {
64312             if (!ts.isInJSFile(node)) {
64313                 grammarErrorOnNode(node, ts.Diagnostics.JSDoc_types_can_only_be_used_inside_documentation_comments);
64314             }
64315         }
64316         function checkJSDocVariadicType(node) {
64317             checkJSDocTypeIsInJsFile(node);
64318             checkSourceElement(node.type);
64319             var parent = node.parent;
64320             if (ts.isParameter(parent) && ts.isJSDocFunctionType(parent.parent)) {
64321                 if (ts.last(parent.parent.parameters) !== parent) {
64322                     error(node, ts.Diagnostics.A_rest_parameter_must_be_last_in_a_parameter_list);
64323                 }
64324                 return;
64325             }
64326             if (!ts.isJSDocTypeExpression(parent)) {
64327                 error(node, ts.Diagnostics.JSDoc_may_only_appear_in_the_last_parameter_of_a_signature);
64328             }
64329             var paramTag = node.parent.parent;
64330             if (!ts.isJSDocParameterTag(paramTag)) {
64331                 error(node, ts.Diagnostics.JSDoc_may_only_appear_in_the_last_parameter_of_a_signature);
64332                 return;
64333             }
64334             var param = ts.getParameterSymbolFromJSDoc(paramTag);
64335             if (!param) {
64336                 return;
64337             }
64338             var host = ts.getHostSignatureFromJSDoc(paramTag);
64339             if (!host || ts.last(host.parameters).symbol !== param) {
64340                 error(node, ts.Diagnostics.A_rest_parameter_must_be_last_in_a_parameter_list);
64341             }
64342         }
64343         function getTypeFromJSDocVariadicType(node) {
64344             var type = getTypeFromTypeNode(node.type);
64345             var parent = node.parent;
64346             var paramTag = node.parent.parent;
64347             if (ts.isJSDocTypeExpression(node.parent) && ts.isJSDocParameterTag(paramTag)) {
64348                 var host_1 = ts.getHostSignatureFromJSDoc(paramTag);
64349                 if (host_1) {
64350                     var lastParamDeclaration = ts.lastOrUndefined(host_1.parameters);
64351                     var symbol = ts.getParameterSymbolFromJSDoc(paramTag);
64352                     if (!lastParamDeclaration ||
64353                         symbol && lastParamDeclaration.symbol === symbol && ts.isRestParameter(lastParamDeclaration)) {
64354                         return createArrayType(type);
64355                     }
64356                 }
64357             }
64358             if (ts.isParameter(parent) && ts.isJSDocFunctionType(parent.parent)) {
64359                 return createArrayType(type);
64360             }
64361             return addOptionality(type);
64362         }
64363         function checkNodeDeferred(node) {
64364             var enclosingFile = ts.getSourceFileOfNode(node);
64365             var links = getNodeLinks(enclosingFile);
64366             if (!(links.flags & 1)) {
64367                 links.deferredNodes = links.deferredNodes || new ts.Map();
64368                 var id = getNodeId(node);
64369                 links.deferredNodes.set(id, node);
64370             }
64371         }
64372         function checkDeferredNodes(context) {
64373             var links = getNodeLinks(context);
64374             if (links.deferredNodes) {
64375                 links.deferredNodes.forEach(checkDeferredNode);
64376             }
64377         }
64378         function checkDeferredNode(node) {
64379             var saveCurrentNode = currentNode;
64380             currentNode = node;
64381             instantiationCount = 0;
64382             switch (node.kind) {
64383                 case 203:
64384                 case 204:
64385                 case 205:
64386                 case 161:
64387                 case 275:
64388                     resolveUntypedCall(node);
64389                     break;
64390                 case 208:
64391                 case 209:
64392                 case 165:
64393                 case 164:
64394                     checkFunctionExpressionOrObjectLiteralMethodDeferred(node);
64395                     break;
64396                 case 167:
64397                 case 168:
64398                     checkAccessorDeclaration(node);
64399                     break;
64400                 case 221:
64401                     checkClassExpressionDeferred(node);
64402                     break;
64403                 case 274:
64404                     checkJsxSelfClosingElementDeferred(node);
64405                     break;
64406                 case 273:
64407                     checkJsxElementDeferred(node);
64408                     break;
64409             }
64410             currentNode = saveCurrentNode;
64411         }
64412         function checkSourceFile(node) {
64413             var tracingData = ["check", "checkSourceFile", { path: node.path }];
64414             ts.tracing.begin.apply(ts.tracing, tracingData);
64415             ts.performance.mark("beforeCheck");
64416             checkSourceFileWorker(node);
64417             ts.performance.mark("afterCheck");
64418             ts.performance.measure("Check", "beforeCheck", "afterCheck");
64419             ts.tracing.end.apply(ts.tracing, tracingData);
64420         }
64421         function unusedIsError(kind, isAmbient) {
64422             if (isAmbient) {
64423                 return false;
64424             }
64425             switch (kind) {
64426                 case 0:
64427                     return !!compilerOptions.noUnusedLocals;
64428                 case 1:
64429                     return !!compilerOptions.noUnusedParameters;
64430                 default:
64431                     return ts.Debug.assertNever(kind);
64432             }
64433         }
64434         function getPotentiallyUnusedIdentifiers(sourceFile) {
64435             return allPotentiallyUnusedIdentifiers.get(sourceFile.path) || ts.emptyArray;
64436         }
64437         function checkSourceFileWorker(node) {
64438             var links = getNodeLinks(node);
64439             if (!(links.flags & 1)) {
64440                 if (ts.skipTypeChecking(node, compilerOptions, host)) {
64441                     return;
64442                 }
64443                 checkGrammarSourceFile(node);
64444                 ts.clear(potentialThisCollisions);
64445                 ts.clear(potentialNewTargetCollisions);
64446                 ts.clear(potentialWeakMapCollisions);
64447                 ts.forEach(node.statements, checkSourceElement);
64448                 checkSourceElement(node.endOfFileToken);
64449                 checkDeferredNodes(node);
64450                 if (ts.isExternalOrCommonJsModule(node)) {
64451                     registerForUnusedIdentifiersCheck(node);
64452                 }
64453                 if (!node.isDeclarationFile && (compilerOptions.noUnusedLocals || compilerOptions.noUnusedParameters)) {
64454                     checkUnusedIdentifiers(getPotentiallyUnusedIdentifiers(node), function (containingNode, kind, diag) {
64455                         if (!ts.containsParseError(containingNode) && unusedIsError(kind, !!(containingNode.flags & 8388608))) {
64456                             diagnostics.add(diag);
64457                         }
64458                     });
64459                 }
64460                 if (compilerOptions.importsNotUsedAsValues === 2 &&
64461                     !node.isDeclarationFile &&
64462                     ts.isExternalModule(node)) {
64463                     checkImportsForTypeOnlyConversion(node);
64464                 }
64465                 if (ts.isExternalOrCommonJsModule(node)) {
64466                     checkExternalModuleExports(node);
64467                 }
64468                 if (potentialThisCollisions.length) {
64469                     ts.forEach(potentialThisCollisions, checkIfThisIsCapturedInEnclosingScope);
64470                     ts.clear(potentialThisCollisions);
64471                 }
64472                 if (potentialNewTargetCollisions.length) {
64473                     ts.forEach(potentialNewTargetCollisions, checkIfNewTargetIsCapturedInEnclosingScope);
64474                     ts.clear(potentialNewTargetCollisions);
64475                 }
64476                 if (potentialWeakMapCollisions.length) {
64477                     ts.forEach(potentialWeakMapCollisions, checkWeakMapCollision);
64478                     ts.clear(potentialWeakMapCollisions);
64479                 }
64480                 links.flags |= 1;
64481             }
64482         }
64483         function getDiagnostics(sourceFile, ct) {
64484             try {
64485                 cancellationToken = ct;
64486                 return getDiagnosticsWorker(sourceFile);
64487             }
64488             finally {
64489                 cancellationToken = undefined;
64490             }
64491         }
64492         function getDiagnosticsWorker(sourceFile) {
64493             throwIfNonDiagnosticsProducing();
64494             if (sourceFile) {
64495                 var previousGlobalDiagnostics = diagnostics.getGlobalDiagnostics();
64496                 var previousGlobalDiagnosticsSize = previousGlobalDiagnostics.length;
64497                 checkSourceFile(sourceFile);
64498                 var semanticDiagnostics = diagnostics.getDiagnostics(sourceFile.fileName);
64499                 var currentGlobalDiagnostics = diagnostics.getGlobalDiagnostics();
64500                 if (currentGlobalDiagnostics !== previousGlobalDiagnostics) {
64501                     var deferredGlobalDiagnostics = ts.relativeComplement(previousGlobalDiagnostics, currentGlobalDiagnostics, ts.compareDiagnostics);
64502                     return ts.concatenate(deferredGlobalDiagnostics, semanticDiagnostics);
64503                 }
64504                 else if (previousGlobalDiagnosticsSize === 0 && currentGlobalDiagnostics.length > 0) {
64505                     return ts.concatenate(currentGlobalDiagnostics, semanticDiagnostics);
64506                 }
64507                 return semanticDiagnostics;
64508             }
64509             ts.forEach(host.getSourceFiles(), checkSourceFile);
64510             return diagnostics.getDiagnostics();
64511         }
64512         function getGlobalDiagnostics() {
64513             throwIfNonDiagnosticsProducing();
64514             return diagnostics.getGlobalDiagnostics();
64515         }
64516         function throwIfNonDiagnosticsProducing() {
64517             if (!produceDiagnostics) {
64518                 throw new Error("Trying to get diagnostics from a type checker that does not produce them.");
64519             }
64520         }
64521         function getSymbolsInScope(location, meaning) {
64522             if (location.flags & 16777216) {
64523                 return [];
64524             }
64525             var symbols = ts.createSymbolTable();
64526             var isStatic = false;
64527             populateSymbols();
64528             symbols.delete("this");
64529             return symbolsToArray(symbols);
64530             function populateSymbols() {
64531                 while (location) {
64532                     if (location.locals && !isGlobalSourceFile(location)) {
64533                         copySymbols(location.locals, meaning);
64534                     }
64535                     switch (location.kind) {
64536                         case 297:
64537                             if (!ts.isExternalOrCommonJsModule(location))
64538                                 break;
64539                         case 256:
64540                             copySymbols(getSymbolOfNode(location).exports, meaning & 2623475);
64541                             break;
64542                         case 255:
64543                             copySymbols(getSymbolOfNode(location).exports, meaning & 8);
64544                             break;
64545                         case 221:
64546                             var className = location.name;
64547                             if (className) {
64548                                 copySymbol(location.symbol, meaning);
64549                             }
64550                         case 252:
64551                         case 253:
64552                             if (!isStatic) {
64553                                 copySymbols(getMembersOfSymbol(getSymbolOfNode(location)), meaning & 788968);
64554                             }
64555                             break;
64556                         case 208:
64557                             var funcName = location.name;
64558                             if (funcName) {
64559                                 copySymbol(location.symbol, meaning);
64560                             }
64561                             break;
64562                     }
64563                     if (ts.introducesArgumentsExoticObject(location)) {
64564                         copySymbol(argumentsSymbol, meaning);
64565                     }
64566                     isStatic = ts.hasSyntacticModifier(location, 32);
64567                     location = location.parent;
64568                 }
64569                 copySymbols(globals, meaning);
64570             }
64571             function copySymbol(symbol, meaning) {
64572                 if (ts.getCombinedLocalAndExportSymbolFlags(symbol) & meaning) {
64573                     var id = symbol.escapedName;
64574                     if (!symbols.has(id)) {
64575                         symbols.set(id, symbol);
64576                     }
64577                 }
64578             }
64579             function copySymbols(source, meaning) {
64580                 if (meaning) {
64581                     source.forEach(function (symbol) {
64582                         copySymbol(symbol, meaning);
64583                     });
64584                 }
64585             }
64586         }
64587         function isTypeDeclarationName(name) {
64588             return name.kind === 78 &&
64589                 isTypeDeclaration(name.parent) &&
64590                 ts.getNameOfDeclaration(name.parent) === name;
64591         }
64592         function isTypeDeclaration(node) {
64593             switch (node.kind) {
64594                 case 159:
64595                 case 252:
64596                 case 253:
64597                 case 254:
64598                 case 255:
64599                 case 331:
64600                 case 324:
64601                 case 325:
64602                     return true;
64603                 case 262:
64604                     return node.isTypeOnly;
64605                 case 265:
64606                 case 270:
64607                     return node.parent.parent.isTypeOnly;
64608                 default:
64609                     return false;
64610             }
64611         }
64612         function isTypeReferenceIdentifier(node) {
64613             while (node.parent.kind === 157) {
64614                 node = node.parent;
64615             }
64616             return node.parent.kind === 173;
64617         }
64618         function isHeritageClauseElementIdentifier(node) {
64619             while (node.parent.kind === 201) {
64620                 node = node.parent;
64621             }
64622             return node.parent.kind === 223;
64623         }
64624         function isJSDocEntryNameReference(node) {
64625             while (node.parent.kind === 157) {
64626                 node = node.parent;
64627             }
64628             while (node.parent.kind === 201) {
64629                 node = node.parent;
64630             }
64631             return node.parent.kind === 302;
64632         }
64633         function forEachEnclosingClass(node, callback) {
64634             var result;
64635             while (true) {
64636                 node = ts.getContainingClass(node);
64637                 if (!node)
64638                     break;
64639                 if (result = callback(node))
64640                     break;
64641             }
64642             return result;
64643         }
64644         function isNodeUsedDuringClassInitialization(node) {
64645             return !!ts.findAncestor(node, function (element) {
64646                 if (ts.isConstructorDeclaration(element) && ts.nodeIsPresent(element.body) || ts.isPropertyDeclaration(element)) {
64647                     return true;
64648                 }
64649                 else if (ts.isClassLike(element) || ts.isFunctionLikeDeclaration(element)) {
64650                     return "quit";
64651                 }
64652                 return false;
64653             });
64654         }
64655         function isNodeWithinClass(node, classDeclaration) {
64656             return !!forEachEnclosingClass(node, function (n) { return n === classDeclaration; });
64657         }
64658         function getLeftSideOfImportEqualsOrExportAssignment(nodeOnRightSide) {
64659             while (nodeOnRightSide.parent.kind === 157) {
64660                 nodeOnRightSide = nodeOnRightSide.parent;
64661             }
64662             if (nodeOnRightSide.parent.kind === 260) {
64663                 return nodeOnRightSide.parent.moduleReference === nodeOnRightSide ? nodeOnRightSide.parent : undefined;
64664             }
64665             if (nodeOnRightSide.parent.kind === 266) {
64666                 return nodeOnRightSide.parent.expression === nodeOnRightSide ? nodeOnRightSide.parent : undefined;
64667             }
64668             return undefined;
64669         }
64670         function isInRightSideOfImportOrExportAssignment(node) {
64671             return getLeftSideOfImportEqualsOrExportAssignment(node) !== undefined;
64672         }
64673         function getSpecialPropertyAssignmentSymbolFromEntityName(entityName) {
64674             var specialPropertyAssignmentKind = ts.getAssignmentDeclarationKind(entityName.parent.parent);
64675             switch (specialPropertyAssignmentKind) {
64676                 case 1:
64677                 case 3:
64678                     return getSymbolOfNode(entityName.parent);
64679                 case 4:
64680                 case 2:
64681                 case 5:
64682                     return getSymbolOfNode(entityName.parent.parent);
64683             }
64684         }
64685         function isImportTypeQualifierPart(node) {
64686             var parent = node.parent;
64687             while (ts.isQualifiedName(parent)) {
64688                 node = parent;
64689                 parent = parent.parent;
64690             }
64691             if (parent && parent.kind === 195 && parent.qualifier === node) {
64692                 return parent;
64693             }
64694             return undefined;
64695         }
64696         function getSymbolOfNameOrPropertyAccessExpression(name) {
64697             if (ts.isDeclarationName(name)) {
64698                 return getSymbolOfNode(name.parent);
64699             }
64700             if (ts.isInJSFile(name) &&
64701                 name.parent.kind === 201 &&
64702                 name.parent === name.parent.parent.left) {
64703                 if (!ts.isPrivateIdentifier(name)) {
64704                     var specialPropertyAssignmentSymbol = getSpecialPropertyAssignmentSymbolFromEntityName(name);
64705                     if (specialPropertyAssignmentSymbol) {
64706                         return specialPropertyAssignmentSymbol;
64707                     }
64708                 }
64709             }
64710             if (name.parent.kind === 266 && ts.isEntityNameExpression(name)) {
64711                 var success = resolveEntityName(name, 111551 | 788968 | 1920 | 2097152, true);
64712                 if (success && success !== unknownSymbol) {
64713                     return success;
64714                 }
64715             }
64716             else if (!ts.isPropertyAccessExpression(name) && !ts.isPrivateIdentifier(name) && isInRightSideOfImportOrExportAssignment(name)) {
64717                 var importEqualsDeclaration = ts.getAncestor(name, 260);
64718                 ts.Debug.assert(importEqualsDeclaration !== undefined);
64719                 return getSymbolOfPartOfRightHandSideOfImportEquals(name, true);
64720             }
64721             if (!ts.isPropertyAccessExpression(name) && !ts.isPrivateIdentifier(name)) {
64722                 var possibleImportNode = isImportTypeQualifierPart(name);
64723                 if (possibleImportNode) {
64724                     getTypeFromTypeNode(possibleImportNode);
64725                     var sym = getNodeLinks(name).resolvedSymbol;
64726                     return sym === unknownSymbol ? undefined : sym;
64727                 }
64728             }
64729             while (ts.isRightSideOfQualifiedNameOrPropertyAccess(name)) {
64730                 name = name.parent;
64731             }
64732             if (isHeritageClauseElementIdentifier(name)) {
64733                 var meaning = 0;
64734                 if (name.parent.kind === 223) {
64735                     meaning = 788968;
64736                     if (ts.isExpressionWithTypeArgumentsInClassExtendsClause(name.parent)) {
64737                         meaning |= 111551;
64738                     }
64739                 }
64740                 else {
64741                     meaning = 1920;
64742                 }
64743                 meaning |= 2097152;
64744                 var entityNameSymbol = ts.isEntityNameExpression(name) ? resolveEntityName(name, meaning) : undefined;
64745                 if (entityNameSymbol) {
64746                     return entityNameSymbol;
64747                 }
64748             }
64749             if (name.parent.kind === 326) {
64750                 return ts.getParameterSymbolFromJSDoc(name.parent);
64751             }
64752             if (name.parent.kind === 159 && name.parent.parent.kind === 330) {
64753                 ts.Debug.assert(!ts.isInJSFile(name));
64754                 var typeParameter = ts.getTypeParameterFromJsDoc(name.parent);
64755                 return typeParameter && typeParameter.symbol;
64756             }
64757             if (ts.isExpressionNode(name)) {
64758                 if (ts.nodeIsMissing(name)) {
64759                     return undefined;
64760                 }
64761                 if (name.kind === 78) {
64762                     if (ts.isJSXTagName(name) && isJsxIntrinsicIdentifier(name)) {
64763                         var symbol = getIntrinsicTagSymbol(name.parent);
64764                         return symbol === unknownSymbol ? undefined : symbol;
64765                     }
64766                     return resolveEntityName(name, 111551, false, true);
64767                 }
64768                 else if (name.kind === 201 || name.kind === 157) {
64769                     var links = getNodeLinks(name);
64770                     if (links.resolvedSymbol) {
64771                         return links.resolvedSymbol;
64772                     }
64773                     if (name.kind === 201) {
64774                         checkPropertyAccessExpression(name);
64775                     }
64776                     else {
64777                         checkQualifiedName(name);
64778                     }
64779                     return links.resolvedSymbol;
64780                 }
64781             }
64782             else if (isTypeReferenceIdentifier(name)) {
64783                 var meaning = name.parent.kind === 173 ? 788968 : 1920;
64784                 return resolveEntityName(name, meaning, false, true);
64785             }
64786             else if (isJSDocEntryNameReference(name)) {
64787                 var meaning = 788968 | 1920 | 111551;
64788                 return resolveEntityName(name, meaning, false, true, ts.getHostSignatureFromJSDoc(name));
64789             }
64790             if (name.parent.kind === 172) {
64791                 return resolveEntityName(name, 1);
64792             }
64793             return undefined;
64794         }
64795         function getSymbolAtLocation(node, ignoreErrors) {
64796             if (node.kind === 297) {
64797                 return ts.isExternalModule(node) ? getMergedSymbol(node.symbol) : undefined;
64798             }
64799             var parent = node.parent;
64800             var grandParent = parent.parent;
64801             if (node.flags & 16777216) {
64802                 return undefined;
64803             }
64804             if (isDeclarationNameOrImportPropertyName(node)) {
64805                 var parentSymbol = getSymbolOfNode(parent);
64806                 return ts.isImportOrExportSpecifier(node.parent) && node.parent.propertyName === node
64807                     ? getImmediateAliasedSymbol(parentSymbol)
64808                     : parentSymbol;
64809             }
64810             else if (ts.isLiteralComputedPropertyDeclarationName(node)) {
64811                 return getSymbolOfNode(parent.parent);
64812             }
64813             if (node.kind === 78) {
64814                 if (isInRightSideOfImportOrExportAssignment(node)) {
64815                     return getSymbolOfNameOrPropertyAccessExpression(node);
64816                 }
64817                 else if (parent.kind === 198 &&
64818                     grandParent.kind === 196 &&
64819                     node === parent.propertyName) {
64820                     var typeOfPattern = getTypeOfNode(grandParent);
64821                     var propertyDeclaration = getPropertyOfType(typeOfPattern, node.escapedText);
64822                     if (propertyDeclaration) {
64823                         return propertyDeclaration;
64824                     }
64825                 }
64826             }
64827             switch (node.kind) {
64828                 case 78:
64829                 case 79:
64830                 case 201:
64831                 case 157:
64832                     return getSymbolOfNameOrPropertyAccessExpression(node);
64833                 case 107:
64834                     var container = ts.getThisContainer(node, false);
64835                     if (ts.isFunctionLike(container)) {
64836                         var sig = getSignatureFromDeclaration(container);
64837                         if (sig.thisParameter) {
64838                             return sig.thisParameter;
64839                         }
64840                     }
64841                     if (ts.isInExpressionContext(node)) {
64842                         return checkExpression(node).symbol;
64843                     }
64844                 case 187:
64845                     return getTypeFromThisTypeNode(node).symbol;
64846                 case 105:
64847                     return checkExpression(node).symbol;
64848                 case 132:
64849                     var constructorDeclaration = node.parent;
64850                     if (constructorDeclaration && constructorDeclaration.kind === 166) {
64851                         return constructorDeclaration.parent.symbol;
64852                     }
64853                     return undefined;
64854                 case 10:
64855                 case 14:
64856                     if ((ts.isExternalModuleImportEqualsDeclaration(node.parent.parent) && ts.getExternalModuleImportEqualsDeclarationExpression(node.parent.parent) === node) ||
64857                         ((node.parent.kind === 261 || node.parent.kind === 267) && node.parent.moduleSpecifier === node) ||
64858                         ((ts.isInJSFile(node) && ts.isRequireCall(node.parent, false)) || ts.isImportCall(node.parent)) ||
64859                         (ts.isLiteralTypeNode(node.parent) && ts.isLiteralImportTypeNode(node.parent.parent) && node.parent.parent.argument === node.parent)) {
64860                         return resolveExternalModuleName(node, node, ignoreErrors);
64861                     }
64862                     if (ts.isCallExpression(parent) && ts.isBindableObjectDefinePropertyCall(parent) && parent.arguments[1] === node) {
64863                         return getSymbolOfNode(parent);
64864                     }
64865                 case 8:
64866                     var objectType = ts.isElementAccessExpression(parent)
64867                         ? parent.argumentExpression === node ? getTypeOfExpression(parent.expression) : undefined
64868                         : ts.isLiteralTypeNode(parent) && ts.isIndexedAccessTypeNode(grandParent)
64869                             ? getTypeFromTypeNode(grandParent.objectType)
64870                             : undefined;
64871                     return objectType && getPropertyOfType(objectType, ts.escapeLeadingUnderscores(node.text));
64872                 case 87:
64873                 case 97:
64874                 case 38:
64875                 case 83:
64876                     return getSymbolOfNode(node.parent);
64877                 case 195:
64878                     return ts.isLiteralImportTypeNode(node) ? getSymbolAtLocation(node.argument.literal, ignoreErrors) : undefined;
64879                 case 92:
64880                     return ts.isExportAssignment(node.parent) ? ts.Debug.checkDefined(node.parent.symbol) : undefined;
64881                 default:
64882                     return undefined;
64883             }
64884         }
64885         function getShorthandAssignmentValueSymbol(location) {
64886             if (location && location.kind === 289) {
64887                 return resolveEntityName(location.name, 111551 | 2097152);
64888             }
64889             return undefined;
64890         }
64891         function getExportSpecifierLocalTargetSymbol(node) {
64892             if (ts.isExportSpecifier(node)) {
64893                 return node.parent.parent.moduleSpecifier ?
64894                     getExternalModuleMember(node.parent.parent, node) :
64895                     resolveEntityName(node.propertyName || node.name, 111551 | 788968 | 1920 | 2097152);
64896             }
64897             else {
64898                 return resolveEntityName(node, 111551 | 788968 | 1920 | 2097152);
64899             }
64900         }
64901         function getTypeOfNode(node) {
64902             if (ts.isSourceFile(node) && !ts.isExternalModule(node)) {
64903                 return errorType;
64904             }
64905             if (node.flags & 16777216) {
64906                 return errorType;
64907             }
64908             var classDecl = ts.tryGetClassImplementingOrExtendingExpressionWithTypeArguments(node);
64909             var classType = classDecl && getDeclaredTypeOfClassOrInterface(getSymbolOfNode(classDecl.class));
64910             if (ts.isPartOfTypeNode(node)) {
64911                 var typeFromTypeNode = getTypeFromTypeNode(node);
64912                 return classType ? getTypeWithThisArgument(typeFromTypeNode, classType.thisType) : typeFromTypeNode;
64913             }
64914             if (ts.isExpressionNode(node)) {
64915                 return getRegularTypeOfExpression(node);
64916             }
64917             if (classType && !classDecl.isImplements) {
64918                 var baseType = ts.firstOrUndefined(getBaseTypes(classType));
64919                 return baseType ? getTypeWithThisArgument(baseType, classType.thisType) : errorType;
64920             }
64921             if (isTypeDeclaration(node)) {
64922                 var symbol = getSymbolOfNode(node);
64923                 return getDeclaredTypeOfSymbol(symbol);
64924             }
64925             if (isTypeDeclarationName(node)) {
64926                 var symbol = getSymbolAtLocation(node);
64927                 return symbol ? getDeclaredTypeOfSymbol(symbol) : errorType;
64928             }
64929             if (ts.isDeclaration(node)) {
64930                 var symbol = getSymbolOfNode(node);
64931                 return getTypeOfSymbol(symbol);
64932             }
64933             if (isDeclarationNameOrImportPropertyName(node)) {
64934                 var symbol = getSymbolAtLocation(node);
64935                 if (symbol) {
64936                     return getTypeOfSymbol(symbol);
64937                 }
64938                 return errorType;
64939             }
64940             if (ts.isBindingPattern(node)) {
64941                 return getTypeForVariableLikeDeclaration(node.parent, true) || errorType;
64942             }
64943             if (isInRightSideOfImportOrExportAssignment(node)) {
64944                 var symbol = getSymbolAtLocation(node);
64945                 if (symbol) {
64946                     var declaredType = getDeclaredTypeOfSymbol(symbol);
64947                     return declaredType !== errorType ? declaredType : getTypeOfSymbol(symbol);
64948                 }
64949             }
64950             return errorType;
64951         }
64952         function getTypeOfAssignmentPattern(expr) {
64953             ts.Debug.assert(expr.kind === 200 || expr.kind === 199);
64954             if (expr.parent.kind === 239) {
64955                 var iteratedType = checkRightHandSideOfForOf(expr.parent);
64956                 return checkDestructuringAssignment(expr, iteratedType || errorType);
64957             }
64958             if (expr.parent.kind === 216) {
64959                 var iteratedType = getTypeOfExpression(expr.parent.right);
64960                 return checkDestructuringAssignment(expr, iteratedType || errorType);
64961             }
64962             if (expr.parent.kind === 288) {
64963                 var node_2 = ts.cast(expr.parent.parent, ts.isObjectLiteralExpression);
64964                 var typeOfParentObjectLiteral = getTypeOfAssignmentPattern(node_2) || errorType;
64965                 var propertyIndex = ts.indexOfNode(node_2.properties, expr.parent);
64966                 return checkObjectLiteralDestructuringPropertyAssignment(node_2, typeOfParentObjectLiteral, propertyIndex);
64967             }
64968             var node = ts.cast(expr.parent, ts.isArrayLiteralExpression);
64969             var typeOfArrayLiteral = getTypeOfAssignmentPattern(node) || errorType;
64970             var elementType = checkIteratedTypeOrElementType(65, typeOfArrayLiteral, undefinedType, expr.parent) || errorType;
64971             return checkArrayLiteralDestructuringElementAssignment(node, typeOfArrayLiteral, node.elements.indexOf(expr), elementType);
64972         }
64973         function getPropertySymbolOfDestructuringAssignment(location) {
64974             var typeOfObjectLiteral = getTypeOfAssignmentPattern(ts.cast(location.parent.parent, ts.isAssignmentPattern));
64975             return typeOfObjectLiteral && getPropertyOfType(typeOfObjectLiteral, location.escapedText);
64976         }
64977         function getRegularTypeOfExpression(expr) {
64978             if (ts.isRightSideOfQualifiedNameOrPropertyAccess(expr)) {
64979                 expr = expr.parent;
64980             }
64981             return getRegularTypeOfLiteralType(getTypeOfExpression(expr));
64982         }
64983         function getParentTypeOfClassElement(node) {
64984             var classSymbol = getSymbolOfNode(node.parent);
64985             return ts.hasSyntacticModifier(node, 32)
64986                 ? getTypeOfSymbol(classSymbol)
64987                 : getDeclaredTypeOfSymbol(classSymbol);
64988         }
64989         function getClassElementPropertyKeyType(element) {
64990             var name = element.name;
64991             switch (name.kind) {
64992                 case 78:
64993                     return getLiteralType(ts.idText(name));
64994                 case 8:
64995                 case 10:
64996                     return getLiteralType(name.text);
64997                 case 158:
64998                     var nameType = checkComputedPropertyName(name);
64999                     return isTypeAssignableToKind(nameType, 12288) ? nameType : stringType;
65000                 default:
65001                     return ts.Debug.fail("Unsupported property name.");
65002             }
65003         }
65004         function getAugmentedPropertiesOfType(type) {
65005             type = getApparentType(type);
65006             var propsByName = ts.createSymbolTable(getPropertiesOfType(type));
65007             var functionType = getSignaturesOfType(type, 0).length ? globalCallableFunctionType :
65008                 getSignaturesOfType(type, 1).length ? globalNewableFunctionType :
65009                     undefined;
65010             if (functionType) {
65011                 ts.forEach(getPropertiesOfType(functionType), function (p) {
65012                     if (!propsByName.has(p.escapedName)) {
65013                         propsByName.set(p.escapedName, p);
65014                     }
65015                 });
65016             }
65017             return getNamedMembers(propsByName);
65018         }
65019         function typeHasCallOrConstructSignatures(type) {
65020             return ts.typeHasCallOrConstructSignatures(type, checker);
65021         }
65022         function getRootSymbols(symbol) {
65023             var roots = getImmediateRootSymbols(symbol);
65024             return roots ? ts.flatMap(roots, getRootSymbols) : [symbol];
65025         }
65026         function getImmediateRootSymbols(symbol) {
65027             if (ts.getCheckFlags(symbol) & 6) {
65028                 return ts.mapDefined(getSymbolLinks(symbol).containingType.types, function (type) { return getPropertyOfType(type, symbol.escapedName); });
65029             }
65030             else if (symbol.flags & 33554432) {
65031                 var _a = symbol, leftSpread = _a.leftSpread, rightSpread = _a.rightSpread, syntheticOrigin = _a.syntheticOrigin;
65032                 return leftSpread ? [leftSpread, rightSpread]
65033                     : syntheticOrigin ? [syntheticOrigin]
65034                         : ts.singleElementArray(tryGetAliasTarget(symbol));
65035             }
65036             return undefined;
65037         }
65038         function tryGetAliasTarget(symbol) {
65039             var target;
65040             var next = symbol;
65041             while (next = getSymbolLinks(next).target) {
65042                 target = next;
65043             }
65044             return target;
65045         }
65046         function isArgumentsLocalBinding(nodeIn) {
65047             if (ts.isGeneratedIdentifier(nodeIn))
65048                 return false;
65049             var node = ts.getParseTreeNode(nodeIn, ts.isIdentifier);
65050             if (!node)
65051                 return false;
65052             var parent = node.parent;
65053             if (!parent)
65054                 return false;
65055             var isPropertyName = ((ts.isPropertyAccessExpression(parent)
65056                 || ts.isPropertyAssignment(parent))
65057                 && parent.name === node);
65058             return !isPropertyName && getReferencedValueSymbol(node) === argumentsSymbol;
65059         }
65060         function moduleExportsSomeValue(moduleReferenceExpression) {
65061             var moduleSymbol = resolveExternalModuleName(moduleReferenceExpression.parent, moduleReferenceExpression);
65062             if (!moduleSymbol || ts.isShorthandAmbientModuleSymbol(moduleSymbol)) {
65063                 return true;
65064             }
65065             var hasExportAssignment = hasExportAssignmentSymbol(moduleSymbol);
65066             moduleSymbol = resolveExternalModuleSymbol(moduleSymbol);
65067             var symbolLinks = getSymbolLinks(moduleSymbol);
65068             if (symbolLinks.exportsSomeValue === undefined) {
65069                 symbolLinks.exportsSomeValue = hasExportAssignment
65070                     ? !!(moduleSymbol.flags & 111551)
65071                     : ts.forEachEntry(getExportsOfModule(moduleSymbol), isValue);
65072             }
65073             return symbolLinks.exportsSomeValue;
65074             function isValue(s) {
65075                 s = resolveSymbol(s);
65076                 return s && !!(s.flags & 111551);
65077             }
65078         }
65079         function isNameOfModuleOrEnumDeclaration(node) {
65080             return ts.isModuleOrEnumDeclaration(node.parent) && node === node.parent.name;
65081         }
65082         function getReferencedExportContainer(nodeIn, prefixLocals) {
65083             var node = ts.getParseTreeNode(nodeIn, ts.isIdentifier);
65084             if (node) {
65085                 var symbol = getReferencedValueSymbol(node, isNameOfModuleOrEnumDeclaration(node));
65086                 if (symbol) {
65087                     if (symbol.flags & 1048576) {
65088                         var exportSymbol = getMergedSymbol(symbol.exportSymbol);
65089                         if (!prefixLocals && exportSymbol.flags & 944 && !(exportSymbol.flags & 3)) {
65090                             return undefined;
65091                         }
65092                         symbol = exportSymbol;
65093                     }
65094                     var parentSymbol_1 = getParentOfSymbol(symbol);
65095                     if (parentSymbol_1) {
65096                         if (parentSymbol_1.flags & 512 && parentSymbol_1.valueDeclaration.kind === 297) {
65097                             var symbolFile = parentSymbol_1.valueDeclaration;
65098                             var referenceFile = ts.getSourceFileOfNode(node);
65099                             var symbolIsUmdExport = symbolFile !== referenceFile;
65100                             return symbolIsUmdExport ? undefined : symbolFile;
65101                         }
65102                         return ts.findAncestor(node.parent, function (n) { return ts.isModuleOrEnumDeclaration(n) && getSymbolOfNode(n) === parentSymbol_1; });
65103                     }
65104                 }
65105             }
65106         }
65107         function getReferencedImportDeclaration(nodeIn) {
65108             if (nodeIn.generatedImportReference) {
65109                 return nodeIn.generatedImportReference;
65110             }
65111             var node = ts.getParseTreeNode(nodeIn, ts.isIdentifier);
65112             if (node) {
65113                 var symbol = getReferencedValueSymbol(node);
65114                 if (isNonLocalAlias(symbol, 111551) && !getTypeOnlyAliasDeclaration(symbol)) {
65115                     return getDeclarationOfAliasSymbol(symbol);
65116                 }
65117             }
65118             return undefined;
65119         }
65120         function isSymbolOfDestructuredElementOfCatchBinding(symbol) {
65121             return ts.isBindingElement(symbol.valueDeclaration)
65122                 && ts.walkUpBindingElementsAndPatterns(symbol.valueDeclaration).parent.kind === 287;
65123         }
65124         function isSymbolOfDeclarationWithCollidingName(symbol) {
65125             if (symbol.flags & 418 && !ts.isSourceFile(symbol.valueDeclaration)) {
65126                 var links = getSymbolLinks(symbol);
65127                 if (links.isDeclarationWithCollidingName === undefined) {
65128                     var container = ts.getEnclosingBlockScopeContainer(symbol.valueDeclaration);
65129                     if (ts.isStatementWithLocals(container) || isSymbolOfDestructuredElementOfCatchBinding(symbol)) {
65130                         var nodeLinks_1 = getNodeLinks(symbol.valueDeclaration);
65131                         if (resolveName(container.parent, symbol.escapedName, 111551, undefined, undefined, false)) {
65132                             links.isDeclarationWithCollidingName = true;
65133                         }
65134                         else if (nodeLinks_1.flags & 262144) {
65135                             var isDeclaredInLoop = nodeLinks_1.flags & 524288;
65136                             var inLoopInitializer = ts.isIterationStatement(container, false);
65137                             var inLoopBodyBlock = container.kind === 230 && ts.isIterationStatement(container.parent, false);
65138                             links.isDeclarationWithCollidingName = !ts.isBlockScopedContainerTopLevel(container) && (!isDeclaredInLoop || (!inLoopInitializer && !inLoopBodyBlock));
65139                         }
65140                         else {
65141                             links.isDeclarationWithCollidingName = false;
65142                         }
65143                     }
65144                 }
65145                 return links.isDeclarationWithCollidingName;
65146             }
65147             return false;
65148         }
65149         function getReferencedDeclarationWithCollidingName(nodeIn) {
65150             if (!ts.isGeneratedIdentifier(nodeIn)) {
65151                 var node = ts.getParseTreeNode(nodeIn, ts.isIdentifier);
65152                 if (node) {
65153                     var symbol = getReferencedValueSymbol(node);
65154                     if (symbol && isSymbolOfDeclarationWithCollidingName(symbol)) {
65155                         return symbol.valueDeclaration;
65156                     }
65157                 }
65158             }
65159             return undefined;
65160         }
65161         function isDeclarationWithCollidingName(nodeIn) {
65162             var node = ts.getParseTreeNode(nodeIn, ts.isDeclaration);
65163             if (node) {
65164                 var symbol = getSymbolOfNode(node);
65165                 if (symbol) {
65166                     return isSymbolOfDeclarationWithCollidingName(symbol);
65167                 }
65168             }
65169             return false;
65170         }
65171         function isValueAliasDeclaration(node) {
65172             switch (node.kind) {
65173                 case 260:
65174                     return isAliasResolvedToValue(getSymbolOfNode(node) || unknownSymbol);
65175                 case 262:
65176                 case 263:
65177                 case 265:
65178                 case 270:
65179                     var symbol = getSymbolOfNode(node) || unknownSymbol;
65180                     return isAliasResolvedToValue(symbol) && !getTypeOnlyAliasDeclaration(symbol);
65181                 case 267:
65182                     var exportClause = node.exportClause;
65183                     return !!exportClause && (ts.isNamespaceExport(exportClause) ||
65184                         ts.some(exportClause.elements, isValueAliasDeclaration));
65185                 case 266:
65186                     return node.expression && node.expression.kind === 78 ?
65187                         isAliasResolvedToValue(getSymbolOfNode(node) || unknownSymbol) :
65188                         true;
65189             }
65190             return false;
65191         }
65192         function isTopLevelValueImportEqualsWithEntityName(nodeIn) {
65193             var node = ts.getParseTreeNode(nodeIn, ts.isImportEqualsDeclaration);
65194             if (node === undefined || node.parent.kind !== 297 || !ts.isInternalModuleImportEqualsDeclaration(node)) {
65195                 return false;
65196             }
65197             var isValue = isAliasResolvedToValue(getSymbolOfNode(node));
65198             return isValue && node.moduleReference && !ts.nodeIsMissing(node.moduleReference);
65199         }
65200         function isAliasResolvedToValue(symbol) {
65201             var target = resolveAlias(symbol);
65202             if (target === unknownSymbol) {
65203                 return true;
65204             }
65205             return !!(target.flags & 111551) &&
65206                 (compilerOptions.preserveConstEnums || !isConstEnumOrConstEnumOnlyModule(target));
65207         }
65208         function isConstEnumOrConstEnumOnlyModule(s) {
65209             return isConstEnumSymbol(s) || !!s.constEnumOnlyModule;
65210         }
65211         function isReferencedAliasDeclaration(node, checkChildren) {
65212             if (isAliasSymbolDeclaration(node)) {
65213                 var symbol = getSymbolOfNode(node);
65214                 if (symbol && getSymbolLinks(symbol).referenced) {
65215                     return true;
65216                 }
65217                 var target = getSymbolLinks(symbol).target;
65218                 if (target && ts.getEffectiveModifierFlags(node) & 1 &&
65219                     target.flags & 111551 &&
65220                     (compilerOptions.preserveConstEnums || !isConstEnumOrConstEnumOnlyModule(target))) {
65221                     return true;
65222                 }
65223             }
65224             if (checkChildren) {
65225                 return !!ts.forEachChild(node, function (node) { return isReferencedAliasDeclaration(node, checkChildren); });
65226             }
65227             return false;
65228         }
65229         function isImplementationOfOverload(node) {
65230             if (ts.nodeIsPresent(node.body)) {
65231                 if (ts.isGetAccessor(node) || ts.isSetAccessor(node))
65232                     return false;
65233                 var symbol = getSymbolOfNode(node);
65234                 var signaturesOfSymbol = getSignaturesOfSymbol(symbol);
65235                 return signaturesOfSymbol.length > 1 ||
65236                     (signaturesOfSymbol.length === 1 && signaturesOfSymbol[0].declaration !== node);
65237             }
65238             return false;
65239         }
65240         function isRequiredInitializedParameter(parameter) {
65241             return !!strictNullChecks &&
65242                 !isOptionalParameter(parameter) &&
65243                 !ts.isJSDocParameterTag(parameter) &&
65244                 !!parameter.initializer &&
65245                 !ts.hasSyntacticModifier(parameter, 92);
65246         }
65247         function isOptionalUninitializedParameterProperty(parameter) {
65248             return strictNullChecks &&
65249                 isOptionalParameter(parameter) &&
65250                 !parameter.initializer &&
65251                 ts.hasSyntacticModifier(parameter, 92);
65252         }
65253         function isOptionalUninitializedParameter(parameter) {
65254             return !!strictNullChecks &&
65255                 isOptionalParameter(parameter) &&
65256                 !parameter.initializer;
65257         }
65258         function isExpandoFunctionDeclaration(node) {
65259             var declaration = ts.getParseTreeNode(node, ts.isFunctionDeclaration);
65260             if (!declaration) {
65261                 return false;
65262             }
65263             var symbol = getSymbolOfNode(declaration);
65264             if (!symbol || !(symbol.flags & 16)) {
65265                 return false;
65266             }
65267             return !!ts.forEachEntry(getExportsOfSymbol(symbol), function (p) { return p.flags & 111551 && p.valueDeclaration && ts.isPropertyAccessExpression(p.valueDeclaration); });
65268         }
65269         function getPropertiesOfContainerFunction(node) {
65270             var declaration = ts.getParseTreeNode(node, ts.isFunctionDeclaration);
65271             if (!declaration) {
65272                 return ts.emptyArray;
65273             }
65274             var symbol = getSymbolOfNode(declaration);
65275             return symbol && getPropertiesOfType(getTypeOfSymbol(symbol)) || ts.emptyArray;
65276         }
65277         function getNodeCheckFlags(node) {
65278             return getNodeLinks(node).flags || 0;
65279         }
65280         function getEnumMemberValue(node) {
65281             computeEnumMemberValues(node.parent);
65282             return getNodeLinks(node).enumMemberValue;
65283         }
65284         function canHaveConstantValue(node) {
65285             switch (node.kind) {
65286                 case 291:
65287                 case 201:
65288                 case 202:
65289                     return true;
65290             }
65291             return false;
65292         }
65293         function getConstantValue(node) {
65294             if (node.kind === 291) {
65295                 return getEnumMemberValue(node);
65296             }
65297             var symbol = getNodeLinks(node).resolvedSymbol;
65298             if (symbol && (symbol.flags & 8)) {
65299                 var member = symbol.valueDeclaration;
65300                 if (ts.isEnumConst(member.parent)) {
65301                     return getEnumMemberValue(member);
65302                 }
65303             }
65304             return undefined;
65305         }
65306         function isFunctionType(type) {
65307             return !!(type.flags & 524288) && getSignaturesOfType(type, 0).length > 0;
65308         }
65309         function getTypeReferenceSerializationKind(typeNameIn, location) {
65310             var _a;
65311             var typeName = ts.getParseTreeNode(typeNameIn, ts.isEntityName);
65312             if (!typeName)
65313                 return ts.TypeReferenceSerializationKind.Unknown;
65314             if (location) {
65315                 location = ts.getParseTreeNode(location);
65316                 if (!location)
65317                     return ts.TypeReferenceSerializationKind.Unknown;
65318             }
65319             var valueSymbol = resolveEntityName(typeName, 111551, true, true, location);
65320             var isTypeOnly = ((_a = valueSymbol === null || valueSymbol === void 0 ? void 0 : valueSymbol.declarations) === null || _a === void 0 ? void 0 : _a.every(ts.isTypeOnlyImportOrExportDeclaration)) || false;
65321             var resolvedSymbol = valueSymbol && valueSymbol.flags & 2097152 ? resolveAlias(valueSymbol) : valueSymbol;
65322             var typeSymbol = resolveEntityName(typeName, 788968, true, false, location);
65323             if (resolvedSymbol && resolvedSymbol === typeSymbol) {
65324                 var globalPromiseSymbol = getGlobalPromiseConstructorSymbol(false);
65325                 if (globalPromiseSymbol && resolvedSymbol === globalPromiseSymbol) {
65326                     return ts.TypeReferenceSerializationKind.Promise;
65327                 }
65328                 var constructorType = getTypeOfSymbol(resolvedSymbol);
65329                 if (constructorType && isConstructorType(constructorType)) {
65330                     return isTypeOnly ? ts.TypeReferenceSerializationKind.TypeWithCallSignature : ts.TypeReferenceSerializationKind.TypeWithConstructSignatureAndValue;
65331                 }
65332             }
65333             if (!typeSymbol) {
65334                 return isTypeOnly ? ts.TypeReferenceSerializationKind.ObjectType : ts.TypeReferenceSerializationKind.Unknown;
65335             }
65336             var type = getDeclaredTypeOfSymbol(typeSymbol);
65337             if (type === errorType) {
65338                 return isTypeOnly ? ts.TypeReferenceSerializationKind.ObjectType : ts.TypeReferenceSerializationKind.Unknown;
65339             }
65340             else if (type.flags & 3) {
65341                 return ts.TypeReferenceSerializationKind.ObjectType;
65342             }
65343             else if (isTypeAssignableToKind(type, 16384 | 98304 | 131072)) {
65344                 return ts.TypeReferenceSerializationKind.VoidNullableOrNeverType;
65345             }
65346             else if (isTypeAssignableToKind(type, 528)) {
65347                 return ts.TypeReferenceSerializationKind.BooleanType;
65348             }
65349             else if (isTypeAssignableToKind(type, 296)) {
65350                 return ts.TypeReferenceSerializationKind.NumberLikeType;
65351             }
65352             else if (isTypeAssignableToKind(type, 2112)) {
65353                 return ts.TypeReferenceSerializationKind.BigIntLikeType;
65354             }
65355             else if (isTypeAssignableToKind(type, 402653316)) {
65356                 return ts.TypeReferenceSerializationKind.StringLikeType;
65357             }
65358             else if (isTupleType(type)) {
65359                 return ts.TypeReferenceSerializationKind.ArrayLikeType;
65360             }
65361             else if (isTypeAssignableToKind(type, 12288)) {
65362                 return ts.TypeReferenceSerializationKind.ESSymbolType;
65363             }
65364             else if (isFunctionType(type)) {
65365                 return ts.TypeReferenceSerializationKind.TypeWithCallSignature;
65366             }
65367             else if (isArrayType(type)) {
65368                 return ts.TypeReferenceSerializationKind.ArrayLikeType;
65369             }
65370             else {
65371                 return ts.TypeReferenceSerializationKind.ObjectType;
65372             }
65373         }
65374         function createTypeOfDeclaration(declarationIn, enclosingDeclaration, flags, tracker, addUndefined) {
65375             var declaration = ts.getParseTreeNode(declarationIn, ts.isVariableLikeOrAccessor);
65376             if (!declaration) {
65377                 return ts.factory.createToken(128);
65378             }
65379             var symbol = getSymbolOfNode(declaration);
65380             var type = symbol && !(symbol.flags & (2048 | 131072))
65381                 ? getWidenedLiteralType(getTypeOfSymbol(symbol))
65382                 : errorType;
65383             if (type.flags & 8192 &&
65384                 type.symbol === symbol) {
65385                 flags |= 1048576;
65386             }
65387             if (addUndefined) {
65388                 type = getOptionalType(type);
65389             }
65390             return nodeBuilder.typeToTypeNode(type, enclosingDeclaration, flags | 1024, tracker);
65391         }
65392         function createReturnTypeOfSignatureDeclaration(signatureDeclarationIn, enclosingDeclaration, flags, tracker) {
65393             var signatureDeclaration = ts.getParseTreeNode(signatureDeclarationIn, ts.isFunctionLike);
65394             if (!signatureDeclaration) {
65395                 return ts.factory.createToken(128);
65396             }
65397             var signature = getSignatureFromDeclaration(signatureDeclaration);
65398             return nodeBuilder.typeToTypeNode(getReturnTypeOfSignature(signature), enclosingDeclaration, flags | 1024, tracker);
65399         }
65400         function createTypeOfExpression(exprIn, enclosingDeclaration, flags, tracker) {
65401             var expr = ts.getParseTreeNode(exprIn, ts.isExpression);
65402             if (!expr) {
65403                 return ts.factory.createToken(128);
65404             }
65405             var type = getWidenedType(getRegularTypeOfExpression(expr));
65406             return nodeBuilder.typeToTypeNode(type, enclosingDeclaration, flags | 1024, tracker);
65407         }
65408         function hasGlobalName(name) {
65409             return globals.has(ts.escapeLeadingUnderscores(name));
65410         }
65411         function getReferencedValueSymbol(reference, startInDeclarationContainer) {
65412             var resolvedSymbol = getNodeLinks(reference).resolvedSymbol;
65413             if (resolvedSymbol) {
65414                 return resolvedSymbol;
65415             }
65416             var location = reference;
65417             if (startInDeclarationContainer) {
65418                 var parent = reference.parent;
65419                 if (ts.isDeclaration(parent) && reference === parent.name) {
65420                     location = getDeclarationContainer(parent);
65421                 }
65422             }
65423             return resolveName(location, reference.escapedText, 111551 | 1048576 | 2097152, undefined, undefined, true);
65424         }
65425         function getReferencedValueDeclaration(referenceIn) {
65426             if (!ts.isGeneratedIdentifier(referenceIn)) {
65427                 var reference = ts.getParseTreeNode(referenceIn, ts.isIdentifier);
65428                 if (reference) {
65429                     var symbol = getReferencedValueSymbol(reference);
65430                     if (symbol) {
65431                         return getExportSymbolOfValueSymbolIfExported(symbol).valueDeclaration;
65432                     }
65433                 }
65434             }
65435             return undefined;
65436         }
65437         function isLiteralConstDeclaration(node) {
65438             if (ts.isDeclarationReadonly(node) || ts.isVariableDeclaration(node) && ts.isVarConst(node)) {
65439                 return isFreshLiteralType(getTypeOfSymbol(getSymbolOfNode(node)));
65440             }
65441             return false;
65442         }
65443         function literalTypeToNode(type, enclosing, tracker) {
65444             var enumResult = type.flags & 1024 ? nodeBuilder.symbolToExpression(type.symbol, 111551, enclosing, undefined, tracker)
65445                 : type === trueType ? ts.factory.createTrue() : type === falseType && ts.factory.createFalse();
65446             if (enumResult)
65447                 return enumResult;
65448             var literalValue = type.value;
65449             return typeof literalValue === "object" ? ts.factory.createBigIntLiteral(literalValue) :
65450                 typeof literalValue === "number" ? ts.factory.createNumericLiteral(literalValue) :
65451                     ts.factory.createStringLiteral(literalValue);
65452         }
65453         function createLiteralConstValue(node, tracker) {
65454             var type = getTypeOfSymbol(getSymbolOfNode(node));
65455             return literalTypeToNode(type, node, tracker);
65456         }
65457         function getJsxFactoryEntity(location) {
65458             return location ? (getJsxNamespace(location), (ts.getSourceFileOfNode(location).localJsxFactory || _jsxFactoryEntity)) : _jsxFactoryEntity;
65459         }
65460         function getJsxFragmentFactoryEntity(location) {
65461             if (location) {
65462                 var file = ts.getSourceFileOfNode(location);
65463                 if (file) {
65464                     if (file.localJsxFragmentFactory) {
65465                         return file.localJsxFragmentFactory;
65466                     }
65467                     var jsxFragPragmas = file.pragmas.get("jsxfrag");
65468                     var jsxFragPragma = ts.isArray(jsxFragPragmas) ? jsxFragPragmas[0] : jsxFragPragmas;
65469                     if (jsxFragPragma) {
65470                         file.localJsxFragmentFactory = ts.parseIsolatedEntityName(jsxFragPragma.arguments.factory, languageVersion);
65471                         return file.localJsxFragmentFactory;
65472                     }
65473                 }
65474             }
65475             if (compilerOptions.jsxFragmentFactory) {
65476                 return ts.parseIsolatedEntityName(compilerOptions.jsxFragmentFactory, languageVersion);
65477             }
65478         }
65479         function createResolver() {
65480             var resolvedTypeReferenceDirectives = host.getResolvedTypeReferenceDirectives();
65481             var fileToDirective;
65482             if (resolvedTypeReferenceDirectives) {
65483                 fileToDirective = new ts.Map();
65484                 resolvedTypeReferenceDirectives.forEach(function (resolvedDirective, key) {
65485                     if (!resolvedDirective || !resolvedDirective.resolvedFileName) {
65486                         return;
65487                     }
65488                     var file = host.getSourceFile(resolvedDirective.resolvedFileName);
65489                     if (file) {
65490                         addReferencedFilesToTypeDirective(file, key);
65491                     }
65492                 });
65493             }
65494             return {
65495                 getReferencedExportContainer: getReferencedExportContainer,
65496                 getReferencedImportDeclaration: getReferencedImportDeclaration,
65497                 getReferencedDeclarationWithCollidingName: getReferencedDeclarationWithCollidingName,
65498                 isDeclarationWithCollidingName: isDeclarationWithCollidingName,
65499                 isValueAliasDeclaration: function (nodeIn) {
65500                     var node = ts.getParseTreeNode(nodeIn);
65501                     return node ? isValueAliasDeclaration(node) : true;
65502                 },
65503                 hasGlobalName: hasGlobalName,
65504                 isReferencedAliasDeclaration: function (nodeIn, checkChildren) {
65505                     var node = ts.getParseTreeNode(nodeIn);
65506                     return node ? isReferencedAliasDeclaration(node, checkChildren) : true;
65507                 },
65508                 getNodeCheckFlags: function (nodeIn) {
65509                     var node = ts.getParseTreeNode(nodeIn);
65510                     return node ? getNodeCheckFlags(node) : 0;
65511                 },
65512                 isTopLevelValueImportEqualsWithEntityName: isTopLevelValueImportEqualsWithEntityName,
65513                 isDeclarationVisible: isDeclarationVisible,
65514                 isImplementationOfOverload: isImplementationOfOverload,
65515                 isRequiredInitializedParameter: isRequiredInitializedParameter,
65516                 isOptionalUninitializedParameterProperty: isOptionalUninitializedParameterProperty,
65517                 isExpandoFunctionDeclaration: isExpandoFunctionDeclaration,
65518                 getPropertiesOfContainerFunction: getPropertiesOfContainerFunction,
65519                 createTypeOfDeclaration: createTypeOfDeclaration,
65520                 createReturnTypeOfSignatureDeclaration: createReturnTypeOfSignatureDeclaration,
65521                 createTypeOfExpression: createTypeOfExpression,
65522                 createLiteralConstValue: createLiteralConstValue,
65523                 isSymbolAccessible: isSymbolAccessible,
65524                 isEntityNameVisible: isEntityNameVisible,
65525                 getConstantValue: function (nodeIn) {
65526                     var node = ts.getParseTreeNode(nodeIn, canHaveConstantValue);
65527                     return node ? getConstantValue(node) : undefined;
65528                 },
65529                 collectLinkedAliases: collectLinkedAliases,
65530                 getReferencedValueDeclaration: getReferencedValueDeclaration,
65531                 getTypeReferenceSerializationKind: getTypeReferenceSerializationKind,
65532                 isOptionalParameter: isOptionalParameter,
65533                 moduleExportsSomeValue: moduleExportsSomeValue,
65534                 isArgumentsLocalBinding: isArgumentsLocalBinding,
65535                 getExternalModuleFileFromDeclaration: getExternalModuleFileFromDeclaration,
65536                 getTypeReferenceDirectivesForEntityName: getTypeReferenceDirectivesForEntityName,
65537                 getTypeReferenceDirectivesForSymbol: getTypeReferenceDirectivesForSymbol,
65538                 isLiteralConstDeclaration: isLiteralConstDeclaration,
65539                 isLateBound: function (nodeIn) {
65540                     var node = ts.getParseTreeNode(nodeIn, ts.isDeclaration);
65541                     var symbol = node && getSymbolOfNode(node);
65542                     return !!(symbol && ts.getCheckFlags(symbol) & 4096);
65543                 },
65544                 getJsxFactoryEntity: getJsxFactoryEntity,
65545                 getJsxFragmentFactoryEntity: getJsxFragmentFactoryEntity,
65546                 getAllAccessorDeclarations: function (accessor) {
65547                     accessor = ts.getParseTreeNode(accessor, ts.isGetOrSetAccessorDeclaration);
65548                     var otherKind = accessor.kind === 168 ? 167 : 168;
65549                     var otherAccessor = ts.getDeclarationOfKind(getSymbolOfNode(accessor), otherKind);
65550                     var firstAccessor = otherAccessor && (otherAccessor.pos < accessor.pos) ? otherAccessor : accessor;
65551                     var secondAccessor = otherAccessor && (otherAccessor.pos < accessor.pos) ? accessor : otherAccessor;
65552                     var setAccessor = accessor.kind === 168 ? accessor : otherAccessor;
65553                     var getAccessor = accessor.kind === 167 ? accessor : otherAccessor;
65554                     return {
65555                         firstAccessor: firstAccessor,
65556                         secondAccessor: secondAccessor,
65557                         setAccessor: setAccessor,
65558                         getAccessor: getAccessor
65559                     };
65560                 },
65561                 getSymbolOfExternalModuleSpecifier: function (moduleName) { return resolveExternalModuleNameWorker(moduleName, moduleName, undefined); },
65562                 isBindingCapturedByNode: function (node, decl) {
65563                     var parseNode = ts.getParseTreeNode(node);
65564                     var parseDecl = ts.getParseTreeNode(decl);
65565                     return !!parseNode && !!parseDecl && (ts.isVariableDeclaration(parseDecl) || ts.isBindingElement(parseDecl)) && isBindingCapturedByNode(parseNode, parseDecl);
65566                 },
65567                 getDeclarationStatementsForSourceFile: function (node, flags, tracker, bundled) {
65568                     var n = ts.getParseTreeNode(node);
65569                     ts.Debug.assert(n && n.kind === 297, "Non-sourcefile node passed into getDeclarationsForSourceFile");
65570                     var sym = getSymbolOfNode(node);
65571                     if (!sym) {
65572                         return !node.locals ? [] : nodeBuilder.symbolTableToDeclarationStatements(node.locals, node, flags, tracker, bundled);
65573                     }
65574                     return !sym.exports ? [] : nodeBuilder.symbolTableToDeclarationStatements(sym.exports, node, flags, tracker, bundled);
65575                 },
65576                 isImportRequiredByAugmentation: isImportRequiredByAugmentation,
65577             };
65578             function isImportRequiredByAugmentation(node) {
65579                 var file = ts.getSourceFileOfNode(node);
65580                 if (!file.symbol)
65581                     return false;
65582                 var importTarget = getExternalModuleFileFromDeclaration(node);
65583                 if (!importTarget)
65584                     return false;
65585                 if (importTarget === file)
65586                     return false;
65587                 var exports = getExportsOfModule(file.symbol);
65588                 for (var _i = 0, _a = ts.arrayFrom(exports.values()); _i < _a.length; _i++) {
65589                     var s = _a[_i];
65590                     if (s.mergeId) {
65591                         var merged = getMergedSymbol(s);
65592                         for (var _b = 0, _c = merged.declarations; _b < _c.length; _b++) {
65593                             var d = _c[_b];
65594                             var declFile = ts.getSourceFileOfNode(d);
65595                             if (declFile === importTarget) {
65596                                 return true;
65597                             }
65598                         }
65599                     }
65600                 }
65601                 return false;
65602             }
65603             function isInHeritageClause(node) {
65604                 return node.parent && node.parent.kind === 223 && node.parent.parent && node.parent.parent.kind === 286;
65605             }
65606             function getTypeReferenceDirectivesForEntityName(node) {
65607                 if (!fileToDirective) {
65608                     return undefined;
65609                 }
65610                 var meaning = 788968 | 1920;
65611                 if ((node.kind === 78 && isInTypeQuery(node)) || (node.kind === 201 && !isInHeritageClause(node))) {
65612                     meaning = 111551 | 1048576;
65613                 }
65614                 var symbol = resolveEntityName(node, meaning, true);
65615                 return symbol && symbol !== unknownSymbol ? getTypeReferenceDirectivesForSymbol(symbol, meaning) : undefined;
65616             }
65617             function getTypeReferenceDirectivesForSymbol(symbol, meaning) {
65618                 if (!fileToDirective) {
65619                     return undefined;
65620                 }
65621                 if (!isSymbolFromTypeDeclarationFile(symbol)) {
65622                     return undefined;
65623                 }
65624                 var typeReferenceDirectives;
65625                 for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) {
65626                     var decl = _a[_i];
65627                     if (decl.symbol && decl.symbol.flags & meaning) {
65628                         var file = ts.getSourceFileOfNode(decl);
65629                         var typeReferenceDirective = fileToDirective.get(file.path);
65630                         if (typeReferenceDirective) {
65631                             (typeReferenceDirectives || (typeReferenceDirectives = [])).push(typeReferenceDirective);
65632                         }
65633                         else {
65634                             return undefined;
65635                         }
65636                     }
65637                 }
65638                 return typeReferenceDirectives;
65639             }
65640             function isSymbolFromTypeDeclarationFile(symbol) {
65641                 if (!symbol.declarations) {
65642                     return false;
65643                 }
65644                 var current = symbol;
65645                 while (true) {
65646                     var parent = getParentOfSymbol(current);
65647                     if (parent) {
65648                         current = parent;
65649                     }
65650                     else {
65651                         break;
65652                     }
65653                 }
65654                 if (current.valueDeclaration && current.valueDeclaration.kind === 297 && current.flags & 512) {
65655                     return false;
65656                 }
65657                 for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) {
65658                     var decl = _a[_i];
65659                     var file = ts.getSourceFileOfNode(decl);
65660                     if (fileToDirective.has(file.path)) {
65661                         return true;
65662                     }
65663                 }
65664                 return false;
65665             }
65666             function addReferencedFilesToTypeDirective(file, key) {
65667                 if (fileToDirective.has(file.path))
65668                     return;
65669                 fileToDirective.set(file.path, key);
65670                 for (var _i = 0, _a = file.referencedFiles; _i < _a.length; _i++) {
65671                     var fileName = _a[_i].fileName;
65672                     var resolvedFile = ts.resolveTripleslashReference(fileName, file.fileName);
65673                     var referencedFile = host.getSourceFile(resolvedFile);
65674                     if (referencedFile) {
65675                         addReferencedFilesToTypeDirective(referencedFile, key);
65676                     }
65677                 }
65678             }
65679         }
65680         function getExternalModuleFileFromDeclaration(declaration) {
65681             var specifier = declaration.kind === 256 ? ts.tryCast(declaration.name, ts.isStringLiteral) : ts.getExternalModuleName(declaration);
65682             var moduleSymbol = resolveExternalModuleNameWorker(specifier, specifier, undefined);
65683             if (!moduleSymbol) {
65684                 return undefined;
65685             }
65686             return ts.getDeclarationOfKind(moduleSymbol, 297);
65687         }
65688         function initializeTypeChecker() {
65689             for (var _i = 0, _a = host.getSourceFiles(); _i < _a.length; _i++) {
65690                 var file = _a[_i];
65691                 ts.bindSourceFile(file, compilerOptions);
65692             }
65693             amalgamatedDuplicates = new ts.Map();
65694             var augmentations;
65695             for (var _b = 0, _c = host.getSourceFiles(); _b < _c.length; _b++) {
65696                 var file = _c[_b];
65697                 if (file.redirectInfo) {
65698                     continue;
65699                 }
65700                 if (!ts.isExternalOrCommonJsModule(file)) {
65701                     var fileGlobalThisSymbol = file.locals.get("globalThis");
65702                     if (fileGlobalThisSymbol) {
65703                         for (var _d = 0, _e = fileGlobalThisSymbol.declarations; _d < _e.length; _d++) {
65704                             var declaration = _e[_d];
65705                             diagnostics.add(ts.createDiagnosticForNode(declaration, ts.Diagnostics.Declaration_name_conflicts_with_built_in_global_identifier_0, "globalThis"));
65706                         }
65707                     }
65708                     mergeSymbolTable(globals, file.locals);
65709                 }
65710                 if (file.jsGlobalAugmentations) {
65711                     mergeSymbolTable(globals, file.jsGlobalAugmentations);
65712                 }
65713                 if (file.patternAmbientModules && file.patternAmbientModules.length) {
65714                     patternAmbientModules = ts.concatenate(patternAmbientModules, file.patternAmbientModules);
65715                 }
65716                 if (file.moduleAugmentations.length) {
65717                     (augmentations || (augmentations = [])).push(file.moduleAugmentations);
65718                 }
65719                 if (file.symbol && file.symbol.globalExports) {
65720                     var source = file.symbol.globalExports;
65721                     source.forEach(function (sourceSymbol, id) {
65722                         if (!globals.has(id)) {
65723                             globals.set(id, sourceSymbol);
65724                         }
65725                     });
65726                 }
65727             }
65728             if (augmentations) {
65729                 for (var _f = 0, augmentations_1 = augmentations; _f < augmentations_1.length; _f++) {
65730                     var list = augmentations_1[_f];
65731                     for (var _g = 0, list_1 = list; _g < list_1.length; _g++) {
65732                         var augmentation = list_1[_g];
65733                         if (!ts.isGlobalScopeAugmentation(augmentation.parent))
65734                             continue;
65735                         mergeModuleAugmentation(augmentation);
65736                     }
65737                 }
65738             }
65739             addToSymbolTable(globals, builtinGlobals, ts.Diagnostics.Declaration_name_conflicts_with_built_in_global_identifier_0);
65740             getSymbolLinks(undefinedSymbol).type = undefinedWideningType;
65741             getSymbolLinks(argumentsSymbol).type = getGlobalType("IArguments", 0, true);
65742             getSymbolLinks(unknownSymbol).type = errorType;
65743             getSymbolLinks(globalThisSymbol).type = createObjectType(16, globalThisSymbol);
65744             globalArrayType = getGlobalType("Array", 1, true);
65745             globalObjectType = getGlobalType("Object", 0, true);
65746             globalFunctionType = getGlobalType("Function", 0, true);
65747             globalCallableFunctionType = strictBindCallApply && getGlobalType("CallableFunction", 0, true) || globalFunctionType;
65748             globalNewableFunctionType = strictBindCallApply && getGlobalType("NewableFunction", 0, true) || globalFunctionType;
65749             globalStringType = getGlobalType("String", 0, true);
65750             globalNumberType = getGlobalType("Number", 0, true);
65751             globalBooleanType = getGlobalType("Boolean", 0, true);
65752             globalRegExpType = getGlobalType("RegExp", 0, true);
65753             anyArrayType = createArrayType(anyType);
65754             autoArrayType = createArrayType(autoType);
65755             if (autoArrayType === emptyObjectType) {
65756                 autoArrayType = createAnonymousType(undefined, emptySymbols, ts.emptyArray, ts.emptyArray, undefined, undefined);
65757             }
65758             globalReadonlyArrayType = getGlobalTypeOrUndefined("ReadonlyArray", 1) || globalArrayType;
65759             anyReadonlyArrayType = globalReadonlyArrayType ? createTypeFromGenericGlobalType(globalReadonlyArrayType, [anyType]) : anyArrayType;
65760             globalThisType = getGlobalTypeOrUndefined("ThisType", 1);
65761             if (augmentations) {
65762                 for (var _h = 0, augmentations_2 = augmentations; _h < augmentations_2.length; _h++) {
65763                     var list = augmentations_2[_h];
65764                     for (var _j = 0, list_2 = list; _j < list_2.length; _j++) {
65765                         var augmentation = list_2[_j];
65766                         if (ts.isGlobalScopeAugmentation(augmentation.parent))
65767                             continue;
65768                         mergeModuleAugmentation(augmentation);
65769                     }
65770                 }
65771             }
65772             amalgamatedDuplicates.forEach(function (_a) {
65773                 var firstFile = _a.firstFile, secondFile = _a.secondFile, conflictingSymbols = _a.conflictingSymbols;
65774                 if (conflictingSymbols.size < 8) {
65775                     conflictingSymbols.forEach(function (_a, symbolName) {
65776                         var isBlockScoped = _a.isBlockScoped, firstFileLocations = _a.firstFileLocations, secondFileLocations = _a.secondFileLocations;
65777                         var message = isBlockScoped ? ts.Diagnostics.Cannot_redeclare_block_scoped_variable_0 : ts.Diagnostics.Duplicate_identifier_0;
65778                         for (var _i = 0, firstFileLocations_1 = firstFileLocations; _i < firstFileLocations_1.length; _i++) {
65779                             var node = firstFileLocations_1[_i];
65780                             addDuplicateDeclarationError(node, message, symbolName, secondFileLocations);
65781                         }
65782                         for (var _b = 0, secondFileLocations_1 = secondFileLocations; _b < secondFileLocations_1.length; _b++) {
65783                             var node = secondFileLocations_1[_b];
65784                             addDuplicateDeclarationError(node, message, symbolName, firstFileLocations);
65785                         }
65786                     });
65787                 }
65788                 else {
65789                     var list = ts.arrayFrom(conflictingSymbols.keys()).join(", ");
65790                     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)));
65791                     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)));
65792                 }
65793             });
65794             amalgamatedDuplicates = undefined;
65795         }
65796         function checkExternalEmitHelpers(location, helpers) {
65797             if ((requestedExternalEmitHelpers & helpers) !== helpers && compilerOptions.importHelpers) {
65798                 var sourceFile = ts.getSourceFileOfNode(location);
65799                 if (ts.isEffectiveExternalModule(sourceFile, compilerOptions) && !(location.flags & 8388608)) {
65800                     var helpersModule = resolveHelpersModule(sourceFile, location);
65801                     if (helpersModule !== unknownSymbol) {
65802                         var uncheckedHelpers = helpers & ~requestedExternalEmitHelpers;
65803                         for (var helper = 1; helper <= 4194304; helper <<= 1) {
65804                             if (uncheckedHelpers & helper) {
65805                                 var name = getHelperName(helper);
65806                                 var symbol = getSymbol(helpersModule.exports, ts.escapeLeadingUnderscores(name), 111551);
65807                                 if (!symbol) {
65808                                     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);
65809                                 }
65810                             }
65811                         }
65812                     }
65813                     requestedExternalEmitHelpers |= helpers;
65814                 }
65815             }
65816         }
65817         function getHelperName(helper) {
65818             switch (helper) {
65819                 case 1: return "__extends";
65820                 case 2: return "__assign";
65821                 case 4: return "__rest";
65822                 case 8: return "__decorate";
65823                 case 16: return "__metadata";
65824                 case 32: return "__param";
65825                 case 64: return "__awaiter";
65826                 case 128: return "__generator";
65827                 case 256: return "__values";
65828                 case 512: return "__read";
65829                 case 1024: return "__spread";
65830                 case 2048: return "__spreadArrays";
65831                 case 4096: return "__await";
65832                 case 8192: return "__asyncGenerator";
65833                 case 16384: return "__asyncDelegator";
65834                 case 32768: return "__asyncValues";
65835                 case 65536: return "__exportStar";
65836                 case 131072: return "__importStar";
65837                 case 262144: return "__importDefault";
65838                 case 524288: return "__makeTemplateObject";
65839                 case 1048576: return "__classPrivateFieldGet";
65840                 case 2097152: return "__classPrivateFieldSet";
65841                 case 4194304: return "__createBinding";
65842                 default: return ts.Debug.fail("Unrecognized helper");
65843             }
65844         }
65845         function resolveHelpersModule(node, errorNode) {
65846             if (!externalHelpersModule) {
65847                 externalHelpersModule = resolveExternalModule(node, ts.externalHelpersModuleNameText, ts.Diagnostics.This_syntax_requires_an_imported_helper_but_module_0_cannot_be_found, errorNode) || unknownSymbol;
65848             }
65849             return externalHelpersModule;
65850         }
65851         function checkGrammarDecoratorsAndModifiers(node) {
65852             return checkGrammarDecorators(node) || checkGrammarModifiers(node);
65853         }
65854         function checkGrammarDecorators(node) {
65855             if (!node.decorators) {
65856                 return false;
65857             }
65858             if (!ts.nodeCanBeDecorated(node, node.parent, node.parent.parent)) {
65859                 if (node.kind === 165 && !ts.nodeIsPresent(node.body)) {
65860                     return grammarErrorOnFirstToken(node, ts.Diagnostics.A_decorator_can_only_decorate_a_method_implementation_not_an_overload);
65861                 }
65862                 else {
65863                     return grammarErrorOnFirstToken(node, ts.Diagnostics.Decorators_are_not_valid_here);
65864                 }
65865             }
65866             else if (node.kind === 167 || node.kind === 168) {
65867                 var accessors = ts.getAllAccessorDeclarations(node.parent.members, node);
65868                 if (accessors.firstAccessor.decorators && node === accessors.secondAccessor) {
65869                     return grammarErrorOnFirstToken(node, ts.Diagnostics.Decorators_cannot_be_applied_to_multiple_get_Slashset_accessors_of_the_same_name);
65870                 }
65871             }
65872             return false;
65873         }
65874         function checkGrammarModifiers(node) {
65875             var quickResult = reportObviousModifierErrors(node);
65876             if (quickResult !== undefined) {
65877                 return quickResult;
65878             }
65879             var lastStatic, lastDeclare, lastAsync, lastReadonly;
65880             var flags = 0;
65881             for (var _i = 0, _a = node.modifiers; _i < _a.length; _i++) {
65882                 var modifier = _a[_i];
65883                 if (modifier.kind !== 142) {
65884                     if (node.kind === 162 || node.kind === 164) {
65885                         return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_type_member, ts.tokenToString(modifier.kind));
65886                     }
65887                     if (node.kind === 171) {
65888                         return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_an_index_signature, ts.tokenToString(modifier.kind));
65889                     }
65890                 }
65891                 switch (modifier.kind) {
65892                     case 84:
65893                         if (node.kind !== 255) {
65894                             return grammarErrorOnNode(node, ts.Diagnostics.A_class_member_cannot_have_the_0_keyword, ts.tokenToString(84));
65895                         }
65896                         break;
65897                     case 122:
65898                     case 121:
65899                     case 120:
65900                         var text = visibilityToString(ts.modifierToFlag(modifier.kind));
65901                         if (flags & 28) {
65902                             return grammarErrorOnNode(modifier, ts.Diagnostics.Accessibility_modifier_already_seen);
65903                         }
65904                         else if (flags & 32) {
65905                             return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, text, "static");
65906                         }
65907                         else if (flags & 64) {
65908                             return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, text, "readonly");
65909                         }
65910                         else if (flags & 256) {
65911                             return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, text, "async");
65912                         }
65913                         else if (node.parent.kind === 257 || node.parent.kind === 297) {
65914                             return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_module_or_namespace_element, text);
65915                         }
65916                         else if (flags & 128) {
65917                             if (modifier.kind === 120) {
65918                                 return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_be_used_with_1_modifier, text, "abstract");
65919                             }
65920                             else {
65921                                 return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, text, "abstract");
65922                             }
65923                         }
65924                         else if (ts.isPrivateIdentifierPropertyDeclaration(node)) {
65925                             return grammarErrorOnNode(modifier, ts.Diagnostics.An_accessibility_modifier_cannot_be_used_with_a_private_identifier);
65926                         }
65927                         flags |= ts.modifierToFlag(modifier.kind);
65928                         break;
65929                     case 123:
65930                         if (flags & 32) {
65931                             return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "static");
65932                         }
65933                         else if (flags & 64) {
65934                             return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, "static", "readonly");
65935                         }
65936                         else if (flags & 256) {
65937                             return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, "static", "async");
65938                         }
65939                         else if (node.parent.kind === 257 || node.parent.kind === 297) {
65940                             return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_module_or_namespace_element, "static");
65941                         }
65942                         else if (node.kind === 160) {
65943                             return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_parameter, "static");
65944                         }
65945                         else if (flags & 128) {
65946                             return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_be_used_with_1_modifier, "static", "abstract");
65947                         }
65948                         else if (ts.isPrivateIdentifierPropertyDeclaration(node)) {
65949                             return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_be_used_with_a_private_identifier, "static");
65950                         }
65951                         flags |= 32;
65952                         lastStatic = modifier;
65953                         break;
65954                     case 142:
65955                         if (flags & 64) {
65956                             return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "readonly");
65957                         }
65958                         else if (node.kind !== 163 && node.kind !== 162 && node.kind !== 171 && node.kind !== 160) {
65959                             return grammarErrorOnNode(modifier, ts.Diagnostics.readonly_modifier_can_only_appear_on_a_property_declaration_or_index_signature);
65960                         }
65961                         flags |= 64;
65962                         lastReadonly = modifier;
65963                         break;
65964                     case 92:
65965                         if (flags & 1) {
65966                             return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "export");
65967                         }
65968                         else if (flags & 2) {
65969                             return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, "export", "declare");
65970                         }
65971                         else if (flags & 128) {
65972                             return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, "export", "abstract");
65973                         }
65974                         else if (flags & 256) {
65975                             return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, "export", "async");
65976                         }
65977                         else if (ts.isClassLike(node.parent)) {
65978                             return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_class_elements_of_this_kind, "export");
65979                         }
65980                         else if (node.kind === 160) {
65981                             return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_parameter, "export");
65982                         }
65983                         flags |= 1;
65984                         break;
65985                     case 87:
65986                         var container = node.parent.kind === 297 ? node.parent : node.parent.parent;
65987                         if (container.kind === 256 && !ts.isAmbientModule(container)) {
65988                             return grammarErrorOnNode(modifier, ts.Diagnostics.A_default_export_can_only_be_used_in_an_ECMAScript_style_module);
65989                         }
65990                         flags |= 512;
65991                         break;
65992                     case 133:
65993                         if (flags & 2) {
65994                             return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "declare");
65995                         }
65996                         else if (flags & 256) {
65997                             return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_be_used_in_an_ambient_context, "async");
65998                         }
65999                         else if (ts.isClassLike(node.parent) && !ts.isPropertyDeclaration(node)) {
66000                             return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_class_elements_of_this_kind, "declare");
66001                         }
66002                         else if (node.kind === 160) {
66003                             return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_parameter, "declare");
66004                         }
66005                         else if ((node.parent.flags & 8388608) && node.parent.kind === 257) {
66006                             return grammarErrorOnNode(modifier, ts.Diagnostics.A_declare_modifier_cannot_be_used_in_an_already_ambient_context);
66007                         }
66008                         else if (ts.isPrivateIdentifierPropertyDeclaration(node)) {
66009                             return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_be_used_with_a_private_identifier, "declare");
66010                         }
66011                         flags |= 2;
66012                         lastDeclare = modifier;
66013                         break;
66014                     case 125:
66015                         if (flags & 128) {
66016                             return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "abstract");
66017                         }
66018                         if (node.kind !== 252) {
66019                             if (node.kind !== 165 &&
66020                                 node.kind !== 163 &&
66021                                 node.kind !== 167 &&
66022                                 node.kind !== 168) {
66023                                 return grammarErrorOnNode(modifier, ts.Diagnostics.abstract_modifier_can_only_appear_on_a_class_method_or_property_declaration);
66024                             }
66025                             if (!(node.parent.kind === 252 && ts.hasSyntacticModifier(node.parent, 128))) {
66026                                 return grammarErrorOnNode(modifier, ts.Diagnostics.Abstract_methods_can_only_appear_within_an_abstract_class);
66027                             }
66028                             if (flags & 32) {
66029                                 return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_be_used_with_1_modifier, "static", "abstract");
66030                             }
66031                             if (flags & 8) {
66032                                 return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_be_used_with_1_modifier, "private", "abstract");
66033                             }
66034                             if (flags & 256 && lastAsync) {
66035                                 return grammarErrorOnNode(lastAsync, ts.Diagnostics._0_modifier_cannot_be_used_with_1_modifier, "async", "abstract");
66036                             }
66037                         }
66038                         if (ts.isNamedDeclaration(node) && node.name.kind === 79) {
66039                             return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_be_used_with_a_private_identifier, "abstract");
66040                         }
66041                         flags |= 128;
66042                         break;
66043                     case 129:
66044                         if (flags & 256) {
66045                             return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "async");
66046                         }
66047                         else if (flags & 2 || node.parent.flags & 8388608) {
66048                             return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_be_used_in_an_ambient_context, "async");
66049                         }
66050                         else if (node.kind === 160) {
66051                             return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_parameter, "async");
66052                         }
66053                         if (flags & 128) {
66054                             return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_be_used_with_1_modifier, "async", "abstract");
66055                         }
66056                         flags |= 256;
66057                         lastAsync = modifier;
66058                         break;
66059                 }
66060             }
66061             if (node.kind === 166) {
66062                 if (flags & 32) {
66063                     return grammarErrorOnNode(lastStatic, ts.Diagnostics._0_modifier_cannot_appear_on_a_constructor_declaration, "static");
66064                 }
66065                 if (flags & 128) {
66066                     return grammarErrorOnNode(lastStatic, ts.Diagnostics._0_modifier_cannot_appear_on_a_constructor_declaration, "abstract");
66067                 }
66068                 else if (flags & 256) {
66069                     return grammarErrorOnNode(lastAsync, ts.Diagnostics._0_modifier_cannot_appear_on_a_constructor_declaration, "async");
66070                 }
66071                 else if (flags & 64) {
66072                     return grammarErrorOnNode(lastReadonly, ts.Diagnostics._0_modifier_cannot_appear_on_a_constructor_declaration, "readonly");
66073                 }
66074                 return false;
66075             }
66076             else if ((node.kind === 261 || node.kind === 260) && flags & 2) {
66077                 return grammarErrorOnNode(lastDeclare, ts.Diagnostics.A_0_modifier_cannot_be_used_with_an_import_declaration, "declare");
66078             }
66079             else if (node.kind === 160 && (flags & 92) && ts.isBindingPattern(node.name)) {
66080                 return grammarErrorOnNode(node, ts.Diagnostics.A_parameter_property_may_not_be_declared_using_a_binding_pattern);
66081             }
66082             else if (node.kind === 160 && (flags & 92) && node.dotDotDotToken) {
66083                 return grammarErrorOnNode(node, ts.Diagnostics.A_parameter_property_cannot_be_declared_using_a_rest_parameter);
66084             }
66085             if (flags & 256) {
66086                 return checkGrammarAsyncModifier(node, lastAsync);
66087             }
66088             return false;
66089         }
66090         function reportObviousModifierErrors(node) {
66091             return !node.modifiers
66092                 ? false
66093                 : shouldReportBadModifier(node)
66094                     ? grammarErrorOnFirstToken(node, ts.Diagnostics.Modifiers_cannot_appear_here)
66095                     : undefined;
66096         }
66097         function shouldReportBadModifier(node) {
66098             switch (node.kind) {
66099                 case 167:
66100                 case 168:
66101                 case 166:
66102                 case 163:
66103                 case 162:
66104                 case 165:
66105                 case 164:
66106                 case 171:
66107                 case 256:
66108                 case 261:
66109                 case 260:
66110                 case 267:
66111                 case 266:
66112                 case 208:
66113                 case 209:
66114                 case 160:
66115                     return false;
66116                 default:
66117                     if (node.parent.kind === 257 || node.parent.kind === 297) {
66118                         return false;
66119                     }
66120                     switch (node.kind) {
66121                         case 251:
66122                             return nodeHasAnyModifiersExcept(node, 129);
66123                         case 252:
66124                             return nodeHasAnyModifiersExcept(node, 125);
66125                         case 253:
66126                         case 232:
66127                         case 254:
66128                             return true;
66129                         case 255:
66130                             return nodeHasAnyModifiersExcept(node, 84);
66131                         default:
66132                             ts.Debug.fail();
66133                             return false;
66134                     }
66135             }
66136         }
66137         function nodeHasAnyModifiersExcept(node, allowedModifier) {
66138             return node.modifiers.length > 1 || node.modifiers[0].kind !== allowedModifier;
66139         }
66140         function checkGrammarAsyncModifier(node, asyncModifier) {
66141             switch (node.kind) {
66142                 case 165:
66143                 case 251:
66144                 case 208:
66145                 case 209:
66146                     return false;
66147             }
66148             return grammarErrorOnNode(asyncModifier, ts.Diagnostics._0_modifier_cannot_be_used_here, "async");
66149         }
66150         function checkGrammarForDisallowedTrailingComma(list, diag) {
66151             if (diag === void 0) { diag = ts.Diagnostics.Trailing_comma_not_allowed; }
66152             if (list && list.hasTrailingComma) {
66153                 return grammarErrorAtPos(list[0], list.end - ",".length, ",".length, diag);
66154             }
66155             return false;
66156         }
66157         function checkGrammarTypeParameterList(typeParameters, file) {
66158             if (typeParameters && typeParameters.length === 0) {
66159                 var start = typeParameters.pos - "<".length;
66160                 var end = ts.skipTrivia(file.text, typeParameters.end) + ">".length;
66161                 return grammarErrorAtPos(file, start, end - start, ts.Diagnostics.Type_parameter_list_cannot_be_empty);
66162             }
66163             return false;
66164         }
66165         function checkGrammarParameterList(parameters) {
66166             var seenOptionalParameter = false;
66167             var parameterCount = parameters.length;
66168             for (var i = 0; i < parameterCount; i++) {
66169                 var parameter = parameters[i];
66170                 if (parameter.dotDotDotToken) {
66171                     if (i !== (parameterCount - 1)) {
66172                         return grammarErrorOnNode(parameter.dotDotDotToken, ts.Diagnostics.A_rest_parameter_must_be_last_in_a_parameter_list);
66173                     }
66174                     if (!(parameter.flags & 8388608)) {
66175                         checkGrammarForDisallowedTrailingComma(parameters, ts.Diagnostics.A_rest_parameter_or_binding_pattern_may_not_have_a_trailing_comma);
66176                     }
66177                     if (parameter.questionToken) {
66178                         return grammarErrorOnNode(parameter.questionToken, ts.Diagnostics.A_rest_parameter_cannot_be_optional);
66179                     }
66180                     if (parameter.initializer) {
66181                         return grammarErrorOnNode(parameter.name, ts.Diagnostics.A_rest_parameter_cannot_have_an_initializer);
66182                     }
66183                 }
66184                 else if (isOptionalParameter(parameter)) {
66185                     seenOptionalParameter = true;
66186                     if (parameter.questionToken && parameter.initializer) {
66187                         return grammarErrorOnNode(parameter.name, ts.Diagnostics.Parameter_cannot_have_question_mark_and_initializer);
66188                     }
66189                 }
66190                 else if (seenOptionalParameter && !parameter.initializer) {
66191                     return grammarErrorOnNode(parameter.name, ts.Diagnostics.A_required_parameter_cannot_follow_an_optional_parameter);
66192                 }
66193             }
66194         }
66195         function getNonSimpleParameters(parameters) {
66196             return ts.filter(parameters, function (parameter) { return !!parameter.initializer || ts.isBindingPattern(parameter.name) || ts.isRestParameter(parameter); });
66197         }
66198         function checkGrammarForUseStrictSimpleParameterList(node) {
66199             if (languageVersion >= 3) {
66200                 var useStrictDirective_1 = node.body && ts.isBlock(node.body) && ts.findUseStrictPrologue(node.body.statements);
66201                 if (useStrictDirective_1) {
66202                     var nonSimpleParameters = getNonSimpleParameters(node.parameters);
66203                     if (ts.length(nonSimpleParameters)) {
66204                         ts.forEach(nonSimpleParameters, function (parameter) {
66205                             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));
66206                         });
66207                         var diagnostics_2 = 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)); });
66208                         ts.addRelatedInfo.apply(void 0, __spreadArrays([error(useStrictDirective_1, ts.Diagnostics.use_strict_directive_cannot_be_used_with_non_simple_parameter_list)], diagnostics_2));
66209                         return true;
66210                     }
66211                 }
66212             }
66213             return false;
66214         }
66215         function checkGrammarFunctionLikeDeclaration(node) {
66216             var file = ts.getSourceFileOfNode(node);
66217             return checkGrammarDecoratorsAndModifiers(node) ||
66218                 checkGrammarTypeParameterList(node.typeParameters, file) ||
66219                 checkGrammarParameterList(node.parameters) ||
66220                 checkGrammarArrowFunction(node, file) ||
66221                 (ts.isFunctionLikeDeclaration(node) && checkGrammarForUseStrictSimpleParameterList(node));
66222         }
66223         function checkGrammarClassLikeDeclaration(node) {
66224             var file = ts.getSourceFileOfNode(node);
66225             return checkGrammarClassDeclarationHeritageClauses(node) ||
66226                 checkGrammarTypeParameterList(node.typeParameters, file);
66227         }
66228         function checkGrammarArrowFunction(node, file) {
66229             if (!ts.isArrowFunction(node)) {
66230                 return false;
66231             }
66232             var equalsGreaterThanToken = node.equalsGreaterThanToken;
66233             var startLine = ts.getLineAndCharacterOfPosition(file, equalsGreaterThanToken.pos).line;
66234             var endLine = ts.getLineAndCharacterOfPosition(file, equalsGreaterThanToken.end).line;
66235             return startLine !== endLine && grammarErrorOnNode(equalsGreaterThanToken, ts.Diagnostics.Line_terminator_not_permitted_before_arrow);
66236         }
66237         function checkGrammarIndexSignatureParameters(node) {
66238             var parameter = node.parameters[0];
66239             if (node.parameters.length !== 1) {
66240                 if (parameter) {
66241                     return grammarErrorOnNode(parameter.name, ts.Diagnostics.An_index_signature_must_have_exactly_one_parameter);
66242                 }
66243                 else {
66244                     return grammarErrorOnNode(node, ts.Diagnostics.An_index_signature_must_have_exactly_one_parameter);
66245                 }
66246             }
66247             checkGrammarForDisallowedTrailingComma(node.parameters, ts.Diagnostics.An_index_signature_cannot_have_a_trailing_comma);
66248             if (parameter.dotDotDotToken) {
66249                 return grammarErrorOnNode(parameter.dotDotDotToken, ts.Diagnostics.An_index_signature_cannot_have_a_rest_parameter);
66250             }
66251             if (ts.hasEffectiveModifiers(parameter)) {
66252                 return grammarErrorOnNode(parameter.name, ts.Diagnostics.An_index_signature_parameter_cannot_have_an_accessibility_modifier);
66253             }
66254             if (parameter.questionToken) {
66255                 return grammarErrorOnNode(parameter.questionToken, ts.Diagnostics.An_index_signature_parameter_cannot_have_a_question_mark);
66256             }
66257             if (parameter.initializer) {
66258                 return grammarErrorOnNode(parameter.name, ts.Diagnostics.An_index_signature_parameter_cannot_have_an_initializer);
66259             }
66260             if (!parameter.type) {
66261                 return grammarErrorOnNode(parameter.name, ts.Diagnostics.An_index_signature_parameter_must_have_a_type_annotation);
66262             }
66263             if (parameter.type.kind !== 147 && parameter.type.kind !== 144) {
66264                 var type = getTypeFromTypeNode(parameter.type);
66265                 if (type.flags & 4 || type.flags & 8) {
66266                     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));
66267                 }
66268                 if (type.flags & 1048576 && allTypesAssignableToKind(type, 384, true)) {
66269                     return grammarErrorOnNode(parameter.name, ts.Diagnostics.An_index_signature_parameter_type_cannot_be_a_union_type_Consider_using_a_mapped_object_type_instead);
66270                 }
66271                 return grammarErrorOnNode(parameter.name, ts.Diagnostics.An_index_signature_parameter_type_must_be_either_string_or_number);
66272             }
66273             if (!node.type) {
66274                 return grammarErrorOnNode(node, ts.Diagnostics.An_index_signature_must_have_a_type_annotation);
66275             }
66276             return false;
66277         }
66278         function checkGrammarIndexSignature(node) {
66279             return checkGrammarDecoratorsAndModifiers(node) || checkGrammarIndexSignatureParameters(node);
66280         }
66281         function checkGrammarForAtLeastOneTypeArgument(node, typeArguments) {
66282             if (typeArguments && typeArguments.length === 0) {
66283                 var sourceFile = ts.getSourceFileOfNode(node);
66284                 var start = typeArguments.pos - "<".length;
66285                 var end = ts.skipTrivia(sourceFile.text, typeArguments.end) + ">".length;
66286                 return grammarErrorAtPos(sourceFile, start, end - start, ts.Diagnostics.Type_argument_list_cannot_be_empty);
66287             }
66288             return false;
66289         }
66290         function checkGrammarTypeArguments(node, typeArguments) {
66291             return checkGrammarForDisallowedTrailingComma(typeArguments) ||
66292                 checkGrammarForAtLeastOneTypeArgument(node, typeArguments);
66293         }
66294         function checkGrammarTaggedTemplateChain(node) {
66295             if (node.questionDotToken || node.flags & 32) {
66296                 return grammarErrorOnNode(node.template, ts.Diagnostics.Tagged_template_expressions_are_not_permitted_in_an_optional_chain);
66297             }
66298             return false;
66299         }
66300         function checkGrammarForOmittedArgument(args) {
66301             if (args) {
66302                 for (var _i = 0, args_4 = args; _i < args_4.length; _i++) {
66303                     var arg = args_4[_i];
66304                     if (arg.kind === 222) {
66305                         return grammarErrorAtPos(arg, arg.pos, 0, ts.Diagnostics.Argument_expression_expected);
66306                     }
66307                 }
66308             }
66309             return false;
66310         }
66311         function checkGrammarArguments(args) {
66312             return checkGrammarForOmittedArgument(args);
66313         }
66314         function checkGrammarHeritageClause(node) {
66315             var types = node.types;
66316             if (checkGrammarForDisallowedTrailingComma(types)) {
66317                 return true;
66318             }
66319             if (types && types.length === 0) {
66320                 var listType = ts.tokenToString(node.token);
66321                 return grammarErrorAtPos(node, types.pos, 0, ts.Diagnostics._0_list_cannot_be_empty, listType);
66322             }
66323             return ts.some(types, checkGrammarExpressionWithTypeArguments);
66324         }
66325         function checkGrammarExpressionWithTypeArguments(node) {
66326             return checkGrammarTypeArguments(node, node.typeArguments);
66327         }
66328         function checkGrammarClassDeclarationHeritageClauses(node) {
66329             var seenExtendsClause = false;
66330             var seenImplementsClause = false;
66331             if (!checkGrammarDecoratorsAndModifiers(node) && node.heritageClauses) {
66332                 for (var _i = 0, _a = node.heritageClauses; _i < _a.length; _i++) {
66333                     var heritageClause = _a[_i];
66334                     if (heritageClause.token === 93) {
66335                         if (seenExtendsClause) {
66336                             return grammarErrorOnFirstToken(heritageClause, ts.Diagnostics.extends_clause_already_seen);
66337                         }
66338                         if (seenImplementsClause) {
66339                             return grammarErrorOnFirstToken(heritageClause, ts.Diagnostics.extends_clause_must_precede_implements_clause);
66340                         }
66341                         if (heritageClause.types.length > 1) {
66342                             return grammarErrorOnFirstToken(heritageClause.types[1], ts.Diagnostics.Classes_can_only_extend_a_single_class);
66343                         }
66344                         seenExtendsClause = true;
66345                     }
66346                     else {
66347                         ts.Debug.assert(heritageClause.token === 116);
66348                         if (seenImplementsClause) {
66349                             return grammarErrorOnFirstToken(heritageClause, ts.Diagnostics.implements_clause_already_seen);
66350                         }
66351                         seenImplementsClause = true;
66352                     }
66353                     checkGrammarHeritageClause(heritageClause);
66354                 }
66355             }
66356         }
66357         function checkGrammarInterfaceDeclaration(node) {
66358             var seenExtendsClause = false;
66359             if (node.heritageClauses) {
66360                 for (var _i = 0, _a = node.heritageClauses; _i < _a.length; _i++) {
66361                     var heritageClause = _a[_i];
66362                     if (heritageClause.token === 93) {
66363                         if (seenExtendsClause) {
66364                             return grammarErrorOnFirstToken(heritageClause, ts.Diagnostics.extends_clause_already_seen);
66365                         }
66366                         seenExtendsClause = true;
66367                     }
66368                     else {
66369                         ts.Debug.assert(heritageClause.token === 116);
66370                         return grammarErrorOnFirstToken(heritageClause, ts.Diagnostics.Interface_declaration_cannot_have_implements_clause);
66371                     }
66372                     checkGrammarHeritageClause(heritageClause);
66373                 }
66374             }
66375             return false;
66376         }
66377         function checkGrammarComputedPropertyName(node) {
66378             if (node.kind !== 158) {
66379                 return false;
66380             }
66381             var computedPropertyName = node;
66382             if (computedPropertyName.expression.kind === 216 && computedPropertyName.expression.operatorToken.kind === 27) {
66383                 return grammarErrorOnNode(computedPropertyName.expression, ts.Diagnostics.A_comma_expression_is_not_allowed_in_a_computed_property_name);
66384             }
66385             return false;
66386         }
66387         function checkGrammarForGenerator(node) {
66388             if (node.asteriskToken) {
66389                 ts.Debug.assert(node.kind === 251 ||
66390                     node.kind === 208 ||
66391                     node.kind === 165);
66392                 if (node.flags & 8388608) {
66393                     return grammarErrorOnNode(node.asteriskToken, ts.Diagnostics.Generators_are_not_allowed_in_an_ambient_context);
66394                 }
66395                 if (!node.body) {
66396                     return grammarErrorOnNode(node.asteriskToken, ts.Diagnostics.An_overload_signature_cannot_be_declared_as_a_generator);
66397                 }
66398             }
66399         }
66400         function checkGrammarForInvalidQuestionMark(questionToken, message) {
66401             return !!questionToken && grammarErrorOnNode(questionToken, message);
66402         }
66403         function checkGrammarForInvalidExclamationToken(exclamationToken, message) {
66404             return !!exclamationToken && grammarErrorOnNode(exclamationToken, message);
66405         }
66406         function checkGrammarObjectLiteralExpression(node, inDestructuring) {
66407             var seen = new ts.Map();
66408             for (var _i = 0, _a = node.properties; _i < _a.length; _i++) {
66409                 var prop = _a[_i];
66410                 if (prop.kind === 290) {
66411                     if (inDestructuring) {
66412                         var expression = ts.skipParentheses(prop.expression);
66413                         if (ts.isArrayLiteralExpression(expression) || ts.isObjectLiteralExpression(expression)) {
66414                             return grammarErrorOnNode(prop.expression, ts.Diagnostics.A_rest_element_cannot_contain_a_binding_pattern);
66415                         }
66416                     }
66417                     continue;
66418                 }
66419                 var name = prop.name;
66420                 if (name.kind === 158) {
66421                     checkGrammarComputedPropertyName(name);
66422                 }
66423                 if (prop.kind === 289 && !inDestructuring && prop.objectAssignmentInitializer) {
66424                     return grammarErrorOnNode(prop.equalsToken, ts.Diagnostics.Did_you_mean_to_use_a_Colon_An_can_only_follow_a_property_name_when_the_containing_object_literal_is_part_of_a_destructuring_pattern);
66425                 }
66426                 if (name.kind === 79) {
66427                     return grammarErrorOnNode(name, ts.Diagnostics.Private_identifiers_are_not_allowed_outside_class_bodies);
66428                 }
66429                 if (prop.modifiers) {
66430                     for (var _b = 0, _c = prop.modifiers; _b < _c.length; _b++) {
66431                         var mod = _c[_b];
66432                         if (mod.kind !== 129 || prop.kind !== 165) {
66433                             grammarErrorOnNode(mod, ts.Diagnostics._0_modifier_cannot_be_used_here, ts.getTextOfNode(mod));
66434                         }
66435                     }
66436                 }
66437                 var currentKind = void 0;
66438                 switch (prop.kind) {
66439                     case 289:
66440                         checkGrammarForInvalidExclamationToken(prop.exclamationToken, ts.Diagnostics.A_definite_assignment_assertion_is_not_permitted_in_this_context);
66441                     case 288:
66442                         checkGrammarForInvalidQuestionMark(prop.questionToken, ts.Diagnostics.An_object_member_cannot_be_declared_optional);
66443                         if (name.kind === 8) {
66444                             checkGrammarNumericLiteral(name);
66445                         }
66446                         currentKind = 4;
66447                         break;
66448                     case 165:
66449                         currentKind = 8;
66450                         break;
66451                     case 167:
66452                         currentKind = 1;
66453                         break;
66454                     case 168:
66455                         currentKind = 2;
66456                         break;
66457                     default:
66458                         throw ts.Debug.assertNever(prop, "Unexpected syntax kind:" + prop.kind);
66459                 }
66460                 if (!inDestructuring) {
66461                     var effectiveName = ts.getPropertyNameForPropertyNameNode(name);
66462                     if (effectiveName === undefined) {
66463                         continue;
66464                     }
66465                     var existingKind = seen.get(effectiveName);
66466                     if (!existingKind) {
66467                         seen.set(effectiveName, currentKind);
66468                     }
66469                     else {
66470                         if ((currentKind & 12) && (existingKind & 12)) {
66471                             grammarErrorOnNode(name, ts.Diagnostics.Duplicate_identifier_0, ts.getTextOfNode(name));
66472                         }
66473                         else if ((currentKind & 3) && (existingKind & 3)) {
66474                             if (existingKind !== 3 && currentKind !== existingKind) {
66475                                 seen.set(effectiveName, currentKind | existingKind);
66476                             }
66477                             else {
66478                                 return grammarErrorOnNode(name, ts.Diagnostics.An_object_literal_cannot_have_multiple_get_Slashset_accessors_with_the_same_name);
66479                             }
66480                         }
66481                         else {
66482                             return grammarErrorOnNode(name, ts.Diagnostics.An_object_literal_cannot_have_property_and_accessor_with_the_same_name);
66483                         }
66484                     }
66485                 }
66486             }
66487         }
66488         function checkGrammarJsxElement(node) {
66489             checkGrammarTypeArguments(node, node.typeArguments);
66490             var seen = new ts.Map();
66491             for (var _i = 0, _a = node.attributes.properties; _i < _a.length; _i++) {
66492                 var attr = _a[_i];
66493                 if (attr.kind === 282) {
66494                     continue;
66495                 }
66496                 var name = attr.name, initializer = attr.initializer;
66497                 if (!seen.get(name.escapedText)) {
66498                     seen.set(name.escapedText, true);
66499                 }
66500                 else {
66501                     return grammarErrorOnNode(name, ts.Diagnostics.JSX_elements_cannot_have_multiple_attributes_with_the_same_name);
66502                 }
66503                 if (initializer && initializer.kind === 283 && !initializer.expression) {
66504                     return grammarErrorOnNode(initializer, ts.Diagnostics.JSX_attributes_must_only_be_assigned_a_non_empty_expression);
66505                 }
66506             }
66507         }
66508         function checkGrammarJsxExpression(node) {
66509             if (node.expression && ts.isCommaSequence(node.expression)) {
66510                 return grammarErrorOnNode(node.expression, ts.Diagnostics.JSX_expressions_may_not_use_the_comma_operator_Did_you_mean_to_write_an_array);
66511             }
66512         }
66513         function checkGrammarForInOrForOfStatement(forInOrOfStatement) {
66514             if (checkGrammarStatementInAmbientContext(forInOrOfStatement)) {
66515                 return true;
66516             }
66517             if (forInOrOfStatement.kind === 239 && forInOrOfStatement.awaitModifier) {
66518                 if ((forInOrOfStatement.flags & 32768) === 0) {
66519                     var sourceFile = ts.getSourceFileOfNode(forInOrOfStatement);
66520                     if (!hasParseDiagnostics(sourceFile)) {
66521                         var diagnostic = ts.createDiagnosticForNode(forInOrOfStatement.awaitModifier, ts.Diagnostics.A_for_await_of_statement_is_only_allowed_within_an_async_function_or_async_generator);
66522                         var func = ts.getContainingFunction(forInOrOfStatement);
66523                         if (func && func.kind !== 166) {
66524                             ts.Debug.assert((ts.getFunctionFlags(func) & 2) === 0, "Enclosing function should never be an async function.");
66525                             var relatedInfo = ts.createDiagnosticForNode(func, ts.Diagnostics.Did_you_mean_to_mark_this_function_as_async);
66526                             ts.addRelatedInfo(diagnostic, relatedInfo);
66527                         }
66528                         diagnostics.add(diagnostic);
66529                         return true;
66530                     }
66531                     return false;
66532                 }
66533             }
66534             if (forInOrOfStatement.initializer.kind === 250) {
66535                 var variableList = forInOrOfStatement.initializer;
66536                 if (!checkGrammarVariableDeclarationList(variableList)) {
66537                     var declarations = variableList.declarations;
66538                     if (!declarations.length) {
66539                         return false;
66540                     }
66541                     if (declarations.length > 1) {
66542                         var diagnostic = forInOrOfStatement.kind === 238
66543                             ? ts.Diagnostics.Only_a_single_variable_declaration_is_allowed_in_a_for_in_statement
66544                             : ts.Diagnostics.Only_a_single_variable_declaration_is_allowed_in_a_for_of_statement;
66545                         return grammarErrorOnFirstToken(variableList.declarations[1], diagnostic);
66546                     }
66547                     var firstDeclaration = declarations[0];
66548                     if (firstDeclaration.initializer) {
66549                         var diagnostic = forInOrOfStatement.kind === 238
66550                             ? ts.Diagnostics.The_variable_declaration_of_a_for_in_statement_cannot_have_an_initializer
66551                             : ts.Diagnostics.The_variable_declaration_of_a_for_of_statement_cannot_have_an_initializer;
66552                         return grammarErrorOnNode(firstDeclaration.name, diagnostic);
66553                     }
66554                     if (firstDeclaration.type) {
66555                         var diagnostic = forInOrOfStatement.kind === 238
66556                             ? ts.Diagnostics.The_left_hand_side_of_a_for_in_statement_cannot_use_a_type_annotation
66557                             : ts.Diagnostics.The_left_hand_side_of_a_for_of_statement_cannot_use_a_type_annotation;
66558                         return grammarErrorOnNode(firstDeclaration, diagnostic);
66559                     }
66560                 }
66561             }
66562             return false;
66563         }
66564         function checkGrammarAccessor(accessor) {
66565             if (!(accessor.flags & 8388608)) {
66566                 if (languageVersion < 1) {
66567                     return grammarErrorOnNode(accessor.name, ts.Diagnostics.Accessors_are_only_available_when_targeting_ECMAScript_5_and_higher);
66568                 }
66569                 if (accessor.body === undefined && !ts.hasSyntacticModifier(accessor, 128)) {
66570                     return grammarErrorAtPos(accessor, accessor.end - 1, ";".length, ts.Diagnostics._0_expected, "{");
66571                 }
66572             }
66573             if (accessor.body && ts.hasSyntacticModifier(accessor, 128)) {
66574                 return grammarErrorOnNode(accessor, ts.Diagnostics.An_abstract_accessor_cannot_have_an_implementation);
66575             }
66576             if (accessor.typeParameters) {
66577                 return grammarErrorOnNode(accessor.name, ts.Diagnostics.An_accessor_cannot_have_type_parameters);
66578             }
66579             if (!doesAccessorHaveCorrectParameterCount(accessor)) {
66580                 return grammarErrorOnNode(accessor.name, accessor.kind === 167 ?
66581                     ts.Diagnostics.A_get_accessor_cannot_have_parameters :
66582                     ts.Diagnostics.A_set_accessor_must_have_exactly_one_parameter);
66583             }
66584             if (accessor.kind === 168) {
66585                 if (accessor.type) {
66586                     return grammarErrorOnNode(accessor.name, ts.Diagnostics.A_set_accessor_cannot_have_a_return_type_annotation);
66587                 }
66588                 var parameter = ts.Debug.checkDefined(ts.getSetAccessorValueParameter(accessor), "Return value does not match parameter count assertion.");
66589                 if (parameter.dotDotDotToken) {
66590                     return grammarErrorOnNode(parameter.dotDotDotToken, ts.Diagnostics.A_set_accessor_cannot_have_rest_parameter);
66591                 }
66592                 if (parameter.questionToken) {
66593                     return grammarErrorOnNode(parameter.questionToken, ts.Diagnostics.A_set_accessor_cannot_have_an_optional_parameter);
66594                 }
66595                 if (parameter.initializer) {
66596                     return grammarErrorOnNode(accessor.name, ts.Diagnostics.A_set_accessor_parameter_cannot_have_an_initializer);
66597                 }
66598             }
66599             return false;
66600         }
66601         function doesAccessorHaveCorrectParameterCount(accessor) {
66602             return getAccessorThisParameter(accessor) || accessor.parameters.length === (accessor.kind === 167 ? 0 : 1);
66603         }
66604         function getAccessorThisParameter(accessor) {
66605             if (accessor.parameters.length === (accessor.kind === 167 ? 1 : 2)) {
66606                 return ts.getThisParameter(accessor);
66607             }
66608         }
66609         function checkGrammarTypeOperatorNode(node) {
66610             if (node.operator === 151) {
66611                 if (node.type.kind !== 148) {
66612                     return grammarErrorOnNode(node.type, ts.Diagnostics._0_expected, ts.tokenToString(148));
66613                 }
66614                 var parent = ts.walkUpParenthesizedTypes(node.parent);
66615                 if (ts.isInJSFile(parent) && ts.isJSDocTypeExpression(parent)) {
66616                     parent = parent.parent;
66617                     if (ts.isJSDocTypeTag(parent)) {
66618                         parent = parent.parent.parent;
66619                     }
66620                 }
66621                 switch (parent.kind) {
66622                     case 249:
66623                         var decl = parent;
66624                         if (decl.name.kind !== 78) {
66625                             return grammarErrorOnNode(node, ts.Diagnostics.unique_symbol_types_may_not_be_used_on_a_variable_declaration_with_a_binding_name);
66626                         }
66627                         if (!ts.isVariableDeclarationInVariableStatement(decl)) {
66628                             return grammarErrorOnNode(node, ts.Diagnostics.unique_symbol_types_are_only_allowed_on_variables_in_a_variable_statement);
66629                         }
66630                         if (!(decl.parent.flags & 2)) {
66631                             return grammarErrorOnNode(parent.name, ts.Diagnostics.A_variable_whose_type_is_a_unique_symbol_type_must_be_const);
66632                         }
66633                         break;
66634                     case 163:
66635                         if (!ts.hasSyntacticModifier(parent, 32) ||
66636                             !ts.hasEffectiveModifier(parent, 64)) {
66637                             return grammarErrorOnNode(parent.name, ts.Diagnostics.A_property_of_a_class_whose_type_is_a_unique_symbol_type_must_be_both_static_and_readonly);
66638                         }
66639                         break;
66640                     case 162:
66641                         if (!ts.hasSyntacticModifier(parent, 64)) {
66642                             return grammarErrorOnNode(parent.name, ts.Diagnostics.A_property_of_an_interface_or_type_literal_whose_type_is_a_unique_symbol_type_must_be_readonly);
66643                         }
66644                         break;
66645                     default:
66646                         return grammarErrorOnNode(node, ts.Diagnostics.unique_symbol_types_are_not_allowed_here);
66647                 }
66648             }
66649             else if (node.operator === 142) {
66650                 if (node.type.kind !== 178 && node.type.kind !== 179) {
66651                     return grammarErrorOnFirstToken(node, ts.Diagnostics.readonly_type_modifier_is_only_permitted_on_array_and_tuple_literal_types, ts.tokenToString(148));
66652                 }
66653             }
66654         }
66655         function checkGrammarForInvalidDynamicName(node, message) {
66656             if (isNonBindableDynamicName(node)) {
66657                 return grammarErrorOnNode(node, message);
66658             }
66659         }
66660         function checkGrammarMethod(node) {
66661             if (checkGrammarFunctionLikeDeclaration(node)) {
66662                 return true;
66663             }
66664             if (node.kind === 165) {
66665                 if (node.parent.kind === 200) {
66666                     if (node.modifiers && !(node.modifiers.length === 1 && ts.first(node.modifiers).kind === 129)) {
66667                         return grammarErrorOnFirstToken(node, ts.Diagnostics.Modifiers_cannot_appear_here);
66668                     }
66669                     else if (checkGrammarForInvalidQuestionMark(node.questionToken, ts.Diagnostics.An_object_member_cannot_be_declared_optional)) {
66670                         return true;
66671                     }
66672                     else if (checkGrammarForInvalidExclamationToken(node.exclamationToken, ts.Diagnostics.A_definite_assignment_assertion_is_not_permitted_in_this_context)) {
66673                         return true;
66674                     }
66675                     else if (node.body === undefined) {
66676                         return grammarErrorAtPos(node, node.end - 1, ";".length, ts.Diagnostics._0_expected, "{");
66677                     }
66678                 }
66679                 if (checkGrammarForGenerator(node)) {
66680                     return true;
66681                 }
66682             }
66683             if (ts.isClassLike(node.parent)) {
66684                 if (node.flags & 8388608) {
66685                     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);
66686                 }
66687                 else if (node.kind === 165 && !node.body) {
66688                     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);
66689                 }
66690             }
66691             else if (node.parent.kind === 253) {
66692                 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);
66693             }
66694             else if (node.parent.kind === 177) {
66695                 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);
66696             }
66697         }
66698         function checkGrammarBreakOrContinueStatement(node) {
66699             var current = node;
66700             while (current) {
66701                 if (ts.isFunctionLike(current)) {
66702                     return grammarErrorOnNode(node, ts.Diagnostics.Jump_target_cannot_cross_function_boundary);
66703                 }
66704                 switch (current.kind) {
66705                     case 245:
66706                         if (node.label && current.label.escapedText === node.label.escapedText) {
66707                             var isMisplacedContinueLabel = node.kind === 240
66708                                 && !ts.isIterationStatement(current.statement, true);
66709                             if (isMisplacedContinueLabel) {
66710                                 return grammarErrorOnNode(node, ts.Diagnostics.A_continue_statement_can_only_jump_to_a_label_of_an_enclosing_iteration_statement);
66711                             }
66712                             return false;
66713                         }
66714                         break;
66715                     case 244:
66716                         if (node.kind === 241 && !node.label) {
66717                             return false;
66718                         }
66719                         break;
66720                     default:
66721                         if (ts.isIterationStatement(current, false) && !node.label) {
66722                             return false;
66723                         }
66724                         break;
66725                 }
66726                 current = current.parent;
66727             }
66728             if (node.label) {
66729                 var message = node.kind === 241
66730                     ? ts.Diagnostics.A_break_statement_can_only_jump_to_a_label_of_an_enclosing_statement
66731                     : ts.Diagnostics.A_continue_statement_can_only_jump_to_a_label_of_an_enclosing_iteration_statement;
66732                 return grammarErrorOnNode(node, message);
66733             }
66734             else {
66735                 var message = node.kind === 241
66736                     ? ts.Diagnostics.A_break_statement_can_only_be_used_within_an_enclosing_iteration_or_switch_statement
66737                     : ts.Diagnostics.A_continue_statement_can_only_be_used_within_an_enclosing_iteration_statement;
66738                 return grammarErrorOnNode(node, message);
66739             }
66740         }
66741         function checkGrammarBindingElement(node) {
66742             if (node.dotDotDotToken) {
66743                 var elements = node.parent.elements;
66744                 if (node !== ts.last(elements)) {
66745                     return grammarErrorOnNode(node, ts.Diagnostics.A_rest_element_must_be_last_in_a_destructuring_pattern);
66746                 }
66747                 checkGrammarForDisallowedTrailingComma(elements, ts.Diagnostics.A_rest_parameter_or_binding_pattern_may_not_have_a_trailing_comma);
66748                 if (node.propertyName) {
66749                     return grammarErrorOnNode(node.name, ts.Diagnostics.A_rest_element_cannot_have_a_property_name);
66750                 }
66751             }
66752             if (node.dotDotDotToken && node.initializer) {
66753                 return grammarErrorAtPos(node, node.initializer.pos - 1, 1, ts.Diagnostics.A_rest_element_cannot_have_an_initializer);
66754             }
66755         }
66756         function isStringOrNumberLiteralExpression(expr) {
66757             return ts.isStringOrNumericLiteralLike(expr) ||
66758                 expr.kind === 214 && expr.operator === 40 &&
66759                     expr.operand.kind === 8;
66760         }
66761         function isBigIntLiteralExpression(expr) {
66762             return expr.kind === 9 ||
66763                 expr.kind === 214 && expr.operator === 40 &&
66764                     expr.operand.kind === 9;
66765         }
66766         function isSimpleLiteralEnumReference(expr) {
66767             if ((ts.isPropertyAccessExpression(expr) || (ts.isElementAccessExpression(expr) && isStringOrNumberLiteralExpression(expr.argumentExpression))) &&
66768                 ts.isEntityNameExpression(expr.expression)) {
66769                 return !!(checkExpressionCached(expr).flags & 1024);
66770             }
66771         }
66772         function checkAmbientInitializer(node) {
66773             var initializer = node.initializer;
66774             if (initializer) {
66775                 var isInvalidInitializer = !(isStringOrNumberLiteralExpression(initializer) ||
66776                     isSimpleLiteralEnumReference(initializer) ||
66777                     initializer.kind === 109 || initializer.kind === 94 ||
66778                     isBigIntLiteralExpression(initializer));
66779                 var isConstOrReadonly = ts.isDeclarationReadonly(node) || ts.isVariableDeclaration(node) && ts.isVarConst(node);
66780                 if (isConstOrReadonly && !node.type) {
66781                     if (isInvalidInitializer) {
66782                         return grammarErrorOnNode(initializer, ts.Diagnostics.A_const_initializer_in_an_ambient_context_must_be_a_string_or_numeric_literal_or_literal_enum_reference);
66783                     }
66784                 }
66785                 else {
66786                     return grammarErrorOnNode(initializer, ts.Diagnostics.Initializers_are_not_allowed_in_ambient_contexts);
66787                 }
66788                 if (!isConstOrReadonly || isInvalidInitializer) {
66789                     return grammarErrorOnNode(initializer, ts.Diagnostics.Initializers_are_not_allowed_in_ambient_contexts);
66790                 }
66791             }
66792         }
66793         function checkGrammarVariableDeclaration(node) {
66794             if (node.parent.parent.kind !== 238 && node.parent.parent.kind !== 239) {
66795                 if (node.flags & 8388608) {
66796                     checkAmbientInitializer(node);
66797                 }
66798                 else if (!node.initializer) {
66799                     if (ts.isBindingPattern(node.name) && !ts.isBindingPattern(node.parent)) {
66800                         return grammarErrorOnNode(node, ts.Diagnostics.A_destructuring_declaration_must_have_an_initializer);
66801                     }
66802                     if (ts.isVarConst(node)) {
66803                         return grammarErrorOnNode(node, ts.Diagnostics.const_declarations_must_be_initialized);
66804                     }
66805                 }
66806             }
66807             if (node.exclamationToken && (node.parent.parent.kind !== 232 || !node.type || node.initializer || node.flags & 8388608)) {
66808                 var message = node.initializer
66809                     ? ts.Diagnostics.Declarations_with_initializers_cannot_also_have_definite_assignment_assertions
66810                     : ts.Diagnostics.Declarations_with_definite_assignment_assertions_must_also_have_type_annotations;
66811                 return grammarErrorOnNode(node.exclamationToken, message);
66812             }
66813             var moduleKind = ts.getEmitModuleKind(compilerOptions);
66814             if (moduleKind < ts.ModuleKind.ES2015 && moduleKind !== ts.ModuleKind.System &&
66815                 !(node.parent.parent.flags & 8388608) && ts.hasSyntacticModifier(node.parent.parent, 1)) {
66816                 checkESModuleMarker(node.name);
66817             }
66818             var checkLetConstNames = (ts.isLet(node) || ts.isVarConst(node));
66819             return checkLetConstNames && checkGrammarNameInLetOrConstDeclarations(node.name);
66820         }
66821         function checkESModuleMarker(name) {
66822             if (name.kind === 78) {
66823                 if (ts.idText(name) === "__esModule") {
66824                     return grammarErrorOnNodeSkippedOn("noEmit", name, ts.Diagnostics.Identifier_expected_esModule_is_reserved_as_an_exported_marker_when_transforming_ECMAScript_modules);
66825                 }
66826             }
66827             else {
66828                 var elements = name.elements;
66829                 for (var _i = 0, elements_1 = elements; _i < elements_1.length; _i++) {
66830                     var element = elements_1[_i];
66831                     if (!ts.isOmittedExpression(element)) {
66832                         return checkESModuleMarker(element.name);
66833                     }
66834                 }
66835             }
66836             return false;
66837         }
66838         function checkGrammarNameInLetOrConstDeclarations(name) {
66839             if (name.kind === 78) {
66840                 if (name.originalKeywordKind === 118) {
66841                     return grammarErrorOnNode(name, ts.Diagnostics.let_is_not_allowed_to_be_used_as_a_name_in_let_or_const_declarations);
66842                 }
66843             }
66844             else {
66845                 var elements = name.elements;
66846                 for (var _i = 0, elements_2 = elements; _i < elements_2.length; _i++) {
66847                     var element = elements_2[_i];
66848                     if (!ts.isOmittedExpression(element)) {
66849                         checkGrammarNameInLetOrConstDeclarations(element.name);
66850                     }
66851                 }
66852             }
66853             return false;
66854         }
66855         function checkGrammarVariableDeclarationList(declarationList) {
66856             var declarations = declarationList.declarations;
66857             if (checkGrammarForDisallowedTrailingComma(declarationList.declarations)) {
66858                 return true;
66859             }
66860             if (!declarationList.declarations.length) {
66861                 return grammarErrorAtPos(declarationList, declarations.pos, declarations.end - declarations.pos, ts.Diagnostics.Variable_declaration_list_cannot_be_empty);
66862             }
66863             return false;
66864         }
66865         function allowLetAndConstDeclarations(parent) {
66866             switch (parent.kind) {
66867                 case 234:
66868                 case 235:
66869                 case 236:
66870                 case 243:
66871                 case 237:
66872                 case 238:
66873                 case 239:
66874                     return false;
66875                 case 245:
66876                     return allowLetAndConstDeclarations(parent.parent);
66877             }
66878             return true;
66879         }
66880         function checkGrammarForDisallowedLetOrConstStatement(node) {
66881             if (!allowLetAndConstDeclarations(node.parent)) {
66882                 if (ts.isLet(node.declarationList)) {
66883                     return grammarErrorOnNode(node, ts.Diagnostics.let_declarations_can_only_be_declared_inside_a_block);
66884                 }
66885                 else if (ts.isVarConst(node.declarationList)) {
66886                     return grammarErrorOnNode(node, ts.Diagnostics.const_declarations_can_only_be_declared_inside_a_block);
66887                 }
66888             }
66889         }
66890         function checkGrammarMetaProperty(node) {
66891             var escapedText = node.name.escapedText;
66892             switch (node.keywordToken) {
66893                 case 102:
66894                     if (escapedText !== "target") {
66895                         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");
66896                     }
66897                     break;
66898                 case 99:
66899                     if (escapedText !== "meta") {
66900                         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");
66901                     }
66902                     break;
66903             }
66904         }
66905         function hasParseDiagnostics(sourceFile) {
66906             return sourceFile.parseDiagnostics.length > 0;
66907         }
66908         function grammarErrorOnFirstToken(node, message, arg0, arg1, arg2) {
66909             var sourceFile = ts.getSourceFileOfNode(node);
66910             if (!hasParseDiagnostics(sourceFile)) {
66911                 var span = ts.getSpanOfTokenAtPosition(sourceFile, node.pos);
66912                 diagnostics.add(ts.createFileDiagnostic(sourceFile, span.start, span.length, message, arg0, arg1, arg2));
66913                 return true;
66914             }
66915             return false;
66916         }
66917         function grammarErrorAtPos(nodeForSourceFile, start, length, message, arg0, arg1, arg2) {
66918             var sourceFile = ts.getSourceFileOfNode(nodeForSourceFile);
66919             if (!hasParseDiagnostics(sourceFile)) {
66920                 diagnostics.add(ts.createFileDiagnostic(sourceFile, start, length, message, arg0, arg1, arg2));
66921                 return true;
66922             }
66923             return false;
66924         }
66925         function grammarErrorOnNodeSkippedOn(key, node, message, arg0, arg1, arg2) {
66926             var sourceFile = ts.getSourceFileOfNode(node);
66927             if (!hasParseDiagnostics(sourceFile)) {
66928                 errorSkippedOn(key, node, message, arg0, arg1, arg2);
66929                 return true;
66930             }
66931             return false;
66932         }
66933         function grammarErrorOnNode(node, message, arg0, arg1, arg2) {
66934             var sourceFile = ts.getSourceFileOfNode(node);
66935             if (!hasParseDiagnostics(sourceFile)) {
66936                 diagnostics.add(ts.createDiagnosticForNode(node, message, arg0, arg1, arg2));
66937                 return true;
66938             }
66939             return false;
66940         }
66941         function checkGrammarConstructorTypeParameters(node) {
66942             var jsdocTypeParameters = ts.isInJSFile(node) ? ts.getJSDocTypeParameterDeclarations(node) : undefined;
66943             var range = node.typeParameters || jsdocTypeParameters && ts.firstOrUndefined(jsdocTypeParameters);
66944             if (range) {
66945                 var pos = range.pos === range.end ? range.pos : ts.skipTrivia(ts.getSourceFileOfNode(node).text, range.pos);
66946                 return grammarErrorAtPos(node, pos, range.end - pos, ts.Diagnostics.Type_parameters_cannot_appear_on_a_constructor_declaration);
66947             }
66948         }
66949         function checkGrammarConstructorTypeAnnotation(node) {
66950             var type = ts.getEffectiveReturnTypeNode(node);
66951             if (type) {
66952                 return grammarErrorOnNode(type, ts.Diagnostics.Type_annotation_cannot_appear_on_a_constructor_declaration);
66953             }
66954         }
66955         function checkGrammarProperty(node) {
66956             if (ts.isClassLike(node.parent)) {
66957                 if (ts.isStringLiteral(node.name) && node.name.text === "constructor") {
66958                     return grammarErrorOnNode(node.name, ts.Diagnostics.Classes_may_not_have_a_field_named_constructor);
66959                 }
66960                 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)) {
66961                     return true;
66962                 }
66963                 if (languageVersion < 2 && ts.isPrivateIdentifier(node.name)) {
66964                     return grammarErrorOnNode(node.name, ts.Diagnostics.Private_identifiers_are_only_available_when_targeting_ECMAScript_2015_and_higher);
66965                 }
66966             }
66967             else if (node.parent.kind === 253) {
66968                 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)) {
66969                     return true;
66970                 }
66971                 if (node.initializer) {
66972                     return grammarErrorOnNode(node.initializer, ts.Diagnostics.An_interface_property_cannot_have_an_initializer);
66973                 }
66974             }
66975             else if (node.parent.kind === 177) {
66976                 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)) {
66977                     return true;
66978                 }
66979                 if (node.initializer) {
66980                     return grammarErrorOnNode(node.initializer, ts.Diagnostics.A_type_literal_property_cannot_have_an_initializer);
66981                 }
66982             }
66983             if (node.flags & 8388608) {
66984                 checkAmbientInitializer(node);
66985             }
66986             if (ts.isPropertyDeclaration(node) && node.exclamationToken && (!ts.isClassLike(node.parent) || !node.type || node.initializer ||
66987                 node.flags & 8388608 || ts.hasSyntacticModifier(node, 32 | 128))) {
66988                 var message = node.initializer
66989                     ? ts.Diagnostics.Declarations_with_initializers_cannot_also_have_definite_assignment_assertions
66990                     : !node.type
66991                         ? ts.Diagnostics.Declarations_with_definite_assignment_assertions_must_also_have_type_annotations
66992                         : ts.Diagnostics.A_definite_assignment_assertion_is_not_permitted_in_this_context;
66993                 return grammarErrorOnNode(node.exclamationToken, message);
66994             }
66995         }
66996         function checkGrammarTopLevelElementForRequiredDeclareModifier(node) {
66997             if (node.kind === 253 ||
66998                 node.kind === 254 ||
66999                 node.kind === 261 ||
67000                 node.kind === 260 ||
67001                 node.kind === 267 ||
67002                 node.kind === 266 ||
67003                 node.kind === 259 ||
67004                 ts.hasSyntacticModifier(node, 2 | 1 | 512)) {
67005                 return false;
67006             }
67007             return grammarErrorOnFirstToken(node, ts.Diagnostics.Top_level_declarations_in_d_ts_files_must_start_with_either_a_declare_or_export_modifier);
67008         }
67009         function checkGrammarTopLevelElementsForRequiredDeclareModifier(file) {
67010             for (var _i = 0, _a = file.statements; _i < _a.length; _i++) {
67011                 var decl = _a[_i];
67012                 if (ts.isDeclaration(decl) || decl.kind === 232) {
67013                     if (checkGrammarTopLevelElementForRequiredDeclareModifier(decl)) {
67014                         return true;
67015                     }
67016                 }
67017             }
67018             return false;
67019         }
67020         function checkGrammarSourceFile(node) {
67021             return !!(node.flags & 8388608) && checkGrammarTopLevelElementsForRequiredDeclareModifier(node);
67022         }
67023         function checkGrammarStatementInAmbientContext(node) {
67024             if (node.flags & 8388608) {
67025                 var links = getNodeLinks(node);
67026                 if (!links.hasReportedStatementInAmbientContext && (ts.isFunctionLike(node.parent) || ts.isAccessor(node.parent))) {
67027                     return getNodeLinks(node).hasReportedStatementInAmbientContext = grammarErrorOnFirstToken(node, ts.Diagnostics.An_implementation_cannot_be_declared_in_ambient_contexts);
67028                 }
67029                 if (node.parent.kind === 230 || node.parent.kind === 257 || node.parent.kind === 297) {
67030                     var links_2 = getNodeLinks(node.parent);
67031                     if (!links_2.hasReportedStatementInAmbientContext) {
67032                         return links_2.hasReportedStatementInAmbientContext = grammarErrorOnFirstToken(node, ts.Diagnostics.Statements_are_not_allowed_in_ambient_contexts);
67033                     }
67034                 }
67035                 else {
67036                 }
67037             }
67038             return false;
67039         }
67040         function checkGrammarNumericLiteral(node) {
67041             if (node.numericLiteralFlags & 32) {
67042                 var diagnosticMessage = void 0;
67043                 if (languageVersion >= 1) {
67044                     diagnosticMessage = ts.Diagnostics.Octal_literals_are_not_available_when_targeting_ECMAScript_5_and_higher_Use_the_syntax_0;
67045                 }
67046                 else if (ts.isChildOfNodeWithKind(node, 191)) {
67047                     diagnosticMessage = ts.Diagnostics.Octal_literal_types_must_use_ES2015_syntax_Use_the_syntax_0;
67048                 }
67049                 else if (ts.isChildOfNodeWithKind(node, 291)) {
67050                     diagnosticMessage = ts.Diagnostics.Octal_literals_are_not_allowed_in_enums_members_initializer_Use_the_syntax_0;
67051                 }
67052                 if (diagnosticMessage) {
67053                     var withMinus = ts.isPrefixUnaryExpression(node.parent) && node.parent.operator === 40;
67054                     var literal = (withMinus ? "-" : "") + "0o" + node.text;
67055                     return grammarErrorOnNode(withMinus ? node.parent : node, diagnosticMessage, literal);
67056                 }
67057             }
67058             checkNumericLiteralValueSize(node);
67059             return false;
67060         }
67061         function checkNumericLiteralValueSize(node) {
67062             if (node.numericLiteralFlags & 16 || node.text.length <= 15 || node.text.indexOf(".") !== -1) {
67063                 return;
67064             }
67065             var apparentValue = +ts.getTextOfNode(node);
67066             if (apparentValue <= Math.pow(2, 53) - 1 && apparentValue + 1 > apparentValue) {
67067                 return;
67068             }
67069             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));
67070         }
67071         function checkGrammarBigIntLiteral(node) {
67072             var literalType = ts.isLiteralTypeNode(node.parent) ||
67073                 ts.isPrefixUnaryExpression(node.parent) && ts.isLiteralTypeNode(node.parent.parent);
67074             if (!literalType) {
67075                 if (languageVersion < 7) {
67076                     if (grammarErrorOnNode(node, ts.Diagnostics.BigInt_literals_are_not_available_when_targeting_lower_than_ES2020)) {
67077                         return true;
67078                     }
67079                 }
67080             }
67081             return false;
67082         }
67083         function grammarErrorAfterFirstToken(node, message, arg0, arg1, arg2) {
67084             var sourceFile = ts.getSourceFileOfNode(node);
67085             if (!hasParseDiagnostics(sourceFile)) {
67086                 var span = ts.getSpanOfTokenAtPosition(sourceFile, node.pos);
67087                 diagnostics.add(ts.createFileDiagnostic(sourceFile, ts.textSpanEnd(span), 0, message, arg0, arg1, arg2));
67088                 return true;
67089             }
67090             return false;
67091         }
67092         function getAmbientModules() {
67093             if (!ambientModulesCache) {
67094                 ambientModulesCache = [];
67095                 globals.forEach(function (global, sym) {
67096                     if (ambientModuleSymbolRegex.test(sym)) {
67097                         ambientModulesCache.push(global);
67098                     }
67099                 });
67100             }
67101             return ambientModulesCache;
67102         }
67103         function checkGrammarImportClause(node) {
67104             if (node.isTypeOnly && node.name && node.namedBindings) {
67105                 return grammarErrorOnNode(node, ts.Diagnostics.A_type_only_import_can_specify_a_default_import_or_named_bindings_but_not_both);
67106             }
67107             return false;
67108         }
67109         function checkGrammarImportCallExpression(node) {
67110             if (moduleKind === ts.ModuleKind.ES2015) {
67111                 return grammarErrorOnNode(node, ts.Diagnostics.Dynamic_imports_are_only_supported_when_the_module_flag_is_set_to_es2020_esnext_commonjs_amd_system_or_umd);
67112             }
67113             if (node.typeArguments) {
67114                 return grammarErrorOnNode(node, ts.Diagnostics.Dynamic_import_cannot_have_type_arguments);
67115             }
67116             var nodeArguments = node.arguments;
67117             if (nodeArguments.length !== 1) {
67118                 return grammarErrorOnNode(node, ts.Diagnostics.Dynamic_import_must_have_one_specifier_as_an_argument);
67119             }
67120             checkGrammarForDisallowedTrailingComma(nodeArguments);
67121             if (ts.isSpreadElement(nodeArguments[0])) {
67122                 return grammarErrorOnNode(nodeArguments[0], ts.Diagnostics.Specifier_of_dynamic_import_cannot_be_spread_element);
67123             }
67124             return false;
67125         }
67126         function findMatchingTypeReferenceOrTypeAliasReference(source, unionTarget) {
67127             var sourceObjectFlags = ts.getObjectFlags(source);
67128             if (sourceObjectFlags & (4 | 16) && unionTarget.flags & 1048576) {
67129                 return ts.find(unionTarget.types, function (target) {
67130                     if (target.flags & 524288) {
67131                         var overlapObjFlags = sourceObjectFlags & ts.getObjectFlags(target);
67132                         if (overlapObjFlags & 4) {
67133                             return source.target === target.target;
67134                         }
67135                         if (overlapObjFlags & 16) {
67136                             return !!source.aliasSymbol && source.aliasSymbol === target.aliasSymbol;
67137                         }
67138                     }
67139                     return false;
67140                 });
67141             }
67142         }
67143         function findBestTypeForObjectLiteral(source, unionTarget) {
67144             if (ts.getObjectFlags(source) & 128 && forEachType(unionTarget, isArrayLikeType)) {
67145                 return ts.find(unionTarget.types, function (t) { return !isArrayLikeType(t); });
67146             }
67147         }
67148         function findBestTypeForInvokable(source, unionTarget) {
67149             var signatureKind = 0;
67150             var hasSignatures = getSignaturesOfType(source, signatureKind).length > 0 ||
67151                 (signatureKind = 1, getSignaturesOfType(source, signatureKind).length > 0);
67152             if (hasSignatures) {
67153                 return ts.find(unionTarget.types, function (t) { return getSignaturesOfType(t, signatureKind).length > 0; });
67154             }
67155         }
67156         function findMostOverlappyType(source, unionTarget) {
67157             var bestMatch;
67158             var matchingCount = 0;
67159             for (var _i = 0, _a = unionTarget.types; _i < _a.length; _i++) {
67160                 var target = _a[_i];
67161                 var overlap = getIntersectionType([getIndexType(source), getIndexType(target)]);
67162                 if (overlap.flags & 4194304) {
67163                     bestMatch = target;
67164                     matchingCount = Infinity;
67165                 }
67166                 else if (overlap.flags & 1048576) {
67167                     var len = ts.length(ts.filter(overlap.types, isUnitType));
67168                     if (len >= matchingCount) {
67169                         bestMatch = target;
67170                         matchingCount = len;
67171                     }
67172                 }
67173                 else if (isUnitType(overlap) && 1 >= matchingCount) {
67174                     bestMatch = target;
67175                     matchingCount = 1;
67176                 }
67177             }
67178             return bestMatch;
67179         }
67180         function filterPrimitivesIfContainsNonPrimitive(type) {
67181             if (maybeTypeOfKind(type, 67108864)) {
67182                 var result = filterType(type, function (t) { return !(t.flags & 131068); });
67183                 if (!(result.flags & 131072)) {
67184                     return result;
67185                 }
67186             }
67187             return type;
67188         }
67189         function findMatchingDiscriminantType(source, target, isRelatedTo, skipPartial) {
67190             if (target.flags & 1048576 && source.flags & (2097152 | 524288)) {
67191                 var sourceProperties = getPropertiesOfType(source);
67192                 if (sourceProperties) {
67193                     var sourcePropertiesFiltered = findDiscriminantProperties(sourceProperties, target);
67194                     if (sourcePropertiesFiltered) {
67195                         return discriminateTypeByDiscriminableItems(target, ts.map(sourcePropertiesFiltered, function (p) { return [function () { return getTypeOfSymbol(p); }, p.escapedName]; }), isRelatedTo, undefined, skipPartial);
67196                     }
67197                 }
67198             }
67199             return undefined;
67200         }
67201     }
67202     ts.createTypeChecker = createTypeChecker;
67203     function isNotAccessor(declaration) {
67204         return !ts.isAccessor(declaration);
67205     }
67206     function isNotOverload(declaration) {
67207         return (declaration.kind !== 251 && declaration.kind !== 165) ||
67208             !!declaration.body;
67209     }
67210     function isDeclarationNameOrImportPropertyName(name) {
67211         switch (name.parent.kind) {
67212             case 265:
67213             case 270:
67214                 return ts.isIdentifier(name);
67215             default:
67216                 return ts.isDeclarationName(name);
67217         }
67218     }
67219     function isSomeImportDeclaration(decl) {
67220         switch (decl.kind) {
67221             case 262:
67222             case 260:
67223             case 263:
67224             case 265:
67225                 return true;
67226             case 78:
67227                 return decl.parent.kind === 265;
67228             default:
67229                 return false;
67230         }
67231     }
67232     var JsxNames;
67233     (function (JsxNames) {
67234         JsxNames.JSX = "JSX";
67235         JsxNames.IntrinsicElements = "IntrinsicElements";
67236         JsxNames.ElementClass = "ElementClass";
67237         JsxNames.ElementAttributesPropertyNameContainer = "ElementAttributesProperty";
67238         JsxNames.ElementChildrenAttributeNameContainer = "ElementChildrenAttribute";
67239         JsxNames.Element = "Element";
67240         JsxNames.IntrinsicAttributes = "IntrinsicAttributes";
67241         JsxNames.IntrinsicClassAttributes = "IntrinsicClassAttributes";
67242         JsxNames.LibraryManagedAttributes = "LibraryManagedAttributes";
67243     })(JsxNames || (JsxNames = {}));
67244     function getIterationTypesKeyFromIterationTypeKind(typeKind) {
67245         switch (typeKind) {
67246             case 0: return "yieldType";
67247             case 1: return "returnType";
67248             case 2: return "nextType";
67249         }
67250     }
67251     function signatureHasRestParameter(s) {
67252         return !!(s.flags & 1);
67253     }
67254     ts.signatureHasRestParameter = signatureHasRestParameter;
67255     function signatureHasLiteralTypes(s) {
67256         return !!(s.flags & 2);
67257     }
67258     ts.signatureHasLiteralTypes = signatureHasLiteralTypes;
67259 })(ts || (ts = {}));
67260 var ts;
67261 (function (ts) {
67262     var isTypeNodeOrTypeParameterDeclaration = ts.or(ts.isTypeNode, ts.isTypeParameterDeclaration);
67263     function visitNode(node, visitor, test, lift) {
67264         if (node === undefined || visitor === undefined) {
67265             return node;
67266         }
67267         var visited = visitor(node);
67268         if (visited === node) {
67269             return node;
67270         }
67271         var visitedNode;
67272         if (visited === undefined) {
67273             return undefined;
67274         }
67275         else if (ts.isArray(visited)) {
67276             visitedNode = (lift || extractSingleNode)(visited);
67277         }
67278         else {
67279             visitedNode = visited;
67280         }
67281         ts.Debug.assertNode(visitedNode, test);
67282         return visitedNode;
67283     }
67284     ts.visitNode = visitNode;
67285     function visitNodes(nodes, visitor, test, start, count) {
67286         if (nodes === undefined || visitor === undefined) {
67287             return nodes;
67288         }
67289         var updated;
67290         var length = nodes.length;
67291         if (start === undefined || start < 0) {
67292             start = 0;
67293         }
67294         if (count === undefined || count > length - start) {
67295             count = length - start;
67296         }
67297         var hasTrailingComma;
67298         var pos = -1;
67299         var end = -1;
67300         if (start > 0 || count < length) {
67301             updated = [];
67302             hasTrailingComma = nodes.hasTrailingComma && start + count === length;
67303         }
67304         for (var i = 0; i < count; i++) {
67305             var node = nodes[i + start];
67306             var visited = node !== undefined ? visitor(node) : undefined;
67307             if (updated !== undefined || visited === undefined || visited !== node) {
67308                 if (updated === undefined) {
67309                     updated = nodes.slice(0, i);
67310                     hasTrailingComma = nodes.hasTrailingComma;
67311                     pos = nodes.pos;
67312                     end = nodes.end;
67313                 }
67314                 if (visited) {
67315                     if (ts.isArray(visited)) {
67316                         for (var _i = 0, visited_1 = visited; _i < visited_1.length; _i++) {
67317                             var visitedNode = visited_1[_i];
67318                             void ts.Debug.assertNode(visitedNode, test);
67319                             updated.push(visitedNode);
67320                         }
67321                     }
67322                     else {
67323                         void ts.Debug.assertNode(visited, test);
67324                         updated.push(visited);
67325                     }
67326                 }
67327             }
67328         }
67329         if (updated) {
67330             var updatedArray = ts.factory.createNodeArray(updated, hasTrailingComma);
67331             ts.setTextRangePosEnd(updatedArray, pos, end);
67332             return updatedArray;
67333         }
67334         return nodes;
67335     }
67336     ts.visitNodes = visitNodes;
67337     function visitLexicalEnvironment(statements, visitor, context, start, ensureUseStrict, nodesVisitor) {
67338         if (nodesVisitor === void 0) { nodesVisitor = visitNodes; }
67339         context.startLexicalEnvironment();
67340         statements = nodesVisitor(statements, visitor, ts.isStatement, start);
67341         if (ensureUseStrict)
67342             statements = context.factory.ensureUseStrict(statements);
67343         return ts.factory.mergeLexicalEnvironment(statements, context.endLexicalEnvironment());
67344     }
67345     ts.visitLexicalEnvironment = visitLexicalEnvironment;
67346     function visitParameterList(nodes, visitor, context, nodesVisitor) {
67347         if (nodesVisitor === void 0) { nodesVisitor = visitNodes; }
67348         var updated;
67349         context.startLexicalEnvironment();
67350         if (nodes) {
67351             context.setLexicalEnvironmentFlags(1, true);
67352             updated = nodesVisitor(nodes, visitor, ts.isParameterDeclaration);
67353             if (context.getLexicalEnvironmentFlags() & 2 &&
67354                 ts.getEmitScriptTarget(context.getCompilerOptions()) >= 2) {
67355                 updated = addDefaultValueAssignmentsIfNeeded(updated, context);
67356             }
67357             context.setLexicalEnvironmentFlags(1, false);
67358         }
67359         context.suspendLexicalEnvironment();
67360         return updated;
67361     }
67362     ts.visitParameterList = visitParameterList;
67363     function addDefaultValueAssignmentsIfNeeded(parameters, context) {
67364         var result;
67365         for (var i = 0; i < parameters.length; i++) {
67366             var parameter = parameters[i];
67367             var updated = addDefaultValueAssignmentIfNeeded(parameter, context);
67368             if (result || updated !== parameter) {
67369                 if (!result)
67370                     result = parameters.slice(0, i);
67371                 result[i] = updated;
67372             }
67373         }
67374         if (result) {
67375             return ts.setTextRange(context.factory.createNodeArray(result, parameters.hasTrailingComma), parameters);
67376         }
67377         return parameters;
67378     }
67379     function addDefaultValueAssignmentIfNeeded(parameter, context) {
67380         return parameter.dotDotDotToken ? parameter :
67381             ts.isBindingPattern(parameter.name) ? addDefaultValueAssignmentForBindingPattern(parameter, context) :
67382                 parameter.initializer ? addDefaultValueAssignmentForInitializer(parameter, parameter.name, parameter.initializer, context) :
67383                     parameter;
67384     }
67385     function addDefaultValueAssignmentForBindingPattern(parameter, context) {
67386         var factory = context.factory;
67387         context.addInitializationStatement(factory.createVariableStatement(undefined, factory.createVariableDeclarationList([
67388             factory.createVariableDeclaration(parameter.name, undefined, parameter.type, parameter.initializer ?
67389                 factory.createConditionalExpression(factory.createStrictEquality(factory.getGeneratedNameForNode(parameter), factory.createVoidZero()), undefined, parameter.initializer, undefined, factory.getGeneratedNameForNode(parameter)) :
67390                 factory.getGeneratedNameForNode(parameter)),
67391         ])));
67392         return factory.updateParameterDeclaration(parameter, parameter.decorators, parameter.modifiers, parameter.dotDotDotToken, factory.getGeneratedNameForNode(parameter), parameter.questionToken, parameter.type, undefined);
67393     }
67394     function addDefaultValueAssignmentForInitializer(parameter, name, initializer, context) {
67395         var factory = context.factory;
67396         context.addInitializationStatement(factory.createIfStatement(factory.createTypeCheck(factory.cloneNode(name), "undefined"), ts.setEmitFlags(ts.setTextRange(factory.createBlock([
67397             factory.createExpressionStatement(ts.setEmitFlags(ts.setTextRange(factory.createAssignment(ts.setEmitFlags(factory.cloneNode(name), 48), ts.setEmitFlags(initializer, 48 | ts.getEmitFlags(initializer) | 1536)), parameter), 1536))
67398         ]), parameter), 1 | 32 | 384 | 1536)));
67399         return factory.updateParameterDeclaration(parameter, parameter.decorators, parameter.modifiers, parameter.dotDotDotToken, parameter.name, parameter.questionToken, parameter.type, undefined);
67400     }
67401     function visitFunctionBody(node, visitor, context, nodeVisitor) {
67402         if (nodeVisitor === void 0) { nodeVisitor = visitNode; }
67403         context.resumeLexicalEnvironment();
67404         var updated = nodeVisitor(node, visitor, ts.isConciseBody);
67405         var declarations = context.endLexicalEnvironment();
67406         if (ts.some(declarations)) {
67407             if (!updated) {
67408                 return context.factory.createBlock(declarations);
67409             }
67410             var block = context.factory.converters.convertToFunctionBlock(updated);
67411             var statements = ts.factory.mergeLexicalEnvironment(block.statements, declarations);
67412             return context.factory.updateBlock(block, statements);
67413         }
67414         return updated;
67415     }
67416     ts.visitFunctionBody = visitFunctionBody;
67417     function visitEachChild(node, visitor, context, nodesVisitor, tokenVisitor, nodeVisitor) {
67418         if (nodesVisitor === void 0) { nodesVisitor = visitNodes; }
67419         if (nodeVisitor === void 0) { nodeVisitor = visitNode; }
67420         if (node === undefined) {
67421             return undefined;
67422         }
67423         var kind = node.kind;
67424         if ((kind > 0 && kind <= 156) || kind === 187) {
67425             return node;
67426         }
67427         var factory = context.factory;
67428         switch (kind) {
67429             case 78:
67430                 return factory.updateIdentifier(node, nodesVisitor(node.typeArguments, visitor, isTypeNodeOrTypeParameterDeclaration));
67431             case 157:
67432                 return factory.updateQualifiedName(node, nodeVisitor(node.left, visitor, ts.isEntityName), nodeVisitor(node.right, visitor, ts.isIdentifier));
67433             case 158:
67434                 return factory.updateComputedPropertyName(node, nodeVisitor(node.expression, visitor, ts.isExpression));
67435             case 159:
67436                 return factory.updateTypeParameterDeclaration(node, nodeVisitor(node.name, visitor, ts.isIdentifier), nodeVisitor(node.constraint, visitor, ts.isTypeNode), nodeVisitor(node.default, visitor, ts.isTypeNode));
67437             case 160:
67438                 return factory.updateParameterDeclaration(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), nodeVisitor(node.dotDotDotToken, tokenVisitor, ts.isToken), nodeVisitor(node.name, visitor, ts.isBindingName), nodeVisitor(node.questionToken, tokenVisitor, ts.isToken), nodeVisitor(node.type, visitor, ts.isTypeNode), nodeVisitor(node.initializer, visitor, ts.isExpression));
67439             case 161:
67440                 return factory.updateDecorator(node, nodeVisitor(node.expression, visitor, ts.isExpression));
67441             case 162:
67442                 return factory.updatePropertySignature(node, nodesVisitor(node.modifiers, visitor, ts.isToken), nodeVisitor(node.name, visitor, ts.isPropertyName), nodeVisitor(node.questionToken, tokenVisitor, ts.isToken), nodeVisitor(node.type, visitor, ts.isTypeNode));
67443             case 163:
67444                 return factory.updatePropertyDeclaration(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), nodeVisitor(node.name, visitor, ts.isPropertyName), nodeVisitor(node.questionToken || node.exclamationToken, tokenVisitor, ts.isToken), nodeVisitor(node.type, visitor, ts.isTypeNode), nodeVisitor(node.initializer, visitor, ts.isExpression));
67445             case 164:
67446                 return factory.updateMethodSignature(node, nodesVisitor(node.modifiers, visitor, ts.isModifier), nodeVisitor(node.name, visitor, ts.isPropertyName), nodeVisitor(node.questionToken, tokenVisitor, ts.isToken), nodesVisitor(node.typeParameters, visitor, ts.isTypeParameterDeclaration), nodesVisitor(node.parameters, visitor, ts.isParameterDeclaration), nodeVisitor(node.type, visitor, ts.isTypeNode));
67447             case 165:
67448                 return factory.updateMethodDeclaration(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), nodeVisitor(node.asteriskToken, tokenVisitor, ts.isToken), nodeVisitor(node.name, visitor, ts.isPropertyName), nodeVisitor(node.questionToken, tokenVisitor, ts.isToken), nodesVisitor(node.typeParameters, visitor, ts.isTypeParameterDeclaration), visitParameterList(node.parameters, visitor, context, nodesVisitor), nodeVisitor(node.type, visitor, ts.isTypeNode), visitFunctionBody(node.body, visitor, context, nodeVisitor));
67449             case 166:
67450                 return factory.updateConstructorDeclaration(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), visitParameterList(node.parameters, visitor, context, nodesVisitor), visitFunctionBody(node.body, visitor, context, nodeVisitor));
67451             case 167:
67452                 return factory.updateGetAccessorDeclaration(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), nodeVisitor(node.name, visitor, ts.isPropertyName), visitParameterList(node.parameters, visitor, context, nodesVisitor), nodeVisitor(node.type, visitor, ts.isTypeNode), visitFunctionBody(node.body, visitor, context, nodeVisitor));
67453             case 168:
67454                 return factory.updateSetAccessorDeclaration(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), nodeVisitor(node.name, visitor, ts.isPropertyName), visitParameterList(node.parameters, visitor, context, nodesVisitor), visitFunctionBody(node.body, visitor, context, nodeVisitor));
67455             case 169:
67456                 return factory.updateCallSignature(node, nodesVisitor(node.typeParameters, visitor, ts.isTypeParameterDeclaration), nodesVisitor(node.parameters, visitor, ts.isParameterDeclaration), nodeVisitor(node.type, visitor, ts.isTypeNode));
67457             case 170:
67458                 return factory.updateConstructSignature(node, nodesVisitor(node.typeParameters, visitor, ts.isTypeParameterDeclaration), nodesVisitor(node.parameters, visitor, ts.isParameterDeclaration), nodeVisitor(node.type, visitor, ts.isTypeNode));
67459             case 171:
67460                 return factory.updateIndexSignature(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), nodesVisitor(node.parameters, visitor, ts.isParameterDeclaration), nodeVisitor(node.type, visitor, ts.isTypeNode));
67461             case 172:
67462                 return factory.updateTypePredicateNode(node, nodeVisitor(node.assertsModifier, visitor), nodeVisitor(node.parameterName, visitor), nodeVisitor(node.type, visitor, ts.isTypeNode));
67463             case 173:
67464                 return factory.updateTypeReferenceNode(node, nodeVisitor(node.typeName, visitor, ts.isEntityName), nodesVisitor(node.typeArguments, visitor, ts.isTypeNode));
67465             case 174:
67466                 return factory.updateFunctionTypeNode(node, nodesVisitor(node.typeParameters, visitor, ts.isTypeParameterDeclaration), nodesVisitor(node.parameters, visitor, ts.isParameterDeclaration), nodeVisitor(node.type, visitor, ts.isTypeNode));
67467             case 175:
67468                 return factory.updateConstructorTypeNode(node, nodesVisitor(node.typeParameters, visitor, ts.isTypeParameterDeclaration), nodesVisitor(node.parameters, visitor, ts.isParameterDeclaration), nodeVisitor(node.type, visitor, ts.isTypeNode));
67469             case 176:
67470                 return factory.updateTypeQueryNode(node, nodeVisitor(node.exprName, visitor, ts.isEntityName));
67471             case 177:
67472                 return factory.updateTypeLiteralNode(node, nodesVisitor(node.members, visitor, ts.isTypeElement));
67473             case 178:
67474                 return factory.updateArrayTypeNode(node, nodeVisitor(node.elementType, visitor, ts.isTypeNode));
67475             case 179:
67476                 return factory.updateTupleTypeNode(node, nodesVisitor(node.elements, visitor, ts.isTypeNode));
67477             case 180:
67478                 return factory.updateOptionalTypeNode(node, nodeVisitor(node.type, visitor, ts.isTypeNode));
67479             case 181:
67480                 return factory.updateRestTypeNode(node, nodeVisitor(node.type, visitor, ts.isTypeNode));
67481             case 182:
67482                 return factory.updateUnionTypeNode(node, nodesVisitor(node.types, visitor, ts.isTypeNode));
67483             case 183:
67484                 return factory.updateIntersectionTypeNode(node, nodesVisitor(node.types, visitor, ts.isTypeNode));
67485             case 184:
67486                 return factory.updateConditionalTypeNode(node, nodeVisitor(node.checkType, visitor, ts.isTypeNode), nodeVisitor(node.extendsType, visitor, ts.isTypeNode), nodeVisitor(node.trueType, visitor, ts.isTypeNode), nodeVisitor(node.falseType, visitor, ts.isTypeNode));
67487             case 185:
67488                 return factory.updateInferTypeNode(node, nodeVisitor(node.typeParameter, visitor, ts.isTypeParameterDeclaration));
67489             case 195:
67490                 return factory.updateImportTypeNode(node, nodeVisitor(node.argument, visitor, ts.isTypeNode), nodeVisitor(node.qualifier, visitor, ts.isEntityName), visitNodes(node.typeArguments, visitor, ts.isTypeNode), node.isTypeOf);
67491             case 192:
67492                 return factory.updateNamedTupleMember(node, visitNode(node.dotDotDotToken, visitor, ts.isToken), visitNode(node.name, visitor, ts.isIdentifier), visitNode(node.questionToken, visitor, ts.isToken), visitNode(node.type, visitor, ts.isTypeNode));
67493             case 186:
67494                 return factory.updateParenthesizedType(node, nodeVisitor(node.type, visitor, ts.isTypeNode));
67495             case 188:
67496                 return factory.updateTypeOperatorNode(node, nodeVisitor(node.type, visitor, ts.isTypeNode));
67497             case 189:
67498                 return factory.updateIndexedAccessTypeNode(node, nodeVisitor(node.objectType, visitor, ts.isTypeNode), nodeVisitor(node.indexType, visitor, ts.isTypeNode));
67499             case 190:
67500                 return factory.updateMappedTypeNode(node, nodeVisitor(node.readonlyToken, tokenVisitor, ts.isToken), nodeVisitor(node.typeParameter, visitor, ts.isTypeParameterDeclaration), nodeVisitor(node.nameType, visitor, ts.isTypeNode), nodeVisitor(node.questionToken, tokenVisitor, ts.isToken), nodeVisitor(node.type, visitor, ts.isTypeNode));
67501             case 191:
67502                 return factory.updateLiteralTypeNode(node, nodeVisitor(node.literal, visitor, ts.isExpression));
67503             case 193:
67504                 return factory.updateTemplateLiteralType(node, nodeVisitor(node.head, visitor, ts.isTemplateHead), nodesVisitor(node.templateSpans, visitor, ts.isTemplateLiteralTypeSpan));
67505             case 194:
67506                 return factory.updateTemplateLiteralTypeSpan(node, nodeVisitor(node.type, visitor, ts.isTypeNode), nodeVisitor(node.literal, visitor, ts.isTemplateMiddleOrTemplateTail));
67507             case 196:
67508                 return factory.updateObjectBindingPattern(node, nodesVisitor(node.elements, visitor, ts.isBindingElement));
67509             case 197:
67510                 return factory.updateArrayBindingPattern(node, nodesVisitor(node.elements, visitor, ts.isArrayBindingElement));
67511             case 198:
67512                 return factory.updateBindingElement(node, nodeVisitor(node.dotDotDotToken, tokenVisitor, ts.isToken), nodeVisitor(node.propertyName, visitor, ts.isPropertyName), nodeVisitor(node.name, visitor, ts.isBindingName), nodeVisitor(node.initializer, visitor, ts.isExpression));
67513             case 199:
67514                 return factory.updateArrayLiteralExpression(node, nodesVisitor(node.elements, visitor, ts.isExpression));
67515             case 200:
67516                 return factory.updateObjectLiteralExpression(node, nodesVisitor(node.properties, visitor, ts.isObjectLiteralElementLike));
67517             case 201:
67518                 if (node.flags & 32) {
67519                     return factory.updatePropertyAccessChain(node, nodeVisitor(node.expression, visitor, ts.isExpression), nodeVisitor(node.questionDotToken, tokenVisitor, ts.isToken), nodeVisitor(node.name, visitor, ts.isIdentifier));
67520                 }
67521                 return factory.updatePropertyAccessExpression(node, nodeVisitor(node.expression, visitor, ts.isExpression), nodeVisitor(node.name, visitor, ts.isIdentifierOrPrivateIdentifier));
67522             case 202:
67523                 if (node.flags & 32) {
67524                     return factory.updateElementAccessChain(node, nodeVisitor(node.expression, visitor, ts.isExpression), nodeVisitor(node.questionDotToken, tokenVisitor, ts.isToken), nodeVisitor(node.argumentExpression, visitor, ts.isExpression));
67525                 }
67526                 return factory.updateElementAccessExpression(node, nodeVisitor(node.expression, visitor, ts.isExpression), nodeVisitor(node.argumentExpression, visitor, ts.isExpression));
67527             case 203:
67528                 if (node.flags & 32) {
67529                     return factory.updateCallChain(node, nodeVisitor(node.expression, visitor, ts.isExpression), nodeVisitor(node.questionDotToken, tokenVisitor, ts.isToken), nodesVisitor(node.typeArguments, visitor, ts.isTypeNode), nodesVisitor(node.arguments, visitor, ts.isExpression));
67530                 }
67531                 return factory.updateCallExpression(node, nodeVisitor(node.expression, visitor, ts.isExpression), nodesVisitor(node.typeArguments, visitor, ts.isTypeNode), nodesVisitor(node.arguments, visitor, ts.isExpression));
67532             case 204:
67533                 return factory.updateNewExpression(node, nodeVisitor(node.expression, visitor, ts.isExpression), nodesVisitor(node.typeArguments, visitor, ts.isTypeNode), nodesVisitor(node.arguments, visitor, ts.isExpression));
67534             case 205:
67535                 return factory.updateTaggedTemplateExpression(node, nodeVisitor(node.tag, visitor, ts.isExpression), visitNodes(node.typeArguments, visitor, ts.isExpression), nodeVisitor(node.template, visitor, ts.isTemplateLiteral));
67536             case 206:
67537                 return factory.updateTypeAssertion(node, nodeVisitor(node.type, visitor, ts.isTypeNode), nodeVisitor(node.expression, visitor, ts.isExpression));
67538             case 207:
67539                 return factory.updateParenthesizedExpression(node, nodeVisitor(node.expression, visitor, ts.isExpression));
67540             case 208:
67541                 return factory.updateFunctionExpression(node, nodesVisitor(node.modifiers, visitor, ts.isModifier), nodeVisitor(node.asteriskToken, tokenVisitor, ts.isToken), nodeVisitor(node.name, visitor, ts.isIdentifier), nodesVisitor(node.typeParameters, visitor, ts.isTypeParameterDeclaration), visitParameterList(node.parameters, visitor, context, nodesVisitor), nodeVisitor(node.type, visitor, ts.isTypeNode), visitFunctionBody(node.body, visitor, context, nodeVisitor));
67542             case 209:
67543                 return factory.updateArrowFunction(node, nodesVisitor(node.modifiers, visitor, ts.isModifier), nodesVisitor(node.typeParameters, visitor, ts.isTypeParameterDeclaration), visitParameterList(node.parameters, visitor, context, nodesVisitor), nodeVisitor(node.type, visitor, ts.isTypeNode), nodeVisitor(node.equalsGreaterThanToken, tokenVisitor, ts.isToken), visitFunctionBody(node.body, visitor, context, nodeVisitor));
67544             case 210:
67545                 return factory.updateDeleteExpression(node, nodeVisitor(node.expression, visitor, ts.isExpression));
67546             case 211:
67547                 return factory.updateTypeOfExpression(node, nodeVisitor(node.expression, visitor, ts.isExpression));
67548             case 212:
67549                 return factory.updateVoidExpression(node, nodeVisitor(node.expression, visitor, ts.isExpression));
67550             case 213:
67551                 return factory.updateAwaitExpression(node, nodeVisitor(node.expression, visitor, ts.isExpression));
67552             case 214:
67553                 return factory.updatePrefixUnaryExpression(node, nodeVisitor(node.operand, visitor, ts.isExpression));
67554             case 215:
67555                 return factory.updatePostfixUnaryExpression(node, nodeVisitor(node.operand, visitor, ts.isExpression));
67556             case 216:
67557                 return factory.updateBinaryExpression(node, nodeVisitor(node.left, visitor, ts.isExpression), nodeVisitor(node.operatorToken, tokenVisitor, ts.isToken), nodeVisitor(node.right, visitor, ts.isExpression));
67558             case 217:
67559                 return factory.updateConditionalExpression(node, nodeVisitor(node.condition, visitor, ts.isExpression), nodeVisitor(node.questionToken, tokenVisitor, ts.isToken), nodeVisitor(node.whenTrue, visitor, ts.isExpression), nodeVisitor(node.colonToken, tokenVisitor, ts.isToken), nodeVisitor(node.whenFalse, visitor, ts.isExpression));
67560             case 218:
67561                 return factory.updateTemplateExpression(node, nodeVisitor(node.head, visitor, ts.isTemplateHead), nodesVisitor(node.templateSpans, visitor, ts.isTemplateSpan));
67562             case 219:
67563                 return factory.updateYieldExpression(node, nodeVisitor(node.asteriskToken, tokenVisitor, ts.isToken), nodeVisitor(node.expression, visitor, ts.isExpression));
67564             case 220:
67565                 return factory.updateSpreadElement(node, nodeVisitor(node.expression, visitor, ts.isExpression));
67566             case 221:
67567                 return factory.updateClassExpression(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), nodeVisitor(node.name, visitor, ts.isIdentifier), nodesVisitor(node.typeParameters, visitor, ts.isTypeParameterDeclaration), nodesVisitor(node.heritageClauses, visitor, ts.isHeritageClause), nodesVisitor(node.members, visitor, ts.isClassElement));
67568             case 223:
67569                 return factory.updateExpressionWithTypeArguments(node, nodeVisitor(node.expression, visitor, ts.isExpression), nodesVisitor(node.typeArguments, visitor, ts.isTypeNode));
67570             case 224:
67571                 return factory.updateAsExpression(node, nodeVisitor(node.expression, visitor, ts.isExpression), nodeVisitor(node.type, visitor, ts.isTypeNode));
67572             case 225:
67573                 if (node.flags & 32) {
67574                     return factory.updateNonNullChain(node, nodeVisitor(node.expression, visitor, ts.isExpression));
67575                 }
67576                 return factory.updateNonNullExpression(node, nodeVisitor(node.expression, visitor, ts.isExpression));
67577             case 226:
67578                 return factory.updateMetaProperty(node, nodeVisitor(node.name, visitor, ts.isIdentifier));
67579             case 228:
67580                 return factory.updateTemplateSpan(node, nodeVisitor(node.expression, visitor, ts.isExpression), nodeVisitor(node.literal, visitor, ts.isTemplateMiddleOrTemplateTail));
67581             case 230:
67582                 return factory.updateBlock(node, nodesVisitor(node.statements, visitor, ts.isStatement));
67583             case 232:
67584                 return factory.updateVariableStatement(node, nodesVisitor(node.modifiers, visitor, ts.isModifier), nodeVisitor(node.declarationList, visitor, ts.isVariableDeclarationList));
67585             case 233:
67586                 return factory.updateExpressionStatement(node, nodeVisitor(node.expression, visitor, ts.isExpression));
67587             case 234:
67588                 return factory.updateIfStatement(node, nodeVisitor(node.expression, visitor, ts.isExpression), nodeVisitor(node.thenStatement, visitor, ts.isStatement, factory.liftToBlock), nodeVisitor(node.elseStatement, visitor, ts.isStatement, factory.liftToBlock));
67589             case 235:
67590                 return factory.updateDoStatement(node, nodeVisitor(node.statement, visitor, ts.isStatement, factory.liftToBlock), nodeVisitor(node.expression, visitor, ts.isExpression));
67591             case 236:
67592                 return factory.updateWhileStatement(node, nodeVisitor(node.expression, visitor, ts.isExpression), nodeVisitor(node.statement, visitor, ts.isStatement, factory.liftToBlock));
67593             case 237:
67594                 return factory.updateForStatement(node, nodeVisitor(node.initializer, visitor, ts.isForInitializer), nodeVisitor(node.condition, visitor, ts.isExpression), nodeVisitor(node.incrementor, visitor, ts.isExpression), nodeVisitor(node.statement, visitor, ts.isStatement, factory.liftToBlock));
67595             case 238:
67596                 return factory.updateForInStatement(node, nodeVisitor(node.initializer, visitor, ts.isForInitializer), nodeVisitor(node.expression, visitor, ts.isExpression), nodeVisitor(node.statement, visitor, ts.isStatement, factory.liftToBlock));
67597             case 239:
67598                 return factory.updateForOfStatement(node, nodeVisitor(node.awaitModifier, tokenVisitor, ts.isToken), nodeVisitor(node.initializer, visitor, ts.isForInitializer), nodeVisitor(node.expression, visitor, ts.isExpression), nodeVisitor(node.statement, visitor, ts.isStatement, factory.liftToBlock));
67599             case 240:
67600                 return factory.updateContinueStatement(node, nodeVisitor(node.label, visitor, ts.isIdentifier));
67601             case 241:
67602                 return factory.updateBreakStatement(node, nodeVisitor(node.label, visitor, ts.isIdentifier));
67603             case 242:
67604                 return factory.updateReturnStatement(node, nodeVisitor(node.expression, visitor, ts.isExpression));
67605             case 243:
67606                 return factory.updateWithStatement(node, nodeVisitor(node.expression, visitor, ts.isExpression), nodeVisitor(node.statement, visitor, ts.isStatement, factory.liftToBlock));
67607             case 244:
67608                 return factory.updateSwitchStatement(node, nodeVisitor(node.expression, visitor, ts.isExpression), nodeVisitor(node.caseBlock, visitor, ts.isCaseBlock));
67609             case 245:
67610                 return factory.updateLabeledStatement(node, nodeVisitor(node.label, visitor, ts.isIdentifier), nodeVisitor(node.statement, visitor, ts.isStatement, factory.liftToBlock));
67611             case 246:
67612                 return factory.updateThrowStatement(node, nodeVisitor(node.expression, visitor, ts.isExpression));
67613             case 247:
67614                 return factory.updateTryStatement(node, nodeVisitor(node.tryBlock, visitor, ts.isBlock), nodeVisitor(node.catchClause, visitor, ts.isCatchClause), nodeVisitor(node.finallyBlock, visitor, ts.isBlock));
67615             case 249:
67616                 return factory.updateVariableDeclaration(node, nodeVisitor(node.name, visitor, ts.isBindingName), nodeVisitor(node.exclamationToken, tokenVisitor, ts.isToken), nodeVisitor(node.type, visitor, ts.isTypeNode), nodeVisitor(node.initializer, visitor, ts.isExpression));
67617             case 250:
67618                 return factory.updateVariableDeclarationList(node, nodesVisitor(node.declarations, visitor, ts.isVariableDeclaration));
67619             case 251:
67620                 return factory.updateFunctionDeclaration(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), nodeVisitor(node.asteriskToken, tokenVisitor, ts.isToken), nodeVisitor(node.name, visitor, ts.isIdentifier), nodesVisitor(node.typeParameters, visitor, ts.isTypeParameterDeclaration), visitParameterList(node.parameters, visitor, context, nodesVisitor), nodeVisitor(node.type, visitor, ts.isTypeNode), visitFunctionBody(node.body, visitor, context, nodeVisitor));
67621             case 252:
67622                 return factory.updateClassDeclaration(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), nodeVisitor(node.name, visitor, ts.isIdentifier), nodesVisitor(node.typeParameters, visitor, ts.isTypeParameterDeclaration), nodesVisitor(node.heritageClauses, visitor, ts.isHeritageClause), nodesVisitor(node.members, visitor, ts.isClassElement));
67623             case 253:
67624                 return factory.updateInterfaceDeclaration(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), nodeVisitor(node.name, visitor, ts.isIdentifier), nodesVisitor(node.typeParameters, visitor, ts.isTypeParameterDeclaration), nodesVisitor(node.heritageClauses, visitor, ts.isHeritageClause), nodesVisitor(node.members, visitor, ts.isTypeElement));
67625             case 254:
67626                 return factory.updateTypeAliasDeclaration(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), nodeVisitor(node.name, visitor, ts.isIdentifier), nodesVisitor(node.typeParameters, visitor, ts.isTypeParameterDeclaration), nodeVisitor(node.type, visitor, ts.isTypeNode));
67627             case 255:
67628                 return factory.updateEnumDeclaration(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), nodeVisitor(node.name, visitor, ts.isIdentifier), nodesVisitor(node.members, visitor, ts.isEnumMember));
67629             case 256:
67630                 return factory.updateModuleDeclaration(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), nodeVisitor(node.name, visitor, ts.isIdentifier), nodeVisitor(node.body, visitor, ts.isModuleBody));
67631             case 257:
67632                 return factory.updateModuleBlock(node, nodesVisitor(node.statements, visitor, ts.isStatement));
67633             case 258:
67634                 return factory.updateCaseBlock(node, nodesVisitor(node.clauses, visitor, ts.isCaseOrDefaultClause));
67635             case 259:
67636                 return factory.updateNamespaceExportDeclaration(node, nodeVisitor(node.name, visitor, ts.isIdentifier));
67637             case 260:
67638                 return factory.updateImportEqualsDeclaration(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), nodeVisitor(node.name, visitor, ts.isIdentifier), nodeVisitor(node.moduleReference, visitor, ts.isModuleReference));
67639             case 261:
67640                 return factory.updateImportDeclaration(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), nodeVisitor(node.importClause, visitor, ts.isImportClause), nodeVisitor(node.moduleSpecifier, visitor, ts.isExpression));
67641             case 262:
67642                 return factory.updateImportClause(node, node.isTypeOnly, nodeVisitor(node.name, visitor, ts.isIdentifier), nodeVisitor(node.namedBindings, visitor, ts.isNamedImportBindings));
67643             case 263:
67644                 return factory.updateNamespaceImport(node, nodeVisitor(node.name, visitor, ts.isIdentifier));
67645             case 269:
67646                 return factory.updateNamespaceExport(node, nodeVisitor(node.name, visitor, ts.isIdentifier));
67647             case 264:
67648                 return factory.updateNamedImports(node, nodesVisitor(node.elements, visitor, ts.isImportSpecifier));
67649             case 265:
67650                 return factory.updateImportSpecifier(node, nodeVisitor(node.propertyName, visitor, ts.isIdentifier), nodeVisitor(node.name, visitor, ts.isIdentifier));
67651             case 266:
67652                 return factory.updateExportAssignment(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), nodeVisitor(node.expression, visitor, ts.isExpression));
67653             case 267:
67654                 return factory.updateExportDeclaration(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), node.isTypeOnly, nodeVisitor(node.exportClause, visitor, ts.isNamedExportBindings), nodeVisitor(node.moduleSpecifier, visitor, ts.isExpression));
67655             case 268:
67656                 return factory.updateNamedExports(node, nodesVisitor(node.elements, visitor, ts.isExportSpecifier));
67657             case 270:
67658                 return factory.updateExportSpecifier(node, nodeVisitor(node.propertyName, visitor, ts.isIdentifier), nodeVisitor(node.name, visitor, ts.isIdentifier));
67659             case 272:
67660                 return factory.updateExternalModuleReference(node, nodeVisitor(node.expression, visitor, ts.isExpression));
67661             case 273:
67662                 return factory.updateJsxElement(node, nodeVisitor(node.openingElement, visitor, ts.isJsxOpeningElement), nodesVisitor(node.children, visitor, ts.isJsxChild), nodeVisitor(node.closingElement, visitor, ts.isJsxClosingElement));
67663             case 274:
67664                 return factory.updateJsxSelfClosingElement(node, nodeVisitor(node.tagName, visitor, ts.isJsxTagNameExpression), nodesVisitor(node.typeArguments, visitor, ts.isTypeNode), nodeVisitor(node.attributes, visitor, ts.isJsxAttributes));
67665             case 275:
67666                 return factory.updateJsxOpeningElement(node, nodeVisitor(node.tagName, visitor, ts.isJsxTagNameExpression), nodesVisitor(node.typeArguments, visitor, ts.isTypeNode), nodeVisitor(node.attributes, visitor, ts.isJsxAttributes));
67667             case 276:
67668                 return factory.updateJsxClosingElement(node, nodeVisitor(node.tagName, visitor, ts.isJsxTagNameExpression));
67669             case 277:
67670                 return factory.updateJsxFragment(node, nodeVisitor(node.openingFragment, visitor, ts.isJsxOpeningFragment), nodesVisitor(node.children, visitor, ts.isJsxChild), nodeVisitor(node.closingFragment, visitor, ts.isJsxClosingFragment));
67671             case 280:
67672                 return factory.updateJsxAttribute(node, nodeVisitor(node.name, visitor, ts.isIdentifier), nodeVisitor(node.initializer, visitor, ts.isStringLiteralOrJsxExpression));
67673             case 281:
67674                 return factory.updateJsxAttributes(node, nodesVisitor(node.properties, visitor, ts.isJsxAttributeLike));
67675             case 282:
67676                 return factory.updateJsxSpreadAttribute(node, nodeVisitor(node.expression, visitor, ts.isExpression));
67677             case 283:
67678                 return factory.updateJsxExpression(node, nodeVisitor(node.expression, visitor, ts.isExpression));
67679             case 284:
67680                 return factory.updateCaseClause(node, nodeVisitor(node.expression, visitor, ts.isExpression), nodesVisitor(node.statements, visitor, ts.isStatement));
67681             case 285:
67682                 return factory.updateDefaultClause(node, nodesVisitor(node.statements, visitor, ts.isStatement));
67683             case 286:
67684                 return factory.updateHeritageClause(node, nodesVisitor(node.types, visitor, ts.isExpressionWithTypeArguments));
67685             case 287:
67686                 return factory.updateCatchClause(node, nodeVisitor(node.variableDeclaration, visitor, ts.isVariableDeclaration), nodeVisitor(node.block, visitor, ts.isBlock));
67687             case 288:
67688                 return factory.updatePropertyAssignment(node, nodeVisitor(node.name, visitor, ts.isPropertyName), nodeVisitor(node.initializer, visitor, ts.isExpression));
67689             case 289:
67690                 return factory.updateShorthandPropertyAssignment(node, nodeVisitor(node.name, visitor, ts.isIdentifier), nodeVisitor(node.objectAssignmentInitializer, visitor, ts.isExpression));
67691             case 290:
67692                 return factory.updateSpreadAssignment(node, nodeVisitor(node.expression, visitor, ts.isExpression));
67693             case 291:
67694                 return factory.updateEnumMember(node, nodeVisitor(node.name, visitor, ts.isPropertyName), nodeVisitor(node.initializer, visitor, ts.isExpression));
67695             case 297:
67696                 return factory.updateSourceFile(node, visitLexicalEnvironment(node.statements, visitor, context));
67697             case 336:
67698                 return factory.updatePartiallyEmittedExpression(node, nodeVisitor(node.expression, visitor, ts.isExpression));
67699             case 337:
67700                 return factory.updateCommaListExpression(node, nodesVisitor(node.elements, visitor, ts.isExpression));
67701             default:
67702                 return node;
67703         }
67704     }
67705     ts.visitEachChild = visitEachChild;
67706     function extractSingleNode(nodes) {
67707         ts.Debug.assert(nodes.length <= 1, "Too many nodes written to output.");
67708         return ts.singleOrUndefined(nodes);
67709     }
67710 })(ts || (ts = {}));
67711 var ts;
67712 (function (ts) {
67713     function createSourceMapGenerator(host, file, sourceRoot, sourcesDirectoryPath, generatorOptions) {
67714         var _a = generatorOptions.extendedDiagnostics
67715             ? ts.performance.createTimer("Source Map", "beforeSourcemap", "afterSourcemap")
67716             : ts.performance.nullTimer, enter = _a.enter, exit = _a.exit;
67717         var rawSources = [];
67718         var sources = [];
67719         var sourceToSourceIndexMap = new ts.Map();
67720         var sourcesContent;
67721         var names = [];
67722         var nameToNameIndexMap;
67723         var mappings = "";
67724         var lastGeneratedLine = 0;
67725         var lastGeneratedCharacter = 0;
67726         var lastSourceIndex = 0;
67727         var lastSourceLine = 0;
67728         var lastSourceCharacter = 0;
67729         var lastNameIndex = 0;
67730         var hasLast = false;
67731         var pendingGeneratedLine = 0;
67732         var pendingGeneratedCharacter = 0;
67733         var pendingSourceIndex = 0;
67734         var pendingSourceLine = 0;
67735         var pendingSourceCharacter = 0;
67736         var pendingNameIndex = 0;
67737         var hasPending = false;
67738         var hasPendingSource = false;
67739         var hasPendingName = false;
67740         return {
67741             getSources: function () { return rawSources; },
67742             addSource: addSource,
67743             setSourceContent: setSourceContent,
67744             addName: addName,
67745             addMapping: addMapping,
67746             appendSourceMap: appendSourceMap,
67747             toJSON: toJSON,
67748             toString: function () { return JSON.stringify(toJSON()); }
67749         };
67750         function addSource(fileName) {
67751             enter();
67752             var source = ts.getRelativePathToDirectoryOrUrl(sourcesDirectoryPath, fileName, host.getCurrentDirectory(), host.getCanonicalFileName, true);
67753             var sourceIndex = sourceToSourceIndexMap.get(source);
67754             if (sourceIndex === undefined) {
67755                 sourceIndex = sources.length;
67756                 sources.push(source);
67757                 rawSources.push(fileName);
67758                 sourceToSourceIndexMap.set(source, sourceIndex);
67759             }
67760             exit();
67761             return sourceIndex;
67762         }
67763         function setSourceContent(sourceIndex, content) {
67764             enter();
67765             if (content !== null) {
67766                 if (!sourcesContent)
67767                     sourcesContent = [];
67768                 while (sourcesContent.length < sourceIndex) {
67769                     sourcesContent.push(null);
67770                 }
67771                 sourcesContent[sourceIndex] = content;
67772             }
67773             exit();
67774         }
67775         function addName(name) {
67776             enter();
67777             if (!nameToNameIndexMap)
67778                 nameToNameIndexMap = new ts.Map();
67779             var nameIndex = nameToNameIndexMap.get(name);
67780             if (nameIndex === undefined) {
67781                 nameIndex = names.length;
67782                 names.push(name);
67783                 nameToNameIndexMap.set(name, nameIndex);
67784             }
67785             exit();
67786             return nameIndex;
67787         }
67788         function isNewGeneratedPosition(generatedLine, generatedCharacter) {
67789             return !hasPending
67790                 || pendingGeneratedLine !== generatedLine
67791                 || pendingGeneratedCharacter !== generatedCharacter;
67792         }
67793         function isBacktrackingSourcePosition(sourceIndex, sourceLine, sourceCharacter) {
67794             return sourceIndex !== undefined
67795                 && sourceLine !== undefined
67796                 && sourceCharacter !== undefined
67797                 && pendingSourceIndex === sourceIndex
67798                 && (pendingSourceLine > sourceLine
67799                     || pendingSourceLine === sourceLine && pendingSourceCharacter > sourceCharacter);
67800         }
67801         function addMapping(generatedLine, generatedCharacter, sourceIndex, sourceLine, sourceCharacter, nameIndex) {
67802             ts.Debug.assert(generatedLine >= pendingGeneratedLine, "generatedLine cannot backtrack");
67803             ts.Debug.assert(generatedCharacter >= 0, "generatedCharacter cannot be negative");
67804             ts.Debug.assert(sourceIndex === undefined || sourceIndex >= 0, "sourceIndex cannot be negative");
67805             ts.Debug.assert(sourceLine === undefined || sourceLine >= 0, "sourceLine cannot be negative");
67806             ts.Debug.assert(sourceCharacter === undefined || sourceCharacter >= 0, "sourceCharacter cannot be negative");
67807             enter();
67808             if (isNewGeneratedPosition(generatedLine, generatedCharacter) ||
67809                 isBacktrackingSourcePosition(sourceIndex, sourceLine, sourceCharacter)) {
67810                 commitPendingMapping();
67811                 pendingGeneratedLine = generatedLine;
67812                 pendingGeneratedCharacter = generatedCharacter;
67813                 hasPendingSource = false;
67814                 hasPendingName = false;
67815                 hasPending = true;
67816             }
67817             if (sourceIndex !== undefined && sourceLine !== undefined && sourceCharacter !== undefined) {
67818                 pendingSourceIndex = sourceIndex;
67819                 pendingSourceLine = sourceLine;
67820                 pendingSourceCharacter = sourceCharacter;
67821                 hasPendingSource = true;
67822                 if (nameIndex !== undefined) {
67823                     pendingNameIndex = nameIndex;
67824                     hasPendingName = true;
67825                 }
67826             }
67827             exit();
67828         }
67829         function appendSourceMap(generatedLine, generatedCharacter, map, sourceMapPath, start, end) {
67830             ts.Debug.assert(generatedLine >= pendingGeneratedLine, "generatedLine cannot backtrack");
67831             ts.Debug.assert(generatedCharacter >= 0, "generatedCharacter cannot be negative");
67832             enter();
67833             var sourceIndexToNewSourceIndexMap = [];
67834             var nameIndexToNewNameIndexMap;
67835             var mappingIterator = decodeMappings(map.mappings);
67836             for (var iterResult = mappingIterator.next(); !iterResult.done; iterResult = mappingIterator.next()) {
67837                 var raw = iterResult.value;
67838                 if (end && (raw.generatedLine > end.line ||
67839                     (raw.generatedLine === end.line && raw.generatedCharacter > end.character))) {
67840                     break;
67841                 }
67842                 if (start && (raw.generatedLine < start.line ||
67843                     (start.line === raw.generatedLine && raw.generatedCharacter < start.character))) {
67844                     continue;
67845                 }
67846                 var newSourceIndex = void 0;
67847                 var newSourceLine = void 0;
67848                 var newSourceCharacter = void 0;
67849                 var newNameIndex = void 0;
67850                 if (raw.sourceIndex !== undefined) {
67851                     newSourceIndex = sourceIndexToNewSourceIndexMap[raw.sourceIndex];
67852                     if (newSourceIndex === undefined) {
67853                         var rawPath = map.sources[raw.sourceIndex];
67854                         var relativePath = map.sourceRoot ? ts.combinePaths(map.sourceRoot, rawPath) : rawPath;
67855                         var combinedPath = ts.combinePaths(ts.getDirectoryPath(sourceMapPath), relativePath);
67856                         sourceIndexToNewSourceIndexMap[raw.sourceIndex] = newSourceIndex = addSource(combinedPath);
67857                         if (map.sourcesContent && typeof map.sourcesContent[raw.sourceIndex] === "string") {
67858                             setSourceContent(newSourceIndex, map.sourcesContent[raw.sourceIndex]);
67859                         }
67860                     }
67861                     newSourceLine = raw.sourceLine;
67862                     newSourceCharacter = raw.sourceCharacter;
67863                     if (map.names && raw.nameIndex !== undefined) {
67864                         if (!nameIndexToNewNameIndexMap)
67865                             nameIndexToNewNameIndexMap = [];
67866                         newNameIndex = nameIndexToNewNameIndexMap[raw.nameIndex];
67867                         if (newNameIndex === undefined) {
67868                             nameIndexToNewNameIndexMap[raw.nameIndex] = newNameIndex = addName(map.names[raw.nameIndex]);
67869                         }
67870                     }
67871                 }
67872                 var rawGeneratedLine = raw.generatedLine - (start ? start.line : 0);
67873                 var newGeneratedLine = rawGeneratedLine + generatedLine;
67874                 var rawGeneratedCharacter = start && start.line === raw.generatedLine ? raw.generatedCharacter - start.character : raw.generatedCharacter;
67875                 var newGeneratedCharacter = rawGeneratedLine === 0 ? rawGeneratedCharacter + generatedCharacter : rawGeneratedCharacter;
67876                 addMapping(newGeneratedLine, newGeneratedCharacter, newSourceIndex, newSourceLine, newSourceCharacter, newNameIndex);
67877             }
67878             exit();
67879         }
67880         function shouldCommitMapping() {
67881             return !hasLast
67882                 || lastGeneratedLine !== pendingGeneratedLine
67883                 || lastGeneratedCharacter !== pendingGeneratedCharacter
67884                 || lastSourceIndex !== pendingSourceIndex
67885                 || lastSourceLine !== pendingSourceLine
67886                 || lastSourceCharacter !== pendingSourceCharacter
67887                 || lastNameIndex !== pendingNameIndex;
67888         }
67889         function commitPendingMapping() {
67890             if (!hasPending || !shouldCommitMapping()) {
67891                 return;
67892             }
67893             enter();
67894             if (lastGeneratedLine < pendingGeneratedLine) {
67895                 do {
67896                     mappings += ";";
67897                     lastGeneratedLine++;
67898                     lastGeneratedCharacter = 0;
67899                 } while (lastGeneratedLine < pendingGeneratedLine);
67900             }
67901             else {
67902                 ts.Debug.assertEqual(lastGeneratedLine, pendingGeneratedLine, "generatedLine cannot backtrack");
67903                 if (hasLast) {
67904                     mappings += ",";
67905                 }
67906             }
67907             mappings += base64VLQFormatEncode(pendingGeneratedCharacter - lastGeneratedCharacter);
67908             lastGeneratedCharacter = pendingGeneratedCharacter;
67909             if (hasPendingSource) {
67910                 mappings += base64VLQFormatEncode(pendingSourceIndex - lastSourceIndex);
67911                 lastSourceIndex = pendingSourceIndex;
67912                 mappings += base64VLQFormatEncode(pendingSourceLine - lastSourceLine);
67913                 lastSourceLine = pendingSourceLine;
67914                 mappings += base64VLQFormatEncode(pendingSourceCharacter - lastSourceCharacter);
67915                 lastSourceCharacter = pendingSourceCharacter;
67916                 if (hasPendingName) {
67917                     mappings += base64VLQFormatEncode(pendingNameIndex - lastNameIndex);
67918                     lastNameIndex = pendingNameIndex;
67919                 }
67920             }
67921             hasLast = true;
67922             exit();
67923         }
67924         function toJSON() {
67925             commitPendingMapping();
67926             return {
67927                 version: 3,
67928                 file: file,
67929                 sourceRoot: sourceRoot,
67930                 sources: sources,
67931                 names: names,
67932                 mappings: mappings,
67933                 sourcesContent: sourcesContent,
67934             };
67935         }
67936     }
67937     ts.createSourceMapGenerator = createSourceMapGenerator;
67938     var sourceMapCommentRegExp = /^\/\/[@#] source[M]appingURL=(.+)\s*$/;
67939     var whitespaceOrMapCommentRegExp = /^\s*(\/\/[@#] .*)?$/;
67940     function getLineInfo(text, lineStarts) {
67941         return {
67942             getLineCount: function () { return lineStarts.length; },
67943             getLineText: function (line) { return text.substring(lineStarts[line], lineStarts[line + 1]); }
67944         };
67945     }
67946     ts.getLineInfo = getLineInfo;
67947     function tryGetSourceMappingURL(lineInfo) {
67948         for (var index = lineInfo.getLineCount() - 1; index >= 0; index--) {
67949             var line = lineInfo.getLineText(index);
67950             var comment = sourceMapCommentRegExp.exec(line);
67951             if (comment) {
67952                 return comment[1];
67953             }
67954             else if (!line.match(whitespaceOrMapCommentRegExp)) {
67955                 break;
67956             }
67957         }
67958     }
67959     ts.tryGetSourceMappingURL = tryGetSourceMappingURL;
67960     function isStringOrNull(x) {
67961         return typeof x === "string" || x === null;
67962     }
67963     function isRawSourceMap(x) {
67964         return x !== null
67965             && typeof x === "object"
67966             && x.version === 3
67967             && typeof x.file === "string"
67968             && typeof x.mappings === "string"
67969             && ts.isArray(x.sources) && ts.every(x.sources, ts.isString)
67970             && (x.sourceRoot === undefined || x.sourceRoot === null || typeof x.sourceRoot === "string")
67971             && (x.sourcesContent === undefined || x.sourcesContent === null || ts.isArray(x.sourcesContent) && ts.every(x.sourcesContent, isStringOrNull))
67972             && (x.names === undefined || x.names === null || ts.isArray(x.names) && ts.every(x.names, ts.isString));
67973     }
67974     ts.isRawSourceMap = isRawSourceMap;
67975     function tryParseRawSourceMap(text) {
67976         try {
67977             var parsed = JSON.parse(text);
67978             if (isRawSourceMap(parsed)) {
67979                 return parsed;
67980             }
67981         }
67982         catch (_a) {
67983         }
67984         return undefined;
67985     }
67986     ts.tryParseRawSourceMap = tryParseRawSourceMap;
67987     function decodeMappings(mappings) {
67988         var done = false;
67989         var pos = 0;
67990         var generatedLine = 0;
67991         var generatedCharacter = 0;
67992         var sourceIndex = 0;
67993         var sourceLine = 0;
67994         var sourceCharacter = 0;
67995         var nameIndex = 0;
67996         var error;
67997         return {
67998             get pos() { return pos; },
67999             get error() { return error; },
68000             get state() { return captureMapping(true, true); },
68001             next: function () {
68002                 while (!done && pos < mappings.length) {
68003                     var ch = mappings.charCodeAt(pos);
68004                     if (ch === 59) {
68005                         generatedLine++;
68006                         generatedCharacter = 0;
68007                         pos++;
68008                         continue;
68009                     }
68010                     if (ch === 44) {
68011                         pos++;
68012                         continue;
68013                     }
68014                     var hasSource = false;
68015                     var hasName = false;
68016                     generatedCharacter += base64VLQFormatDecode();
68017                     if (hasReportedError())
68018                         return stopIterating();
68019                     if (generatedCharacter < 0)
68020                         return setErrorAndStopIterating("Invalid generatedCharacter found");
68021                     if (!isSourceMappingSegmentEnd()) {
68022                         hasSource = true;
68023                         sourceIndex += base64VLQFormatDecode();
68024                         if (hasReportedError())
68025                             return stopIterating();
68026                         if (sourceIndex < 0)
68027                             return setErrorAndStopIterating("Invalid sourceIndex found");
68028                         if (isSourceMappingSegmentEnd())
68029                             return setErrorAndStopIterating("Unsupported Format: No entries after sourceIndex");
68030                         sourceLine += base64VLQFormatDecode();
68031                         if (hasReportedError())
68032                             return stopIterating();
68033                         if (sourceLine < 0)
68034                             return setErrorAndStopIterating("Invalid sourceLine found");
68035                         if (isSourceMappingSegmentEnd())
68036                             return setErrorAndStopIterating("Unsupported Format: No entries after sourceLine");
68037                         sourceCharacter += base64VLQFormatDecode();
68038                         if (hasReportedError())
68039                             return stopIterating();
68040                         if (sourceCharacter < 0)
68041                             return setErrorAndStopIterating("Invalid sourceCharacter found");
68042                         if (!isSourceMappingSegmentEnd()) {
68043                             hasName = true;
68044                             nameIndex += base64VLQFormatDecode();
68045                             if (hasReportedError())
68046                                 return stopIterating();
68047                             if (nameIndex < 0)
68048                                 return setErrorAndStopIterating("Invalid nameIndex found");
68049                             if (!isSourceMappingSegmentEnd())
68050                                 return setErrorAndStopIterating("Unsupported Error Format: Entries after nameIndex");
68051                         }
68052                     }
68053                     return { value: captureMapping(hasSource, hasName), done: done };
68054                 }
68055                 return stopIterating();
68056             }
68057         };
68058         function captureMapping(hasSource, hasName) {
68059             return {
68060                 generatedLine: generatedLine,
68061                 generatedCharacter: generatedCharacter,
68062                 sourceIndex: hasSource ? sourceIndex : undefined,
68063                 sourceLine: hasSource ? sourceLine : undefined,
68064                 sourceCharacter: hasSource ? sourceCharacter : undefined,
68065                 nameIndex: hasName ? nameIndex : undefined
68066             };
68067         }
68068         function stopIterating() {
68069             done = true;
68070             return { value: undefined, done: true };
68071         }
68072         function setError(message) {
68073             if (error === undefined) {
68074                 error = message;
68075             }
68076         }
68077         function setErrorAndStopIterating(message) {
68078             setError(message);
68079             return stopIterating();
68080         }
68081         function hasReportedError() {
68082             return error !== undefined;
68083         }
68084         function isSourceMappingSegmentEnd() {
68085             return (pos === mappings.length ||
68086                 mappings.charCodeAt(pos) === 44 ||
68087                 mappings.charCodeAt(pos) === 59);
68088         }
68089         function base64VLQFormatDecode() {
68090             var moreDigits = true;
68091             var shiftCount = 0;
68092             var value = 0;
68093             for (; moreDigits; pos++) {
68094                 if (pos >= mappings.length)
68095                     return setError("Error in decoding base64VLQFormatDecode, past the mapping string"), -1;
68096                 var currentByte = base64FormatDecode(mappings.charCodeAt(pos));
68097                 if (currentByte === -1)
68098                     return setError("Invalid character in VLQ"), -1;
68099                 moreDigits = (currentByte & 32) !== 0;
68100                 value = value | ((currentByte & 31) << shiftCount);
68101                 shiftCount += 5;
68102             }
68103             if ((value & 1) === 0) {
68104                 value = value >> 1;
68105             }
68106             else {
68107                 value = value >> 1;
68108                 value = -value;
68109             }
68110             return value;
68111         }
68112     }
68113     ts.decodeMappings = decodeMappings;
68114     function sameMapping(left, right) {
68115         return left === right
68116             || left.generatedLine === right.generatedLine
68117                 && left.generatedCharacter === right.generatedCharacter
68118                 && left.sourceIndex === right.sourceIndex
68119                 && left.sourceLine === right.sourceLine
68120                 && left.sourceCharacter === right.sourceCharacter
68121                 && left.nameIndex === right.nameIndex;
68122     }
68123     ts.sameMapping = sameMapping;
68124     function isSourceMapping(mapping) {
68125         return mapping.sourceIndex !== undefined
68126             && mapping.sourceLine !== undefined
68127             && mapping.sourceCharacter !== undefined;
68128     }
68129     ts.isSourceMapping = isSourceMapping;
68130     function base64FormatEncode(value) {
68131         return value >= 0 && value < 26 ? 65 + value :
68132             value >= 26 && value < 52 ? 97 + value - 26 :
68133                 value >= 52 && value < 62 ? 48 + value - 52 :
68134                     value === 62 ? 43 :
68135                         value === 63 ? 47 :
68136                             ts.Debug.fail(value + ": not a base64 value");
68137     }
68138     function base64FormatDecode(ch) {
68139         return ch >= 65 && ch <= 90 ? ch - 65 :
68140             ch >= 97 && ch <= 122 ? ch - 97 + 26 :
68141                 ch >= 48 && ch <= 57 ? ch - 48 + 52 :
68142                     ch === 43 ? 62 :
68143                         ch === 47 ? 63 :
68144                             -1;
68145     }
68146     function base64VLQFormatEncode(inValue) {
68147         if (inValue < 0) {
68148             inValue = ((-inValue) << 1) + 1;
68149         }
68150         else {
68151             inValue = inValue << 1;
68152         }
68153         var encodedStr = "";
68154         do {
68155             var currentDigit = inValue & 31;
68156             inValue = inValue >> 5;
68157             if (inValue > 0) {
68158                 currentDigit = currentDigit | 32;
68159             }
68160             encodedStr = encodedStr + String.fromCharCode(base64FormatEncode(currentDigit));
68161         } while (inValue > 0);
68162         return encodedStr;
68163     }
68164     function isSourceMappedPosition(value) {
68165         return value.sourceIndex !== undefined
68166             && value.sourcePosition !== undefined;
68167     }
68168     function sameMappedPosition(left, right) {
68169         return left.generatedPosition === right.generatedPosition
68170             && left.sourceIndex === right.sourceIndex
68171             && left.sourcePosition === right.sourcePosition;
68172     }
68173     function compareSourcePositions(left, right) {
68174         ts.Debug.assert(left.sourceIndex === right.sourceIndex);
68175         return ts.compareValues(left.sourcePosition, right.sourcePosition);
68176     }
68177     function compareGeneratedPositions(left, right) {
68178         return ts.compareValues(left.generatedPosition, right.generatedPosition);
68179     }
68180     function getSourcePositionOfMapping(value) {
68181         return value.sourcePosition;
68182     }
68183     function getGeneratedPositionOfMapping(value) {
68184         return value.generatedPosition;
68185     }
68186     function createDocumentPositionMapper(host, map, mapPath) {
68187         var mapDirectory = ts.getDirectoryPath(mapPath);
68188         var sourceRoot = map.sourceRoot ? ts.getNormalizedAbsolutePath(map.sourceRoot, mapDirectory) : mapDirectory;
68189         var generatedAbsoluteFilePath = ts.getNormalizedAbsolutePath(map.file, mapDirectory);
68190         var generatedFile = host.getSourceFileLike(generatedAbsoluteFilePath);
68191         var sourceFileAbsolutePaths = map.sources.map(function (source) { return ts.getNormalizedAbsolutePath(source, sourceRoot); });
68192         var sourceToSourceIndexMap = new ts.Map(sourceFileAbsolutePaths.map(function (source, i) { return [host.getCanonicalFileName(source), i]; }));
68193         var decodedMappings;
68194         var generatedMappings;
68195         var sourceMappings;
68196         return {
68197             getSourcePosition: getSourcePosition,
68198             getGeneratedPosition: getGeneratedPosition
68199         };
68200         function processMapping(mapping) {
68201             var generatedPosition = generatedFile !== undefined
68202                 ? ts.getPositionOfLineAndCharacter(generatedFile, mapping.generatedLine, mapping.generatedCharacter, true)
68203                 : -1;
68204             var source;
68205             var sourcePosition;
68206             if (isSourceMapping(mapping)) {
68207                 var sourceFile = host.getSourceFileLike(sourceFileAbsolutePaths[mapping.sourceIndex]);
68208                 source = map.sources[mapping.sourceIndex];
68209                 sourcePosition = sourceFile !== undefined
68210                     ? ts.getPositionOfLineAndCharacter(sourceFile, mapping.sourceLine, mapping.sourceCharacter, true)
68211                     : -1;
68212             }
68213             return {
68214                 generatedPosition: generatedPosition,
68215                 source: source,
68216                 sourceIndex: mapping.sourceIndex,
68217                 sourcePosition: sourcePosition,
68218                 nameIndex: mapping.nameIndex
68219             };
68220         }
68221         function getDecodedMappings() {
68222             if (decodedMappings === undefined) {
68223                 var decoder = decodeMappings(map.mappings);
68224                 var mappings = ts.arrayFrom(decoder, processMapping);
68225                 if (decoder.error !== undefined) {
68226                     if (host.log) {
68227                         host.log("Encountered error while decoding sourcemap: " + decoder.error);
68228                     }
68229                     decodedMappings = ts.emptyArray;
68230                 }
68231                 else {
68232                     decodedMappings = mappings;
68233                 }
68234             }
68235             return decodedMappings;
68236         }
68237         function getSourceMappings(sourceIndex) {
68238             if (sourceMappings === undefined) {
68239                 var lists = [];
68240                 for (var _i = 0, _a = getDecodedMappings(); _i < _a.length; _i++) {
68241                     var mapping = _a[_i];
68242                     if (!isSourceMappedPosition(mapping))
68243                         continue;
68244                     var list = lists[mapping.sourceIndex];
68245                     if (!list)
68246                         lists[mapping.sourceIndex] = list = [];
68247                     list.push(mapping);
68248                 }
68249                 sourceMappings = lists.map(function (list) { return ts.sortAndDeduplicate(list, compareSourcePositions, sameMappedPosition); });
68250             }
68251             return sourceMappings[sourceIndex];
68252         }
68253         function getGeneratedMappings() {
68254             if (generatedMappings === undefined) {
68255                 var list = [];
68256                 for (var _i = 0, _a = getDecodedMappings(); _i < _a.length; _i++) {
68257                     var mapping = _a[_i];
68258                     list.push(mapping);
68259                 }
68260                 generatedMappings = ts.sortAndDeduplicate(list, compareGeneratedPositions, sameMappedPosition);
68261             }
68262             return generatedMappings;
68263         }
68264         function getGeneratedPosition(loc) {
68265             var sourceIndex = sourceToSourceIndexMap.get(host.getCanonicalFileName(loc.fileName));
68266             if (sourceIndex === undefined)
68267                 return loc;
68268             var sourceMappings = getSourceMappings(sourceIndex);
68269             if (!ts.some(sourceMappings))
68270                 return loc;
68271             var targetIndex = ts.binarySearchKey(sourceMappings, loc.pos, getSourcePositionOfMapping, ts.compareValues);
68272             if (targetIndex < 0) {
68273                 targetIndex = ~targetIndex;
68274             }
68275             var mapping = sourceMappings[targetIndex];
68276             if (mapping === undefined || mapping.sourceIndex !== sourceIndex) {
68277                 return loc;
68278             }
68279             return { fileName: generatedAbsoluteFilePath, pos: mapping.generatedPosition };
68280         }
68281         function getSourcePosition(loc) {
68282             var generatedMappings = getGeneratedMappings();
68283             if (!ts.some(generatedMappings))
68284                 return loc;
68285             var targetIndex = ts.binarySearchKey(generatedMappings, loc.pos, getGeneratedPositionOfMapping, ts.compareValues);
68286             if (targetIndex < 0) {
68287                 targetIndex = ~targetIndex;
68288             }
68289             var mapping = generatedMappings[targetIndex];
68290             if (mapping === undefined || !isSourceMappedPosition(mapping)) {
68291                 return loc;
68292             }
68293             return { fileName: sourceFileAbsolutePaths[mapping.sourceIndex], pos: mapping.sourcePosition };
68294         }
68295     }
68296     ts.createDocumentPositionMapper = createDocumentPositionMapper;
68297     ts.identitySourceMapConsumer = {
68298         getSourcePosition: ts.identity,
68299         getGeneratedPosition: ts.identity
68300     };
68301 })(ts || (ts = {}));
68302 var ts;
68303 (function (ts) {
68304     function getOriginalNodeId(node) {
68305         node = ts.getOriginalNode(node);
68306         return node ? ts.getNodeId(node) : 0;
68307     }
68308     ts.getOriginalNodeId = getOriginalNodeId;
68309     function containsDefaultReference(node) {
68310         if (!node)
68311             return false;
68312         if (!ts.isNamedImports(node))
68313             return false;
68314         return ts.some(node.elements, isNamedDefaultReference);
68315     }
68316     function isNamedDefaultReference(e) {
68317         return e.propertyName !== undefined && e.propertyName.escapedText === "default";
68318     }
68319     function chainBundle(context, transformSourceFile) {
68320         return transformSourceFileOrBundle;
68321         function transformSourceFileOrBundle(node) {
68322             return node.kind === 297 ? transformSourceFile(node) : transformBundle(node);
68323         }
68324         function transformBundle(node) {
68325             return context.factory.createBundle(ts.map(node.sourceFiles, transformSourceFile), node.prepends);
68326         }
68327     }
68328     ts.chainBundle = chainBundle;
68329     function getExportNeedsImportStarHelper(node) {
68330         return !!ts.getNamespaceDeclarationNode(node);
68331     }
68332     ts.getExportNeedsImportStarHelper = getExportNeedsImportStarHelper;
68333     function getImportNeedsImportStarHelper(node) {
68334         if (!!ts.getNamespaceDeclarationNode(node)) {
68335             return true;
68336         }
68337         var bindings = node.importClause && node.importClause.namedBindings;
68338         if (!bindings) {
68339             return false;
68340         }
68341         if (!ts.isNamedImports(bindings))
68342             return false;
68343         var defaultRefCount = 0;
68344         for (var _i = 0, _a = bindings.elements; _i < _a.length; _i++) {
68345             var binding = _a[_i];
68346             if (isNamedDefaultReference(binding)) {
68347                 defaultRefCount++;
68348             }
68349         }
68350         return (defaultRefCount > 0 && defaultRefCount !== bindings.elements.length) || (!!(bindings.elements.length - defaultRefCount) && ts.isDefaultImport(node));
68351     }
68352     ts.getImportNeedsImportStarHelper = getImportNeedsImportStarHelper;
68353     function getImportNeedsImportDefaultHelper(node) {
68354         return !getImportNeedsImportStarHelper(node) && (ts.isDefaultImport(node) || (!!node.importClause && ts.isNamedImports(node.importClause.namedBindings) && containsDefaultReference(node.importClause.namedBindings)));
68355     }
68356     ts.getImportNeedsImportDefaultHelper = getImportNeedsImportDefaultHelper;
68357     function collectExternalModuleInfo(context, sourceFile, resolver, compilerOptions) {
68358         var externalImports = [];
68359         var exportSpecifiers = ts.createMultiMap();
68360         var exportedBindings = [];
68361         var uniqueExports = new ts.Map();
68362         var exportedNames;
68363         var hasExportDefault = false;
68364         var exportEquals;
68365         var hasExportStarsToExportValues = false;
68366         var hasImportStar = false;
68367         var hasImportDefault = false;
68368         for (var _i = 0, _a = sourceFile.statements; _i < _a.length; _i++) {
68369             var node = _a[_i];
68370             switch (node.kind) {
68371                 case 261:
68372                     externalImports.push(node);
68373                     if (!hasImportStar && getImportNeedsImportStarHelper(node)) {
68374                         hasImportStar = true;
68375                     }
68376                     if (!hasImportDefault && getImportNeedsImportDefaultHelper(node)) {
68377                         hasImportDefault = true;
68378                     }
68379                     break;
68380                 case 260:
68381                     if (node.moduleReference.kind === 272) {
68382                         externalImports.push(node);
68383                     }
68384                     break;
68385                 case 267:
68386                     if (node.moduleSpecifier) {
68387                         if (!node.exportClause) {
68388                             externalImports.push(node);
68389                             hasExportStarsToExportValues = true;
68390                         }
68391                         else {
68392                             externalImports.push(node);
68393                             if (ts.isNamedExports(node.exportClause)) {
68394                                 addExportedNamesForExportDeclaration(node);
68395                             }
68396                             else {
68397                                 var name = node.exportClause.name;
68398                                 if (!uniqueExports.get(ts.idText(name))) {
68399                                     multiMapSparseArrayAdd(exportedBindings, getOriginalNodeId(node), name);
68400                                     uniqueExports.set(ts.idText(name), true);
68401                                     exportedNames = ts.append(exportedNames, name);
68402                                 }
68403                                 hasImportStar = true;
68404                             }
68405                         }
68406                     }
68407                     else {
68408                         addExportedNamesForExportDeclaration(node);
68409                     }
68410                     break;
68411                 case 266:
68412                     if (node.isExportEquals && !exportEquals) {
68413                         exportEquals = node;
68414                     }
68415                     break;
68416                 case 232:
68417                     if (ts.hasSyntacticModifier(node, 1)) {
68418                         for (var _b = 0, _c = node.declarationList.declarations; _b < _c.length; _b++) {
68419                             var decl = _c[_b];
68420                             exportedNames = collectExportedVariableInfo(decl, uniqueExports, exportedNames);
68421                         }
68422                     }
68423                     break;
68424                 case 251:
68425                     if (ts.hasSyntacticModifier(node, 1)) {
68426                         if (ts.hasSyntacticModifier(node, 512)) {
68427                             if (!hasExportDefault) {
68428                                 multiMapSparseArrayAdd(exportedBindings, getOriginalNodeId(node), context.factory.getDeclarationName(node));
68429                                 hasExportDefault = true;
68430                             }
68431                         }
68432                         else {
68433                             var name = node.name;
68434                             if (!uniqueExports.get(ts.idText(name))) {
68435                                 multiMapSparseArrayAdd(exportedBindings, getOriginalNodeId(node), name);
68436                                 uniqueExports.set(ts.idText(name), true);
68437                                 exportedNames = ts.append(exportedNames, name);
68438                             }
68439                         }
68440                     }
68441                     break;
68442                 case 252:
68443                     if (ts.hasSyntacticModifier(node, 1)) {
68444                         if (ts.hasSyntacticModifier(node, 512)) {
68445                             if (!hasExportDefault) {
68446                                 multiMapSparseArrayAdd(exportedBindings, getOriginalNodeId(node), context.factory.getDeclarationName(node));
68447                                 hasExportDefault = true;
68448                             }
68449                         }
68450                         else {
68451                             var name = node.name;
68452                             if (name && !uniqueExports.get(ts.idText(name))) {
68453                                 multiMapSparseArrayAdd(exportedBindings, getOriginalNodeId(node), name);
68454                                 uniqueExports.set(ts.idText(name), true);
68455                                 exportedNames = ts.append(exportedNames, name);
68456                             }
68457                         }
68458                     }
68459                     break;
68460             }
68461         }
68462         var externalHelpersImportDeclaration = ts.createExternalHelpersImportDeclarationIfNeeded(context.factory, context.getEmitHelperFactory(), sourceFile, compilerOptions, hasExportStarsToExportValues, hasImportStar, hasImportDefault);
68463         if (externalHelpersImportDeclaration) {
68464             externalImports.unshift(externalHelpersImportDeclaration);
68465         }
68466         return { externalImports: externalImports, exportSpecifiers: exportSpecifiers, exportEquals: exportEquals, hasExportStarsToExportValues: hasExportStarsToExportValues, exportedBindings: exportedBindings, exportedNames: exportedNames, externalHelpersImportDeclaration: externalHelpersImportDeclaration };
68467         function addExportedNamesForExportDeclaration(node) {
68468             for (var _i = 0, _a = ts.cast(node.exportClause, ts.isNamedExports).elements; _i < _a.length; _i++) {
68469                 var specifier = _a[_i];
68470                 if (!uniqueExports.get(ts.idText(specifier.name))) {
68471                     var name = specifier.propertyName || specifier.name;
68472                     if (!node.moduleSpecifier) {
68473                         exportSpecifiers.add(ts.idText(name), specifier);
68474                     }
68475                     var decl = resolver.getReferencedImportDeclaration(name)
68476                         || resolver.getReferencedValueDeclaration(name);
68477                     if (decl) {
68478                         multiMapSparseArrayAdd(exportedBindings, getOriginalNodeId(decl), specifier.name);
68479                     }
68480                     uniqueExports.set(ts.idText(specifier.name), true);
68481                     exportedNames = ts.append(exportedNames, specifier.name);
68482                 }
68483             }
68484         }
68485     }
68486     ts.collectExternalModuleInfo = collectExternalModuleInfo;
68487     function collectExportedVariableInfo(decl, uniqueExports, exportedNames) {
68488         if (ts.isBindingPattern(decl.name)) {
68489             for (var _i = 0, _a = decl.name.elements; _i < _a.length; _i++) {
68490                 var element = _a[_i];
68491                 if (!ts.isOmittedExpression(element)) {
68492                     exportedNames = collectExportedVariableInfo(element, uniqueExports, exportedNames);
68493                 }
68494             }
68495         }
68496         else if (!ts.isGeneratedIdentifier(decl.name)) {
68497             var text = ts.idText(decl.name);
68498             if (!uniqueExports.get(text)) {
68499                 uniqueExports.set(text, true);
68500                 exportedNames = ts.append(exportedNames, decl.name);
68501             }
68502         }
68503         return exportedNames;
68504     }
68505     function multiMapSparseArrayAdd(map, key, value) {
68506         var values = map[key];
68507         if (values) {
68508             values.push(value);
68509         }
68510         else {
68511             map[key] = values = [value];
68512         }
68513         return values;
68514     }
68515     function isSimpleCopiableExpression(expression) {
68516         return ts.isStringLiteralLike(expression) ||
68517             expression.kind === 8 ||
68518             ts.isKeyword(expression.kind) ||
68519             ts.isIdentifier(expression);
68520     }
68521     ts.isSimpleCopiableExpression = isSimpleCopiableExpression;
68522     function isSimpleInlineableExpression(expression) {
68523         return !ts.isIdentifier(expression) && isSimpleCopiableExpression(expression) ||
68524             ts.isWellKnownSymbolSyntactically(expression);
68525     }
68526     ts.isSimpleInlineableExpression = isSimpleInlineableExpression;
68527     function isCompoundAssignment(kind) {
68528         return kind >= 63
68529             && kind <= 77;
68530     }
68531     ts.isCompoundAssignment = isCompoundAssignment;
68532     function getNonAssignmentOperatorForCompoundAssignment(kind) {
68533         switch (kind) {
68534             case 63: return 39;
68535             case 64: return 40;
68536             case 65: return 41;
68537             case 66: return 42;
68538             case 67: return 43;
68539             case 68: return 44;
68540             case 69: return 47;
68541             case 70: return 48;
68542             case 71: return 49;
68543             case 72: return 50;
68544             case 73: return 51;
68545             case 77: return 52;
68546             case 74: return 56;
68547             case 75: return 55;
68548             case 76: return 60;
68549         }
68550     }
68551     ts.getNonAssignmentOperatorForCompoundAssignment = getNonAssignmentOperatorForCompoundAssignment;
68552     function addPrologueDirectivesAndInitialSuperCall(factory, ctor, result, visitor) {
68553         if (ctor.body) {
68554             var statements = ctor.body.statements;
68555             var index = factory.copyPrologue(statements, result, false, visitor);
68556             if (index === statements.length) {
68557                 return index;
68558             }
68559             var superIndex = ts.findIndex(statements, function (s) { return ts.isExpressionStatement(s) && ts.isSuperCall(s.expression); }, index);
68560             if (superIndex > -1) {
68561                 for (var i = index; i <= superIndex; i++) {
68562                     result.push(ts.visitNode(statements[i], visitor, ts.isStatement));
68563                 }
68564                 return superIndex + 1;
68565             }
68566             return index;
68567         }
68568         return 0;
68569     }
68570     ts.addPrologueDirectivesAndInitialSuperCall = addPrologueDirectivesAndInitialSuperCall;
68571     function getProperties(node, requireInitializer, isStatic) {
68572         return ts.filter(node.members, function (m) { return isInitializedOrStaticProperty(m, requireInitializer, isStatic); });
68573     }
68574     ts.getProperties = getProperties;
68575     function isInitializedOrStaticProperty(member, requireInitializer, isStatic) {
68576         return ts.isPropertyDeclaration(member)
68577             && (!!member.initializer || !requireInitializer)
68578             && ts.hasStaticModifier(member) === isStatic;
68579     }
68580     function isInitializedProperty(member) {
68581         return member.kind === 163
68582             && member.initializer !== undefined;
68583     }
68584     ts.isInitializedProperty = isInitializedProperty;
68585 })(ts || (ts = {}));
68586 var ts;
68587 (function (ts) {
68588     function flattenDestructuringAssignment(node, visitor, context, level, needsValue, createAssignmentCallback) {
68589         var location = node;
68590         var value;
68591         if (ts.isDestructuringAssignment(node)) {
68592             value = node.right;
68593             while (ts.isEmptyArrayLiteral(node.left) || ts.isEmptyObjectLiteral(node.left)) {
68594                 if (ts.isDestructuringAssignment(value)) {
68595                     location = node = value;
68596                     value = node.right;
68597                 }
68598                 else {
68599                     return ts.visitNode(value, visitor, ts.isExpression);
68600                 }
68601             }
68602         }
68603         var expressions;
68604         var flattenContext = {
68605             context: context,
68606             level: level,
68607             downlevelIteration: !!context.getCompilerOptions().downlevelIteration,
68608             hoistTempVariables: true,
68609             emitExpression: emitExpression,
68610             emitBindingOrAssignment: emitBindingOrAssignment,
68611             createArrayBindingOrAssignmentPattern: function (elements) { return makeArrayAssignmentPattern(context.factory, elements); },
68612             createObjectBindingOrAssignmentPattern: function (elements) { return makeObjectAssignmentPattern(context.factory, elements); },
68613             createArrayBindingOrAssignmentElement: makeAssignmentElement,
68614             visitor: visitor
68615         };
68616         if (value) {
68617             value = ts.visitNode(value, visitor, ts.isExpression);
68618             if (ts.isIdentifier(value) && bindingOrAssignmentElementAssignsToName(node, value.escapedText) ||
68619                 bindingOrAssignmentElementContainsNonLiteralComputedName(node)) {
68620                 value = ensureIdentifier(flattenContext, value, false, location);
68621             }
68622             else if (needsValue) {
68623                 value = ensureIdentifier(flattenContext, value, true, location);
68624             }
68625             else if (ts.nodeIsSynthesized(node)) {
68626                 location = value;
68627             }
68628         }
68629         flattenBindingOrAssignmentElement(flattenContext, node, value, location, ts.isDestructuringAssignment(node));
68630         if (value && needsValue) {
68631             if (!ts.some(expressions)) {
68632                 return value;
68633             }
68634             expressions.push(value);
68635         }
68636         return context.factory.inlineExpressions(expressions) || context.factory.createOmittedExpression();
68637         function emitExpression(expression) {
68638             expressions = ts.append(expressions, expression);
68639         }
68640         function emitBindingOrAssignment(target, value, location, original) {
68641             ts.Debug.assertNode(target, createAssignmentCallback ? ts.isIdentifier : ts.isExpression);
68642             var expression = createAssignmentCallback
68643                 ? createAssignmentCallback(target, value, location)
68644                 : ts.setTextRange(context.factory.createAssignment(ts.visitNode(target, visitor, ts.isExpression), value), location);
68645             expression.original = original;
68646             emitExpression(expression);
68647         }
68648     }
68649     ts.flattenDestructuringAssignment = flattenDestructuringAssignment;
68650     function bindingOrAssignmentElementAssignsToName(element, escapedName) {
68651         var target = ts.getTargetOfBindingOrAssignmentElement(element);
68652         if (ts.isBindingOrAssignmentPattern(target)) {
68653             return bindingOrAssignmentPatternAssignsToName(target, escapedName);
68654         }
68655         else if (ts.isIdentifier(target)) {
68656             return target.escapedText === escapedName;
68657         }
68658         return false;
68659     }
68660     function bindingOrAssignmentPatternAssignsToName(pattern, escapedName) {
68661         var elements = ts.getElementsOfBindingOrAssignmentPattern(pattern);
68662         for (var _i = 0, elements_3 = elements; _i < elements_3.length; _i++) {
68663             var element = elements_3[_i];
68664             if (bindingOrAssignmentElementAssignsToName(element, escapedName)) {
68665                 return true;
68666             }
68667         }
68668         return false;
68669     }
68670     function bindingOrAssignmentElementContainsNonLiteralComputedName(element) {
68671         var propertyName = ts.tryGetPropertyNameOfBindingOrAssignmentElement(element);
68672         if (propertyName && ts.isComputedPropertyName(propertyName) && !ts.isLiteralExpression(propertyName.expression)) {
68673             return true;
68674         }
68675         var target = ts.getTargetOfBindingOrAssignmentElement(element);
68676         return !!target && ts.isBindingOrAssignmentPattern(target) && bindingOrAssignmentPatternContainsNonLiteralComputedName(target);
68677     }
68678     function bindingOrAssignmentPatternContainsNonLiteralComputedName(pattern) {
68679         return !!ts.forEach(ts.getElementsOfBindingOrAssignmentPattern(pattern), bindingOrAssignmentElementContainsNonLiteralComputedName);
68680     }
68681     function flattenDestructuringBinding(node, visitor, context, level, rval, hoistTempVariables, skipInitializer) {
68682         if (hoistTempVariables === void 0) { hoistTempVariables = false; }
68683         var pendingExpressions;
68684         var pendingDeclarations = [];
68685         var declarations = [];
68686         var flattenContext = {
68687             context: context,
68688             level: level,
68689             downlevelIteration: !!context.getCompilerOptions().downlevelIteration,
68690             hoistTempVariables: hoistTempVariables,
68691             emitExpression: emitExpression,
68692             emitBindingOrAssignment: emitBindingOrAssignment,
68693             createArrayBindingOrAssignmentPattern: function (elements) { return makeArrayBindingPattern(context.factory, elements); },
68694             createObjectBindingOrAssignmentPattern: function (elements) { return makeObjectBindingPattern(context.factory, elements); },
68695             createArrayBindingOrAssignmentElement: function (name) { return makeBindingElement(context.factory, name); },
68696             visitor: visitor
68697         };
68698         if (ts.isVariableDeclaration(node)) {
68699             var initializer = ts.getInitializerOfBindingOrAssignmentElement(node);
68700             if (initializer && (ts.isIdentifier(initializer) && bindingOrAssignmentElementAssignsToName(node, initializer.escapedText) ||
68701                 bindingOrAssignmentElementContainsNonLiteralComputedName(node))) {
68702                 initializer = ensureIdentifier(flattenContext, initializer, false, initializer);
68703                 node = context.factory.updateVariableDeclaration(node, node.name, undefined, undefined, initializer);
68704             }
68705         }
68706         flattenBindingOrAssignmentElement(flattenContext, node, rval, node, skipInitializer);
68707         if (pendingExpressions) {
68708             var temp = context.factory.createTempVariable(undefined);
68709             if (hoistTempVariables) {
68710                 var value = context.factory.inlineExpressions(pendingExpressions);
68711                 pendingExpressions = undefined;
68712                 emitBindingOrAssignment(temp, value, undefined, undefined);
68713             }
68714             else {
68715                 context.hoistVariableDeclaration(temp);
68716                 var pendingDeclaration = ts.last(pendingDeclarations);
68717                 pendingDeclaration.pendingExpressions = ts.append(pendingDeclaration.pendingExpressions, context.factory.createAssignment(temp, pendingDeclaration.value));
68718                 ts.addRange(pendingDeclaration.pendingExpressions, pendingExpressions);
68719                 pendingDeclaration.value = temp;
68720             }
68721         }
68722         for (var _i = 0, pendingDeclarations_1 = pendingDeclarations; _i < pendingDeclarations_1.length; _i++) {
68723             var _a = pendingDeclarations_1[_i], pendingExpressions_1 = _a.pendingExpressions, name = _a.name, value = _a.value, location = _a.location, original = _a.original;
68724             var variable = context.factory.createVariableDeclaration(name, undefined, undefined, pendingExpressions_1 ? context.factory.inlineExpressions(ts.append(pendingExpressions_1, value)) : value);
68725             variable.original = original;
68726             ts.setTextRange(variable, location);
68727             declarations.push(variable);
68728         }
68729         return declarations;
68730         function emitExpression(value) {
68731             pendingExpressions = ts.append(pendingExpressions, value);
68732         }
68733         function emitBindingOrAssignment(target, value, location, original) {
68734             ts.Debug.assertNode(target, ts.isBindingName);
68735             if (pendingExpressions) {
68736                 value = context.factory.inlineExpressions(ts.append(pendingExpressions, value));
68737                 pendingExpressions = undefined;
68738             }
68739             pendingDeclarations.push({ pendingExpressions: pendingExpressions, name: target, value: value, location: location, original: original });
68740         }
68741     }
68742     ts.flattenDestructuringBinding = flattenDestructuringBinding;
68743     function flattenBindingOrAssignmentElement(flattenContext, element, value, location, skipInitializer) {
68744         var bindingTarget = ts.getTargetOfBindingOrAssignmentElement(element);
68745         if (!skipInitializer) {
68746             var initializer = ts.visitNode(ts.getInitializerOfBindingOrAssignmentElement(element), flattenContext.visitor, ts.isExpression);
68747             if (initializer) {
68748                 if (value) {
68749                     value = createDefaultValueCheck(flattenContext, value, initializer, location);
68750                     if (!ts.isSimpleInlineableExpression(initializer) && ts.isBindingOrAssignmentPattern(bindingTarget)) {
68751                         value = ensureIdentifier(flattenContext, value, true, location);
68752                     }
68753                 }
68754                 else {
68755                     value = initializer;
68756                 }
68757             }
68758             else if (!value) {
68759                 value = flattenContext.context.factory.createVoidZero();
68760             }
68761         }
68762         if (ts.isObjectBindingOrAssignmentPattern(bindingTarget)) {
68763             flattenObjectBindingOrAssignmentPattern(flattenContext, element, bindingTarget, value, location);
68764         }
68765         else if (ts.isArrayBindingOrAssignmentPattern(bindingTarget)) {
68766             flattenArrayBindingOrAssignmentPattern(flattenContext, element, bindingTarget, value, location);
68767         }
68768         else {
68769             flattenContext.emitBindingOrAssignment(bindingTarget, value, location, element);
68770         }
68771     }
68772     function flattenObjectBindingOrAssignmentPattern(flattenContext, parent, pattern, value, location) {
68773         var elements = ts.getElementsOfBindingOrAssignmentPattern(pattern);
68774         var numElements = elements.length;
68775         if (numElements !== 1) {
68776             var reuseIdentifierExpressions = !ts.isDeclarationBindingElement(parent) || numElements !== 0;
68777             value = ensureIdentifier(flattenContext, value, reuseIdentifierExpressions, location);
68778         }
68779         var bindingElements;
68780         var computedTempVariables;
68781         for (var i = 0; i < numElements; i++) {
68782             var element = elements[i];
68783             if (!ts.getRestIndicatorOfBindingOrAssignmentElement(element)) {
68784                 var propertyName = ts.getPropertyNameOfBindingOrAssignmentElement(element);
68785                 if (flattenContext.level >= 1
68786                     && !(element.transformFlags & (8192 | 16384))
68787                     && !(ts.getTargetOfBindingOrAssignmentElement(element).transformFlags & (8192 | 16384))
68788                     && !ts.isComputedPropertyName(propertyName)) {
68789                     bindingElements = ts.append(bindingElements, ts.visitNode(element, flattenContext.visitor));
68790                 }
68791                 else {
68792                     if (bindingElements) {
68793                         flattenContext.emitBindingOrAssignment(flattenContext.createObjectBindingOrAssignmentPattern(bindingElements), value, location, pattern);
68794                         bindingElements = undefined;
68795                     }
68796                     var rhsValue = createDestructuringPropertyAccess(flattenContext, value, propertyName);
68797                     if (ts.isComputedPropertyName(propertyName)) {
68798                         computedTempVariables = ts.append(computedTempVariables, rhsValue.argumentExpression);
68799                     }
68800                     flattenBindingOrAssignmentElement(flattenContext, element, rhsValue, element);
68801                 }
68802             }
68803             else if (i === numElements - 1) {
68804                 if (bindingElements) {
68805                     flattenContext.emitBindingOrAssignment(flattenContext.createObjectBindingOrAssignmentPattern(bindingElements), value, location, pattern);
68806                     bindingElements = undefined;
68807                 }
68808                 var rhsValue = flattenContext.context.getEmitHelperFactory().createRestHelper(value, elements, computedTempVariables, pattern);
68809                 flattenBindingOrAssignmentElement(flattenContext, element, rhsValue, element);
68810             }
68811         }
68812         if (bindingElements) {
68813             flattenContext.emitBindingOrAssignment(flattenContext.createObjectBindingOrAssignmentPattern(bindingElements), value, location, pattern);
68814         }
68815     }
68816     function flattenArrayBindingOrAssignmentPattern(flattenContext, parent, pattern, value, location) {
68817         var elements = ts.getElementsOfBindingOrAssignmentPattern(pattern);
68818         var numElements = elements.length;
68819         if (flattenContext.level < 1 && flattenContext.downlevelIteration) {
68820             value = ensureIdentifier(flattenContext, ts.setTextRange(flattenContext.context.getEmitHelperFactory().createReadHelper(value, numElements > 0 && ts.getRestIndicatorOfBindingOrAssignmentElement(elements[numElements - 1])
68821                 ? undefined
68822                 : numElements), location), false, location);
68823         }
68824         else if (numElements !== 1 && (flattenContext.level < 1 || numElements === 0)
68825             || ts.every(elements, ts.isOmittedExpression)) {
68826             var reuseIdentifierExpressions = !ts.isDeclarationBindingElement(parent) || numElements !== 0;
68827             value = ensureIdentifier(flattenContext, value, reuseIdentifierExpressions, location);
68828         }
68829         var bindingElements;
68830         var restContainingElements;
68831         for (var i = 0; i < numElements; i++) {
68832             var element = elements[i];
68833             if (flattenContext.level >= 1) {
68834                 if (element.transformFlags & 16384 || flattenContext.hasTransformedPriorElement && !isSimpleBindingOrAssignmentElement(element)) {
68835                     flattenContext.hasTransformedPriorElement = true;
68836                     var temp = flattenContext.context.factory.createTempVariable(undefined);
68837                     if (flattenContext.hoistTempVariables) {
68838                         flattenContext.context.hoistVariableDeclaration(temp);
68839                     }
68840                     restContainingElements = ts.append(restContainingElements, [temp, element]);
68841                     bindingElements = ts.append(bindingElements, flattenContext.createArrayBindingOrAssignmentElement(temp));
68842                 }
68843                 else {
68844                     bindingElements = ts.append(bindingElements, element);
68845                 }
68846             }
68847             else if (ts.isOmittedExpression(element)) {
68848                 continue;
68849             }
68850             else if (!ts.getRestIndicatorOfBindingOrAssignmentElement(element)) {
68851                 var rhsValue = flattenContext.context.factory.createElementAccessExpression(value, i);
68852                 flattenBindingOrAssignmentElement(flattenContext, element, rhsValue, element);
68853             }
68854             else if (i === numElements - 1) {
68855                 var rhsValue = flattenContext.context.factory.createArraySliceCall(value, i);
68856                 flattenBindingOrAssignmentElement(flattenContext, element, rhsValue, element);
68857             }
68858         }
68859         if (bindingElements) {
68860             flattenContext.emitBindingOrAssignment(flattenContext.createArrayBindingOrAssignmentPattern(bindingElements), value, location, pattern);
68861         }
68862         if (restContainingElements) {
68863             for (var _i = 0, restContainingElements_1 = restContainingElements; _i < restContainingElements_1.length; _i++) {
68864                 var _a = restContainingElements_1[_i], id = _a[0], element = _a[1];
68865                 flattenBindingOrAssignmentElement(flattenContext, element, id, element);
68866             }
68867         }
68868     }
68869     function isSimpleBindingOrAssignmentElement(element) {
68870         var target = ts.getTargetOfBindingOrAssignmentElement(element);
68871         if (!target || ts.isOmittedExpression(target))
68872             return true;
68873         var propertyName = ts.tryGetPropertyNameOfBindingOrAssignmentElement(element);
68874         if (propertyName && !ts.isPropertyNameLiteral(propertyName))
68875             return false;
68876         var initializer = ts.getInitializerOfBindingOrAssignmentElement(element);
68877         if (initializer && !ts.isSimpleInlineableExpression(initializer))
68878             return false;
68879         if (ts.isBindingOrAssignmentPattern(target))
68880             return ts.every(ts.getElementsOfBindingOrAssignmentPattern(target), isSimpleBindingOrAssignmentElement);
68881         return ts.isIdentifier(target);
68882     }
68883     function createDefaultValueCheck(flattenContext, value, defaultValue, location) {
68884         value = ensureIdentifier(flattenContext, value, true, location);
68885         return flattenContext.context.factory.createConditionalExpression(flattenContext.context.factory.createTypeCheck(value, "undefined"), undefined, defaultValue, undefined, value);
68886     }
68887     function createDestructuringPropertyAccess(flattenContext, value, propertyName) {
68888         if (ts.isComputedPropertyName(propertyName)) {
68889             var argumentExpression = ensureIdentifier(flattenContext, ts.visitNode(propertyName.expression, flattenContext.visitor), false, propertyName);
68890             return flattenContext.context.factory.createElementAccessExpression(value, argumentExpression);
68891         }
68892         else if (ts.isStringOrNumericLiteralLike(propertyName)) {
68893             var argumentExpression = ts.factory.cloneNode(propertyName);
68894             return flattenContext.context.factory.createElementAccessExpression(value, argumentExpression);
68895         }
68896         else {
68897             var name = flattenContext.context.factory.createIdentifier(ts.idText(propertyName));
68898             return flattenContext.context.factory.createPropertyAccessExpression(value, name);
68899         }
68900     }
68901     function ensureIdentifier(flattenContext, value, reuseIdentifierExpressions, location) {
68902         if (ts.isIdentifier(value) && reuseIdentifierExpressions) {
68903             return value;
68904         }
68905         else {
68906             var temp = flattenContext.context.factory.createTempVariable(undefined);
68907             if (flattenContext.hoistTempVariables) {
68908                 flattenContext.context.hoistVariableDeclaration(temp);
68909                 flattenContext.emitExpression(ts.setTextRange(flattenContext.context.factory.createAssignment(temp, value), location));
68910             }
68911             else {
68912                 flattenContext.emitBindingOrAssignment(temp, value, location, undefined);
68913             }
68914             return temp;
68915         }
68916     }
68917     function makeArrayBindingPattern(factory, elements) {
68918         ts.Debug.assertEachNode(elements, ts.isArrayBindingElement);
68919         return factory.createArrayBindingPattern(elements);
68920     }
68921     function makeArrayAssignmentPattern(factory, elements) {
68922         return factory.createArrayLiteralExpression(ts.map(elements, factory.converters.convertToArrayAssignmentElement));
68923     }
68924     function makeObjectBindingPattern(factory, elements) {
68925         ts.Debug.assertEachNode(elements, ts.isBindingElement);
68926         return factory.createObjectBindingPattern(elements);
68927     }
68928     function makeObjectAssignmentPattern(factory, elements) {
68929         return factory.createObjectLiteralExpression(ts.map(elements, factory.converters.convertToObjectAssignmentElement));
68930     }
68931     function makeBindingElement(factory, name) {
68932         return factory.createBindingElement(undefined, undefined, name);
68933     }
68934     function makeAssignmentElement(name) {
68935         return name;
68936     }
68937 })(ts || (ts = {}));
68938 var ts;
68939 (function (ts) {
68940     var ProcessLevel;
68941     (function (ProcessLevel) {
68942         ProcessLevel[ProcessLevel["LiftRestriction"] = 0] = "LiftRestriction";
68943         ProcessLevel[ProcessLevel["All"] = 1] = "All";
68944     })(ProcessLevel = ts.ProcessLevel || (ts.ProcessLevel = {}));
68945     function processTaggedTemplateExpression(context, node, visitor, currentSourceFile, recordTaggedTemplateString, level) {
68946         var tag = ts.visitNode(node.tag, visitor, ts.isExpression);
68947         var templateArguments = [undefined];
68948         var cookedStrings = [];
68949         var rawStrings = [];
68950         var template = node.template;
68951         if (level === ProcessLevel.LiftRestriction && !ts.hasInvalidEscape(template)) {
68952             return ts.visitEachChild(node, visitor, context);
68953         }
68954         if (ts.isNoSubstitutionTemplateLiteral(template)) {
68955             cookedStrings.push(createTemplateCooked(template));
68956             rawStrings.push(getRawLiteral(template, currentSourceFile));
68957         }
68958         else {
68959             cookedStrings.push(createTemplateCooked(template.head));
68960             rawStrings.push(getRawLiteral(template.head, currentSourceFile));
68961             for (var _i = 0, _a = template.templateSpans; _i < _a.length; _i++) {
68962                 var templateSpan = _a[_i];
68963                 cookedStrings.push(createTemplateCooked(templateSpan.literal));
68964                 rawStrings.push(getRawLiteral(templateSpan.literal, currentSourceFile));
68965                 templateArguments.push(ts.visitNode(templateSpan.expression, visitor, ts.isExpression));
68966             }
68967         }
68968         var helperCall = context.getEmitHelperFactory().createTemplateObjectHelper(ts.factory.createArrayLiteralExpression(cookedStrings), ts.factory.createArrayLiteralExpression(rawStrings));
68969         if (ts.isExternalModule(currentSourceFile)) {
68970             var tempVar = ts.factory.createUniqueName("templateObject");
68971             recordTaggedTemplateString(tempVar);
68972             templateArguments[0] = ts.factory.createLogicalOr(tempVar, ts.factory.createAssignment(tempVar, helperCall));
68973         }
68974         else {
68975             templateArguments[0] = helperCall;
68976         }
68977         return ts.factory.createCallExpression(tag, undefined, templateArguments);
68978     }
68979     ts.processTaggedTemplateExpression = processTaggedTemplateExpression;
68980     function createTemplateCooked(template) {
68981         return template.templateFlags ? ts.factory.createVoidZero() : ts.factory.createStringLiteral(template.text);
68982     }
68983     function getRawLiteral(node, currentSourceFile) {
68984         var text = node.rawText;
68985         if (text === undefined) {
68986             text = ts.getSourceTextOfNodeFromSourceFile(currentSourceFile, node);
68987             var isLast = node.kind === 14 || node.kind === 17;
68988             text = text.substring(1, text.length - (isLast ? 1 : 2));
68989         }
68990         text = text.replace(/\r\n?/g, "\n");
68991         return ts.setTextRange(ts.factory.createStringLiteral(text), node);
68992     }
68993 })(ts || (ts = {}));
68994 var ts;
68995 (function (ts) {
68996     var USE_NEW_TYPE_METADATA_FORMAT = false;
68997     function transformTypeScript(context) {
68998         var factory = context.factory, emitHelpers = context.getEmitHelperFactory, startLexicalEnvironment = context.startLexicalEnvironment, resumeLexicalEnvironment = context.resumeLexicalEnvironment, endLexicalEnvironment = context.endLexicalEnvironment, hoistVariableDeclaration = context.hoistVariableDeclaration;
68999         var resolver = context.getEmitResolver();
69000         var compilerOptions = context.getCompilerOptions();
69001         var strictNullChecks = ts.getStrictOptionValue(compilerOptions, "strictNullChecks");
69002         var languageVersion = ts.getEmitScriptTarget(compilerOptions);
69003         var moduleKind = ts.getEmitModuleKind(compilerOptions);
69004         var previousOnEmitNode = context.onEmitNode;
69005         var previousOnSubstituteNode = context.onSubstituteNode;
69006         context.onEmitNode = onEmitNode;
69007         context.onSubstituteNode = onSubstituteNode;
69008         context.enableSubstitution(201);
69009         context.enableSubstitution(202);
69010         var currentSourceFile;
69011         var currentNamespace;
69012         var currentNamespaceContainerName;
69013         var currentLexicalScope;
69014         var currentNameScope;
69015         var currentScopeFirstDeclarationsOfName;
69016         var currentClassHasParameterProperties;
69017         var enabledSubstitutions;
69018         var classAliases;
69019         var applicableSubstitutions;
69020         return transformSourceFileOrBundle;
69021         function transformSourceFileOrBundle(node) {
69022             if (node.kind === 298) {
69023                 return transformBundle(node);
69024             }
69025             return transformSourceFile(node);
69026         }
69027         function transformBundle(node) {
69028             return factory.createBundle(node.sourceFiles.map(transformSourceFile), ts.mapDefined(node.prepends, function (prepend) {
69029                 if (prepend.kind === 300) {
69030                     return ts.createUnparsedSourceFile(prepend, "js");
69031                 }
69032                 return prepend;
69033             }));
69034         }
69035         function transformSourceFile(node) {
69036             if (node.isDeclarationFile) {
69037                 return node;
69038             }
69039             currentSourceFile = node;
69040             var visited = saveStateAndInvoke(node, visitSourceFile);
69041             ts.addEmitHelpers(visited, context.readEmitHelpers());
69042             currentSourceFile = undefined;
69043             return visited;
69044         }
69045         function saveStateAndInvoke(node, f) {
69046             var savedCurrentScope = currentLexicalScope;
69047             var savedCurrentNameScope = currentNameScope;
69048             var savedCurrentScopeFirstDeclarationsOfName = currentScopeFirstDeclarationsOfName;
69049             var savedCurrentClassHasParameterProperties = currentClassHasParameterProperties;
69050             onBeforeVisitNode(node);
69051             var visited = f(node);
69052             if (currentLexicalScope !== savedCurrentScope) {
69053                 currentScopeFirstDeclarationsOfName = savedCurrentScopeFirstDeclarationsOfName;
69054             }
69055             currentLexicalScope = savedCurrentScope;
69056             currentNameScope = savedCurrentNameScope;
69057             currentClassHasParameterProperties = savedCurrentClassHasParameterProperties;
69058             return visited;
69059         }
69060         function onBeforeVisitNode(node) {
69061             switch (node.kind) {
69062                 case 297:
69063                 case 258:
69064                 case 257:
69065                 case 230:
69066                     currentLexicalScope = node;
69067                     currentNameScope = undefined;
69068                     currentScopeFirstDeclarationsOfName = undefined;
69069                     break;
69070                 case 252:
69071                 case 251:
69072                     if (ts.hasSyntacticModifier(node, 2)) {
69073                         break;
69074                     }
69075                     if (node.name) {
69076                         recordEmittedDeclarationInScope(node);
69077                     }
69078                     else {
69079                         ts.Debug.assert(node.kind === 252 || ts.hasSyntacticModifier(node, 512));
69080                     }
69081                     if (ts.isClassDeclaration(node)) {
69082                         currentNameScope = node;
69083                     }
69084                     break;
69085             }
69086         }
69087         function visitor(node) {
69088             return saveStateAndInvoke(node, visitorWorker);
69089         }
69090         function visitorWorker(node) {
69091             if (node.transformFlags & 1) {
69092                 return visitTypeScript(node);
69093             }
69094             return node;
69095         }
69096         function sourceElementVisitor(node) {
69097             return saveStateAndInvoke(node, sourceElementVisitorWorker);
69098         }
69099         function sourceElementVisitorWorker(node) {
69100             switch (node.kind) {
69101                 case 261:
69102                 case 260:
69103                 case 266:
69104                 case 267:
69105                     return visitElidableStatement(node);
69106                 default:
69107                     return visitorWorker(node);
69108             }
69109         }
69110         function visitElidableStatement(node) {
69111             var parsed = ts.getParseTreeNode(node);
69112             if (parsed !== node) {
69113                 if (node.transformFlags & 1) {
69114                     return ts.visitEachChild(node, visitor, context);
69115                 }
69116                 return node;
69117             }
69118             switch (node.kind) {
69119                 case 261:
69120                     return visitImportDeclaration(node);
69121                 case 260:
69122                     return visitImportEqualsDeclaration(node);
69123                 case 266:
69124                     return visitExportAssignment(node);
69125                 case 267:
69126                     return visitExportDeclaration(node);
69127                 default:
69128                     ts.Debug.fail("Unhandled ellided statement");
69129             }
69130         }
69131         function namespaceElementVisitor(node) {
69132             return saveStateAndInvoke(node, namespaceElementVisitorWorker);
69133         }
69134         function namespaceElementVisitorWorker(node) {
69135             if (node.kind === 267 ||
69136                 node.kind === 261 ||
69137                 node.kind === 262 ||
69138                 (node.kind === 260 &&
69139                     node.moduleReference.kind === 272)) {
69140                 return undefined;
69141             }
69142             else if (node.transformFlags & 1 || ts.hasSyntacticModifier(node, 1)) {
69143                 return visitTypeScript(node);
69144             }
69145             return node;
69146         }
69147         function classElementVisitor(node) {
69148             return saveStateAndInvoke(node, classElementVisitorWorker);
69149         }
69150         function classElementVisitorWorker(node) {
69151             switch (node.kind) {
69152                 case 166:
69153                     return visitConstructor(node);
69154                 case 163:
69155                     return visitPropertyDeclaration(node);
69156                 case 171:
69157                 case 167:
69158                 case 168:
69159                 case 165:
69160                     return visitorWorker(node);
69161                 case 229:
69162                     return node;
69163                 default:
69164                     return ts.Debug.failBadSyntaxKind(node);
69165             }
69166         }
69167         function modifierVisitor(node) {
69168             if (ts.modifierToFlag(node.kind) & 2270) {
69169                 return undefined;
69170             }
69171             else if (currentNamespace && node.kind === 92) {
69172                 return undefined;
69173             }
69174             return node;
69175         }
69176         function visitTypeScript(node) {
69177             if (ts.isStatement(node) && ts.hasSyntacticModifier(node, 2)) {
69178                 return factory.createNotEmittedStatement(node);
69179             }
69180             switch (node.kind) {
69181                 case 92:
69182                 case 87:
69183                     return currentNamespace ? undefined : node;
69184                 case 122:
69185                 case 120:
69186                 case 121:
69187                 case 125:
69188                 case 84:
69189                 case 133:
69190                 case 142:
69191                 case 178:
69192                 case 179:
69193                 case 180:
69194                 case 181:
69195                 case 177:
69196                 case 172:
69197                 case 159:
69198                 case 128:
69199                 case 152:
69200                 case 131:
69201                 case 147:
69202                 case 144:
69203                 case 141:
69204                 case 113:
69205                 case 148:
69206                 case 175:
69207                 case 174:
69208                 case 176:
69209                 case 173:
69210                 case 182:
69211                 case 183:
69212                 case 184:
69213                 case 186:
69214                 case 187:
69215                 case 188:
69216                 case 189:
69217                 case 190:
69218                 case 191:
69219                 case 171:
69220                 case 161:
69221                 case 254:
69222                     return undefined;
69223                 case 163:
69224                     return visitPropertyDeclaration(node);
69225                 case 259:
69226                     return undefined;
69227                 case 166:
69228                     return visitConstructor(node);
69229                 case 253:
69230                     return factory.createNotEmittedStatement(node);
69231                 case 252:
69232                     return visitClassDeclaration(node);
69233                 case 221:
69234                     return visitClassExpression(node);
69235                 case 286:
69236                     return visitHeritageClause(node);
69237                 case 223:
69238                     return visitExpressionWithTypeArguments(node);
69239                 case 165:
69240                     return visitMethodDeclaration(node);
69241                 case 167:
69242                     return visitGetAccessor(node);
69243                 case 168:
69244                     return visitSetAccessor(node);
69245                 case 251:
69246                     return visitFunctionDeclaration(node);
69247                 case 208:
69248                     return visitFunctionExpression(node);
69249                 case 209:
69250                     return visitArrowFunction(node);
69251                 case 160:
69252                     return visitParameter(node);
69253                 case 207:
69254                     return visitParenthesizedExpression(node);
69255                 case 206:
69256                 case 224:
69257                     return visitAssertionExpression(node);
69258                 case 203:
69259                     return visitCallExpression(node);
69260                 case 204:
69261                     return visitNewExpression(node);
69262                 case 205:
69263                     return visitTaggedTemplateExpression(node);
69264                 case 225:
69265                     return visitNonNullExpression(node);
69266                 case 255:
69267                     return visitEnumDeclaration(node);
69268                 case 232:
69269                     return visitVariableStatement(node);
69270                 case 249:
69271                     return visitVariableDeclaration(node);
69272                 case 256:
69273                     return visitModuleDeclaration(node);
69274                 case 260:
69275                     return visitImportEqualsDeclaration(node);
69276                 case 274:
69277                     return visitJsxSelfClosingElement(node);
69278                 case 275:
69279                     return visitJsxJsxOpeningElement(node);
69280                 default:
69281                     return ts.visitEachChild(node, visitor, context);
69282             }
69283         }
69284         function visitSourceFile(node) {
69285             var alwaysStrict = ts.getStrictOptionValue(compilerOptions, "alwaysStrict") &&
69286                 !(ts.isExternalModule(node) && moduleKind >= ts.ModuleKind.ES2015) &&
69287                 !ts.isJsonSourceFile(node);
69288             return factory.updateSourceFile(node, ts.visitLexicalEnvironment(node.statements, sourceElementVisitor, context, 0, alwaysStrict));
69289         }
69290         function shouldEmitDecorateCallForClass(node) {
69291             if (node.decorators && node.decorators.length > 0) {
69292                 return true;
69293             }
69294             var constructor = ts.getFirstConstructorWithBody(node);
69295             if (constructor) {
69296                 return ts.forEach(constructor.parameters, shouldEmitDecorateCallForParameter);
69297             }
69298             return false;
69299         }
69300         function shouldEmitDecorateCallForParameter(parameter) {
69301             return parameter.decorators !== undefined && parameter.decorators.length > 0;
69302         }
69303         function getClassFacts(node, staticProperties) {
69304             var facts = 0;
69305             if (ts.some(staticProperties))
69306                 facts |= 1;
69307             var extendsClauseElement = ts.getEffectiveBaseTypeNode(node);
69308             if (extendsClauseElement && ts.skipOuterExpressions(extendsClauseElement.expression).kind !== 103)
69309                 facts |= 64;
69310             if (shouldEmitDecorateCallForClass(node))
69311                 facts |= 2;
69312             if (ts.childIsDecorated(node))
69313                 facts |= 4;
69314             if (isExportOfNamespace(node))
69315                 facts |= 8;
69316             else if (isDefaultExternalModuleExport(node))
69317                 facts |= 32;
69318             else if (isNamedExternalModuleExport(node))
69319                 facts |= 16;
69320             if (languageVersion <= 1 && (facts & 7))
69321                 facts |= 128;
69322             return facts;
69323         }
69324         function hasTypeScriptClassSyntax(node) {
69325             return !!(node.transformFlags & 2048);
69326         }
69327         function isClassLikeDeclarationWithTypeScriptSyntax(node) {
69328             return ts.some(node.decorators)
69329                 || ts.some(node.typeParameters)
69330                 || ts.some(node.heritageClauses, hasTypeScriptClassSyntax)
69331                 || ts.some(node.members, hasTypeScriptClassSyntax);
69332         }
69333         function visitClassDeclaration(node) {
69334             if (!isClassLikeDeclarationWithTypeScriptSyntax(node) && !(currentNamespace && ts.hasSyntacticModifier(node, 1))) {
69335                 return ts.visitEachChild(node, visitor, context);
69336             }
69337             var staticProperties = ts.getProperties(node, true, true);
69338             var facts = getClassFacts(node, staticProperties);
69339             if (facts & 128) {
69340                 context.startLexicalEnvironment();
69341             }
69342             var name = node.name || (facts & 5 ? factory.getGeneratedNameForNode(node) : undefined);
69343             var classStatement = facts & 2
69344                 ? createClassDeclarationHeadWithDecorators(node, name)
69345                 : createClassDeclarationHeadWithoutDecorators(node, name, facts);
69346             var statements = [classStatement];
69347             addClassElementDecorationStatements(statements, node, false);
69348             addClassElementDecorationStatements(statements, node, true);
69349             addConstructorDecorationStatement(statements, node);
69350             if (facts & 128) {
69351                 var closingBraceLocation = ts.createTokenRange(ts.skipTrivia(currentSourceFile.text, node.members.end), 19);
69352                 var localName = factory.getInternalName(node);
69353                 var outer = factory.createPartiallyEmittedExpression(localName);
69354                 ts.setTextRangeEnd(outer, closingBraceLocation.end);
69355                 ts.setEmitFlags(outer, 1536);
69356                 var statement = factory.createReturnStatement(outer);
69357                 ts.setTextRangePos(statement, closingBraceLocation.pos);
69358                 ts.setEmitFlags(statement, 1536 | 384);
69359                 statements.push(statement);
69360                 ts.insertStatementsAfterStandardPrologue(statements, context.endLexicalEnvironment());
69361                 var iife = factory.createImmediatelyInvokedArrowFunction(statements);
69362                 ts.setEmitFlags(iife, 33554432);
69363                 var varStatement = factory.createVariableStatement(undefined, factory.createVariableDeclarationList([
69364                     factory.createVariableDeclaration(factory.getLocalName(node, false, false), undefined, undefined, iife)
69365                 ]));
69366                 ts.setOriginalNode(varStatement, node);
69367                 ts.setCommentRange(varStatement, node);
69368                 ts.setSourceMapRange(varStatement, ts.moveRangePastDecorators(node));
69369                 ts.startOnNewLine(varStatement);
69370                 statements = [varStatement];
69371             }
69372             if (facts & 8) {
69373                 addExportMemberAssignment(statements, node);
69374             }
69375             else if (facts & 128 || facts & 2) {
69376                 if (facts & 32) {
69377                     statements.push(factory.createExportDefault(factory.getLocalName(node, false, true)));
69378                 }
69379                 else if (facts & 16) {
69380                     statements.push(factory.createExternalModuleExport(factory.getLocalName(node, false, true)));
69381                 }
69382             }
69383             if (statements.length > 1) {
69384                 statements.push(factory.createEndOfDeclarationMarker(node));
69385                 ts.setEmitFlags(classStatement, ts.getEmitFlags(classStatement) | 4194304);
69386             }
69387             return ts.singleOrMany(statements);
69388         }
69389         function createClassDeclarationHeadWithoutDecorators(node, name, facts) {
69390             var modifiers = !(facts & 128)
69391                 ? ts.visitNodes(node.modifiers, modifierVisitor, ts.isModifier)
69392                 : undefined;
69393             var classDeclaration = factory.createClassDeclaration(undefined, modifiers, name, undefined, ts.visitNodes(node.heritageClauses, visitor, ts.isHeritageClause), transformClassMembers(node));
69394             var emitFlags = ts.getEmitFlags(node);
69395             if (facts & 1) {
69396                 emitFlags |= 32;
69397             }
69398             ts.setTextRange(classDeclaration, node);
69399             ts.setOriginalNode(classDeclaration, node);
69400             ts.setEmitFlags(classDeclaration, emitFlags);
69401             return classDeclaration;
69402         }
69403         function createClassDeclarationHeadWithDecorators(node, name) {
69404             var location = ts.moveRangePastDecorators(node);
69405             var classAlias = getClassAliasIfNeeded(node);
69406             var declName = factory.getLocalName(node, false, true);
69407             var heritageClauses = ts.visitNodes(node.heritageClauses, visitor, ts.isHeritageClause);
69408             var members = transformClassMembers(node);
69409             var classExpression = factory.createClassExpression(undefined, undefined, name, undefined, heritageClauses, members);
69410             ts.setOriginalNode(classExpression, node);
69411             ts.setTextRange(classExpression, location);
69412             var statement = factory.createVariableStatement(undefined, factory.createVariableDeclarationList([
69413                 factory.createVariableDeclaration(declName, undefined, undefined, classAlias ? factory.createAssignment(classAlias, classExpression) : classExpression)
69414             ], 1));
69415             ts.setOriginalNode(statement, node);
69416             ts.setTextRange(statement, location);
69417             ts.setCommentRange(statement, node);
69418             return statement;
69419         }
69420         function visitClassExpression(node) {
69421             if (!isClassLikeDeclarationWithTypeScriptSyntax(node)) {
69422                 return ts.visitEachChild(node, visitor, context);
69423             }
69424             var classExpression = factory.createClassExpression(undefined, undefined, node.name, undefined, ts.visitNodes(node.heritageClauses, visitor, ts.isHeritageClause), transformClassMembers(node));
69425             ts.setOriginalNode(classExpression, node);
69426             ts.setTextRange(classExpression, node);
69427             return classExpression;
69428         }
69429         function transformClassMembers(node) {
69430             var members = [];
69431             var constructor = ts.getFirstConstructorWithBody(node);
69432             var parametersWithPropertyAssignments = constructor &&
69433                 ts.filter(constructor.parameters, function (p) { return ts.isParameterPropertyDeclaration(p, constructor); });
69434             if (parametersWithPropertyAssignments) {
69435                 for (var _i = 0, parametersWithPropertyAssignments_1 = parametersWithPropertyAssignments; _i < parametersWithPropertyAssignments_1.length; _i++) {
69436                     var parameter = parametersWithPropertyAssignments_1[_i];
69437                     if (ts.isIdentifier(parameter.name)) {
69438                         members.push(ts.setOriginalNode(factory.createPropertyDeclaration(undefined, undefined, parameter.name, undefined, undefined, undefined), parameter));
69439                     }
69440                 }
69441             }
69442             ts.addRange(members, ts.visitNodes(node.members, classElementVisitor, ts.isClassElement));
69443             return ts.setTextRange(factory.createNodeArray(members), node.members);
69444         }
69445         function getDecoratedClassElements(node, isStatic) {
69446             return ts.filter(node.members, isStatic ? function (m) { return isStaticDecoratedClassElement(m, node); } : function (m) { return isInstanceDecoratedClassElement(m, node); });
69447         }
69448         function isStaticDecoratedClassElement(member, parent) {
69449             return isDecoratedClassElement(member, true, parent);
69450         }
69451         function isInstanceDecoratedClassElement(member, parent) {
69452             return isDecoratedClassElement(member, false, parent);
69453         }
69454         function isDecoratedClassElement(member, isStatic, parent) {
69455             return ts.nodeOrChildIsDecorated(member, parent)
69456                 && isStatic === ts.hasSyntacticModifier(member, 32);
69457         }
69458         function getDecoratorsOfParameters(node) {
69459             var decorators;
69460             if (node) {
69461                 var parameters = node.parameters;
69462                 var firstParameterIsThis = parameters.length > 0 && ts.parameterIsThisKeyword(parameters[0]);
69463                 var firstParameterOffset = firstParameterIsThis ? 1 : 0;
69464                 var numParameters = firstParameterIsThis ? parameters.length - 1 : parameters.length;
69465                 for (var i = 0; i < numParameters; i++) {
69466                     var parameter = parameters[i + firstParameterOffset];
69467                     if (decorators || parameter.decorators) {
69468                         if (!decorators) {
69469                             decorators = new Array(numParameters);
69470                         }
69471                         decorators[i] = parameter.decorators;
69472                     }
69473                 }
69474             }
69475             return decorators;
69476         }
69477         function getAllDecoratorsOfConstructor(node) {
69478             var decorators = node.decorators;
69479             var parameters = getDecoratorsOfParameters(ts.getFirstConstructorWithBody(node));
69480             if (!decorators && !parameters) {
69481                 return undefined;
69482             }
69483             return {
69484                 decorators: decorators,
69485                 parameters: parameters
69486             };
69487         }
69488         function getAllDecoratorsOfClassElement(node, member) {
69489             switch (member.kind) {
69490                 case 167:
69491                 case 168:
69492                     return getAllDecoratorsOfAccessors(node, member);
69493                 case 165:
69494                     return getAllDecoratorsOfMethod(member);
69495                 case 163:
69496                     return getAllDecoratorsOfProperty(member);
69497                 default:
69498                     return undefined;
69499             }
69500         }
69501         function getAllDecoratorsOfAccessors(node, accessor) {
69502             if (!accessor.body) {
69503                 return undefined;
69504             }
69505             var _a = ts.getAllAccessorDeclarations(node.members, accessor), firstAccessor = _a.firstAccessor, secondAccessor = _a.secondAccessor, setAccessor = _a.setAccessor;
69506             var firstAccessorWithDecorators = firstAccessor.decorators ? firstAccessor : secondAccessor && secondAccessor.decorators ? secondAccessor : undefined;
69507             if (!firstAccessorWithDecorators || accessor !== firstAccessorWithDecorators) {
69508                 return undefined;
69509             }
69510             var decorators = firstAccessorWithDecorators.decorators;
69511             var parameters = getDecoratorsOfParameters(setAccessor);
69512             if (!decorators && !parameters) {
69513                 return undefined;
69514             }
69515             return { decorators: decorators, parameters: parameters };
69516         }
69517         function getAllDecoratorsOfMethod(method) {
69518             if (!method.body) {
69519                 return undefined;
69520             }
69521             var decorators = method.decorators;
69522             var parameters = getDecoratorsOfParameters(method);
69523             if (!decorators && !parameters) {
69524                 return undefined;
69525             }
69526             return { decorators: decorators, parameters: parameters };
69527         }
69528         function getAllDecoratorsOfProperty(property) {
69529             var decorators = property.decorators;
69530             if (!decorators) {
69531                 return undefined;
69532             }
69533             return { decorators: decorators };
69534         }
69535         function transformAllDecoratorsOfDeclaration(node, container, allDecorators) {
69536             if (!allDecorators) {
69537                 return undefined;
69538             }
69539             var decoratorExpressions = [];
69540             ts.addRange(decoratorExpressions, ts.map(allDecorators.decorators, transformDecorator));
69541             ts.addRange(decoratorExpressions, ts.flatMap(allDecorators.parameters, transformDecoratorsOfParameter));
69542             addTypeMetadata(node, container, decoratorExpressions);
69543             return decoratorExpressions;
69544         }
69545         function addClassElementDecorationStatements(statements, node, isStatic) {
69546             ts.addRange(statements, ts.map(generateClassElementDecorationExpressions(node, isStatic), expressionToStatement));
69547         }
69548         function generateClassElementDecorationExpressions(node, isStatic) {
69549             var members = getDecoratedClassElements(node, isStatic);
69550             var expressions;
69551             for (var _i = 0, members_6 = members; _i < members_6.length; _i++) {
69552                 var member = members_6[_i];
69553                 var expression = generateClassElementDecorationExpression(node, member);
69554                 if (expression) {
69555                     if (!expressions) {
69556                         expressions = [expression];
69557                     }
69558                     else {
69559                         expressions.push(expression);
69560                     }
69561                 }
69562             }
69563             return expressions;
69564         }
69565         function generateClassElementDecorationExpression(node, member) {
69566             var allDecorators = getAllDecoratorsOfClassElement(node, member);
69567             var decoratorExpressions = transformAllDecoratorsOfDeclaration(member, node, allDecorators);
69568             if (!decoratorExpressions) {
69569                 return undefined;
69570             }
69571             var prefix = getClassMemberPrefix(node, member);
69572             var memberName = getExpressionForPropertyName(member, true);
69573             var descriptor = languageVersion > 0
69574                 ? member.kind === 163
69575                     ? factory.createVoidZero()
69576                     : factory.createNull()
69577                 : undefined;
69578             var helper = emitHelpers().createDecorateHelper(decoratorExpressions, prefix, memberName, descriptor);
69579             ts.setTextRange(helper, ts.moveRangePastDecorators(member));
69580             ts.setEmitFlags(helper, 1536);
69581             return helper;
69582         }
69583         function addConstructorDecorationStatement(statements, node) {
69584             var expression = generateConstructorDecorationExpression(node);
69585             if (expression) {
69586                 statements.push(ts.setOriginalNode(factory.createExpressionStatement(expression), node));
69587             }
69588         }
69589         function generateConstructorDecorationExpression(node) {
69590             var allDecorators = getAllDecoratorsOfConstructor(node);
69591             var decoratorExpressions = transformAllDecoratorsOfDeclaration(node, node, allDecorators);
69592             if (!decoratorExpressions) {
69593                 return undefined;
69594             }
69595             var classAlias = classAliases && classAliases[ts.getOriginalNodeId(node)];
69596             var localName = factory.getLocalName(node, false, true);
69597             var decorate = emitHelpers().createDecorateHelper(decoratorExpressions, localName);
69598             var expression = factory.createAssignment(localName, classAlias ? factory.createAssignment(classAlias, decorate) : decorate);
69599             ts.setEmitFlags(expression, 1536);
69600             ts.setSourceMapRange(expression, ts.moveRangePastDecorators(node));
69601             return expression;
69602         }
69603         function transformDecorator(decorator) {
69604             return ts.visitNode(decorator.expression, visitor, ts.isExpression);
69605         }
69606         function transformDecoratorsOfParameter(decorators, parameterOffset) {
69607             var expressions;
69608             if (decorators) {
69609                 expressions = [];
69610                 for (var _i = 0, decorators_1 = decorators; _i < decorators_1.length; _i++) {
69611                     var decorator = decorators_1[_i];
69612                     var helper = emitHelpers().createParamHelper(transformDecorator(decorator), parameterOffset);
69613                     ts.setTextRange(helper, decorator.expression);
69614                     ts.setEmitFlags(helper, 1536);
69615                     expressions.push(helper);
69616                 }
69617             }
69618             return expressions;
69619         }
69620         function addTypeMetadata(node, container, decoratorExpressions) {
69621             if (USE_NEW_TYPE_METADATA_FORMAT) {
69622                 addNewTypeMetadata(node, container, decoratorExpressions);
69623             }
69624             else {
69625                 addOldTypeMetadata(node, container, decoratorExpressions);
69626             }
69627         }
69628         function addOldTypeMetadata(node, container, decoratorExpressions) {
69629             if (compilerOptions.emitDecoratorMetadata) {
69630                 if (shouldAddTypeMetadata(node)) {
69631                     decoratorExpressions.push(emitHelpers().createMetadataHelper("design:type", serializeTypeOfNode(node)));
69632                 }
69633                 if (shouldAddParamTypesMetadata(node)) {
69634                     decoratorExpressions.push(emitHelpers().createMetadataHelper("design:paramtypes", serializeParameterTypesOfNode(node, container)));
69635                 }
69636                 if (shouldAddReturnTypeMetadata(node)) {
69637                     decoratorExpressions.push(emitHelpers().createMetadataHelper("design:returntype", serializeReturnTypeOfNode(node)));
69638                 }
69639             }
69640         }
69641         function addNewTypeMetadata(node, container, decoratorExpressions) {
69642             if (compilerOptions.emitDecoratorMetadata) {
69643                 var properties = void 0;
69644                 if (shouldAddTypeMetadata(node)) {
69645                     (properties || (properties = [])).push(factory.createPropertyAssignment("type", factory.createArrowFunction(undefined, undefined, [], undefined, factory.createToken(38), serializeTypeOfNode(node))));
69646                 }
69647                 if (shouldAddParamTypesMetadata(node)) {
69648                     (properties || (properties = [])).push(factory.createPropertyAssignment("paramTypes", factory.createArrowFunction(undefined, undefined, [], undefined, factory.createToken(38), serializeParameterTypesOfNode(node, container))));
69649                 }
69650                 if (shouldAddReturnTypeMetadata(node)) {
69651                     (properties || (properties = [])).push(factory.createPropertyAssignment("returnType", factory.createArrowFunction(undefined, undefined, [], undefined, factory.createToken(38), serializeReturnTypeOfNode(node))));
69652                 }
69653                 if (properties) {
69654                     decoratorExpressions.push(emitHelpers().createMetadataHelper("design:typeinfo", factory.createObjectLiteralExpression(properties, true)));
69655                 }
69656             }
69657         }
69658         function shouldAddTypeMetadata(node) {
69659             var kind = node.kind;
69660             return kind === 165
69661                 || kind === 167
69662                 || kind === 168
69663                 || kind === 163;
69664         }
69665         function shouldAddReturnTypeMetadata(node) {
69666             return node.kind === 165;
69667         }
69668         function shouldAddParamTypesMetadata(node) {
69669             switch (node.kind) {
69670                 case 252:
69671                 case 221:
69672                     return ts.getFirstConstructorWithBody(node) !== undefined;
69673                 case 165:
69674                 case 167:
69675                 case 168:
69676                     return true;
69677             }
69678             return false;
69679         }
69680         function getAccessorTypeNode(node) {
69681             var accessors = resolver.getAllAccessorDeclarations(node);
69682             return accessors.setAccessor && ts.getSetAccessorTypeAnnotationNode(accessors.setAccessor)
69683                 || accessors.getAccessor && ts.getEffectiveReturnTypeNode(accessors.getAccessor);
69684         }
69685         function serializeTypeOfNode(node) {
69686             switch (node.kind) {
69687                 case 163:
69688                 case 160:
69689                     return serializeTypeNode(node.type);
69690                 case 168:
69691                 case 167:
69692                     return serializeTypeNode(getAccessorTypeNode(node));
69693                 case 252:
69694                 case 221:
69695                 case 165:
69696                     return factory.createIdentifier("Function");
69697                 default:
69698                     return factory.createVoidZero();
69699             }
69700         }
69701         function serializeParameterTypesOfNode(node, container) {
69702             var valueDeclaration = ts.isClassLike(node)
69703                 ? ts.getFirstConstructorWithBody(node)
69704                 : ts.isFunctionLike(node) && ts.nodeIsPresent(node.body)
69705                     ? node
69706                     : undefined;
69707             var expressions = [];
69708             if (valueDeclaration) {
69709                 var parameters = getParametersOfDecoratedDeclaration(valueDeclaration, container);
69710                 var numParameters = parameters.length;
69711                 for (var i = 0; i < numParameters; i++) {
69712                     var parameter = parameters[i];
69713                     if (i === 0 && ts.isIdentifier(parameter.name) && parameter.name.escapedText === "this") {
69714                         continue;
69715                     }
69716                     if (parameter.dotDotDotToken) {
69717                         expressions.push(serializeTypeNode(ts.getRestParameterElementType(parameter.type)));
69718                     }
69719                     else {
69720                         expressions.push(serializeTypeOfNode(parameter));
69721                     }
69722                 }
69723             }
69724             return factory.createArrayLiteralExpression(expressions);
69725         }
69726         function getParametersOfDecoratedDeclaration(node, container) {
69727             if (container && node.kind === 167) {
69728                 var setAccessor = ts.getAllAccessorDeclarations(container.members, node).setAccessor;
69729                 if (setAccessor) {
69730                     return setAccessor.parameters;
69731                 }
69732             }
69733             return node.parameters;
69734         }
69735         function serializeReturnTypeOfNode(node) {
69736             if (ts.isFunctionLike(node) && node.type) {
69737                 return serializeTypeNode(node.type);
69738             }
69739             else if (ts.isAsyncFunction(node)) {
69740                 return factory.createIdentifier("Promise");
69741             }
69742             return factory.createVoidZero();
69743         }
69744         function serializeTypeNode(node) {
69745             if (node === undefined) {
69746                 return factory.createIdentifier("Object");
69747             }
69748             switch (node.kind) {
69749                 case 113:
69750                 case 150:
69751                 case 141:
69752                     return factory.createVoidZero();
69753                 case 186:
69754                     return serializeTypeNode(node.type);
69755                 case 174:
69756                 case 175:
69757                     return factory.createIdentifier("Function");
69758                 case 178:
69759                 case 179:
69760                     return factory.createIdentifier("Array");
69761                 case 172:
69762                 case 131:
69763                     return factory.createIdentifier("Boolean");
69764                 case 147:
69765                     return factory.createIdentifier("String");
69766                 case 145:
69767                     return factory.createIdentifier("Object");
69768                 case 191:
69769                     switch (node.literal.kind) {
69770                         case 10:
69771                         case 14:
69772                             return factory.createIdentifier("String");
69773                         case 214:
69774                         case 8:
69775                             return factory.createIdentifier("Number");
69776                         case 9:
69777                             return getGlobalBigIntNameWithFallback();
69778                         case 109:
69779                         case 94:
69780                             return factory.createIdentifier("Boolean");
69781                         case 103:
69782                             return factory.createVoidZero();
69783                         default:
69784                             return ts.Debug.failBadSyntaxKind(node.literal);
69785                     }
69786                 case 144:
69787                     return factory.createIdentifier("Number");
69788                 case 155:
69789                     return getGlobalBigIntNameWithFallback();
69790                 case 148:
69791                     return languageVersion < 2
69792                         ? getGlobalSymbolNameWithFallback()
69793                         : factory.createIdentifier("Symbol");
69794                 case 173:
69795                     return serializeTypeReferenceNode(node);
69796                 case 183:
69797                 case 182:
69798                     return serializeTypeList(node.types);
69799                 case 184:
69800                     return serializeTypeList([node.trueType, node.falseType]);
69801                 case 188:
69802                     if (node.operator === 142) {
69803                         return serializeTypeNode(node.type);
69804                     }
69805                     break;
69806                 case 176:
69807                 case 189:
69808                 case 190:
69809                 case 177:
69810                 case 128:
69811                 case 152:
69812                 case 187:
69813                 case 195:
69814                     break;
69815                 case 303:
69816                 case 304:
69817                 case 308:
69818                 case 309:
69819                 case 310:
69820                     break;
69821                 case 305:
69822                 case 306:
69823                 case 307:
69824                     return serializeTypeNode(node.type);
69825                 default:
69826                     return ts.Debug.failBadSyntaxKind(node);
69827             }
69828             return factory.createIdentifier("Object");
69829         }
69830         function serializeTypeList(types) {
69831             var serializedUnion;
69832             for (var _i = 0, types_22 = types; _i < types_22.length; _i++) {
69833                 var typeNode = types_22[_i];
69834                 while (typeNode.kind === 186) {
69835                     typeNode = typeNode.type;
69836                 }
69837                 if (typeNode.kind === 141) {
69838                     continue;
69839                 }
69840                 if (!strictNullChecks && (typeNode.kind === 191 && typeNode.literal.kind === 103 || typeNode.kind === 150)) {
69841                     continue;
69842                 }
69843                 var serializedIndividual = serializeTypeNode(typeNode);
69844                 if (ts.isIdentifier(serializedIndividual) && serializedIndividual.escapedText === "Object") {
69845                     return serializedIndividual;
69846                 }
69847                 else if (serializedUnion) {
69848                     if (!ts.isIdentifier(serializedUnion) ||
69849                         !ts.isIdentifier(serializedIndividual) ||
69850                         serializedUnion.escapedText !== serializedIndividual.escapedText) {
69851                         return factory.createIdentifier("Object");
69852                     }
69853                 }
69854                 else {
69855                     serializedUnion = serializedIndividual;
69856                 }
69857             }
69858             return serializedUnion || factory.createVoidZero();
69859         }
69860         function serializeTypeReferenceNode(node) {
69861             var kind = resolver.getTypeReferenceSerializationKind(node.typeName, currentNameScope || currentLexicalScope);
69862             switch (kind) {
69863                 case ts.TypeReferenceSerializationKind.Unknown:
69864                     if (ts.findAncestor(node, function (n) { return n.parent && ts.isConditionalTypeNode(n.parent) && (n.parent.trueType === n || n.parent.falseType === n); })) {
69865                         return factory.createIdentifier("Object");
69866                     }
69867                     var serialized = serializeEntityNameAsExpressionFallback(node.typeName);
69868                     var temp = factory.createTempVariable(hoistVariableDeclaration);
69869                     return factory.createConditionalExpression(factory.createTypeCheck(factory.createAssignment(temp, serialized), "function"), undefined, temp, undefined, factory.createIdentifier("Object"));
69870                 case ts.TypeReferenceSerializationKind.TypeWithConstructSignatureAndValue:
69871                     return serializeEntityNameAsExpression(node.typeName);
69872                 case ts.TypeReferenceSerializationKind.VoidNullableOrNeverType:
69873                     return factory.createVoidZero();
69874                 case ts.TypeReferenceSerializationKind.BigIntLikeType:
69875                     return getGlobalBigIntNameWithFallback();
69876                 case ts.TypeReferenceSerializationKind.BooleanType:
69877                     return factory.createIdentifier("Boolean");
69878                 case ts.TypeReferenceSerializationKind.NumberLikeType:
69879                     return factory.createIdentifier("Number");
69880                 case ts.TypeReferenceSerializationKind.StringLikeType:
69881                     return factory.createIdentifier("String");
69882                 case ts.TypeReferenceSerializationKind.ArrayLikeType:
69883                     return factory.createIdentifier("Array");
69884                 case ts.TypeReferenceSerializationKind.ESSymbolType:
69885                     return languageVersion < 2
69886                         ? getGlobalSymbolNameWithFallback()
69887                         : factory.createIdentifier("Symbol");
69888                 case ts.TypeReferenceSerializationKind.TypeWithCallSignature:
69889                     return factory.createIdentifier("Function");
69890                 case ts.TypeReferenceSerializationKind.Promise:
69891                     return factory.createIdentifier("Promise");
69892                 case ts.TypeReferenceSerializationKind.ObjectType:
69893                     return factory.createIdentifier("Object");
69894                 default:
69895                     return ts.Debug.assertNever(kind);
69896             }
69897         }
69898         function createCheckedValue(left, right) {
69899             return factory.createLogicalAnd(factory.createStrictInequality(factory.createTypeOfExpression(left), factory.createStringLiteral("undefined")), right);
69900         }
69901         function serializeEntityNameAsExpressionFallback(node) {
69902             if (node.kind === 78) {
69903                 var copied = serializeEntityNameAsExpression(node);
69904                 return createCheckedValue(copied, copied);
69905             }
69906             if (node.left.kind === 78) {
69907                 return createCheckedValue(serializeEntityNameAsExpression(node.left), serializeEntityNameAsExpression(node));
69908             }
69909             var left = serializeEntityNameAsExpressionFallback(node.left);
69910             var temp = factory.createTempVariable(hoistVariableDeclaration);
69911             return factory.createLogicalAnd(factory.createLogicalAnd(left.left, factory.createStrictInequality(factory.createAssignment(temp, left.right), factory.createVoidZero())), factory.createPropertyAccessExpression(temp, node.right));
69912         }
69913         function serializeEntityNameAsExpression(node) {
69914             switch (node.kind) {
69915                 case 78:
69916                     var name = ts.setParent(ts.setTextRange(ts.parseNodeFactory.cloneNode(node), node), node.parent);
69917                     name.original = undefined;
69918                     ts.setParent(name, ts.getParseTreeNode(currentLexicalScope));
69919                     return name;
69920                 case 157:
69921                     return serializeQualifiedNameAsExpression(node);
69922             }
69923         }
69924         function serializeQualifiedNameAsExpression(node) {
69925             return factory.createPropertyAccessExpression(serializeEntityNameAsExpression(node.left), node.right);
69926         }
69927         function getGlobalSymbolNameWithFallback() {
69928             return factory.createConditionalExpression(factory.createTypeCheck(factory.createIdentifier("Symbol"), "function"), undefined, factory.createIdentifier("Symbol"), undefined, factory.createIdentifier("Object"));
69929         }
69930         function getGlobalBigIntNameWithFallback() {
69931             return languageVersion < 99
69932                 ? factory.createConditionalExpression(factory.createTypeCheck(factory.createIdentifier("BigInt"), "function"), undefined, factory.createIdentifier("BigInt"), undefined, factory.createIdentifier("Object"))
69933                 : factory.createIdentifier("BigInt");
69934         }
69935         function getExpressionForPropertyName(member, generateNameForComputedPropertyName) {
69936             var name = member.name;
69937             if (ts.isPrivateIdentifier(name)) {
69938                 return factory.createIdentifier("");
69939             }
69940             else if (ts.isComputedPropertyName(name)) {
69941                 return generateNameForComputedPropertyName && !ts.isSimpleInlineableExpression(name.expression)
69942                     ? factory.getGeneratedNameForNode(name)
69943                     : name.expression;
69944             }
69945             else if (ts.isIdentifier(name)) {
69946                 return factory.createStringLiteral(ts.idText(name));
69947             }
69948             else {
69949                 return factory.cloneNode(name);
69950             }
69951         }
69952         function visitPropertyNameOfClassElement(member) {
69953             var name = member.name;
69954             if (ts.isComputedPropertyName(name) && ((!ts.hasStaticModifier(member) && currentClassHasParameterProperties) || ts.some(member.decorators))) {
69955                 var expression = ts.visitNode(name.expression, visitor, ts.isExpression);
69956                 var innerExpression = ts.skipPartiallyEmittedExpressions(expression);
69957                 if (!ts.isSimpleInlineableExpression(innerExpression)) {
69958                     var generatedName = factory.getGeneratedNameForNode(name);
69959                     hoistVariableDeclaration(generatedName);
69960                     return factory.updateComputedPropertyName(name, factory.createAssignment(generatedName, expression));
69961                 }
69962             }
69963             return ts.visitNode(name, visitor, ts.isPropertyName);
69964         }
69965         function visitHeritageClause(node) {
69966             if (node.token === 116) {
69967                 return undefined;
69968             }
69969             return ts.visitEachChild(node, visitor, context);
69970         }
69971         function visitExpressionWithTypeArguments(node) {
69972             return factory.updateExpressionWithTypeArguments(node, ts.visitNode(node.expression, visitor, ts.isLeftHandSideExpression), undefined);
69973         }
69974         function shouldEmitFunctionLikeDeclaration(node) {
69975             return !ts.nodeIsMissing(node.body);
69976         }
69977         function visitPropertyDeclaration(node) {
69978             if (node.flags & 8388608) {
69979                 return undefined;
69980             }
69981             var updated = factory.updatePropertyDeclaration(node, undefined, ts.visitNodes(node.modifiers, visitor, ts.isModifier), visitPropertyNameOfClassElement(node), undefined, undefined, ts.visitNode(node.initializer, visitor));
69982             if (updated !== node) {
69983                 ts.setCommentRange(updated, node);
69984                 ts.setSourceMapRange(updated, ts.moveRangePastDecorators(node));
69985             }
69986             return updated;
69987         }
69988         function visitConstructor(node) {
69989             if (!shouldEmitFunctionLikeDeclaration(node)) {
69990                 return undefined;
69991             }
69992             return factory.updateConstructorDeclaration(node, undefined, undefined, ts.visitParameterList(node.parameters, visitor, context), transformConstructorBody(node.body, node));
69993         }
69994         function transformConstructorBody(body, constructor) {
69995             var parametersWithPropertyAssignments = constructor &&
69996                 ts.filter(constructor.parameters, function (p) { return ts.isParameterPropertyDeclaration(p, constructor); });
69997             if (!ts.some(parametersWithPropertyAssignments)) {
69998                 return ts.visitFunctionBody(body, visitor, context);
69999             }
70000             var statements = [];
70001             var indexOfFirstStatement = 0;
70002             resumeLexicalEnvironment();
70003             indexOfFirstStatement = ts.addPrologueDirectivesAndInitialSuperCall(factory, constructor, statements, visitor);
70004             ts.addRange(statements, ts.map(parametersWithPropertyAssignments, transformParameterWithPropertyAssignment));
70005             ts.addRange(statements, ts.visitNodes(body.statements, visitor, ts.isStatement, indexOfFirstStatement));
70006             statements = factory.mergeLexicalEnvironment(statements, endLexicalEnvironment());
70007             var block = factory.createBlock(ts.setTextRange(factory.createNodeArray(statements), body.statements), true);
70008             ts.setTextRange(block, body);
70009             ts.setOriginalNode(block, body);
70010             return block;
70011         }
70012         function transformParameterWithPropertyAssignment(node) {
70013             var name = node.name;
70014             if (!ts.isIdentifier(name)) {
70015                 return undefined;
70016             }
70017             var propertyName = ts.setParent(ts.setTextRange(factory.cloneNode(name), name), name.parent);
70018             ts.setEmitFlags(propertyName, 1536 | 48);
70019             var localName = ts.setParent(ts.setTextRange(factory.cloneNode(name), name), name.parent);
70020             ts.setEmitFlags(localName, 1536);
70021             return ts.startOnNewLine(ts.removeAllComments(ts.setTextRange(ts.setOriginalNode(factory.createExpressionStatement(factory.createAssignment(ts.setTextRange(factory.createPropertyAccessExpression(factory.createThis(), propertyName), node.name), localName)), node), ts.moveRangePos(node, -1))));
70022         }
70023         function visitMethodDeclaration(node) {
70024             if (!shouldEmitFunctionLikeDeclaration(node)) {
70025                 return undefined;
70026             }
70027             var updated = factory.updateMethodDeclaration(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));
70028             if (updated !== node) {
70029                 ts.setCommentRange(updated, node);
70030                 ts.setSourceMapRange(updated, ts.moveRangePastDecorators(node));
70031             }
70032             return updated;
70033         }
70034         function shouldEmitAccessorDeclaration(node) {
70035             return !(ts.nodeIsMissing(node.body) && ts.hasSyntacticModifier(node, 128));
70036         }
70037         function visitGetAccessor(node) {
70038             if (!shouldEmitAccessorDeclaration(node)) {
70039                 return undefined;
70040             }
70041             var updated = factory.updateGetAccessorDeclaration(node, undefined, ts.visitNodes(node.modifiers, modifierVisitor, ts.isModifier), visitPropertyNameOfClassElement(node), ts.visitParameterList(node.parameters, visitor, context), undefined, ts.visitFunctionBody(node.body, visitor, context) || factory.createBlock([]));
70042             if (updated !== node) {
70043                 ts.setCommentRange(updated, node);
70044                 ts.setSourceMapRange(updated, ts.moveRangePastDecorators(node));
70045             }
70046             return updated;
70047         }
70048         function visitSetAccessor(node) {
70049             if (!shouldEmitAccessorDeclaration(node)) {
70050                 return undefined;
70051             }
70052             var updated = factory.updateSetAccessorDeclaration(node, undefined, ts.visitNodes(node.modifiers, modifierVisitor, ts.isModifier), visitPropertyNameOfClassElement(node), ts.visitParameterList(node.parameters, visitor, context), ts.visitFunctionBody(node.body, visitor, context) || factory.createBlock([]));
70053             if (updated !== node) {
70054                 ts.setCommentRange(updated, node);
70055                 ts.setSourceMapRange(updated, ts.moveRangePastDecorators(node));
70056             }
70057             return updated;
70058         }
70059         function visitFunctionDeclaration(node) {
70060             if (!shouldEmitFunctionLikeDeclaration(node)) {
70061                 return factory.createNotEmittedStatement(node);
70062             }
70063             var updated = factory.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) || factory.createBlock([]));
70064             if (isExportOfNamespace(node)) {
70065                 var statements = [updated];
70066                 addExportMemberAssignment(statements, node);
70067                 return statements;
70068             }
70069             return updated;
70070         }
70071         function visitFunctionExpression(node) {
70072             if (!shouldEmitFunctionLikeDeclaration(node)) {
70073                 return factory.createOmittedExpression();
70074             }
70075             var updated = factory.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) || factory.createBlock([]));
70076             return updated;
70077         }
70078         function visitArrowFunction(node) {
70079             var updated = factory.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));
70080             return updated;
70081         }
70082         function visitParameter(node) {
70083             if (ts.parameterIsThisKeyword(node)) {
70084                 return undefined;
70085             }
70086             var updated = factory.updateParameterDeclaration(node, undefined, undefined, node.dotDotDotToken, ts.visitNode(node.name, visitor, ts.isBindingName), undefined, undefined, ts.visitNode(node.initializer, visitor, ts.isExpression));
70087             if (updated !== node) {
70088                 ts.setCommentRange(updated, node);
70089                 ts.setTextRange(updated, ts.moveRangePastModifiers(node));
70090                 ts.setSourceMapRange(updated, ts.moveRangePastModifiers(node));
70091                 ts.setEmitFlags(updated.name, 32);
70092             }
70093             return updated;
70094         }
70095         function visitVariableStatement(node) {
70096             if (isExportOfNamespace(node)) {
70097                 var variables = ts.getInitializedVariables(node.declarationList);
70098                 if (variables.length === 0) {
70099                     return undefined;
70100                 }
70101                 return ts.setTextRange(factory.createExpressionStatement(factory.inlineExpressions(ts.map(variables, transformInitializedVariable))), node);
70102             }
70103             else {
70104                 return ts.visitEachChild(node, visitor, context);
70105             }
70106         }
70107         function transformInitializedVariable(node) {
70108             var name = node.name;
70109             if (ts.isBindingPattern(name)) {
70110                 return ts.flattenDestructuringAssignment(node, visitor, context, 0, false, createNamespaceExportExpression);
70111             }
70112             else {
70113                 return ts.setTextRange(factory.createAssignment(getNamespaceMemberNameWithSourceMapsAndWithoutComments(name), ts.visitNode(node.initializer, visitor, ts.isExpression)), node);
70114             }
70115         }
70116         function visitVariableDeclaration(node) {
70117             return factory.updateVariableDeclaration(node, ts.visitNode(node.name, visitor, ts.isBindingName), undefined, undefined, ts.visitNode(node.initializer, visitor, ts.isExpression));
70118         }
70119         function visitParenthesizedExpression(node) {
70120             var innerExpression = ts.skipOuterExpressions(node.expression, ~6);
70121             if (ts.isAssertionExpression(innerExpression)) {
70122                 var expression = ts.visitNode(node.expression, visitor, ts.isExpression);
70123                 if (ts.length(ts.getLeadingCommentRangesOfNode(expression, currentSourceFile))) {
70124                     return factory.updateParenthesizedExpression(node, expression);
70125                 }
70126                 return factory.createPartiallyEmittedExpression(expression, node);
70127             }
70128             return ts.visitEachChild(node, visitor, context);
70129         }
70130         function visitAssertionExpression(node) {
70131             var expression = ts.visitNode(node.expression, visitor, ts.isExpression);
70132             return factory.createPartiallyEmittedExpression(expression, node);
70133         }
70134         function visitNonNullExpression(node) {
70135             var expression = ts.visitNode(node.expression, visitor, ts.isLeftHandSideExpression);
70136             return factory.createPartiallyEmittedExpression(expression, node);
70137         }
70138         function visitCallExpression(node) {
70139             return factory.updateCallExpression(node, ts.visitNode(node.expression, visitor, ts.isExpression), undefined, ts.visitNodes(node.arguments, visitor, ts.isExpression));
70140         }
70141         function visitNewExpression(node) {
70142             return factory.updateNewExpression(node, ts.visitNode(node.expression, visitor, ts.isExpression), undefined, ts.visitNodes(node.arguments, visitor, ts.isExpression));
70143         }
70144         function visitTaggedTemplateExpression(node) {
70145             return factory.updateTaggedTemplateExpression(node, ts.visitNode(node.tag, visitor, ts.isExpression), undefined, ts.visitNode(node.template, visitor, ts.isExpression));
70146         }
70147         function visitJsxSelfClosingElement(node) {
70148             return factory.updateJsxSelfClosingElement(node, ts.visitNode(node.tagName, visitor, ts.isJsxTagNameExpression), undefined, ts.visitNode(node.attributes, visitor, ts.isJsxAttributes));
70149         }
70150         function visitJsxJsxOpeningElement(node) {
70151             return factory.updateJsxOpeningElement(node, ts.visitNode(node.tagName, visitor, ts.isJsxTagNameExpression), undefined, ts.visitNode(node.attributes, visitor, ts.isJsxAttributes));
70152         }
70153         function shouldEmitEnumDeclaration(node) {
70154             return !ts.isEnumConst(node)
70155                 || compilerOptions.preserveConstEnums
70156                 || compilerOptions.isolatedModules;
70157         }
70158         function visitEnumDeclaration(node) {
70159             if (!shouldEmitEnumDeclaration(node)) {
70160                 return factory.createNotEmittedStatement(node);
70161             }
70162             var statements = [];
70163             var emitFlags = 2;
70164             var varAdded = addVarForEnumOrModuleDeclaration(statements, node);
70165             if (varAdded) {
70166                 if (moduleKind !== ts.ModuleKind.System || currentLexicalScope !== currentSourceFile) {
70167                     emitFlags |= 512;
70168                 }
70169             }
70170             var parameterName = getNamespaceParameterName(node);
70171             var containerName = getNamespaceContainerName(node);
70172             var exportName = ts.hasSyntacticModifier(node, 1)
70173                 ? factory.getExternalModuleOrNamespaceExportName(currentNamespaceContainerName, node, false, true)
70174                 : factory.getLocalName(node, false, true);
70175             var moduleArg = factory.createLogicalOr(exportName, factory.createAssignment(exportName, factory.createObjectLiteralExpression()));
70176             if (hasNamespaceQualifiedExportName(node)) {
70177                 var localName = factory.getLocalName(node, false, true);
70178                 moduleArg = factory.createAssignment(localName, moduleArg);
70179             }
70180             var enumStatement = factory.createExpressionStatement(factory.createCallExpression(factory.createFunctionExpression(undefined, undefined, undefined, undefined, [factory.createParameterDeclaration(undefined, undefined, undefined, parameterName)], undefined, transformEnumBody(node, containerName)), undefined, [moduleArg]));
70181             ts.setOriginalNode(enumStatement, node);
70182             if (varAdded) {
70183                 ts.setSyntheticLeadingComments(enumStatement, undefined);
70184                 ts.setSyntheticTrailingComments(enumStatement, undefined);
70185             }
70186             ts.setTextRange(enumStatement, node);
70187             ts.addEmitFlags(enumStatement, emitFlags);
70188             statements.push(enumStatement);
70189             statements.push(factory.createEndOfDeclarationMarker(node));
70190             return statements;
70191         }
70192         function transformEnumBody(node, localName) {
70193             var savedCurrentNamespaceLocalName = currentNamespaceContainerName;
70194             currentNamespaceContainerName = localName;
70195             var statements = [];
70196             startLexicalEnvironment();
70197             var members = ts.map(node.members, transformEnumMember);
70198             ts.insertStatementsAfterStandardPrologue(statements, endLexicalEnvironment());
70199             ts.addRange(statements, members);
70200             currentNamespaceContainerName = savedCurrentNamespaceLocalName;
70201             return factory.createBlock(ts.setTextRange(factory.createNodeArray(statements), node.members), true);
70202         }
70203         function transformEnumMember(member) {
70204             var name = getExpressionForPropertyName(member, false);
70205             var valueExpression = transformEnumMemberDeclarationValue(member);
70206             var innerAssignment = factory.createAssignment(factory.createElementAccessExpression(currentNamespaceContainerName, name), valueExpression);
70207             var outerAssignment = valueExpression.kind === 10 ?
70208                 innerAssignment :
70209                 factory.createAssignment(factory.createElementAccessExpression(currentNamespaceContainerName, innerAssignment), name);
70210             return ts.setTextRange(factory.createExpressionStatement(ts.setTextRange(outerAssignment, member)), member);
70211         }
70212         function transformEnumMemberDeclarationValue(member) {
70213             var value = resolver.getConstantValue(member);
70214             if (value !== undefined) {
70215                 return typeof value === "string" ? factory.createStringLiteral(value) : factory.createNumericLiteral(value);
70216             }
70217             else {
70218                 enableSubstitutionForNonQualifiedEnumMembers();
70219                 if (member.initializer) {
70220                     return ts.visitNode(member.initializer, visitor, ts.isExpression);
70221                 }
70222                 else {
70223                     return factory.createVoidZero();
70224                 }
70225             }
70226         }
70227         function shouldEmitModuleDeclaration(nodeIn) {
70228             var node = ts.getParseTreeNode(nodeIn, ts.isModuleDeclaration);
70229             if (!node) {
70230                 return true;
70231             }
70232             return ts.isInstantiatedModule(node, !!compilerOptions.preserveConstEnums || !!compilerOptions.isolatedModules);
70233         }
70234         function hasNamespaceQualifiedExportName(node) {
70235             return isExportOfNamespace(node)
70236                 || (isExternalModuleExport(node)
70237                     && moduleKind !== ts.ModuleKind.ES2015
70238                     && moduleKind !== ts.ModuleKind.ES2020
70239                     && moduleKind !== ts.ModuleKind.ESNext
70240                     && moduleKind !== ts.ModuleKind.System);
70241         }
70242         function recordEmittedDeclarationInScope(node) {
70243             if (!currentScopeFirstDeclarationsOfName) {
70244                 currentScopeFirstDeclarationsOfName = new ts.Map();
70245             }
70246             var name = declaredNameInScope(node);
70247             if (!currentScopeFirstDeclarationsOfName.has(name)) {
70248                 currentScopeFirstDeclarationsOfName.set(name, node);
70249             }
70250         }
70251         function isFirstEmittedDeclarationInScope(node) {
70252             if (currentScopeFirstDeclarationsOfName) {
70253                 var name = declaredNameInScope(node);
70254                 return currentScopeFirstDeclarationsOfName.get(name) === node;
70255             }
70256             return true;
70257         }
70258         function declaredNameInScope(node) {
70259             ts.Debug.assertNode(node.name, ts.isIdentifier);
70260             return node.name.escapedText;
70261         }
70262         function addVarForEnumOrModuleDeclaration(statements, node) {
70263             var statement = factory.createVariableStatement(ts.visitNodes(node.modifiers, modifierVisitor, ts.isModifier), factory.createVariableDeclarationList([
70264                 factory.createVariableDeclaration(factory.getLocalName(node, false, true))
70265             ], currentLexicalScope.kind === 297 ? 0 : 1));
70266             ts.setOriginalNode(statement, node);
70267             recordEmittedDeclarationInScope(node);
70268             if (isFirstEmittedDeclarationInScope(node)) {
70269                 if (node.kind === 255) {
70270                     ts.setSourceMapRange(statement.declarationList, node);
70271                 }
70272                 else {
70273                     ts.setSourceMapRange(statement, node);
70274                 }
70275                 ts.setCommentRange(statement, node);
70276                 ts.addEmitFlags(statement, 1024 | 4194304);
70277                 statements.push(statement);
70278                 return true;
70279             }
70280             else {
70281                 var mergeMarker = factory.createMergeDeclarationMarker(statement);
70282                 ts.setEmitFlags(mergeMarker, 1536 | 4194304);
70283                 statements.push(mergeMarker);
70284                 return false;
70285             }
70286         }
70287         function visitModuleDeclaration(node) {
70288             if (!shouldEmitModuleDeclaration(node)) {
70289                 return factory.createNotEmittedStatement(node);
70290             }
70291             ts.Debug.assertNode(node.name, ts.isIdentifier, "A TypeScript namespace should have an Identifier name.");
70292             enableSubstitutionForNamespaceExports();
70293             var statements = [];
70294             var emitFlags = 2;
70295             var varAdded = addVarForEnumOrModuleDeclaration(statements, node);
70296             if (varAdded) {
70297                 if (moduleKind !== ts.ModuleKind.System || currentLexicalScope !== currentSourceFile) {
70298                     emitFlags |= 512;
70299                 }
70300             }
70301             var parameterName = getNamespaceParameterName(node);
70302             var containerName = getNamespaceContainerName(node);
70303             var exportName = ts.hasSyntacticModifier(node, 1)
70304                 ? factory.getExternalModuleOrNamespaceExportName(currentNamespaceContainerName, node, false, true)
70305                 : factory.getLocalName(node, false, true);
70306             var moduleArg = factory.createLogicalOr(exportName, factory.createAssignment(exportName, factory.createObjectLiteralExpression()));
70307             if (hasNamespaceQualifiedExportName(node)) {
70308                 var localName = factory.getLocalName(node, false, true);
70309                 moduleArg = factory.createAssignment(localName, moduleArg);
70310             }
70311             var moduleStatement = factory.createExpressionStatement(factory.createCallExpression(factory.createFunctionExpression(undefined, undefined, undefined, undefined, [factory.createParameterDeclaration(undefined, undefined, undefined, parameterName)], undefined, transformModuleBody(node, containerName)), undefined, [moduleArg]));
70312             ts.setOriginalNode(moduleStatement, node);
70313             if (varAdded) {
70314                 ts.setSyntheticLeadingComments(moduleStatement, undefined);
70315                 ts.setSyntheticTrailingComments(moduleStatement, undefined);
70316             }
70317             ts.setTextRange(moduleStatement, node);
70318             ts.addEmitFlags(moduleStatement, emitFlags);
70319             statements.push(moduleStatement);
70320             statements.push(factory.createEndOfDeclarationMarker(node));
70321             return statements;
70322         }
70323         function transformModuleBody(node, namespaceLocalName) {
70324             var savedCurrentNamespaceContainerName = currentNamespaceContainerName;
70325             var savedCurrentNamespace = currentNamespace;
70326             var savedCurrentScopeFirstDeclarationsOfName = currentScopeFirstDeclarationsOfName;
70327             currentNamespaceContainerName = namespaceLocalName;
70328             currentNamespace = node;
70329             currentScopeFirstDeclarationsOfName = undefined;
70330             var statements = [];
70331             startLexicalEnvironment();
70332             var statementsLocation;
70333             var blockLocation;
70334             if (node.body) {
70335                 if (node.body.kind === 257) {
70336                     saveStateAndInvoke(node.body, function (body) { return ts.addRange(statements, ts.visitNodes(body.statements, namespaceElementVisitor, ts.isStatement)); });
70337                     statementsLocation = node.body.statements;
70338                     blockLocation = node.body;
70339                 }
70340                 else {
70341                     var result = visitModuleDeclaration(node.body);
70342                     if (result) {
70343                         if (ts.isArray(result)) {
70344                             ts.addRange(statements, result);
70345                         }
70346                         else {
70347                             statements.push(result);
70348                         }
70349                     }
70350                     var moduleBlock = getInnerMostModuleDeclarationFromDottedModule(node).body;
70351                     statementsLocation = ts.moveRangePos(moduleBlock.statements, -1);
70352                 }
70353             }
70354             ts.insertStatementsAfterStandardPrologue(statements, endLexicalEnvironment());
70355             currentNamespaceContainerName = savedCurrentNamespaceContainerName;
70356             currentNamespace = savedCurrentNamespace;
70357             currentScopeFirstDeclarationsOfName = savedCurrentScopeFirstDeclarationsOfName;
70358             var block = factory.createBlock(ts.setTextRange(factory.createNodeArray(statements), statementsLocation), true);
70359             ts.setTextRange(block, blockLocation);
70360             if (!node.body || node.body.kind !== 257) {
70361                 ts.setEmitFlags(block, ts.getEmitFlags(block) | 1536);
70362             }
70363             return block;
70364         }
70365         function getInnerMostModuleDeclarationFromDottedModule(moduleDeclaration) {
70366             if (moduleDeclaration.body.kind === 256) {
70367                 var recursiveInnerModule = getInnerMostModuleDeclarationFromDottedModule(moduleDeclaration.body);
70368                 return recursiveInnerModule || moduleDeclaration.body;
70369             }
70370         }
70371         function visitImportDeclaration(node) {
70372             if (!node.importClause) {
70373                 return node;
70374             }
70375             if (node.importClause.isTypeOnly) {
70376                 return undefined;
70377             }
70378             var importClause = ts.visitNode(node.importClause, visitImportClause, ts.isImportClause);
70379             return importClause ||
70380                 compilerOptions.importsNotUsedAsValues === 1 ||
70381                 compilerOptions.importsNotUsedAsValues === 2
70382                 ? factory.updateImportDeclaration(node, undefined, undefined, importClause, node.moduleSpecifier)
70383                 : undefined;
70384         }
70385         function visitImportClause(node) {
70386             if (node.isTypeOnly) {
70387                 return undefined;
70388             }
70389             var name = resolver.isReferencedAliasDeclaration(node) ? node.name : undefined;
70390             var namedBindings = ts.visitNode(node.namedBindings, visitNamedImportBindings, ts.isNamedImportBindings);
70391             return (name || namedBindings) ? factory.updateImportClause(node, false, name, namedBindings) : undefined;
70392         }
70393         function visitNamedImportBindings(node) {
70394             if (node.kind === 263) {
70395                 return resolver.isReferencedAliasDeclaration(node) ? node : undefined;
70396             }
70397             else {
70398                 var elements = ts.visitNodes(node.elements, visitImportSpecifier, ts.isImportSpecifier);
70399                 return ts.some(elements) ? factory.updateNamedImports(node, elements) : undefined;
70400             }
70401         }
70402         function visitImportSpecifier(node) {
70403             return resolver.isReferencedAliasDeclaration(node) ? node : undefined;
70404         }
70405         function visitExportAssignment(node) {
70406             return resolver.isValueAliasDeclaration(node)
70407                 ? ts.visitEachChild(node, visitor, context)
70408                 : undefined;
70409         }
70410         function visitExportDeclaration(node) {
70411             if (node.isTypeOnly) {
70412                 return undefined;
70413             }
70414             if (!node.exportClause || ts.isNamespaceExport(node.exportClause)) {
70415                 return node;
70416             }
70417             if (!resolver.isValueAliasDeclaration(node)) {
70418                 return undefined;
70419             }
70420             var exportClause = ts.visitNode(node.exportClause, visitNamedExportBindings, ts.isNamedExportBindings);
70421             return exportClause
70422                 ? factory.updateExportDeclaration(node, undefined, undefined, node.isTypeOnly, exportClause, node.moduleSpecifier)
70423                 : undefined;
70424         }
70425         function visitNamedExports(node) {
70426             var elements = ts.visitNodes(node.elements, visitExportSpecifier, ts.isExportSpecifier);
70427             return ts.some(elements) ? factory.updateNamedExports(node, elements) : undefined;
70428         }
70429         function visitNamespaceExports(node) {
70430             return factory.updateNamespaceExport(node, ts.visitNode(node.name, visitor, ts.isIdentifier));
70431         }
70432         function visitNamedExportBindings(node) {
70433             return ts.isNamespaceExport(node) ? visitNamespaceExports(node) : visitNamedExports(node);
70434         }
70435         function visitExportSpecifier(node) {
70436             return resolver.isValueAliasDeclaration(node) ? node : undefined;
70437         }
70438         function shouldEmitImportEqualsDeclaration(node) {
70439             return resolver.isReferencedAliasDeclaration(node)
70440                 || (!ts.isExternalModule(currentSourceFile)
70441                     && resolver.isTopLevelValueImportEqualsWithEntityName(node));
70442         }
70443         function visitImportEqualsDeclaration(node) {
70444             if (ts.isExternalModuleImportEqualsDeclaration(node)) {
70445                 var isReferenced = resolver.isReferencedAliasDeclaration(node);
70446                 if (!isReferenced && compilerOptions.importsNotUsedAsValues === 1) {
70447                     return ts.setOriginalNode(ts.setTextRange(factory.createImportDeclaration(undefined, undefined, undefined, node.moduleReference.expression), node), node);
70448                 }
70449                 return isReferenced ? ts.visitEachChild(node, visitor, context) : undefined;
70450             }
70451             if (!shouldEmitImportEqualsDeclaration(node)) {
70452                 return undefined;
70453             }
70454             var moduleReference = ts.createExpressionFromEntityName(factory, node.moduleReference);
70455             ts.setEmitFlags(moduleReference, 1536 | 2048);
70456             if (isNamedExternalModuleExport(node) || !isExportOfNamespace(node)) {
70457                 return ts.setOriginalNode(ts.setTextRange(factory.createVariableStatement(ts.visitNodes(node.modifiers, modifierVisitor, ts.isModifier), factory.createVariableDeclarationList([
70458                     ts.setOriginalNode(factory.createVariableDeclaration(node.name, undefined, undefined, moduleReference), node)
70459                 ])), node), node);
70460             }
70461             else {
70462                 return ts.setOriginalNode(createNamespaceExport(node.name, moduleReference, node), node);
70463             }
70464         }
70465         function isExportOfNamespace(node) {
70466             return currentNamespace !== undefined && ts.hasSyntacticModifier(node, 1);
70467         }
70468         function isExternalModuleExport(node) {
70469             return currentNamespace === undefined && ts.hasSyntacticModifier(node, 1);
70470         }
70471         function isNamedExternalModuleExport(node) {
70472             return isExternalModuleExport(node)
70473                 && !ts.hasSyntacticModifier(node, 512);
70474         }
70475         function isDefaultExternalModuleExport(node) {
70476             return isExternalModuleExport(node)
70477                 && ts.hasSyntacticModifier(node, 512);
70478         }
70479         function expressionToStatement(expression) {
70480             return factory.createExpressionStatement(expression);
70481         }
70482         function addExportMemberAssignment(statements, node) {
70483             var expression = factory.createAssignment(factory.getExternalModuleOrNamespaceExportName(currentNamespaceContainerName, node, false, true), factory.getLocalName(node));
70484             ts.setSourceMapRange(expression, ts.createRange(node.name ? node.name.pos : node.pos, node.end));
70485             var statement = factory.createExpressionStatement(expression);
70486             ts.setSourceMapRange(statement, ts.createRange(-1, node.end));
70487             statements.push(statement);
70488         }
70489         function createNamespaceExport(exportName, exportValue, location) {
70490             return ts.setTextRange(factory.createExpressionStatement(factory.createAssignment(factory.getNamespaceMemberName(currentNamespaceContainerName, exportName, false, true), exportValue)), location);
70491         }
70492         function createNamespaceExportExpression(exportName, exportValue, location) {
70493             return ts.setTextRange(factory.createAssignment(getNamespaceMemberNameWithSourceMapsAndWithoutComments(exportName), exportValue), location);
70494         }
70495         function getNamespaceMemberNameWithSourceMapsAndWithoutComments(name) {
70496             return factory.getNamespaceMemberName(currentNamespaceContainerName, name, false, true);
70497         }
70498         function getNamespaceParameterName(node) {
70499             var name = factory.getGeneratedNameForNode(node);
70500             ts.setSourceMapRange(name, node.name);
70501             return name;
70502         }
70503         function getNamespaceContainerName(node) {
70504             return factory.getGeneratedNameForNode(node);
70505         }
70506         function getClassAliasIfNeeded(node) {
70507             if (resolver.getNodeCheckFlags(node) & 16777216) {
70508                 enableSubstitutionForClassAliases();
70509                 var classAlias = factory.createUniqueName(node.name && !ts.isGeneratedIdentifier(node.name) ? ts.idText(node.name) : "default");
70510                 classAliases[ts.getOriginalNodeId(node)] = classAlias;
70511                 hoistVariableDeclaration(classAlias);
70512                 return classAlias;
70513             }
70514         }
70515         function getClassPrototype(node) {
70516             return factory.createPropertyAccessExpression(factory.getDeclarationName(node), "prototype");
70517         }
70518         function getClassMemberPrefix(node, member) {
70519             return ts.hasSyntacticModifier(member, 32)
70520                 ? factory.getDeclarationName(node)
70521                 : getClassPrototype(node);
70522         }
70523         function enableSubstitutionForNonQualifiedEnumMembers() {
70524             if ((enabledSubstitutions & 8) === 0) {
70525                 enabledSubstitutions |= 8;
70526                 context.enableSubstitution(78);
70527             }
70528         }
70529         function enableSubstitutionForClassAliases() {
70530             if ((enabledSubstitutions & 1) === 0) {
70531                 enabledSubstitutions |= 1;
70532                 context.enableSubstitution(78);
70533                 classAliases = [];
70534             }
70535         }
70536         function enableSubstitutionForNamespaceExports() {
70537             if ((enabledSubstitutions & 2) === 0) {
70538                 enabledSubstitutions |= 2;
70539                 context.enableSubstitution(78);
70540                 context.enableSubstitution(289);
70541                 context.enableEmitNotification(256);
70542             }
70543         }
70544         function isTransformedModuleDeclaration(node) {
70545             return ts.getOriginalNode(node).kind === 256;
70546         }
70547         function isTransformedEnumDeclaration(node) {
70548             return ts.getOriginalNode(node).kind === 255;
70549         }
70550         function onEmitNode(hint, node, emitCallback) {
70551             var savedApplicableSubstitutions = applicableSubstitutions;
70552             var savedCurrentSourceFile = currentSourceFile;
70553             if (ts.isSourceFile(node)) {
70554                 currentSourceFile = node;
70555             }
70556             if (enabledSubstitutions & 2 && isTransformedModuleDeclaration(node)) {
70557                 applicableSubstitutions |= 2;
70558             }
70559             if (enabledSubstitutions & 8 && isTransformedEnumDeclaration(node)) {
70560                 applicableSubstitutions |= 8;
70561             }
70562             previousOnEmitNode(hint, node, emitCallback);
70563             applicableSubstitutions = savedApplicableSubstitutions;
70564             currentSourceFile = savedCurrentSourceFile;
70565         }
70566         function onSubstituteNode(hint, node) {
70567             node = previousOnSubstituteNode(hint, node);
70568             if (hint === 1) {
70569                 return substituteExpression(node);
70570             }
70571             else if (ts.isShorthandPropertyAssignment(node)) {
70572                 return substituteShorthandPropertyAssignment(node);
70573             }
70574             return node;
70575         }
70576         function substituteShorthandPropertyAssignment(node) {
70577             if (enabledSubstitutions & 2) {
70578                 var name = node.name;
70579                 var exportedName = trySubstituteNamespaceExportedName(name);
70580                 if (exportedName) {
70581                     if (node.objectAssignmentInitializer) {
70582                         var initializer = factory.createAssignment(exportedName, node.objectAssignmentInitializer);
70583                         return ts.setTextRange(factory.createPropertyAssignment(name, initializer), node);
70584                     }
70585                     return ts.setTextRange(factory.createPropertyAssignment(name, exportedName), node);
70586                 }
70587             }
70588             return node;
70589         }
70590         function substituteExpression(node) {
70591             switch (node.kind) {
70592                 case 78:
70593                     return substituteExpressionIdentifier(node);
70594                 case 201:
70595                     return substitutePropertyAccessExpression(node);
70596                 case 202:
70597                     return substituteElementAccessExpression(node);
70598             }
70599             return node;
70600         }
70601         function substituteExpressionIdentifier(node) {
70602             return trySubstituteClassAlias(node)
70603                 || trySubstituteNamespaceExportedName(node)
70604                 || node;
70605         }
70606         function trySubstituteClassAlias(node) {
70607             if (enabledSubstitutions & 1) {
70608                 if (resolver.getNodeCheckFlags(node) & 33554432) {
70609                     var declaration = resolver.getReferencedValueDeclaration(node);
70610                     if (declaration) {
70611                         var classAlias = classAliases[declaration.id];
70612                         if (classAlias) {
70613                             var clone_1 = factory.cloneNode(classAlias);
70614                             ts.setSourceMapRange(clone_1, node);
70615                             ts.setCommentRange(clone_1, node);
70616                             return clone_1;
70617                         }
70618                     }
70619                 }
70620             }
70621             return undefined;
70622         }
70623         function trySubstituteNamespaceExportedName(node) {
70624             if (enabledSubstitutions & applicableSubstitutions && !ts.isGeneratedIdentifier(node) && !ts.isLocalName(node)) {
70625                 var container = resolver.getReferencedExportContainer(node, false);
70626                 if (container && container.kind !== 297) {
70627                     var substitute = (applicableSubstitutions & 2 && container.kind === 256) ||
70628                         (applicableSubstitutions & 8 && container.kind === 255);
70629                     if (substitute) {
70630                         return ts.setTextRange(factory.createPropertyAccessExpression(factory.getGeneratedNameForNode(container), node), node);
70631                     }
70632                 }
70633             }
70634             return undefined;
70635         }
70636         function substitutePropertyAccessExpression(node) {
70637             return substituteConstantValue(node);
70638         }
70639         function substituteElementAccessExpression(node) {
70640             return substituteConstantValue(node);
70641         }
70642         function substituteConstantValue(node) {
70643             var constantValue = tryGetConstEnumValue(node);
70644             if (constantValue !== undefined) {
70645                 ts.setConstantValue(node, constantValue);
70646                 var substitute = typeof constantValue === "string" ? factory.createStringLiteral(constantValue) : factory.createNumericLiteral(constantValue);
70647                 if (!compilerOptions.removeComments) {
70648                     var originalNode = ts.getOriginalNode(node, ts.isAccessExpression);
70649                     var propertyName = ts.isPropertyAccessExpression(originalNode)
70650                         ? ts.declarationNameToString(originalNode.name)
70651                         : ts.getTextOfNode(originalNode.argumentExpression);
70652                     ts.addSyntheticTrailingComment(substitute, 3, " " + propertyName + " ");
70653                 }
70654                 return substitute;
70655             }
70656             return node;
70657         }
70658         function tryGetConstEnumValue(node) {
70659             if (compilerOptions.isolatedModules) {
70660                 return undefined;
70661             }
70662             return ts.isPropertyAccessExpression(node) || ts.isElementAccessExpression(node) ? resolver.getConstantValue(node) : undefined;
70663         }
70664     }
70665     ts.transformTypeScript = transformTypeScript;
70666 })(ts || (ts = {}));
70667 var ts;
70668 (function (ts) {
70669     function transformClassFields(context) {
70670         var factory = context.factory, hoistVariableDeclaration = context.hoistVariableDeclaration, endLexicalEnvironment = context.endLexicalEnvironment, resumeLexicalEnvironment = context.resumeLexicalEnvironment;
70671         var resolver = context.getEmitResolver();
70672         var compilerOptions = context.getCompilerOptions();
70673         var languageVersion = ts.getEmitScriptTarget(compilerOptions);
70674         var shouldTransformPrivateFields = languageVersion < 99;
70675         var previousOnSubstituteNode = context.onSubstituteNode;
70676         context.onSubstituteNode = onSubstituteNode;
70677         var enabledSubstitutions;
70678         var classAliases;
70679         var pendingExpressions;
70680         var pendingStatements;
70681         var privateIdentifierEnvironmentStack = [];
70682         var currentPrivateIdentifierEnvironment;
70683         return ts.chainBundle(context, transformSourceFile);
70684         function transformSourceFile(node) {
70685             var options = context.getCompilerOptions();
70686             if (node.isDeclarationFile
70687                 || options.useDefineForClassFields && options.target === 99) {
70688                 return node;
70689             }
70690             var visited = ts.visitEachChild(node, visitor, context);
70691             ts.addEmitHelpers(visited, context.readEmitHelpers());
70692             return visited;
70693         }
70694         function visitor(node) {
70695             if (!(node.transformFlags & 4194304))
70696                 return node;
70697             switch (node.kind) {
70698                 case 221:
70699                 case 252:
70700                     return visitClassLike(node);
70701                 case 163:
70702                     return visitPropertyDeclaration(node);
70703                 case 232:
70704                     return visitVariableStatement(node);
70705                 case 158:
70706                     return visitComputedPropertyName(node);
70707                 case 201:
70708                     return visitPropertyAccessExpression(node);
70709                 case 214:
70710                     return visitPrefixUnaryExpression(node);
70711                 case 215:
70712                     return visitPostfixUnaryExpression(node, false);
70713                 case 203:
70714                     return visitCallExpression(node);
70715                 case 216:
70716                     return visitBinaryExpression(node);
70717                 case 79:
70718                     return visitPrivateIdentifier(node);
70719                 case 233:
70720                     return visitExpressionStatement(node);
70721                 case 237:
70722                     return visitForStatement(node);
70723                 case 205:
70724                     return visitTaggedTemplateExpression(node);
70725             }
70726             return ts.visitEachChild(node, visitor, context);
70727         }
70728         function visitorDestructuringTarget(node) {
70729             switch (node.kind) {
70730                 case 200:
70731                 case 199:
70732                     return visitAssignmentPattern(node);
70733                 default:
70734                     return visitor(node);
70735             }
70736         }
70737         function visitPrivateIdentifier(node) {
70738             if (!shouldTransformPrivateFields) {
70739                 return node;
70740             }
70741             return ts.setOriginalNode(factory.createIdentifier(""), node);
70742         }
70743         function classElementVisitor(node) {
70744             switch (node.kind) {
70745                 case 166:
70746                     return undefined;
70747                 case 167:
70748                 case 168:
70749                 case 165:
70750                     return ts.visitEachChild(node, classElementVisitor, context);
70751                 case 163:
70752                     return visitPropertyDeclaration(node);
70753                 case 158:
70754                     return visitComputedPropertyName(node);
70755                 case 229:
70756                     return node;
70757                 default:
70758                     return visitor(node);
70759             }
70760         }
70761         function visitVariableStatement(node) {
70762             var savedPendingStatements = pendingStatements;
70763             pendingStatements = [];
70764             var visitedNode = ts.visitEachChild(node, visitor, context);
70765             var statement = ts.some(pendingStatements) ? __spreadArrays([visitedNode], pendingStatements) :
70766                 visitedNode;
70767             pendingStatements = savedPendingStatements;
70768             return statement;
70769         }
70770         function visitComputedPropertyName(name) {
70771             var node = ts.visitEachChild(name, visitor, context);
70772             if (ts.some(pendingExpressions)) {
70773                 var expressions = pendingExpressions;
70774                 expressions.push(name.expression);
70775                 pendingExpressions = [];
70776                 node = factory.updateComputedPropertyName(node, factory.inlineExpressions(expressions));
70777             }
70778             return node;
70779         }
70780         function visitPropertyDeclaration(node) {
70781             ts.Debug.assert(!ts.some(node.decorators));
70782             if (!shouldTransformPrivateFields && ts.isPrivateIdentifier(node.name)) {
70783                 return factory.updatePropertyDeclaration(node, undefined, ts.visitNodes(node.modifiers, visitor, ts.isModifier), node.name, undefined, undefined, undefined);
70784             }
70785             var expr = getPropertyNameExpressionIfNeeded(node.name, !!node.initializer || !!context.getCompilerOptions().useDefineForClassFields);
70786             if (expr && !ts.isSimpleInlineableExpression(expr)) {
70787                 getPendingExpressions().push(expr);
70788             }
70789             return undefined;
70790         }
70791         function createPrivateIdentifierAccess(info, receiver) {
70792             receiver = ts.visitNode(receiver, visitor, ts.isExpression);
70793             switch (info.placement) {
70794                 case 0:
70795                     return context.getEmitHelperFactory().createClassPrivateFieldGetHelper(ts.nodeIsSynthesized(receiver) ? receiver : factory.cloneNode(receiver), info.weakMapName);
70796                 default: return ts.Debug.fail("Unexpected private identifier placement");
70797             }
70798         }
70799         function visitPropertyAccessExpression(node) {
70800             if (shouldTransformPrivateFields && ts.isPrivateIdentifier(node.name)) {
70801                 var privateIdentifierInfo = accessPrivateIdentifier(node.name);
70802                 if (privateIdentifierInfo) {
70803                     return ts.setOriginalNode(createPrivateIdentifierAccess(privateIdentifierInfo, node.expression), node);
70804                 }
70805             }
70806             return ts.visitEachChild(node, visitor, context);
70807         }
70808         function visitPrefixUnaryExpression(node) {
70809             if (shouldTransformPrivateFields && ts.isPrivateIdentifierPropertyAccessExpression(node.operand)) {
70810                 var operator = node.operator === 45 ?
70811                     39 : node.operator === 46 ?
70812                     40 : undefined;
70813                 var info = void 0;
70814                 if (operator && (info = accessPrivateIdentifier(node.operand.name))) {
70815                     var receiver = ts.visitNode(node.operand.expression, visitor, ts.isExpression);
70816                     var _a = createCopiableReceiverExpr(receiver), readExpression = _a.readExpression, initializeExpression = _a.initializeExpression;
70817                     var existingValue = factory.createPrefixUnaryExpression(39, createPrivateIdentifierAccess(info, readExpression));
70818                     return ts.setOriginalNode(createPrivateIdentifierAssignment(info, initializeExpression || readExpression, factory.createBinaryExpression(existingValue, operator, factory.createNumericLiteral(1)), 62), node);
70819                 }
70820             }
70821             return ts.visitEachChild(node, visitor, context);
70822         }
70823         function visitPostfixUnaryExpression(node, valueIsDiscarded) {
70824             if (shouldTransformPrivateFields && ts.isPrivateIdentifierPropertyAccessExpression(node.operand)) {
70825                 var operator = node.operator === 45 ?
70826                     39 : node.operator === 46 ?
70827                     40 : undefined;
70828                 var info = void 0;
70829                 if (operator && (info = accessPrivateIdentifier(node.operand.name))) {
70830                     var receiver = ts.visitNode(node.operand.expression, visitor, ts.isExpression);
70831                     var _a = createCopiableReceiverExpr(receiver), readExpression = _a.readExpression, initializeExpression = _a.initializeExpression;
70832                     var existingValue = factory.createPrefixUnaryExpression(39, createPrivateIdentifierAccess(info, readExpression));
70833                     var returnValue = valueIsDiscarded ? undefined : factory.createTempVariable(hoistVariableDeclaration);
70834                     return ts.setOriginalNode(factory.inlineExpressions(ts.compact([
70835                         createPrivateIdentifierAssignment(info, initializeExpression || readExpression, factory.createBinaryExpression(returnValue ? factory.createAssignment(returnValue, existingValue) : existingValue, operator, factory.createNumericLiteral(1)), 62),
70836                         returnValue
70837                     ])), node);
70838                 }
70839             }
70840             return ts.visitEachChild(node, visitor, context);
70841         }
70842         function visitForStatement(node) {
70843             if (node.incrementor && ts.isPostfixUnaryExpression(node.incrementor)) {
70844                 return factory.updateForStatement(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));
70845             }
70846             return ts.visitEachChild(node, visitor, context);
70847         }
70848         function visitExpressionStatement(node) {
70849             if (ts.isPostfixUnaryExpression(node.expression)) {
70850                 return factory.updateExpressionStatement(node, visitPostfixUnaryExpression(node.expression, true));
70851             }
70852             return ts.visitEachChild(node, visitor, context);
70853         }
70854         function createCopiableReceiverExpr(receiver) {
70855             var clone = ts.nodeIsSynthesized(receiver) ? receiver : factory.cloneNode(receiver);
70856             if (ts.isSimpleInlineableExpression(receiver)) {
70857                 return { readExpression: clone, initializeExpression: undefined };
70858             }
70859             var readExpression = factory.createTempVariable(hoistVariableDeclaration);
70860             var initializeExpression = factory.createAssignment(readExpression, clone);
70861             return { readExpression: readExpression, initializeExpression: initializeExpression };
70862         }
70863         function visitCallExpression(node) {
70864             if (shouldTransformPrivateFields && ts.isPrivateIdentifierPropertyAccessExpression(node.expression)) {
70865                 var _a = factory.createCallBinding(node.expression, hoistVariableDeclaration, languageVersion), thisArg = _a.thisArg, target = _a.target;
70866                 return factory.updateCallExpression(node, factory.createPropertyAccessExpression(ts.visitNode(target, visitor), "call"), undefined, __spreadArrays([ts.visitNode(thisArg, visitor, ts.isExpression)], ts.visitNodes(node.arguments, visitor, ts.isExpression)));
70867             }
70868             return ts.visitEachChild(node, visitor, context);
70869         }
70870         function visitTaggedTemplateExpression(node) {
70871             if (shouldTransformPrivateFields && ts.isPrivateIdentifierPropertyAccessExpression(node.tag)) {
70872                 var _a = factory.createCallBinding(node.tag, hoistVariableDeclaration, languageVersion), thisArg = _a.thisArg, target = _a.target;
70873                 return factory.updateTaggedTemplateExpression(node, factory.createCallExpression(factory.createPropertyAccessExpression(ts.visitNode(target, visitor), "bind"), undefined, [ts.visitNode(thisArg, visitor, ts.isExpression)]), undefined, ts.visitNode(node.template, visitor, ts.isTemplateLiteral));
70874             }
70875             return ts.visitEachChild(node, visitor, context);
70876         }
70877         function visitBinaryExpression(node) {
70878             if (shouldTransformPrivateFields) {
70879                 if (ts.isDestructuringAssignment(node)) {
70880                     var savedPendingExpressions = pendingExpressions;
70881                     pendingExpressions = undefined;
70882                     node = factory.updateBinaryExpression(node, ts.visitNode(node.left, visitorDestructuringTarget), node.operatorToken, ts.visitNode(node.right, visitor));
70883                     var expr = ts.some(pendingExpressions) ?
70884                         factory.inlineExpressions(ts.compact(__spreadArrays(pendingExpressions, [node]))) :
70885                         node;
70886                     pendingExpressions = savedPendingExpressions;
70887                     return expr;
70888                 }
70889                 if (ts.isAssignmentExpression(node) && ts.isPrivateIdentifierPropertyAccessExpression(node.left)) {
70890                     var info = accessPrivateIdentifier(node.left.name);
70891                     if (info) {
70892                         return ts.setOriginalNode(createPrivateIdentifierAssignment(info, node.left.expression, node.right, node.operatorToken.kind), node);
70893                     }
70894                 }
70895             }
70896             return ts.visitEachChild(node, visitor, context);
70897         }
70898         function createPrivateIdentifierAssignment(info, receiver, right, operator) {
70899             switch (info.placement) {
70900                 case 0: {
70901                     return createPrivateIdentifierInstanceFieldAssignment(info, receiver, right, operator);
70902                 }
70903                 default: return ts.Debug.fail("Unexpected private identifier placement");
70904             }
70905         }
70906         function createPrivateIdentifierInstanceFieldAssignment(info, receiver, right, operator) {
70907             receiver = ts.visitNode(receiver, visitor, ts.isExpression);
70908             right = ts.visitNode(right, visitor, ts.isExpression);
70909             if (ts.isCompoundAssignment(operator)) {
70910                 var _a = createCopiableReceiverExpr(receiver), readExpression = _a.readExpression, initializeExpression = _a.initializeExpression;
70911                 return context.getEmitHelperFactory().createClassPrivateFieldSetHelper(initializeExpression || readExpression, info.weakMapName, factory.createBinaryExpression(context.getEmitHelperFactory().createClassPrivateFieldGetHelper(readExpression, info.weakMapName), ts.getNonAssignmentOperatorForCompoundAssignment(operator), right));
70912             }
70913             else {
70914                 return context.getEmitHelperFactory().createClassPrivateFieldSetHelper(receiver, info.weakMapName, right);
70915             }
70916         }
70917         function visitClassLike(node) {
70918             var savedPendingExpressions = pendingExpressions;
70919             pendingExpressions = undefined;
70920             if (shouldTransformPrivateFields) {
70921                 startPrivateIdentifierEnvironment();
70922             }
70923             var result = ts.isClassDeclaration(node) ?
70924                 visitClassDeclaration(node) :
70925                 visitClassExpression(node);
70926             if (shouldTransformPrivateFields) {
70927                 endPrivateIdentifierEnvironment();
70928             }
70929             pendingExpressions = savedPendingExpressions;
70930             return result;
70931         }
70932         function doesClassElementNeedTransform(node) {
70933             return ts.isPropertyDeclaration(node) || (shouldTransformPrivateFields && node.name && ts.isPrivateIdentifier(node.name));
70934         }
70935         function visitClassDeclaration(node) {
70936             if (!ts.forEach(node.members, doesClassElementNeedTransform)) {
70937                 return ts.visitEachChild(node, visitor, context);
70938             }
70939             var extendsClauseElement = ts.getEffectiveBaseTypeNode(node);
70940             var isDerivedClass = !!(extendsClauseElement && ts.skipOuterExpressions(extendsClauseElement.expression).kind !== 103);
70941             var statements = [
70942                 factory.updateClassDeclaration(node, undefined, node.modifiers, node.name, undefined, ts.visitNodes(node.heritageClauses, visitor, ts.isHeritageClause), transformClassMembers(node, isDerivedClass))
70943             ];
70944             if (ts.some(pendingExpressions)) {
70945                 statements.push(factory.createExpressionStatement(factory.inlineExpressions(pendingExpressions)));
70946             }
70947             var staticProperties = ts.getProperties(node, true, true);
70948             if (ts.some(staticProperties)) {
70949                 addPropertyStatements(statements, staticProperties, factory.getInternalName(node));
70950             }
70951             return statements;
70952         }
70953         function visitClassExpression(node) {
70954             if (!ts.forEach(node.members, doesClassElementNeedTransform)) {
70955                 return ts.visitEachChild(node, visitor, context);
70956             }
70957             var isDecoratedClassDeclaration = ts.isClassDeclaration(ts.getOriginalNode(node));
70958             var staticProperties = ts.getProperties(node, true, true);
70959             var extendsClauseElement = ts.getEffectiveBaseTypeNode(node);
70960             var isDerivedClass = !!(extendsClauseElement && ts.skipOuterExpressions(extendsClauseElement.expression).kind !== 103);
70961             var classExpression = factory.updateClassExpression(node, ts.visitNodes(node.decorators, visitor, ts.isDecorator), node.modifiers, node.name, undefined, ts.visitNodes(node.heritageClauses, visitor, ts.isHeritageClause), transformClassMembers(node, isDerivedClass));
70962             if (ts.some(staticProperties) || ts.some(pendingExpressions)) {
70963                 if (isDecoratedClassDeclaration) {
70964                     ts.Debug.assertIsDefined(pendingStatements, "Decorated classes transformed by TypeScript are expected to be within a variable declaration.");
70965                     if (pendingStatements && pendingExpressions && ts.some(pendingExpressions)) {
70966                         pendingStatements.push(factory.createExpressionStatement(factory.inlineExpressions(pendingExpressions)));
70967                     }
70968                     if (pendingStatements && ts.some(staticProperties)) {
70969                         addPropertyStatements(pendingStatements, staticProperties, factory.getInternalName(node));
70970                     }
70971                     return classExpression;
70972                 }
70973                 else {
70974                     var expressions = [];
70975                     var isClassWithConstructorReference = resolver.getNodeCheckFlags(node) & 16777216;
70976                     var temp = factory.createTempVariable(hoistVariableDeclaration, !!isClassWithConstructorReference);
70977                     if (isClassWithConstructorReference) {
70978                         enableSubstitutionForClassAliases();
70979                         var alias = factory.cloneNode(temp);
70980                         alias.autoGenerateFlags &= ~8;
70981                         classAliases[ts.getOriginalNodeId(node)] = alias;
70982                     }
70983                     ts.setEmitFlags(classExpression, 65536 | ts.getEmitFlags(classExpression));
70984                     expressions.push(ts.startOnNewLine(factory.createAssignment(temp, classExpression)));
70985                     ts.addRange(expressions, ts.map(pendingExpressions, ts.startOnNewLine));
70986                     ts.addRange(expressions, generateInitializedPropertyExpressions(staticProperties, temp));
70987                     expressions.push(ts.startOnNewLine(temp));
70988                     return factory.inlineExpressions(expressions);
70989                 }
70990             }
70991             return classExpression;
70992         }
70993         function transformClassMembers(node, isDerivedClass) {
70994             if (shouldTransformPrivateFields) {
70995                 for (var _i = 0, _a = node.members; _i < _a.length; _i++) {
70996                     var member = _a[_i];
70997                     if (ts.isPrivateIdentifierPropertyDeclaration(member)) {
70998                         addPrivateIdentifierToEnvironment(member.name);
70999                     }
71000                 }
71001             }
71002             var members = [];
71003             var constructor = transformConstructor(node, isDerivedClass);
71004             if (constructor) {
71005                 members.push(constructor);
71006             }
71007             ts.addRange(members, ts.visitNodes(node.members, classElementVisitor, ts.isClassElement));
71008             return ts.setTextRange(factory.createNodeArray(members), node.members);
71009         }
71010         function isPropertyDeclarationThatRequiresConstructorStatement(member) {
71011             if (!ts.isPropertyDeclaration(member) || ts.hasStaticModifier(member)) {
71012                 return false;
71013             }
71014             if (context.getCompilerOptions().useDefineForClassFields) {
71015                 return languageVersion < 99;
71016             }
71017             return ts.isInitializedProperty(member) || shouldTransformPrivateFields && ts.isPrivateIdentifierPropertyDeclaration(member);
71018         }
71019         function transformConstructor(node, isDerivedClass) {
71020             var constructor = ts.visitNode(ts.getFirstConstructorWithBody(node), visitor, ts.isConstructorDeclaration);
71021             var properties = node.members.filter(isPropertyDeclarationThatRequiresConstructorStatement);
71022             if (!ts.some(properties)) {
71023                 return constructor;
71024             }
71025             var parameters = ts.visitParameterList(constructor ? constructor.parameters : undefined, visitor, context);
71026             var body = transformConstructorBody(node, constructor, isDerivedClass);
71027             if (!body) {
71028                 return undefined;
71029             }
71030             return ts.startOnNewLine(ts.setOriginalNode(ts.setTextRange(factory.createConstructorDeclaration(undefined, undefined, parameters !== null && parameters !== void 0 ? parameters : [], body), constructor || node), constructor));
71031         }
71032         function transformConstructorBody(node, constructor, isDerivedClass) {
71033             var useDefineForClassFields = context.getCompilerOptions().useDefineForClassFields;
71034             var properties = ts.getProperties(node, false, false);
71035             if (!useDefineForClassFields) {
71036                 properties = ts.filter(properties, function (property) { return !!property.initializer || ts.isPrivateIdentifier(property.name); });
71037             }
71038             if (!constructor && !ts.some(properties)) {
71039                 return ts.visitFunctionBody(undefined, visitor, context);
71040             }
71041             resumeLexicalEnvironment();
71042             var indexOfFirstStatement = 0;
71043             var statements = [];
71044             if (!constructor && isDerivedClass) {
71045                 statements.push(factory.createExpressionStatement(factory.createCallExpression(factory.createSuper(), undefined, [factory.createSpreadElement(factory.createIdentifier("arguments"))])));
71046             }
71047             if (constructor) {
71048                 indexOfFirstStatement = ts.addPrologueDirectivesAndInitialSuperCall(factory, constructor, statements, visitor);
71049             }
71050             if (constructor === null || constructor === void 0 ? void 0 : constructor.body) {
71051                 var afterParameterProperties = ts.findIndex(constructor.body.statements, function (s) { return !ts.isParameterPropertyDeclaration(ts.getOriginalNode(s), constructor); }, indexOfFirstStatement);
71052                 if (afterParameterProperties === -1) {
71053                     afterParameterProperties = constructor.body.statements.length;
71054                 }
71055                 if (afterParameterProperties > indexOfFirstStatement) {
71056                     if (!useDefineForClassFields) {
71057                         ts.addRange(statements, ts.visitNodes(constructor.body.statements, visitor, ts.isStatement, indexOfFirstStatement, afterParameterProperties - indexOfFirstStatement));
71058                     }
71059                     indexOfFirstStatement = afterParameterProperties;
71060                 }
71061             }
71062             addPropertyStatements(statements, properties, factory.createThis());
71063             if (constructor) {
71064                 ts.addRange(statements, ts.visitNodes(constructor.body.statements, visitor, ts.isStatement, indexOfFirstStatement));
71065             }
71066             statements = factory.mergeLexicalEnvironment(statements, endLexicalEnvironment());
71067             return ts.setTextRange(factory.createBlock(ts.setTextRange(factory.createNodeArray(statements), constructor ? constructor.body.statements : node.members), true), constructor ? constructor.body : undefined);
71068         }
71069         function addPropertyStatements(statements, properties, receiver) {
71070             for (var _i = 0, properties_7 = properties; _i < properties_7.length; _i++) {
71071                 var property = properties_7[_i];
71072                 var expression = transformProperty(property, receiver);
71073                 if (!expression) {
71074                     continue;
71075                 }
71076                 var statement = factory.createExpressionStatement(expression);
71077                 ts.setSourceMapRange(statement, ts.moveRangePastModifiers(property));
71078                 ts.setCommentRange(statement, property);
71079                 ts.setOriginalNode(statement, property);
71080                 statements.push(statement);
71081             }
71082         }
71083         function generateInitializedPropertyExpressions(properties, receiver) {
71084             var expressions = [];
71085             for (var _i = 0, properties_8 = properties; _i < properties_8.length; _i++) {
71086                 var property = properties_8[_i];
71087                 var expression = transformProperty(property, receiver);
71088                 if (!expression) {
71089                     continue;
71090                 }
71091                 ts.startOnNewLine(expression);
71092                 ts.setSourceMapRange(expression, ts.moveRangePastModifiers(property));
71093                 ts.setCommentRange(expression, property);
71094                 ts.setOriginalNode(expression, property);
71095                 expressions.push(expression);
71096             }
71097             return expressions;
71098         }
71099         function transformProperty(property, receiver) {
71100             var _a;
71101             var emitAssignment = !context.getCompilerOptions().useDefineForClassFields;
71102             var propertyName = ts.isComputedPropertyName(property.name) && !ts.isSimpleInlineableExpression(property.name.expression)
71103                 ? factory.updateComputedPropertyName(property.name, factory.getGeneratedNameForNode(property.name))
71104                 : property.name;
71105             if (shouldTransformPrivateFields && ts.isPrivateIdentifier(propertyName)) {
71106                 var privateIdentifierInfo = accessPrivateIdentifier(propertyName);
71107                 if (privateIdentifierInfo) {
71108                     switch (privateIdentifierInfo.placement) {
71109                         case 0: {
71110                             return createPrivateInstanceFieldInitializer(receiver, ts.visitNode(property.initializer, visitor, ts.isExpression), privateIdentifierInfo.weakMapName);
71111                         }
71112                     }
71113                 }
71114                 else {
71115                     ts.Debug.fail("Undeclared private name for property declaration.");
71116                 }
71117             }
71118             if (ts.isPrivateIdentifier(propertyName) && !property.initializer) {
71119                 return undefined;
71120             }
71121             if (ts.isPrivateIdentifier(propertyName) && !property.initializer) {
71122                 return undefined;
71123             }
71124             var propertyOriginalNode = ts.getOriginalNode(property);
71125             var initializer = property.initializer || emitAssignment ? (_a = ts.visitNode(property.initializer, visitor, ts.isExpression)) !== null && _a !== void 0 ? _a : factory.createVoidZero() : ts.isParameterPropertyDeclaration(propertyOriginalNode, propertyOriginalNode.parent) && ts.isIdentifier(propertyName) ? propertyName
71126                 : factory.createVoidZero();
71127             if (emitAssignment || ts.isPrivateIdentifier(propertyName)) {
71128                 var memberAccess = ts.createMemberAccessForPropertyName(factory, receiver, propertyName, propertyName);
71129                 return factory.createAssignment(memberAccess, initializer);
71130             }
71131             else {
71132                 var name = ts.isComputedPropertyName(propertyName) ? propertyName.expression
71133                     : ts.isIdentifier(propertyName) ? factory.createStringLiteral(ts.unescapeLeadingUnderscores(propertyName.escapedText))
71134                         : propertyName;
71135                 var descriptor = factory.createPropertyDescriptor({ value: initializer, configurable: true, writable: true, enumerable: true });
71136                 return factory.createObjectDefinePropertyCall(receiver, name, descriptor);
71137             }
71138         }
71139         function enableSubstitutionForClassAliases() {
71140             if ((enabledSubstitutions & 1) === 0) {
71141                 enabledSubstitutions |= 1;
71142                 context.enableSubstitution(78);
71143                 classAliases = [];
71144             }
71145         }
71146         function onSubstituteNode(hint, node) {
71147             node = previousOnSubstituteNode(hint, node);
71148             if (hint === 1) {
71149                 return substituteExpression(node);
71150             }
71151             return node;
71152         }
71153         function substituteExpression(node) {
71154             switch (node.kind) {
71155                 case 78:
71156                     return substituteExpressionIdentifier(node);
71157             }
71158             return node;
71159         }
71160         function substituteExpressionIdentifier(node) {
71161             return trySubstituteClassAlias(node) || node;
71162         }
71163         function trySubstituteClassAlias(node) {
71164             if (enabledSubstitutions & 1) {
71165                 if (resolver.getNodeCheckFlags(node) & 33554432) {
71166                     var declaration = resolver.getReferencedValueDeclaration(node);
71167                     if (declaration) {
71168                         var classAlias = classAliases[declaration.id];
71169                         if (classAlias) {
71170                             var clone_2 = factory.cloneNode(classAlias);
71171                             ts.setSourceMapRange(clone_2, node);
71172                             ts.setCommentRange(clone_2, node);
71173                             return clone_2;
71174                         }
71175                     }
71176                 }
71177             }
71178             return undefined;
71179         }
71180         function getPropertyNameExpressionIfNeeded(name, shouldHoist) {
71181             if (ts.isComputedPropertyName(name)) {
71182                 var expression = ts.visitNode(name.expression, visitor, ts.isExpression);
71183                 var innerExpression = ts.skipPartiallyEmittedExpressions(expression);
71184                 var inlinable = ts.isSimpleInlineableExpression(innerExpression);
71185                 var alreadyTransformed = ts.isAssignmentExpression(innerExpression) && ts.isGeneratedIdentifier(innerExpression.left);
71186                 if (!alreadyTransformed && !inlinable && shouldHoist) {
71187                     var generatedName = factory.getGeneratedNameForNode(name);
71188                     hoistVariableDeclaration(generatedName);
71189                     return factory.createAssignment(generatedName, expression);
71190                 }
71191                 return (inlinable || ts.isIdentifier(innerExpression)) ? undefined : expression;
71192             }
71193         }
71194         function startPrivateIdentifierEnvironment() {
71195             privateIdentifierEnvironmentStack.push(currentPrivateIdentifierEnvironment);
71196             currentPrivateIdentifierEnvironment = undefined;
71197         }
71198         function endPrivateIdentifierEnvironment() {
71199             currentPrivateIdentifierEnvironment = privateIdentifierEnvironmentStack.pop();
71200         }
71201         function getPrivateIdentifierEnvironment() {
71202             return currentPrivateIdentifierEnvironment || (currentPrivateIdentifierEnvironment = new ts.Map());
71203         }
71204         function getPendingExpressions() {
71205             return pendingExpressions || (pendingExpressions = []);
71206         }
71207         function addPrivateIdentifierToEnvironment(name) {
71208             var text = ts.getTextOfPropertyName(name);
71209             var weakMapName = factory.createUniqueName("_" + text.substring(1), 16 | 8);
71210             hoistVariableDeclaration(weakMapName);
71211             getPrivateIdentifierEnvironment().set(name.escapedText, { placement: 0, weakMapName: weakMapName });
71212             getPendingExpressions().push(factory.createAssignment(weakMapName, factory.createNewExpression(factory.createIdentifier("WeakMap"), undefined, [])));
71213         }
71214         function accessPrivateIdentifier(name) {
71215             if (currentPrivateIdentifierEnvironment) {
71216                 var info = currentPrivateIdentifierEnvironment.get(name.escapedText);
71217                 if (info) {
71218                     return info;
71219                 }
71220             }
71221             for (var i = privateIdentifierEnvironmentStack.length - 1; i >= 0; --i) {
71222                 var env = privateIdentifierEnvironmentStack[i];
71223                 if (!env) {
71224                     continue;
71225                 }
71226                 var info = env.get(name.escapedText);
71227                 if (info) {
71228                     return info;
71229                 }
71230             }
71231             return undefined;
71232         }
71233         function wrapPrivateIdentifierForDestructuringTarget(node) {
71234             var parameter = factory.getGeneratedNameForNode(node);
71235             var info = accessPrivateIdentifier(node.name);
71236             if (!info) {
71237                 return ts.visitEachChild(node, visitor, context);
71238             }
71239             var receiver = node.expression;
71240             if (ts.isThisProperty(node) || ts.isSuperProperty(node) || !ts.isSimpleCopiableExpression(node.expression)) {
71241                 receiver = factory.createTempVariable(hoistVariableDeclaration, true);
71242                 getPendingExpressions().push(factory.createBinaryExpression(receiver, 62, node.expression));
71243             }
71244             return factory.createPropertyAccessExpression(factory.createParenthesizedExpression(factory.createObjectLiteralExpression([
71245                 factory.createSetAccessorDeclaration(undefined, undefined, "value", [factory.createParameterDeclaration(undefined, undefined, undefined, parameter, undefined, undefined, undefined)], factory.createBlock([factory.createExpressionStatement(createPrivateIdentifierAssignment(info, receiver, parameter, 62))]))
71246             ])), "value");
71247         }
71248         function visitArrayAssignmentTarget(node) {
71249             var target = ts.getTargetOfBindingOrAssignmentElement(node);
71250             if (target && ts.isPrivateIdentifierPropertyAccessExpression(target)) {
71251                 var wrapped = wrapPrivateIdentifierForDestructuringTarget(target);
71252                 if (ts.isAssignmentExpression(node)) {
71253                     return factory.updateBinaryExpression(node, wrapped, node.operatorToken, ts.visitNode(node.right, visitor, ts.isExpression));
71254                 }
71255                 else if (ts.isSpreadElement(node)) {
71256                     return factory.updateSpreadElement(node, wrapped);
71257                 }
71258                 else {
71259                     return wrapped;
71260                 }
71261             }
71262             return ts.visitNode(node, visitorDestructuringTarget);
71263         }
71264         function visitObjectAssignmentTarget(node) {
71265             if (ts.isPropertyAssignment(node)) {
71266                 var target = ts.getTargetOfBindingOrAssignmentElement(node);
71267                 if (target && ts.isPrivateIdentifierPropertyAccessExpression(target)) {
71268                     var initializer = ts.getInitializerOfBindingOrAssignmentElement(node);
71269                     var wrapped = wrapPrivateIdentifierForDestructuringTarget(target);
71270                     return factory.updatePropertyAssignment(node, ts.visitNode(node.name, visitor), initializer ? factory.createAssignment(wrapped, ts.visitNode(initializer, visitor)) : wrapped);
71271                 }
71272                 return factory.updatePropertyAssignment(node, ts.visitNode(node.name, visitor), ts.visitNode(node.initializer, visitorDestructuringTarget));
71273             }
71274             return ts.visitNode(node, visitor);
71275         }
71276         function visitAssignmentPattern(node) {
71277             if (ts.isArrayLiteralExpression(node)) {
71278                 return factory.updateArrayLiteralExpression(node, ts.visitNodes(node.elements, visitArrayAssignmentTarget, ts.isExpression));
71279             }
71280             else {
71281                 return factory.updateObjectLiteralExpression(node, ts.visitNodes(node.properties, visitObjectAssignmentTarget, ts.isObjectLiteralElementLike));
71282             }
71283         }
71284     }
71285     ts.transformClassFields = transformClassFields;
71286     function createPrivateInstanceFieldInitializer(receiver, initializer, weakMapName) {
71287         return ts.factory.createCallExpression(ts.factory.createPropertyAccessExpression(weakMapName, "set"), undefined, [receiver, initializer || ts.factory.createVoidZero()]);
71288     }
71289 })(ts || (ts = {}));
71290 var ts;
71291 (function (ts) {
71292     function transformES2017(context) {
71293         var factory = context.factory, emitHelpers = context.getEmitHelperFactory, resumeLexicalEnvironment = context.resumeLexicalEnvironment, endLexicalEnvironment = context.endLexicalEnvironment, hoistVariableDeclaration = context.hoistVariableDeclaration;
71294         var resolver = context.getEmitResolver();
71295         var compilerOptions = context.getCompilerOptions();
71296         var languageVersion = ts.getEmitScriptTarget(compilerOptions);
71297         var enabledSubstitutions;
71298         var enclosingSuperContainerFlags = 0;
71299         var enclosingFunctionParameterNames;
71300         var capturedSuperProperties;
71301         var hasSuperElementAccess;
71302         var substitutedSuperAccessors = [];
71303         var contextFlags = 0;
71304         var previousOnEmitNode = context.onEmitNode;
71305         var previousOnSubstituteNode = context.onSubstituteNode;
71306         context.onEmitNode = onEmitNode;
71307         context.onSubstituteNode = onSubstituteNode;
71308         return ts.chainBundle(context, transformSourceFile);
71309         function transformSourceFile(node) {
71310             if (node.isDeclarationFile) {
71311                 return node;
71312             }
71313             setContextFlag(1, false);
71314             setContextFlag(2, !ts.isEffectiveStrictModeSourceFile(node, compilerOptions));
71315             var visited = ts.visitEachChild(node, visitor, context);
71316             ts.addEmitHelpers(visited, context.readEmitHelpers());
71317             return visited;
71318         }
71319         function setContextFlag(flag, val) {
71320             contextFlags = val ? contextFlags | flag : contextFlags & ~flag;
71321         }
71322         function inContext(flags) {
71323             return (contextFlags & flags) !== 0;
71324         }
71325         function inTopLevelContext() {
71326             return !inContext(1);
71327         }
71328         function inHasLexicalThisContext() {
71329             return inContext(2);
71330         }
71331         function doWithContext(flags, cb, value) {
71332             var contextFlagsToSet = flags & ~contextFlags;
71333             if (contextFlagsToSet) {
71334                 setContextFlag(contextFlagsToSet, true);
71335                 var result = cb(value);
71336                 setContextFlag(contextFlagsToSet, false);
71337                 return result;
71338             }
71339             return cb(value);
71340         }
71341         function visitDefault(node) {
71342             return ts.visitEachChild(node, visitor, context);
71343         }
71344         function visitor(node) {
71345             if ((node.transformFlags & 64) === 0) {
71346                 return node;
71347             }
71348             switch (node.kind) {
71349                 case 129:
71350                     return undefined;
71351                 case 213:
71352                     return visitAwaitExpression(node);
71353                 case 165:
71354                     return doWithContext(1 | 2, visitMethodDeclaration, node);
71355                 case 251:
71356                     return doWithContext(1 | 2, visitFunctionDeclaration, node);
71357                 case 208:
71358                     return doWithContext(1 | 2, visitFunctionExpression, node);
71359                 case 209:
71360                     return doWithContext(1, visitArrowFunction, node);
71361                 case 201:
71362                     if (capturedSuperProperties && ts.isPropertyAccessExpression(node) && node.expression.kind === 105) {
71363                         capturedSuperProperties.add(node.name.escapedText);
71364                     }
71365                     return ts.visitEachChild(node, visitor, context);
71366                 case 202:
71367                     if (capturedSuperProperties && node.expression.kind === 105) {
71368                         hasSuperElementAccess = true;
71369                     }
71370                     return ts.visitEachChild(node, visitor, context);
71371                 case 167:
71372                 case 168:
71373                 case 166:
71374                 case 252:
71375                 case 221:
71376                     return doWithContext(1 | 2, visitDefault, node);
71377                 default:
71378                     return ts.visitEachChild(node, visitor, context);
71379             }
71380         }
71381         function asyncBodyVisitor(node) {
71382             if (ts.isNodeWithPossibleHoistedDeclaration(node)) {
71383                 switch (node.kind) {
71384                     case 232:
71385                         return visitVariableStatementInAsyncBody(node);
71386                     case 237:
71387                         return visitForStatementInAsyncBody(node);
71388                     case 238:
71389                         return visitForInStatementInAsyncBody(node);
71390                     case 239:
71391                         return visitForOfStatementInAsyncBody(node);
71392                     case 287:
71393                         return visitCatchClauseInAsyncBody(node);
71394                     case 230:
71395                     case 244:
71396                     case 258:
71397                     case 284:
71398                     case 285:
71399                     case 247:
71400                     case 235:
71401                     case 236:
71402                     case 234:
71403                     case 243:
71404                     case 245:
71405                         return ts.visitEachChild(node, asyncBodyVisitor, context);
71406                     default:
71407                         return ts.Debug.assertNever(node, "Unhandled node.");
71408                 }
71409             }
71410             return visitor(node);
71411         }
71412         function visitCatchClauseInAsyncBody(node) {
71413             var catchClauseNames = new ts.Set();
71414             recordDeclarationName(node.variableDeclaration, catchClauseNames);
71415             var catchClauseUnshadowedNames;
71416             catchClauseNames.forEach(function (_, escapedName) {
71417                 if (enclosingFunctionParameterNames.has(escapedName)) {
71418                     if (!catchClauseUnshadowedNames) {
71419                         catchClauseUnshadowedNames = new ts.Set(enclosingFunctionParameterNames);
71420                     }
71421                     catchClauseUnshadowedNames.delete(escapedName);
71422                 }
71423             });
71424             if (catchClauseUnshadowedNames) {
71425                 var savedEnclosingFunctionParameterNames = enclosingFunctionParameterNames;
71426                 enclosingFunctionParameterNames = catchClauseUnshadowedNames;
71427                 var result = ts.visitEachChild(node, asyncBodyVisitor, context);
71428                 enclosingFunctionParameterNames = savedEnclosingFunctionParameterNames;
71429                 return result;
71430             }
71431             else {
71432                 return ts.visitEachChild(node, asyncBodyVisitor, context);
71433             }
71434         }
71435         function visitVariableStatementInAsyncBody(node) {
71436             if (isVariableDeclarationListWithCollidingName(node.declarationList)) {
71437                 var expression = visitVariableDeclarationListWithCollidingNames(node.declarationList, false);
71438                 return expression ? factory.createExpressionStatement(expression) : undefined;
71439             }
71440             return ts.visitEachChild(node, visitor, context);
71441         }
71442         function visitForInStatementInAsyncBody(node) {
71443             return factory.updateForInStatement(node, isVariableDeclarationListWithCollidingName(node.initializer)
71444                 ? visitVariableDeclarationListWithCollidingNames(node.initializer, true)
71445                 : ts.visitNode(node.initializer, visitor, ts.isForInitializer), ts.visitNode(node.expression, visitor, ts.isExpression), ts.visitNode(node.statement, asyncBodyVisitor, ts.isStatement, factory.liftToBlock));
71446         }
71447         function visitForOfStatementInAsyncBody(node) {
71448             return factory.updateForOfStatement(node, ts.visitNode(node.awaitModifier, visitor, ts.isToken), isVariableDeclarationListWithCollidingName(node.initializer)
71449                 ? visitVariableDeclarationListWithCollidingNames(node.initializer, true)
71450                 : ts.visitNode(node.initializer, visitor, ts.isForInitializer), ts.visitNode(node.expression, visitor, ts.isExpression), ts.visitNode(node.statement, asyncBodyVisitor, ts.isStatement, factory.liftToBlock));
71451         }
71452         function visitForStatementInAsyncBody(node) {
71453             var initializer = node.initializer;
71454             return factory.updateForStatement(node, isVariableDeclarationListWithCollidingName(initializer)
71455                 ? visitVariableDeclarationListWithCollidingNames(initializer, false)
71456                 : 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, factory.liftToBlock));
71457         }
71458         function visitAwaitExpression(node) {
71459             if (inTopLevelContext()) {
71460                 return ts.visitEachChild(node, visitor, context);
71461             }
71462             return ts.setOriginalNode(ts.setTextRange(factory.createYieldExpression(undefined, ts.visitNode(node.expression, visitor, ts.isExpression)), node), node);
71463         }
71464         function visitMethodDeclaration(node) {
71465             return factory.updateMethodDeclaration(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
71466                 ? transformAsyncFunctionBody(node)
71467                 : ts.visitFunctionBody(node.body, visitor, context));
71468         }
71469         function visitFunctionDeclaration(node) {
71470             return factory.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
71471                 ? transformAsyncFunctionBody(node)
71472                 : ts.visitFunctionBody(node.body, visitor, context));
71473         }
71474         function visitFunctionExpression(node) {
71475             return factory.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
71476                 ? transformAsyncFunctionBody(node)
71477                 : ts.visitFunctionBody(node.body, visitor, context));
71478         }
71479         function visitArrowFunction(node) {
71480             return factory.updateArrowFunction(node, ts.visitNodes(node.modifiers, visitor, ts.isModifier), undefined, ts.visitParameterList(node.parameters, visitor, context), undefined, node.equalsGreaterThanToken, ts.getFunctionFlags(node) & 2
71481                 ? transformAsyncFunctionBody(node)
71482                 : ts.visitFunctionBody(node.body, visitor, context));
71483         }
71484         function recordDeclarationName(_a, names) {
71485             var name = _a.name;
71486             if (ts.isIdentifier(name)) {
71487                 names.add(name.escapedText);
71488             }
71489             else {
71490                 for (var _i = 0, _b = name.elements; _i < _b.length; _i++) {
71491                     var element = _b[_i];
71492                     if (!ts.isOmittedExpression(element)) {
71493                         recordDeclarationName(element, names);
71494                     }
71495                 }
71496             }
71497         }
71498         function isVariableDeclarationListWithCollidingName(node) {
71499             return !!node
71500                 && ts.isVariableDeclarationList(node)
71501                 && !(node.flags & 3)
71502                 && node.declarations.some(collidesWithParameterName);
71503         }
71504         function visitVariableDeclarationListWithCollidingNames(node, hasReceiver) {
71505             hoistVariableDeclarationList(node);
71506             var variables = ts.getInitializedVariables(node);
71507             if (variables.length === 0) {
71508                 if (hasReceiver) {
71509                     return ts.visitNode(factory.converters.convertToAssignmentElementTarget(node.declarations[0].name), visitor, ts.isExpression);
71510                 }
71511                 return undefined;
71512             }
71513             return factory.inlineExpressions(ts.map(variables, transformInitializedVariable));
71514         }
71515         function hoistVariableDeclarationList(node) {
71516             ts.forEach(node.declarations, hoistVariable);
71517         }
71518         function hoistVariable(_a) {
71519             var name = _a.name;
71520             if (ts.isIdentifier(name)) {
71521                 hoistVariableDeclaration(name);
71522             }
71523             else {
71524                 for (var _i = 0, _b = name.elements; _i < _b.length; _i++) {
71525                     var element = _b[_i];
71526                     if (!ts.isOmittedExpression(element)) {
71527                         hoistVariable(element);
71528                     }
71529                 }
71530             }
71531         }
71532         function transformInitializedVariable(node) {
71533             var converted = ts.setSourceMapRange(factory.createAssignment(factory.converters.convertToAssignmentElementTarget(node.name), node.initializer), node);
71534             return ts.visitNode(converted, visitor, ts.isExpression);
71535         }
71536         function collidesWithParameterName(_a) {
71537             var name = _a.name;
71538             if (ts.isIdentifier(name)) {
71539                 return enclosingFunctionParameterNames.has(name.escapedText);
71540             }
71541             else {
71542                 for (var _i = 0, _b = name.elements; _i < _b.length; _i++) {
71543                     var element = _b[_i];
71544                     if (!ts.isOmittedExpression(element) && collidesWithParameterName(element)) {
71545                         return true;
71546                     }
71547                 }
71548             }
71549             return false;
71550         }
71551         function transformAsyncFunctionBody(node) {
71552             resumeLexicalEnvironment();
71553             var original = ts.getOriginalNode(node, ts.isFunctionLike);
71554             var nodeType = original.type;
71555             var promiseConstructor = languageVersion < 2 ? getPromiseConstructor(nodeType) : undefined;
71556             var isArrowFunction = node.kind === 209;
71557             var hasLexicalArguments = (resolver.getNodeCheckFlags(node) & 8192) !== 0;
71558             var savedEnclosingFunctionParameterNames = enclosingFunctionParameterNames;
71559             enclosingFunctionParameterNames = new ts.Set();
71560             for (var _i = 0, _a = node.parameters; _i < _a.length; _i++) {
71561                 var parameter = _a[_i];
71562                 recordDeclarationName(parameter, enclosingFunctionParameterNames);
71563             }
71564             var savedCapturedSuperProperties = capturedSuperProperties;
71565             var savedHasSuperElementAccess = hasSuperElementAccess;
71566             if (!isArrowFunction) {
71567                 capturedSuperProperties = new ts.Set();
71568                 hasSuperElementAccess = false;
71569             }
71570             var result;
71571             if (!isArrowFunction) {
71572                 var statements = [];
71573                 var statementOffset = factory.copyPrologue(node.body.statements, statements, false, visitor);
71574                 statements.push(factory.createReturnStatement(emitHelpers().createAwaiterHelper(inHasLexicalThisContext(), hasLexicalArguments, promiseConstructor, transformAsyncFunctionBodyWorker(node.body, statementOffset))));
71575                 ts.insertStatementsAfterStandardPrologue(statements, endLexicalEnvironment());
71576                 var emitSuperHelpers = languageVersion >= 2 && resolver.getNodeCheckFlags(node) & (4096 | 2048);
71577                 if (emitSuperHelpers) {
71578                     enableSubstitutionForAsyncMethodsWithSuper();
71579                     if (capturedSuperProperties.size) {
71580                         var variableStatement = createSuperAccessVariableStatement(factory, resolver, node, capturedSuperProperties);
71581                         substitutedSuperAccessors[ts.getNodeId(variableStatement)] = true;
71582                         ts.insertStatementsAfterStandardPrologue(statements, [variableStatement]);
71583                     }
71584                 }
71585                 var block = factory.createBlock(statements, true);
71586                 ts.setTextRange(block, node.body);
71587                 if (emitSuperHelpers && hasSuperElementAccess) {
71588                     if (resolver.getNodeCheckFlags(node) & 4096) {
71589                         ts.addEmitHelper(block, ts.advancedAsyncSuperHelper);
71590                     }
71591                     else if (resolver.getNodeCheckFlags(node) & 2048) {
71592                         ts.addEmitHelper(block, ts.asyncSuperHelper);
71593                     }
71594                 }
71595                 result = block;
71596             }
71597             else {
71598                 var expression = emitHelpers().createAwaiterHelper(inHasLexicalThisContext(), hasLexicalArguments, promiseConstructor, transformAsyncFunctionBodyWorker(node.body));
71599                 var declarations = endLexicalEnvironment();
71600                 if (ts.some(declarations)) {
71601                     var block = factory.converters.convertToFunctionBlock(expression);
71602                     result = factory.updateBlock(block, ts.setTextRange(factory.createNodeArray(ts.concatenate(declarations, block.statements)), block.statements));
71603                 }
71604                 else {
71605                     result = expression;
71606                 }
71607             }
71608             enclosingFunctionParameterNames = savedEnclosingFunctionParameterNames;
71609             if (!isArrowFunction) {
71610                 capturedSuperProperties = savedCapturedSuperProperties;
71611                 hasSuperElementAccess = savedHasSuperElementAccess;
71612             }
71613             return result;
71614         }
71615         function transformAsyncFunctionBodyWorker(body, start) {
71616             if (ts.isBlock(body)) {
71617                 return factory.updateBlock(body, ts.visitNodes(body.statements, asyncBodyVisitor, ts.isStatement, start));
71618             }
71619             else {
71620                 return factory.converters.convertToFunctionBlock(ts.visitNode(body, asyncBodyVisitor, ts.isConciseBody));
71621             }
71622         }
71623         function getPromiseConstructor(type) {
71624             var typeName = type && ts.getEntityNameFromTypeNode(type);
71625             if (typeName && ts.isEntityName(typeName)) {
71626                 var serializationKind = resolver.getTypeReferenceSerializationKind(typeName);
71627                 if (serializationKind === ts.TypeReferenceSerializationKind.TypeWithConstructSignatureAndValue
71628                     || serializationKind === ts.TypeReferenceSerializationKind.Unknown) {
71629                     return typeName;
71630                 }
71631             }
71632             return undefined;
71633         }
71634         function enableSubstitutionForAsyncMethodsWithSuper() {
71635             if ((enabledSubstitutions & 1) === 0) {
71636                 enabledSubstitutions |= 1;
71637                 context.enableSubstitution(203);
71638                 context.enableSubstitution(201);
71639                 context.enableSubstitution(202);
71640                 context.enableEmitNotification(252);
71641                 context.enableEmitNotification(165);
71642                 context.enableEmitNotification(167);
71643                 context.enableEmitNotification(168);
71644                 context.enableEmitNotification(166);
71645                 context.enableEmitNotification(232);
71646             }
71647         }
71648         function onEmitNode(hint, node, emitCallback) {
71649             if (enabledSubstitutions & 1 && isSuperContainer(node)) {
71650                 var superContainerFlags = resolver.getNodeCheckFlags(node) & (2048 | 4096);
71651                 if (superContainerFlags !== enclosingSuperContainerFlags) {
71652                     var savedEnclosingSuperContainerFlags = enclosingSuperContainerFlags;
71653                     enclosingSuperContainerFlags = superContainerFlags;
71654                     previousOnEmitNode(hint, node, emitCallback);
71655                     enclosingSuperContainerFlags = savedEnclosingSuperContainerFlags;
71656                     return;
71657                 }
71658             }
71659             else if (enabledSubstitutions && substitutedSuperAccessors[ts.getNodeId(node)]) {
71660                 var savedEnclosingSuperContainerFlags = enclosingSuperContainerFlags;
71661                 enclosingSuperContainerFlags = 0;
71662                 previousOnEmitNode(hint, node, emitCallback);
71663                 enclosingSuperContainerFlags = savedEnclosingSuperContainerFlags;
71664                 return;
71665             }
71666             previousOnEmitNode(hint, node, emitCallback);
71667         }
71668         function onSubstituteNode(hint, node) {
71669             node = previousOnSubstituteNode(hint, node);
71670             if (hint === 1 && enclosingSuperContainerFlags) {
71671                 return substituteExpression(node);
71672             }
71673             return node;
71674         }
71675         function substituteExpression(node) {
71676             switch (node.kind) {
71677                 case 201:
71678                     return substitutePropertyAccessExpression(node);
71679                 case 202:
71680                     return substituteElementAccessExpression(node);
71681                 case 203:
71682                     return substituteCallExpression(node);
71683             }
71684             return node;
71685         }
71686         function substitutePropertyAccessExpression(node) {
71687             if (node.expression.kind === 105) {
71688                 return ts.setTextRange(factory.createPropertyAccessExpression(factory.createUniqueName("_super", 16 | 32), node.name), node);
71689             }
71690             return node;
71691         }
71692         function substituteElementAccessExpression(node) {
71693             if (node.expression.kind === 105) {
71694                 return createSuperElementAccessInAsyncMethod(node.argumentExpression, node);
71695             }
71696             return node;
71697         }
71698         function substituteCallExpression(node) {
71699             var expression = node.expression;
71700             if (ts.isSuperProperty(expression)) {
71701                 var argumentExpression = ts.isPropertyAccessExpression(expression)
71702                     ? substitutePropertyAccessExpression(expression)
71703                     : substituteElementAccessExpression(expression);
71704                 return factory.createCallExpression(factory.createPropertyAccessExpression(argumentExpression, "call"), undefined, __spreadArrays([
71705                     factory.createThis()
71706                 ], node.arguments));
71707             }
71708             return node;
71709         }
71710         function isSuperContainer(node) {
71711             var kind = node.kind;
71712             return kind === 252
71713                 || kind === 166
71714                 || kind === 165
71715                 || kind === 167
71716                 || kind === 168;
71717         }
71718         function createSuperElementAccessInAsyncMethod(argumentExpression, location) {
71719             if (enclosingSuperContainerFlags & 4096) {
71720                 return ts.setTextRange(factory.createPropertyAccessExpression(factory.createCallExpression(factory.createUniqueName("_superIndex", 16 | 32), undefined, [argumentExpression]), "value"), location);
71721             }
71722             else {
71723                 return ts.setTextRange(factory.createCallExpression(factory.createUniqueName("_superIndex", 16 | 32), undefined, [argumentExpression]), location);
71724             }
71725         }
71726     }
71727     ts.transformES2017 = transformES2017;
71728     function createSuperAccessVariableStatement(factory, resolver, node, names) {
71729         var hasBinding = (resolver.getNodeCheckFlags(node) & 4096) !== 0;
71730         var accessors = [];
71731         names.forEach(function (_, key) {
71732             var name = ts.unescapeLeadingUnderscores(key);
71733             var getterAndSetter = [];
71734             getterAndSetter.push(factory.createPropertyAssignment("get", factory.createArrowFunction(undefined, undefined, [], undefined, undefined, ts.setEmitFlags(factory.createPropertyAccessExpression(ts.setEmitFlags(factory.createSuper(), 4), name), 4))));
71735             if (hasBinding) {
71736                 getterAndSetter.push(factory.createPropertyAssignment("set", factory.createArrowFunction(undefined, undefined, [
71737                     factory.createParameterDeclaration(undefined, undefined, undefined, "v", undefined, undefined, undefined)
71738                 ], undefined, undefined, factory.createAssignment(ts.setEmitFlags(factory.createPropertyAccessExpression(ts.setEmitFlags(factory.createSuper(), 4), name), 4), factory.createIdentifier("v")))));
71739             }
71740             accessors.push(factory.createPropertyAssignment(name, factory.createObjectLiteralExpression(getterAndSetter)));
71741         });
71742         return factory.createVariableStatement(undefined, factory.createVariableDeclarationList([
71743             factory.createVariableDeclaration(factory.createUniqueName("_super", 16 | 32), undefined, undefined, factory.createCallExpression(factory.createPropertyAccessExpression(factory.createIdentifier("Object"), "create"), undefined, [
71744                 factory.createNull(),
71745                 factory.createObjectLiteralExpression(accessors, true)
71746             ]))
71747         ], 2));
71748     }
71749     ts.createSuperAccessVariableStatement = createSuperAccessVariableStatement;
71750 })(ts || (ts = {}));
71751 var ts;
71752 (function (ts) {
71753     function transformES2018(context) {
71754         var factory = context.factory, emitHelpers = context.getEmitHelperFactory, resumeLexicalEnvironment = context.resumeLexicalEnvironment, endLexicalEnvironment = context.endLexicalEnvironment, hoistVariableDeclaration = context.hoistVariableDeclaration;
71755         var resolver = context.getEmitResolver();
71756         var compilerOptions = context.getCompilerOptions();
71757         var languageVersion = ts.getEmitScriptTarget(compilerOptions);
71758         var previousOnEmitNode = context.onEmitNode;
71759         context.onEmitNode = onEmitNode;
71760         var previousOnSubstituteNode = context.onSubstituteNode;
71761         context.onSubstituteNode = onSubstituteNode;
71762         var exportedVariableStatement = false;
71763         var enabledSubstitutions;
71764         var enclosingFunctionFlags;
71765         var enclosingSuperContainerFlags = 0;
71766         var hierarchyFacts = 0;
71767         var currentSourceFile;
71768         var taggedTemplateStringDeclarations;
71769         var capturedSuperProperties;
71770         var hasSuperElementAccess;
71771         var substitutedSuperAccessors = [];
71772         return ts.chainBundle(context, transformSourceFile);
71773         function affectsSubtree(excludeFacts, includeFacts) {
71774             return hierarchyFacts !== (hierarchyFacts & ~excludeFacts | includeFacts);
71775         }
71776         function enterSubtree(excludeFacts, includeFacts) {
71777             var ancestorFacts = hierarchyFacts;
71778             hierarchyFacts = (hierarchyFacts & ~excludeFacts | includeFacts) & 3;
71779             return ancestorFacts;
71780         }
71781         function exitSubtree(ancestorFacts) {
71782             hierarchyFacts = ancestorFacts;
71783         }
71784         function recordTaggedTemplateString(temp) {
71785             taggedTemplateStringDeclarations = ts.append(taggedTemplateStringDeclarations, factory.createVariableDeclaration(temp));
71786         }
71787         function transformSourceFile(node) {
71788             if (node.isDeclarationFile) {
71789                 return node;
71790             }
71791             currentSourceFile = node;
71792             var visited = visitSourceFile(node);
71793             ts.addEmitHelpers(visited, context.readEmitHelpers());
71794             currentSourceFile = undefined;
71795             taggedTemplateStringDeclarations = undefined;
71796             return visited;
71797         }
71798         function visitor(node) {
71799             return visitorWorker(node, false);
71800         }
71801         function visitorWithUnusedExpressionResult(node) {
71802             return visitorWorker(node, true);
71803         }
71804         function visitorNoAsyncModifier(node) {
71805             if (node.kind === 129) {
71806                 return undefined;
71807             }
71808             return node;
71809         }
71810         function doWithHierarchyFacts(cb, value, excludeFacts, includeFacts) {
71811             if (affectsSubtree(excludeFacts, includeFacts)) {
71812                 var ancestorFacts = enterSubtree(excludeFacts, includeFacts);
71813                 var result = cb(value);
71814                 exitSubtree(ancestorFacts);
71815                 return result;
71816             }
71817             return cb(value);
71818         }
71819         function visitDefault(node) {
71820             return ts.visitEachChild(node, visitor, context);
71821         }
71822         function visitorWorker(node, expressionResultIsUnused) {
71823             if ((node.transformFlags & 32) === 0) {
71824                 return node;
71825             }
71826             switch (node.kind) {
71827                 case 213:
71828                     return visitAwaitExpression(node);
71829                 case 219:
71830                     return visitYieldExpression(node);
71831                 case 242:
71832                     return visitReturnStatement(node);
71833                 case 245:
71834                     return visitLabeledStatement(node);
71835                 case 200:
71836                     return visitObjectLiteralExpression(node);
71837                 case 216:
71838                     return visitBinaryExpression(node, expressionResultIsUnused);
71839                 case 337:
71840                     return visitCommaListExpression(node, expressionResultIsUnused);
71841                 case 287:
71842                     return visitCatchClause(node);
71843                 case 232:
71844                     return visitVariableStatement(node);
71845                 case 249:
71846                     return visitVariableDeclaration(node);
71847                 case 235:
71848                 case 236:
71849                 case 238:
71850                     return doWithHierarchyFacts(visitDefault, node, 0, 2);
71851                 case 239:
71852                     return visitForOfStatement(node, undefined);
71853                 case 237:
71854                     return doWithHierarchyFacts(visitForStatement, node, 0, 2);
71855                 case 212:
71856                     return visitVoidExpression(node);
71857                 case 166:
71858                     return doWithHierarchyFacts(visitConstructorDeclaration, node, 2, 1);
71859                 case 165:
71860                     return doWithHierarchyFacts(visitMethodDeclaration, node, 2, 1);
71861                 case 167:
71862                     return doWithHierarchyFacts(visitGetAccessorDeclaration, node, 2, 1);
71863                 case 168:
71864                     return doWithHierarchyFacts(visitSetAccessorDeclaration, node, 2, 1);
71865                 case 251:
71866                     return doWithHierarchyFacts(visitFunctionDeclaration, node, 2, 1);
71867                 case 208:
71868                     return doWithHierarchyFacts(visitFunctionExpression, node, 2, 1);
71869                 case 209:
71870                     return doWithHierarchyFacts(visitArrowFunction, node, 2, 0);
71871                 case 160:
71872                     return visitParameter(node);
71873                 case 233:
71874                     return visitExpressionStatement(node);
71875                 case 207:
71876                     return visitParenthesizedExpression(node, expressionResultIsUnused);
71877                 case 205:
71878                     return visitTaggedTemplateExpression(node);
71879                 case 201:
71880                     if (capturedSuperProperties && ts.isPropertyAccessExpression(node) && node.expression.kind === 105) {
71881                         capturedSuperProperties.add(node.name.escapedText);
71882                     }
71883                     return ts.visitEachChild(node, visitor, context);
71884                 case 202:
71885                     if (capturedSuperProperties && node.expression.kind === 105) {
71886                         hasSuperElementAccess = true;
71887                     }
71888                     return ts.visitEachChild(node, visitor, context);
71889                 case 252:
71890                 case 221:
71891                     return doWithHierarchyFacts(visitDefault, node, 2, 1);
71892                 default:
71893                     return ts.visitEachChild(node, visitor, context);
71894             }
71895         }
71896         function visitAwaitExpression(node) {
71897             if (enclosingFunctionFlags & 2 && enclosingFunctionFlags & 1) {
71898                 return ts.setOriginalNode(ts.setTextRange(factory.createYieldExpression(undefined, emitHelpers().createAwaitHelper(ts.visitNode(node.expression, visitor, ts.isExpression))), node), node);
71899             }
71900             return ts.visitEachChild(node, visitor, context);
71901         }
71902         function visitYieldExpression(node) {
71903             if (enclosingFunctionFlags & 2 && enclosingFunctionFlags & 1) {
71904                 if (node.asteriskToken) {
71905                     var expression = ts.visitNode(ts.Debug.assertDefined(node.expression), visitor, ts.isExpression);
71906                     return ts.setOriginalNode(ts.setTextRange(factory.createYieldExpression(undefined, emitHelpers().createAwaitHelper(factory.updateYieldExpression(node, node.asteriskToken, ts.setTextRange(emitHelpers().createAsyncDelegatorHelper(ts.setTextRange(emitHelpers().createAsyncValuesHelper(expression), expression)), expression)))), node), node);
71907                 }
71908                 return ts.setOriginalNode(ts.setTextRange(factory.createYieldExpression(undefined, createDownlevelAwait(node.expression
71909                     ? ts.visitNode(node.expression, visitor, ts.isExpression)
71910                     : factory.createVoidZero())), node), node);
71911             }
71912             return ts.visitEachChild(node, visitor, context);
71913         }
71914         function visitReturnStatement(node) {
71915             if (enclosingFunctionFlags & 2 && enclosingFunctionFlags & 1) {
71916                 return factory.updateReturnStatement(node, createDownlevelAwait(node.expression ? ts.visitNode(node.expression, visitor, ts.isExpression) : factory.createVoidZero()));
71917             }
71918             return ts.visitEachChild(node, visitor, context);
71919         }
71920         function visitLabeledStatement(node) {
71921             if (enclosingFunctionFlags & 2) {
71922                 var statement = ts.unwrapInnermostStatementOfLabel(node);
71923                 if (statement.kind === 239 && statement.awaitModifier) {
71924                     return visitForOfStatement(statement, node);
71925                 }
71926                 return factory.restoreEnclosingLabel(ts.visitNode(statement, visitor, ts.isStatement, factory.liftToBlock), node);
71927             }
71928             return ts.visitEachChild(node, visitor, context);
71929         }
71930         function chunkObjectLiteralElements(elements) {
71931             var chunkObject;
71932             var objects = [];
71933             for (var _i = 0, elements_4 = elements; _i < elements_4.length; _i++) {
71934                 var e = elements_4[_i];
71935                 if (e.kind === 290) {
71936                     if (chunkObject) {
71937                         objects.push(factory.createObjectLiteralExpression(chunkObject));
71938                         chunkObject = undefined;
71939                     }
71940                     var target = e.expression;
71941                     objects.push(ts.visitNode(target, visitor, ts.isExpression));
71942                 }
71943                 else {
71944                     chunkObject = ts.append(chunkObject, e.kind === 288
71945                         ? factory.createPropertyAssignment(e.name, ts.visitNode(e.initializer, visitor, ts.isExpression))
71946                         : ts.visitNode(e, visitor, ts.isObjectLiteralElementLike));
71947                 }
71948             }
71949             if (chunkObject) {
71950                 objects.push(factory.createObjectLiteralExpression(chunkObject));
71951             }
71952             return objects;
71953         }
71954         function visitObjectLiteralExpression(node) {
71955             if (node.transformFlags & 16384) {
71956                 var objects = chunkObjectLiteralElements(node.properties);
71957                 if (objects.length && objects[0].kind !== 200) {
71958                     objects.unshift(factory.createObjectLiteralExpression());
71959                 }
71960                 var expression = objects[0];
71961                 if (objects.length > 1) {
71962                     for (var i = 1; i < objects.length; i++) {
71963                         expression = emitHelpers().createAssignHelper([expression, objects[i]]);
71964                     }
71965                     return expression;
71966                 }
71967                 else {
71968                     return emitHelpers().createAssignHelper(objects);
71969                 }
71970             }
71971             return ts.visitEachChild(node, visitor, context);
71972         }
71973         function visitExpressionStatement(node) {
71974             return ts.visitEachChild(node, visitorWithUnusedExpressionResult, context);
71975         }
71976         function visitParenthesizedExpression(node, expressionResultIsUnused) {
71977             return ts.visitEachChild(node, expressionResultIsUnused ? visitorWithUnusedExpressionResult : visitor, context);
71978         }
71979         function visitSourceFile(node) {
71980             var ancestorFacts = enterSubtree(2, ts.isEffectiveStrictModeSourceFile(node, compilerOptions) ?
71981                 0 :
71982                 1);
71983             exportedVariableStatement = false;
71984             var visited = ts.visitEachChild(node, visitor, context);
71985             var statement = ts.concatenate(visited.statements, taggedTemplateStringDeclarations && [
71986                 factory.createVariableStatement(undefined, factory.createVariableDeclarationList(taggedTemplateStringDeclarations))
71987             ]);
71988             var result = factory.updateSourceFile(visited, ts.setTextRange(factory.createNodeArray(statement), node.statements));
71989             exitSubtree(ancestorFacts);
71990             return result;
71991         }
71992         function visitTaggedTemplateExpression(node) {
71993             return ts.processTaggedTemplateExpression(context, node, visitor, currentSourceFile, recordTaggedTemplateString, ts.ProcessLevel.LiftRestriction);
71994         }
71995         function visitBinaryExpression(node, expressionResultIsUnused) {
71996             if (ts.isDestructuringAssignment(node) && node.left.transformFlags & 16384) {
71997                 return ts.flattenDestructuringAssignment(node, visitor, context, 1, !expressionResultIsUnused);
71998             }
71999             if (node.operatorToken.kind === 27) {
72000                 return factory.updateBinaryExpression(node, ts.visitNode(node.left, visitorWithUnusedExpressionResult, ts.isExpression), node.operatorToken, ts.visitNode(node.right, expressionResultIsUnused ? visitorWithUnusedExpressionResult : visitor, ts.isExpression));
72001             }
72002             return ts.visitEachChild(node, visitor, context);
72003         }
72004         function visitCommaListExpression(node, expressionResultIsUnused) {
72005             if (expressionResultIsUnused) {
72006                 return ts.visitEachChild(node, visitorWithUnusedExpressionResult, context);
72007             }
72008             var result;
72009             for (var i = 0; i < node.elements.length; i++) {
72010                 var element = node.elements[i];
72011                 var visited = ts.visitNode(element, i < node.elements.length - 1 ? visitorWithUnusedExpressionResult : visitor, ts.isExpression);
72012                 if (result || visited !== element) {
72013                     result || (result = node.elements.slice(0, i));
72014                     result.push(visited);
72015                 }
72016             }
72017             var elements = result ? ts.setTextRange(factory.createNodeArray(result), node.elements) : node.elements;
72018             return factory.updateCommaListExpression(node, elements);
72019         }
72020         function visitCatchClause(node) {
72021             if (node.variableDeclaration &&
72022                 ts.isBindingPattern(node.variableDeclaration.name) &&
72023                 node.variableDeclaration.name.transformFlags & 16384) {
72024                 var name = factory.getGeneratedNameForNode(node.variableDeclaration.name);
72025                 var updatedDecl = factory.updateVariableDeclaration(node.variableDeclaration, node.variableDeclaration.name, undefined, undefined, name);
72026                 var visitedBindings = ts.flattenDestructuringBinding(updatedDecl, visitor, context, 1);
72027                 var block = ts.visitNode(node.block, visitor, ts.isBlock);
72028                 if (ts.some(visitedBindings)) {
72029                     block = factory.updateBlock(block, __spreadArrays([
72030                         factory.createVariableStatement(undefined, visitedBindings)
72031                     ], block.statements));
72032                 }
72033                 return factory.updateCatchClause(node, factory.updateVariableDeclaration(node.variableDeclaration, name, undefined, undefined, undefined), block);
72034             }
72035             return ts.visitEachChild(node, visitor, context);
72036         }
72037         function visitVariableStatement(node) {
72038             if (ts.hasSyntacticModifier(node, 1)) {
72039                 var savedExportedVariableStatement = exportedVariableStatement;
72040                 exportedVariableStatement = true;
72041                 var visited = ts.visitEachChild(node, visitor, context);
72042                 exportedVariableStatement = savedExportedVariableStatement;
72043                 return visited;
72044             }
72045             return ts.visitEachChild(node, visitor, context);
72046         }
72047         function visitVariableDeclaration(node) {
72048             if (exportedVariableStatement) {
72049                 var savedExportedVariableStatement = exportedVariableStatement;
72050                 exportedVariableStatement = false;
72051                 var visited = visitVariableDeclarationWorker(node, true);
72052                 exportedVariableStatement = savedExportedVariableStatement;
72053                 return visited;
72054             }
72055             return visitVariableDeclarationWorker(node, false);
72056         }
72057         function visitVariableDeclarationWorker(node, exportedVariableStatement) {
72058             if (ts.isBindingPattern(node.name) && node.name.transformFlags & 16384) {
72059                 return ts.flattenDestructuringBinding(node, visitor, context, 1, undefined, exportedVariableStatement);
72060             }
72061             return ts.visitEachChild(node, visitor, context);
72062         }
72063         function visitForStatement(node) {
72064             return factory.updateForStatement(node, ts.visitNode(node.initializer, visitorWithUnusedExpressionResult, ts.isForInitializer), ts.visitNode(node.condition, visitor, ts.isExpression), ts.visitNode(node.incrementor, visitorWithUnusedExpressionResult, ts.isExpression), ts.visitNode(node.statement, visitor, ts.isStatement));
72065         }
72066         function visitVoidExpression(node) {
72067             return ts.visitEachChild(node, visitorWithUnusedExpressionResult, context);
72068         }
72069         function visitForOfStatement(node, outermostLabeledStatement) {
72070             var ancestorFacts = enterSubtree(0, 2);
72071             if (node.initializer.transformFlags & 16384) {
72072                 node = transformForOfStatementWithObjectRest(node);
72073             }
72074             var result = node.awaitModifier ?
72075                 transformForAwaitOfStatement(node, outermostLabeledStatement, ancestorFacts) :
72076                 factory.restoreEnclosingLabel(ts.visitEachChild(node, visitor, context), outermostLabeledStatement);
72077             exitSubtree(ancestorFacts);
72078             return result;
72079         }
72080         function transformForOfStatementWithObjectRest(node) {
72081             var initializerWithoutParens = ts.skipParentheses(node.initializer);
72082             if (ts.isVariableDeclarationList(initializerWithoutParens) || ts.isAssignmentPattern(initializerWithoutParens)) {
72083                 var bodyLocation = void 0;
72084                 var statementsLocation = void 0;
72085                 var temp = factory.createTempVariable(undefined);
72086                 var statements = [ts.createForOfBindingStatement(factory, initializerWithoutParens, temp)];
72087                 if (ts.isBlock(node.statement)) {
72088                     ts.addRange(statements, node.statement.statements);
72089                     bodyLocation = node.statement;
72090                     statementsLocation = node.statement.statements;
72091                 }
72092                 else if (node.statement) {
72093                     ts.append(statements, node.statement);
72094                     bodyLocation = node.statement;
72095                     statementsLocation = node.statement;
72096                 }
72097                 return factory.updateForOfStatement(node, node.awaitModifier, ts.setTextRange(factory.createVariableDeclarationList([
72098                     ts.setTextRange(factory.createVariableDeclaration(temp), node.initializer)
72099                 ], 1), node.initializer), node.expression, ts.setTextRange(factory.createBlock(ts.setTextRange(factory.createNodeArray(statements), statementsLocation), true), bodyLocation));
72100             }
72101             return node;
72102         }
72103         function convertForOfStatementHead(node, boundValue) {
72104             var binding = ts.createForOfBindingStatement(factory, node.initializer, boundValue);
72105             var bodyLocation;
72106             var statementsLocation;
72107             var statements = [ts.visitNode(binding, visitor, ts.isStatement)];
72108             var statement = ts.visitNode(node.statement, visitor, ts.isStatement);
72109             if (ts.isBlock(statement)) {
72110                 ts.addRange(statements, statement.statements);
72111                 bodyLocation = statement;
72112                 statementsLocation = statement.statements;
72113             }
72114             else {
72115                 statements.push(statement);
72116             }
72117             return ts.setEmitFlags(ts.setTextRange(factory.createBlock(ts.setTextRange(factory.createNodeArray(statements), statementsLocation), true), bodyLocation), 48 | 384);
72118         }
72119         function createDownlevelAwait(expression) {
72120             return enclosingFunctionFlags & 1
72121                 ? factory.createYieldExpression(undefined, emitHelpers().createAwaitHelper(expression))
72122                 : factory.createAwaitExpression(expression);
72123         }
72124         function transformForAwaitOfStatement(node, outermostLabeledStatement, ancestorFacts) {
72125             var expression = ts.visitNode(node.expression, visitor, ts.isExpression);
72126             var iterator = ts.isIdentifier(expression) ? factory.getGeneratedNameForNode(expression) : factory.createTempVariable(undefined);
72127             var result = ts.isIdentifier(expression) ? factory.getGeneratedNameForNode(iterator) : factory.createTempVariable(undefined);
72128             var errorRecord = factory.createUniqueName("e");
72129             var catchVariable = factory.getGeneratedNameForNode(errorRecord);
72130             var returnMethod = factory.createTempVariable(undefined);
72131             var callValues = ts.setTextRange(emitHelpers().createAsyncValuesHelper(expression), node.expression);
72132             var callNext = factory.createCallExpression(factory.createPropertyAccessExpression(iterator, "next"), undefined, []);
72133             var getDone = factory.createPropertyAccessExpression(result, "done");
72134             var getValue = factory.createPropertyAccessExpression(result, "value");
72135             var callReturn = factory.createFunctionCallCall(returnMethod, iterator, []);
72136             hoistVariableDeclaration(errorRecord);
72137             hoistVariableDeclaration(returnMethod);
72138             var initializer = ancestorFacts & 2 ?
72139                 factory.inlineExpressions([factory.createAssignment(errorRecord, factory.createVoidZero()), callValues]) :
72140                 callValues;
72141             var forStatement = ts.setEmitFlags(ts.setTextRange(factory.createForStatement(ts.setEmitFlags(ts.setTextRange(factory.createVariableDeclarationList([
72142                 ts.setTextRange(factory.createVariableDeclaration(iterator, undefined, undefined, initializer), node.expression),
72143                 factory.createVariableDeclaration(result)
72144             ]), node.expression), 2097152), factory.createComma(factory.createAssignment(result, createDownlevelAwait(callNext)), factory.createLogicalNot(getDone)), undefined, convertForOfStatementHead(node, getValue)), node), 256);
72145             return factory.createTryStatement(factory.createBlock([
72146                 factory.restoreEnclosingLabel(forStatement, outermostLabeledStatement)
72147             ]), factory.createCatchClause(factory.createVariableDeclaration(catchVariable), ts.setEmitFlags(factory.createBlock([
72148                 factory.createExpressionStatement(factory.createAssignment(errorRecord, factory.createObjectLiteralExpression([
72149                     factory.createPropertyAssignment("error", catchVariable)
72150                 ])))
72151             ]), 1)), factory.createBlock([
72152                 factory.createTryStatement(factory.createBlock([
72153                     ts.setEmitFlags(factory.createIfStatement(factory.createLogicalAnd(factory.createLogicalAnd(result, factory.createLogicalNot(getDone)), factory.createAssignment(returnMethod, factory.createPropertyAccessExpression(iterator, "return"))), factory.createExpressionStatement(createDownlevelAwait(callReturn))), 1)
72154                 ]), undefined, ts.setEmitFlags(factory.createBlock([
72155                     ts.setEmitFlags(factory.createIfStatement(errorRecord, factory.createThrowStatement(factory.createPropertyAccessExpression(errorRecord, "error"))), 1)
72156                 ]), 1))
72157             ]));
72158         }
72159         function visitParameter(node) {
72160             if (node.transformFlags & 16384) {
72161                 return factory.updateParameterDeclaration(node, undefined, undefined, node.dotDotDotToken, factory.getGeneratedNameForNode(node), undefined, undefined, ts.visitNode(node.initializer, visitor, ts.isExpression));
72162             }
72163             return ts.visitEachChild(node, visitor, context);
72164         }
72165         function visitConstructorDeclaration(node) {
72166             var savedEnclosingFunctionFlags = enclosingFunctionFlags;
72167             enclosingFunctionFlags = 0;
72168             var updated = factory.updateConstructorDeclaration(node, undefined, node.modifiers, ts.visitParameterList(node.parameters, visitor, context), transformFunctionBody(node));
72169             enclosingFunctionFlags = savedEnclosingFunctionFlags;
72170             return updated;
72171         }
72172         function visitGetAccessorDeclaration(node) {
72173             var savedEnclosingFunctionFlags = enclosingFunctionFlags;
72174             enclosingFunctionFlags = 0;
72175             var updated = factory.updateGetAccessorDeclaration(node, undefined, node.modifiers, ts.visitNode(node.name, visitor, ts.isPropertyName), ts.visitParameterList(node.parameters, visitor, context), undefined, transformFunctionBody(node));
72176             enclosingFunctionFlags = savedEnclosingFunctionFlags;
72177             return updated;
72178         }
72179         function visitSetAccessorDeclaration(node) {
72180             var savedEnclosingFunctionFlags = enclosingFunctionFlags;
72181             enclosingFunctionFlags = 0;
72182             var updated = factory.updateSetAccessorDeclaration(node, undefined, node.modifiers, ts.visitNode(node.name, visitor, ts.isPropertyName), ts.visitParameterList(node.parameters, visitor, context), transformFunctionBody(node));
72183             enclosingFunctionFlags = savedEnclosingFunctionFlags;
72184             return updated;
72185         }
72186         function visitMethodDeclaration(node) {
72187             var savedEnclosingFunctionFlags = enclosingFunctionFlags;
72188             enclosingFunctionFlags = ts.getFunctionFlags(node);
72189             var updated = factory.updateMethodDeclaration(node, undefined, enclosingFunctionFlags & 1
72190                 ? ts.visitNodes(node.modifiers, visitorNoAsyncModifier, ts.isModifier)
72191                 : node.modifiers, enclosingFunctionFlags & 2
72192                 ? undefined
72193                 : 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
72194                 ? transformAsyncGeneratorFunctionBody(node)
72195                 : transformFunctionBody(node));
72196             enclosingFunctionFlags = savedEnclosingFunctionFlags;
72197             return updated;
72198         }
72199         function visitFunctionDeclaration(node) {
72200             var savedEnclosingFunctionFlags = enclosingFunctionFlags;
72201             enclosingFunctionFlags = ts.getFunctionFlags(node);
72202             var updated = factory.updateFunctionDeclaration(node, undefined, enclosingFunctionFlags & 1
72203                 ? ts.visitNodes(node.modifiers, visitorNoAsyncModifier, ts.isModifier)
72204                 : node.modifiers, enclosingFunctionFlags & 2
72205                 ? undefined
72206                 : node.asteriskToken, node.name, undefined, ts.visitParameterList(node.parameters, visitor, context), undefined, enclosingFunctionFlags & 2 && enclosingFunctionFlags & 1
72207                 ? transformAsyncGeneratorFunctionBody(node)
72208                 : transformFunctionBody(node));
72209             enclosingFunctionFlags = savedEnclosingFunctionFlags;
72210             return updated;
72211         }
72212         function visitArrowFunction(node) {
72213             var savedEnclosingFunctionFlags = enclosingFunctionFlags;
72214             enclosingFunctionFlags = ts.getFunctionFlags(node);
72215             var updated = factory.updateArrowFunction(node, node.modifiers, undefined, ts.visitParameterList(node.parameters, visitor, context), undefined, node.equalsGreaterThanToken, transformFunctionBody(node));
72216             enclosingFunctionFlags = savedEnclosingFunctionFlags;
72217             return updated;
72218         }
72219         function visitFunctionExpression(node) {
72220             var savedEnclosingFunctionFlags = enclosingFunctionFlags;
72221             enclosingFunctionFlags = ts.getFunctionFlags(node);
72222             var updated = factory.updateFunctionExpression(node, enclosingFunctionFlags & 1
72223                 ? ts.visitNodes(node.modifiers, visitorNoAsyncModifier, ts.isModifier)
72224                 : node.modifiers, enclosingFunctionFlags & 2
72225                 ? undefined
72226                 : node.asteriskToken, node.name, undefined, ts.visitParameterList(node.parameters, visitor, context), undefined, enclosingFunctionFlags & 2 && enclosingFunctionFlags & 1
72227                 ? transformAsyncGeneratorFunctionBody(node)
72228                 : transformFunctionBody(node));
72229             enclosingFunctionFlags = savedEnclosingFunctionFlags;
72230             return updated;
72231         }
72232         function transformAsyncGeneratorFunctionBody(node) {
72233             resumeLexicalEnvironment();
72234             var statements = [];
72235             var statementOffset = factory.copyPrologue(node.body.statements, statements, false, visitor);
72236             appendObjectRestAssignmentsIfNeeded(statements, node);
72237             var savedCapturedSuperProperties = capturedSuperProperties;
72238             var savedHasSuperElementAccess = hasSuperElementAccess;
72239             capturedSuperProperties = new ts.Set();
72240             hasSuperElementAccess = false;
72241             var returnStatement = factory.createReturnStatement(emitHelpers().createAsyncGeneratorHelper(factory.createFunctionExpression(undefined, factory.createToken(41), node.name && factory.getGeneratedNameForNode(node.name), undefined, [], undefined, factory.updateBlock(node.body, ts.visitLexicalEnvironment(node.body.statements, visitor, context, statementOffset))), !!(hierarchyFacts & 1)));
72242             var emitSuperHelpers = languageVersion >= 2 && resolver.getNodeCheckFlags(node) & (4096 | 2048);
72243             if (emitSuperHelpers) {
72244                 enableSubstitutionForAsyncMethodsWithSuper();
72245                 var variableStatement = ts.createSuperAccessVariableStatement(factory, resolver, node, capturedSuperProperties);
72246                 substitutedSuperAccessors[ts.getNodeId(variableStatement)] = true;
72247                 ts.insertStatementsAfterStandardPrologue(statements, [variableStatement]);
72248             }
72249             statements.push(returnStatement);
72250             ts.insertStatementsAfterStandardPrologue(statements, endLexicalEnvironment());
72251             var block = factory.updateBlock(node.body, statements);
72252             if (emitSuperHelpers && hasSuperElementAccess) {
72253                 if (resolver.getNodeCheckFlags(node) & 4096) {
72254                     ts.addEmitHelper(block, ts.advancedAsyncSuperHelper);
72255                 }
72256                 else if (resolver.getNodeCheckFlags(node) & 2048) {
72257                     ts.addEmitHelper(block, ts.asyncSuperHelper);
72258                 }
72259             }
72260             capturedSuperProperties = savedCapturedSuperProperties;
72261             hasSuperElementAccess = savedHasSuperElementAccess;
72262             return block;
72263         }
72264         function transformFunctionBody(node) {
72265             var _a;
72266             resumeLexicalEnvironment();
72267             var statementOffset = 0;
72268             var statements = [];
72269             var body = (_a = ts.visitNode(node.body, visitor, ts.isConciseBody)) !== null && _a !== void 0 ? _a : factory.createBlock([]);
72270             if (ts.isBlock(body)) {
72271                 statementOffset = factory.copyPrologue(body.statements, statements, false, visitor);
72272             }
72273             ts.addRange(statements, appendObjectRestAssignmentsIfNeeded(undefined, node));
72274             var leadingStatements = endLexicalEnvironment();
72275             if (statementOffset > 0 || ts.some(statements) || ts.some(leadingStatements)) {
72276                 var block = factory.converters.convertToFunctionBlock(body, true);
72277                 ts.insertStatementsAfterStandardPrologue(statements, leadingStatements);
72278                 ts.addRange(statements, block.statements.slice(statementOffset));
72279                 return factory.updateBlock(block, ts.setTextRange(factory.createNodeArray(statements), block.statements));
72280             }
72281             return body;
72282         }
72283         function appendObjectRestAssignmentsIfNeeded(statements, node) {
72284             for (var _i = 0, _a = node.parameters; _i < _a.length; _i++) {
72285                 var parameter = _a[_i];
72286                 if (parameter.transformFlags & 16384) {
72287                     var temp = factory.getGeneratedNameForNode(parameter);
72288                     var declarations = ts.flattenDestructuringBinding(parameter, visitor, context, 1, temp, false, true);
72289                     if (ts.some(declarations)) {
72290                         var statement = factory.createVariableStatement(undefined, factory.createVariableDeclarationList(declarations));
72291                         ts.setEmitFlags(statement, 1048576);
72292                         statements = ts.append(statements, statement);
72293                     }
72294                 }
72295             }
72296             return statements;
72297         }
72298         function enableSubstitutionForAsyncMethodsWithSuper() {
72299             if ((enabledSubstitutions & 1) === 0) {
72300                 enabledSubstitutions |= 1;
72301                 context.enableSubstitution(203);
72302                 context.enableSubstitution(201);
72303                 context.enableSubstitution(202);
72304                 context.enableEmitNotification(252);
72305                 context.enableEmitNotification(165);
72306                 context.enableEmitNotification(167);
72307                 context.enableEmitNotification(168);
72308                 context.enableEmitNotification(166);
72309                 context.enableEmitNotification(232);
72310             }
72311         }
72312         function onEmitNode(hint, node, emitCallback) {
72313             if (enabledSubstitutions & 1 && isSuperContainer(node)) {
72314                 var superContainerFlags = resolver.getNodeCheckFlags(node) & (2048 | 4096);
72315                 if (superContainerFlags !== enclosingSuperContainerFlags) {
72316                     var savedEnclosingSuperContainerFlags = enclosingSuperContainerFlags;
72317                     enclosingSuperContainerFlags = superContainerFlags;
72318                     previousOnEmitNode(hint, node, emitCallback);
72319                     enclosingSuperContainerFlags = savedEnclosingSuperContainerFlags;
72320                     return;
72321                 }
72322             }
72323             else if (enabledSubstitutions && substitutedSuperAccessors[ts.getNodeId(node)]) {
72324                 var savedEnclosingSuperContainerFlags = enclosingSuperContainerFlags;
72325                 enclosingSuperContainerFlags = 0;
72326                 previousOnEmitNode(hint, node, emitCallback);
72327                 enclosingSuperContainerFlags = savedEnclosingSuperContainerFlags;
72328                 return;
72329             }
72330             previousOnEmitNode(hint, node, emitCallback);
72331         }
72332         function onSubstituteNode(hint, node) {
72333             node = previousOnSubstituteNode(hint, node);
72334             if (hint === 1 && enclosingSuperContainerFlags) {
72335                 return substituteExpression(node);
72336             }
72337             return node;
72338         }
72339         function substituteExpression(node) {
72340             switch (node.kind) {
72341                 case 201:
72342                     return substitutePropertyAccessExpression(node);
72343                 case 202:
72344                     return substituteElementAccessExpression(node);
72345                 case 203:
72346                     return substituteCallExpression(node);
72347             }
72348             return node;
72349         }
72350         function substitutePropertyAccessExpression(node) {
72351             if (node.expression.kind === 105) {
72352                 return ts.setTextRange(factory.createPropertyAccessExpression(factory.createUniqueName("_super", 16 | 32), node.name), node);
72353             }
72354             return node;
72355         }
72356         function substituteElementAccessExpression(node) {
72357             if (node.expression.kind === 105) {
72358                 return createSuperElementAccessInAsyncMethod(node.argumentExpression, node);
72359             }
72360             return node;
72361         }
72362         function substituteCallExpression(node) {
72363             var expression = node.expression;
72364             if (ts.isSuperProperty(expression)) {
72365                 var argumentExpression = ts.isPropertyAccessExpression(expression)
72366                     ? substitutePropertyAccessExpression(expression)
72367                     : substituteElementAccessExpression(expression);
72368                 return factory.createCallExpression(factory.createPropertyAccessExpression(argumentExpression, "call"), undefined, __spreadArrays([
72369                     factory.createThis()
72370                 ], node.arguments));
72371             }
72372             return node;
72373         }
72374         function isSuperContainer(node) {
72375             var kind = node.kind;
72376             return kind === 252
72377                 || kind === 166
72378                 || kind === 165
72379                 || kind === 167
72380                 || kind === 168;
72381         }
72382         function createSuperElementAccessInAsyncMethod(argumentExpression, location) {
72383             if (enclosingSuperContainerFlags & 4096) {
72384                 return ts.setTextRange(factory.createPropertyAccessExpression(factory.createCallExpression(factory.createIdentifier("_superIndex"), undefined, [argumentExpression]), "value"), location);
72385             }
72386             else {
72387                 return ts.setTextRange(factory.createCallExpression(factory.createIdentifier("_superIndex"), undefined, [argumentExpression]), location);
72388             }
72389         }
72390     }
72391     ts.transformES2018 = transformES2018;
72392 })(ts || (ts = {}));
72393 var ts;
72394 (function (ts) {
72395     function transformES2019(context) {
72396         var factory = context.factory;
72397         return ts.chainBundle(context, transformSourceFile);
72398         function transformSourceFile(node) {
72399             if (node.isDeclarationFile) {
72400                 return node;
72401             }
72402             return ts.visitEachChild(node, visitor, context);
72403         }
72404         function visitor(node) {
72405             if ((node.transformFlags & 16) === 0) {
72406                 return node;
72407             }
72408             switch (node.kind) {
72409                 case 287:
72410                     return visitCatchClause(node);
72411                 default:
72412                     return ts.visitEachChild(node, visitor, context);
72413             }
72414         }
72415         function visitCatchClause(node) {
72416             if (!node.variableDeclaration) {
72417                 return factory.updateCatchClause(node, factory.createVariableDeclaration(factory.createTempVariable(undefined)), ts.visitNode(node.block, visitor, ts.isBlock));
72418             }
72419             return ts.visitEachChild(node, visitor, context);
72420         }
72421     }
72422     ts.transformES2019 = transformES2019;
72423 })(ts || (ts = {}));
72424 var ts;
72425 (function (ts) {
72426     function transformES2020(context) {
72427         var factory = context.factory, hoistVariableDeclaration = context.hoistVariableDeclaration;
72428         return ts.chainBundle(context, transformSourceFile);
72429         function transformSourceFile(node) {
72430             if (node.isDeclarationFile) {
72431                 return node;
72432             }
72433             return ts.visitEachChild(node, visitor, context);
72434         }
72435         function visitor(node) {
72436             if ((node.transformFlags & 8) === 0) {
72437                 return node;
72438             }
72439             switch (node.kind) {
72440                 case 201:
72441                 case 202:
72442                 case 203:
72443                     if (node.flags & 32) {
72444                         var updated = visitOptionalExpression(node, false, false);
72445                         ts.Debug.assertNotNode(updated, ts.isSyntheticReference);
72446                         return updated;
72447                     }
72448                     return ts.visitEachChild(node, visitor, context);
72449                 case 216:
72450                     if (node.operatorToken.kind === 60) {
72451                         return transformNullishCoalescingExpression(node);
72452                     }
72453                     return ts.visitEachChild(node, visitor, context);
72454                 case 210:
72455                     return visitDeleteExpression(node);
72456                 default:
72457                     return ts.visitEachChild(node, visitor, context);
72458             }
72459         }
72460         function flattenChain(chain) {
72461             ts.Debug.assertNotNode(chain, ts.isNonNullChain);
72462             var links = [chain];
72463             while (!chain.questionDotToken && !ts.isTaggedTemplateExpression(chain)) {
72464                 chain = ts.cast(ts.skipPartiallyEmittedExpressions(chain.expression), ts.isOptionalChain);
72465                 ts.Debug.assertNotNode(chain, ts.isNonNullChain);
72466                 links.unshift(chain);
72467             }
72468             return { expression: chain.expression, chain: links };
72469         }
72470         function visitNonOptionalParenthesizedExpression(node, captureThisArg, isDelete) {
72471             var expression = visitNonOptionalExpression(node.expression, captureThisArg, isDelete);
72472             if (ts.isSyntheticReference(expression)) {
72473                 return factory.createSyntheticReferenceExpression(factory.updateParenthesizedExpression(node, expression.expression), expression.thisArg);
72474             }
72475             return factory.updateParenthesizedExpression(node, expression);
72476         }
72477         function visitNonOptionalPropertyOrElementAccessExpression(node, captureThisArg, isDelete) {
72478             if (ts.isOptionalChain(node)) {
72479                 return visitOptionalExpression(node, captureThisArg, isDelete);
72480             }
72481             var expression = ts.visitNode(node.expression, visitor, ts.isExpression);
72482             ts.Debug.assertNotNode(expression, ts.isSyntheticReference);
72483             var thisArg;
72484             if (captureThisArg) {
72485                 if (!ts.isSimpleCopiableExpression(expression)) {
72486                     thisArg = factory.createTempVariable(hoistVariableDeclaration);
72487                     expression = factory.createAssignment(thisArg, expression);
72488                 }
72489                 else {
72490                     thisArg = expression;
72491                 }
72492             }
72493             expression = node.kind === 201
72494                 ? factory.updatePropertyAccessExpression(node, expression, ts.visitNode(node.name, visitor, ts.isIdentifier))
72495                 : factory.updateElementAccessExpression(node, expression, ts.visitNode(node.argumentExpression, visitor, ts.isExpression));
72496             return thisArg ? factory.createSyntheticReferenceExpression(expression, thisArg) : expression;
72497         }
72498         function visitNonOptionalCallExpression(node, captureThisArg) {
72499             if (ts.isOptionalChain(node)) {
72500                 return visitOptionalExpression(node, captureThisArg, false);
72501             }
72502             return ts.visitEachChild(node, visitor, context);
72503         }
72504         function visitNonOptionalExpression(node, captureThisArg, isDelete) {
72505             switch (node.kind) {
72506                 case 207: return visitNonOptionalParenthesizedExpression(node, captureThisArg, isDelete);
72507                 case 201:
72508                 case 202: return visitNonOptionalPropertyOrElementAccessExpression(node, captureThisArg, isDelete);
72509                 case 203: return visitNonOptionalCallExpression(node, captureThisArg);
72510                 default: return ts.visitNode(node, visitor, ts.isExpression);
72511             }
72512         }
72513         function visitOptionalExpression(node, captureThisArg, isDelete) {
72514             var _a = flattenChain(node), expression = _a.expression, chain = _a.chain;
72515             var left = visitNonOptionalExpression(expression, ts.isCallChain(chain[0]), false);
72516             var leftThisArg = ts.isSyntheticReference(left) ? left.thisArg : undefined;
72517             var leftExpression = ts.isSyntheticReference(left) ? left.expression : left;
72518             var capturedLeft = leftExpression;
72519             if (!ts.isSimpleCopiableExpression(leftExpression)) {
72520                 capturedLeft = factory.createTempVariable(hoistVariableDeclaration);
72521                 leftExpression = factory.createAssignment(capturedLeft, leftExpression);
72522             }
72523             var rightExpression = capturedLeft;
72524             var thisArg;
72525             for (var i = 0; i < chain.length; i++) {
72526                 var segment = chain[i];
72527                 switch (segment.kind) {
72528                     case 201:
72529                     case 202:
72530                         if (i === chain.length - 1 && captureThisArg) {
72531                             if (!ts.isSimpleCopiableExpression(rightExpression)) {
72532                                 thisArg = factory.createTempVariable(hoistVariableDeclaration);
72533                                 rightExpression = factory.createAssignment(thisArg, rightExpression);
72534                             }
72535                             else {
72536                                 thisArg = rightExpression;
72537                             }
72538                         }
72539                         rightExpression = segment.kind === 201
72540                             ? factory.createPropertyAccessExpression(rightExpression, ts.visitNode(segment.name, visitor, ts.isIdentifier))
72541                             : factory.createElementAccessExpression(rightExpression, ts.visitNode(segment.argumentExpression, visitor, ts.isExpression));
72542                         break;
72543                     case 203:
72544                         if (i === 0 && leftThisArg) {
72545                             rightExpression = factory.createFunctionCallCall(rightExpression, leftThisArg.kind === 105 ? factory.createThis() : leftThisArg, ts.visitNodes(segment.arguments, visitor, ts.isExpression));
72546                         }
72547                         else {
72548                             rightExpression = factory.createCallExpression(rightExpression, undefined, ts.visitNodes(segment.arguments, visitor, ts.isExpression));
72549                         }
72550                         break;
72551                 }
72552                 ts.setOriginalNode(rightExpression, segment);
72553             }
72554             var target = isDelete
72555                 ? factory.createConditionalExpression(createNotNullCondition(leftExpression, capturedLeft, true), undefined, factory.createTrue(), undefined, factory.createDeleteExpression(rightExpression))
72556                 : factory.createConditionalExpression(createNotNullCondition(leftExpression, capturedLeft, true), undefined, factory.createVoidZero(), undefined, rightExpression);
72557             return thisArg ? factory.createSyntheticReferenceExpression(target, thisArg) : target;
72558         }
72559         function createNotNullCondition(left, right, invert) {
72560             return factory.createBinaryExpression(factory.createBinaryExpression(left, factory.createToken(invert ? 36 : 37), factory.createNull()), factory.createToken(invert ? 56 : 55), factory.createBinaryExpression(right, factory.createToken(invert ? 36 : 37), factory.createVoidZero()));
72561         }
72562         function transformNullishCoalescingExpression(node) {
72563             var left = ts.visitNode(node.left, visitor, ts.isExpression);
72564             var right = left;
72565             if (!ts.isSimpleCopiableExpression(left)) {
72566                 right = factory.createTempVariable(hoistVariableDeclaration);
72567                 left = factory.createAssignment(right, left);
72568             }
72569             return factory.createConditionalExpression(createNotNullCondition(left, right), undefined, right, undefined, ts.visitNode(node.right, visitor, ts.isExpression));
72570         }
72571         function visitDeleteExpression(node) {
72572             return ts.isOptionalChain(ts.skipParentheses(node.expression))
72573                 ? ts.setOriginalNode(visitNonOptionalExpression(node.expression, false, true), node)
72574                 : factory.updateDeleteExpression(node, ts.visitNode(node.expression, visitor, ts.isExpression));
72575         }
72576     }
72577     ts.transformES2020 = transformES2020;
72578 })(ts || (ts = {}));
72579 var ts;
72580 (function (ts) {
72581     function transformESNext(context) {
72582         var hoistVariableDeclaration = context.hoistVariableDeclaration, factory = context.factory;
72583         return ts.chainBundle(context, transformSourceFile);
72584         function transformSourceFile(node) {
72585             if (node.isDeclarationFile) {
72586                 return node;
72587             }
72588             return ts.visitEachChild(node, visitor, context);
72589         }
72590         function visitor(node) {
72591             if ((node.transformFlags & 4) === 0) {
72592                 return node;
72593             }
72594             switch (node.kind) {
72595                 case 216:
72596                     var binaryExpression = node;
72597                     if (ts.isLogicalOrCoalescingAssignmentExpression(binaryExpression)) {
72598                         return transformLogicalAssignment(binaryExpression);
72599                     }
72600                 default:
72601                     return ts.visitEachChild(node, visitor, context);
72602             }
72603         }
72604         function transformLogicalAssignment(binaryExpression) {
72605             var operator = binaryExpression.operatorToken;
72606             var nonAssignmentOperator = ts.getNonAssignmentOperatorForCompoundAssignment(operator.kind);
72607             var left = ts.skipParentheses(ts.visitNode(binaryExpression.left, visitor, ts.isLeftHandSideExpression));
72608             var assignmentTarget = left;
72609             var right = ts.skipParentheses(ts.visitNode(binaryExpression.right, visitor, ts.isExpression));
72610             if (ts.isAccessExpression(left)) {
72611                 var propertyAccessTargetSimpleCopiable = ts.isSimpleCopiableExpression(left.expression);
72612                 var propertyAccessTarget = propertyAccessTargetSimpleCopiable ? left.expression :
72613                     factory.createTempVariable(hoistVariableDeclaration);
72614                 var propertyAccessTargetAssignment = propertyAccessTargetSimpleCopiable ? left.expression : factory.createAssignment(propertyAccessTarget, left.expression);
72615                 if (ts.isPropertyAccessExpression(left)) {
72616                     assignmentTarget = factory.createPropertyAccessExpression(propertyAccessTarget, left.name);
72617                     left = factory.createPropertyAccessExpression(propertyAccessTargetAssignment, left.name);
72618                 }
72619                 else {
72620                     var elementAccessArgumentSimpleCopiable = ts.isSimpleCopiableExpression(left.argumentExpression);
72621                     var elementAccessArgument = elementAccessArgumentSimpleCopiable ? left.argumentExpression :
72622                         factory.createTempVariable(hoistVariableDeclaration);
72623                     assignmentTarget = factory.createElementAccessExpression(propertyAccessTarget, elementAccessArgument);
72624                     left = factory.createElementAccessExpression(propertyAccessTargetAssignment, elementAccessArgumentSimpleCopiable ? left.argumentExpression : factory.createAssignment(elementAccessArgument, left.argumentExpression));
72625                 }
72626             }
72627             return factory.createBinaryExpression(left, nonAssignmentOperator, factory.createParenthesizedExpression(factory.createAssignment(assignmentTarget, right)));
72628         }
72629     }
72630     ts.transformESNext = transformESNext;
72631 })(ts || (ts = {}));
72632 var ts;
72633 (function (ts) {
72634     function transformJsx(context) {
72635         var factory = context.factory, emitHelpers = context.getEmitHelperFactory;
72636         var compilerOptions = context.getCompilerOptions();
72637         var currentSourceFile;
72638         var currentFileState;
72639         return ts.chainBundle(context, transformSourceFile);
72640         function getCurrentFileNameExpression() {
72641             if (currentFileState.filenameDeclaration) {
72642                 return currentFileState.filenameDeclaration.name;
72643             }
72644             var declaration = factory.createVariableDeclaration(factory.createUniqueName("_jsxFileName", 16 | 32), undefined, undefined, factory.createStringLiteral(currentSourceFile.fileName));
72645             currentFileState.filenameDeclaration = declaration;
72646             return currentFileState.filenameDeclaration.name;
72647         }
72648         function getJsxFactoryCalleePrimitive(childrenLength) {
72649             return compilerOptions.jsx === 5 ? "jsxDEV" : childrenLength > 1 ? "jsxs" : "jsx";
72650         }
72651         function getJsxFactoryCallee(childrenLength) {
72652             var type = getJsxFactoryCalleePrimitive(childrenLength);
72653             return getImplicitImportForName(type);
72654         }
72655         function getImplicitJsxFragmentReference() {
72656             return getImplicitImportForName("Fragment");
72657         }
72658         function getImplicitImportForName(name) {
72659             var _a, _b;
72660             var importSource = name === "createElement"
72661                 ? currentFileState.importSpecifier
72662                 : ts.getJSXRuntimeImport(currentFileState.importSpecifier, compilerOptions);
72663             var existing = (_b = (_a = currentFileState.utilizedImplicitRuntimeImports) === null || _a === void 0 ? void 0 : _a.get(importSource)) === null || _b === void 0 ? void 0 : _b.get(name);
72664             if (existing) {
72665                 return existing.name;
72666             }
72667             if (!currentFileState.utilizedImplicitRuntimeImports) {
72668                 currentFileState.utilizedImplicitRuntimeImports = ts.createMap();
72669             }
72670             var specifierSourceImports = currentFileState.utilizedImplicitRuntimeImports.get(importSource);
72671             if (!specifierSourceImports) {
72672                 specifierSourceImports = ts.createMap();
72673                 currentFileState.utilizedImplicitRuntimeImports.set(importSource, specifierSourceImports);
72674             }
72675             var generatedName = factory.createUniqueName("_" + name, 16 | 32 | 64);
72676             var specifier = factory.createImportSpecifier(factory.createIdentifier(name), generatedName);
72677             generatedName.generatedImportReference = specifier;
72678             specifierSourceImports.set(name, specifier);
72679             return generatedName;
72680         }
72681         function transformSourceFile(node) {
72682             if (node.isDeclarationFile) {
72683                 return node;
72684             }
72685             currentSourceFile = node;
72686             currentFileState = {};
72687             currentFileState.importSpecifier = ts.getJSXImplicitImportBase(compilerOptions, node);
72688             var visited = ts.visitEachChild(node, visitor, context);
72689             ts.addEmitHelpers(visited, context.readEmitHelpers());
72690             var statements = visited.statements;
72691             if (currentFileState.filenameDeclaration) {
72692                 statements = ts.insertStatementAfterCustomPrologue(statements.slice(), factory.createVariableStatement(undefined, factory.createVariableDeclarationList([currentFileState.filenameDeclaration], 2)));
72693             }
72694             if (currentFileState.utilizedImplicitRuntimeImports) {
72695                 for (var _i = 0, _a = ts.arrayFrom(currentFileState.utilizedImplicitRuntimeImports.entries()); _i < _a.length; _i++) {
72696                     var _b = _a[_i], importSource = _b[0], importSpecifiersMap = _b[1];
72697                     if (ts.isExternalModule(node)) {
72698                         var importStatement = factory.createImportDeclaration(undefined, undefined, factory.createImportClause(false, undefined, factory.createNamedImports(ts.arrayFrom(importSpecifiersMap.values()))), factory.createStringLiteral(importSource));
72699                         ts.setParentRecursive(importStatement, false);
72700                         statements = ts.insertStatementAfterCustomPrologue(statements.slice(), importStatement);
72701                     }
72702                     else if (ts.isExternalOrCommonJsModule(node)) {
72703                         var requireStatement = factory.createVariableStatement(undefined, factory.createVariableDeclarationList([
72704                             factory.createVariableDeclaration(factory.createObjectBindingPattern(ts.map(ts.arrayFrom(importSpecifiersMap.values()), function (s) { return factory.createBindingElement(undefined, s.propertyName, s.name); })), undefined, undefined, factory.createCallExpression(factory.createIdentifier("require"), undefined, [factory.createStringLiteral(importSource)]))
72705                         ], 2));
72706                         ts.setParentRecursive(requireStatement, false);
72707                         statements = ts.insertStatementAfterCustomPrologue(statements.slice(), requireStatement);
72708                     }
72709                     else {
72710                     }
72711                 }
72712             }
72713             if (statements !== visited.statements) {
72714                 visited = factory.updateSourceFile(visited, statements);
72715             }
72716             currentFileState = undefined;
72717             return visited;
72718         }
72719         function visitor(node) {
72720             if (node.transformFlags & 2) {
72721                 return visitorWorker(node);
72722             }
72723             else {
72724                 return node;
72725             }
72726         }
72727         function visitorWorker(node) {
72728             switch (node.kind) {
72729                 case 273:
72730                     return visitJsxElement(node, false);
72731                 case 274:
72732                     return visitJsxSelfClosingElement(node, false);
72733                 case 277:
72734                     return visitJsxFragment(node, false);
72735                 case 283:
72736                     return visitJsxExpression(node);
72737                 default:
72738                     return ts.visitEachChild(node, visitor, context);
72739             }
72740         }
72741         function transformJsxChildToExpression(node) {
72742             switch (node.kind) {
72743                 case 11:
72744                     return visitJsxText(node);
72745                 case 283:
72746                     return visitJsxExpression(node);
72747                 case 273:
72748                     return visitJsxElement(node, true);
72749                 case 274:
72750                     return visitJsxSelfClosingElement(node, true);
72751                 case 277:
72752                     return visitJsxFragment(node, true);
72753                 default:
72754                     return ts.Debug.failBadSyntaxKind(node);
72755             }
72756         }
72757         function hasKeyAfterPropsSpread(node) {
72758             var spread = false;
72759             for (var _i = 0, _a = node.attributes.properties; _i < _a.length; _i++) {
72760                 var elem = _a[_i];
72761                 if (ts.isJsxSpreadAttribute(elem)) {
72762                     spread = true;
72763                 }
72764                 else if (spread && ts.isJsxAttribute(elem) && elem.name.escapedText === "key") {
72765                     return true;
72766                 }
72767             }
72768             return false;
72769         }
72770         function shouldUseCreateElement(node) {
72771             return currentFileState.importSpecifier === undefined || hasKeyAfterPropsSpread(node);
72772         }
72773         function visitJsxElement(node, isChild) {
72774             var tagTransform = shouldUseCreateElement(node.openingElement) ? visitJsxOpeningLikeElementCreateElement : visitJsxOpeningLikeElementJSX;
72775             return tagTransform(node.openingElement, node.children, isChild, node);
72776         }
72777         function visitJsxSelfClosingElement(node, isChild) {
72778             var tagTransform = shouldUseCreateElement(node) ? visitJsxOpeningLikeElementCreateElement : visitJsxOpeningLikeElementJSX;
72779             return tagTransform(node, undefined, isChild, node);
72780         }
72781         function visitJsxFragment(node, isChild) {
72782             var tagTransform = currentFileState.importSpecifier === undefined ? visitJsxOpeningFragmentCreateElement : visitJsxOpeningFragmentJSX;
72783             return tagTransform(node.openingFragment, node.children, isChild, node);
72784         }
72785         function convertJsxChildrenToChildrenPropObject(children) {
72786             var nonWhitespaceChildren = ts.getSemanticJsxChildren(children);
72787             if (ts.length(nonWhitespaceChildren) === 1) {
72788                 var result_13 = transformJsxChildToExpression(nonWhitespaceChildren[0]);
72789                 return result_13 && factory.createObjectLiteralExpression([
72790                     factory.createPropertyAssignment("children", result_13)
72791                 ]);
72792             }
72793             var result = ts.mapDefined(children, transformJsxChildToExpression);
72794             return !result.length ? undefined : factory.createObjectLiteralExpression([
72795                 factory.createPropertyAssignment("children", factory.createArrayLiteralExpression(result))
72796             ]);
72797         }
72798         function visitJsxOpeningLikeElementJSX(node, children, isChild, location) {
72799             var tagName = getTagName(node);
72800             var objectProperties;
72801             var keyAttr = ts.find(node.attributes.properties, function (p) { return !!p.name && ts.isIdentifier(p.name) && p.name.escapedText === "key"; });
72802             var attrs = keyAttr ? ts.filter(node.attributes.properties, function (p) { return p !== keyAttr; }) : node.attributes.properties;
72803             var segments = [];
72804             if (attrs.length) {
72805                 segments = ts.flatten(ts.spanMap(attrs, ts.isJsxSpreadAttribute, function (attrs, isSpread) { return isSpread
72806                     ? ts.map(attrs, transformJsxSpreadAttributeToExpression)
72807                     : factory.createObjectLiteralExpression(ts.map(attrs, transformJsxAttributeToObjectLiteralElement)); }));
72808                 if (ts.isJsxSpreadAttribute(attrs[0])) {
72809                     segments.unshift(factory.createObjectLiteralExpression());
72810                 }
72811             }
72812             if (children && children.length) {
72813                 var result = convertJsxChildrenToChildrenPropObject(children);
72814                 if (result) {
72815                     segments.push(result);
72816                 }
72817             }
72818             if (segments.length === 0) {
72819                 objectProperties = factory.createObjectLiteralExpression([]);
72820             }
72821             else {
72822                 objectProperties = ts.singleOrUndefined(segments) || emitHelpers().createAssignHelper(segments);
72823             }
72824             return visitJsxOpeningLikeElementOrFragmentJSX(tagName, objectProperties, keyAttr, ts.length(ts.getSemanticJsxChildren(children || ts.emptyArray)), isChild, location);
72825         }
72826         function visitJsxOpeningLikeElementOrFragmentJSX(tagName, objectProperties, keyAttr, childrenLength, isChild, location) {
72827             var args = [tagName, objectProperties, !keyAttr ? factory.createVoidZero() : transformJsxAttributeInitializer(keyAttr.initializer)];
72828             if (compilerOptions.jsx === 5) {
72829                 var originalFile = ts.getOriginalNode(currentSourceFile);
72830                 if (originalFile && ts.isSourceFile(originalFile)) {
72831                     args.push(childrenLength > 1 ? factory.createTrue() : factory.createFalse());
72832                     var lineCol = ts.getLineAndCharacterOfPosition(originalFile, location.pos);
72833                     args.push(factory.createObjectLiteralExpression([
72834                         factory.createPropertyAssignment("fileName", getCurrentFileNameExpression()),
72835                         factory.createPropertyAssignment("lineNumber", factory.createNumericLiteral(lineCol.line + 1)),
72836                         factory.createPropertyAssignment("columnNumber", factory.createNumericLiteral(lineCol.character + 1))
72837                     ]));
72838                     args.push(factory.createThis());
72839                 }
72840             }
72841             var element = ts.setTextRange(factory.createCallExpression(getJsxFactoryCallee(childrenLength), undefined, args), location);
72842             if (isChild) {
72843                 ts.startOnNewLine(element);
72844             }
72845             return element;
72846         }
72847         function visitJsxOpeningLikeElementCreateElement(node, children, isChild, location) {
72848             var tagName = getTagName(node);
72849             var objectProperties;
72850             var attrs = node.attributes.properties;
72851             if (attrs.length === 0) {
72852                 objectProperties = factory.createNull();
72853             }
72854             else {
72855                 var segments = ts.flatten(ts.spanMap(attrs, ts.isJsxSpreadAttribute, function (attrs, isSpread) { return isSpread
72856                     ? ts.map(attrs, transformJsxSpreadAttributeToExpression)
72857                     : factory.createObjectLiteralExpression(ts.map(attrs, transformJsxAttributeToObjectLiteralElement)); }));
72858                 if (ts.isJsxSpreadAttribute(attrs[0])) {
72859                     segments.unshift(factory.createObjectLiteralExpression());
72860                 }
72861                 objectProperties = ts.singleOrUndefined(segments);
72862                 if (!objectProperties) {
72863                     objectProperties = emitHelpers().createAssignHelper(segments);
72864                 }
72865             }
72866             var callee = currentFileState.importSpecifier === undefined
72867                 ? ts.createJsxFactoryExpression(factory, context.getEmitResolver().getJsxFactoryEntity(currentSourceFile), compilerOptions.reactNamespace, node)
72868                 : getImplicitImportForName("createElement");
72869             var element = ts.createExpressionForJsxElement(factory, callee, tagName, objectProperties, ts.mapDefined(children, transformJsxChildToExpression), location);
72870             if (isChild) {
72871                 ts.startOnNewLine(element);
72872             }
72873             return element;
72874         }
72875         function visitJsxOpeningFragmentJSX(_node, children, isChild, location) {
72876             var childrenProps;
72877             if (children && children.length) {
72878                 var result = convertJsxChildrenToChildrenPropObject(children);
72879                 if (result) {
72880                     childrenProps = result;
72881                 }
72882             }
72883             return visitJsxOpeningLikeElementOrFragmentJSX(getImplicitJsxFragmentReference(), childrenProps || factory.createObjectLiteralExpression([]), undefined, ts.length(ts.getSemanticJsxChildren(children)), isChild, location);
72884         }
72885         function visitJsxOpeningFragmentCreateElement(node, children, isChild, location) {
72886             var element = ts.createExpressionForJsxFragment(factory, context.getEmitResolver().getJsxFactoryEntity(currentSourceFile), context.getEmitResolver().getJsxFragmentFactoryEntity(currentSourceFile), compilerOptions.reactNamespace, ts.mapDefined(children, transformJsxChildToExpression), node, location);
72887             if (isChild) {
72888                 ts.startOnNewLine(element);
72889             }
72890             return element;
72891         }
72892         function transformJsxSpreadAttributeToExpression(node) {
72893             return ts.visitNode(node.expression, visitor, ts.isExpression);
72894         }
72895         function transformJsxAttributeToObjectLiteralElement(node) {
72896             var name = getAttributeName(node);
72897             var expression = transformJsxAttributeInitializer(node.initializer);
72898             return factory.createPropertyAssignment(name, expression);
72899         }
72900         function transformJsxAttributeInitializer(node) {
72901             if (node === undefined) {
72902                 return factory.createTrue();
72903             }
72904             else if (node.kind === 10) {
72905                 var singleQuote = node.singleQuote !== undefined ? node.singleQuote : !ts.isStringDoubleQuoted(node, currentSourceFile);
72906                 var literal = factory.createStringLiteral(tryDecodeEntities(node.text) || node.text, singleQuote);
72907                 return ts.setTextRange(literal, node);
72908             }
72909             else if (node.kind === 283) {
72910                 if (node.expression === undefined) {
72911                     return factory.createTrue();
72912                 }
72913                 return ts.visitNode(node.expression, visitor, ts.isExpression);
72914             }
72915             else {
72916                 return ts.Debug.failBadSyntaxKind(node);
72917             }
72918         }
72919         function visitJsxText(node) {
72920             var fixed = fixupWhitespaceAndDecodeEntities(node.text);
72921             return fixed === undefined ? undefined : factory.createStringLiteral(fixed);
72922         }
72923         function fixupWhitespaceAndDecodeEntities(text) {
72924             var acc;
72925             var firstNonWhitespace = 0;
72926             var lastNonWhitespace = -1;
72927             for (var i = 0; i < text.length; i++) {
72928                 var c = text.charCodeAt(i);
72929                 if (ts.isLineBreak(c)) {
72930                     if (firstNonWhitespace !== -1 && lastNonWhitespace !== -1) {
72931                         acc = addLineOfJsxText(acc, text.substr(firstNonWhitespace, lastNonWhitespace - firstNonWhitespace + 1));
72932                     }
72933                     firstNonWhitespace = -1;
72934                 }
72935                 else if (!ts.isWhiteSpaceSingleLine(c)) {
72936                     lastNonWhitespace = i;
72937                     if (firstNonWhitespace === -1) {
72938                         firstNonWhitespace = i;
72939                     }
72940                 }
72941             }
72942             return firstNonWhitespace !== -1
72943                 ? addLineOfJsxText(acc, text.substr(firstNonWhitespace))
72944                 : acc;
72945         }
72946         function addLineOfJsxText(acc, trimmedLine) {
72947             var decoded = decodeEntities(trimmedLine);
72948             return acc === undefined ? decoded : acc + " " + decoded;
72949         }
72950         function decodeEntities(text) {
72951             return text.replace(/&((#((\d+)|x([\da-fA-F]+)))|(\w+));/g, function (match, _all, _number, _digits, decimal, hex, word) {
72952                 if (decimal) {
72953                     return ts.utf16EncodeAsString(parseInt(decimal, 10));
72954                 }
72955                 else if (hex) {
72956                     return ts.utf16EncodeAsString(parseInt(hex, 16));
72957                 }
72958                 else {
72959                     var ch = entities.get(word);
72960                     return ch ? ts.utf16EncodeAsString(ch) : match;
72961                 }
72962             });
72963         }
72964         function tryDecodeEntities(text) {
72965             var decoded = decodeEntities(text);
72966             return decoded === text ? undefined : decoded;
72967         }
72968         function getTagName(node) {
72969             if (node.kind === 273) {
72970                 return getTagName(node.openingElement);
72971             }
72972             else {
72973                 var name = node.tagName;
72974                 if (ts.isIdentifier(name) && ts.isIntrinsicJsxName(name.escapedText)) {
72975                     return factory.createStringLiteral(ts.idText(name));
72976                 }
72977                 else {
72978                     return ts.createExpressionFromEntityName(factory, name);
72979                 }
72980             }
72981         }
72982         function getAttributeName(node) {
72983             var name = node.name;
72984             var text = ts.idText(name);
72985             if (/^[A-Za-z_]\w*$/.test(text)) {
72986                 return name;
72987             }
72988             else {
72989                 return factory.createStringLiteral(text);
72990             }
72991         }
72992         function visitJsxExpression(node) {
72993             return ts.visitNode(node.expression, visitor, ts.isExpression);
72994         }
72995     }
72996     ts.transformJsx = transformJsx;
72997     var entities = new ts.Map(ts.getEntries({
72998         quot: 0x0022,
72999         amp: 0x0026,
73000         apos: 0x0027,
73001         lt: 0x003C,
73002         gt: 0x003E,
73003         nbsp: 0x00A0,
73004         iexcl: 0x00A1,
73005         cent: 0x00A2,
73006         pound: 0x00A3,
73007         curren: 0x00A4,
73008         yen: 0x00A5,
73009         brvbar: 0x00A6,
73010         sect: 0x00A7,
73011         uml: 0x00A8,
73012         copy: 0x00A9,
73013         ordf: 0x00AA,
73014         laquo: 0x00AB,
73015         not: 0x00AC,
73016         shy: 0x00AD,
73017         reg: 0x00AE,
73018         macr: 0x00AF,
73019         deg: 0x00B0,
73020         plusmn: 0x00B1,
73021         sup2: 0x00B2,
73022         sup3: 0x00B3,
73023         acute: 0x00B4,
73024         micro: 0x00B5,
73025         para: 0x00B6,
73026         middot: 0x00B7,
73027         cedil: 0x00B8,
73028         sup1: 0x00B9,
73029         ordm: 0x00BA,
73030         raquo: 0x00BB,
73031         frac14: 0x00BC,
73032         frac12: 0x00BD,
73033         frac34: 0x00BE,
73034         iquest: 0x00BF,
73035         Agrave: 0x00C0,
73036         Aacute: 0x00C1,
73037         Acirc: 0x00C2,
73038         Atilde: 0x00C3,
73039         Auml: 0x00C4,
73040         Aring: 0x00C5,
73041         AElig: 0x00C6,
73042         Ccedil: 0x00C7,
73043         Egrave: 0x00C8,
73044         Eacute: 0x00C9,
73045         Ecirc: 0x00CA,
73046         Euml: 0x00CB,
73047         Igrave: 0x00CC,
73048         Iacute: 0x00CD,
73049         Icirc: 0x00CE,
73050         Iuml: 0x00CF,
73051         ETH: 0x00D0,
73052         Ntilde: 0x00D1,
73053         Ograve: 0x00D2,
73054         Oacute: 0x00D3,
73055         Ocirc: 0x00D4,
73056         Otilde: 0x00D5,
73057         Ouml: 0x00D6,
73058         times: 0x00D7,
73059         Oslash: 0x00D8,
73060         Ugrave: 0x00D9,
73061         Uacute: 0x00DA,
73062         Ucirc: 0x00DB,
73063         Uuml: 0x00DC,
73064         Yacute: 0x00DD,
73065         THORN: 0x00DE,
73066         szlig: 0x00DF,
73067         agrave: 0x00E0,
73068         aacute: 0x00E1,
73069         acirc: 0x00E2,
73070         atilde: 0x00E3,
73071         auml: 0x00E4,
73072         aring: 0x00E5,
73073         aelig: 0x00E6,
73074         ccedil: 0x00E7,
73075         egrave: 0x00E8,
73076         eacute: 0x00E9,
73077         ecirc: 0x00EA,
73078         euml: 0x00EB,
73079         igrave: 0x00EC,
73080         iacute: 0x00ED,
73081         icirc: 0x00EE,
73082         iuml: 0x00EF,
73083         eth: 0x00F0,
73084         ntilde: 0x00F1,
73085         ograve: 0x00F2,
73086         oacute: 0x00F3,
73087         ocirc: 0x00F4,
73088         otilde: 0x00F5,
73089         ouml: 0x00F6,
73090         divide: 0x00F7,
73091         oslash: 0x00F8,
73092         ugrave: 0x00F9,
73093         uacute: 0x00FA,
73094         ucirc: 0x00FB,
73095         uuml: 0x00FC,
73096         yacute: 0x00FD,
73097         thorn: 0x00FE,
73098         yuml: 0x00FF,
73099         OElig: 0x0152,
73100         oelig: 0x0153,
73101         Scaron: 0x0160,
73102         scaron: 0x0161,
73103         Yuml: 0x0178,
73104         fnof: 0x0192,
73105         circ: 0x02C6,
73106         tilde: 0x02DC,
73107         Alpha: 0x0391,
73108         Beta: 0x0392,
73109         Gamma: 0x0393,
73110         Delta: 0x0394,
73111         Epsilon: 0x0395,
73112         Zeta: 0x0396,
73113         Eta: 0x0397,
73114         Theta: 0x0398,
73115         Iota: 0x0399,
73116         Kappa: 0x039A,
73117         Lambda: 0x039B,
73118         Mu: 0x039C,
73119         Nu: 0x039D,
73120         Xi: 0x039E,
73121         Omicron: 0x039F,
73122         Pi: 0x03A0,
73123         Rho: 0x03A1,
73124         Sigma: 0x03A3,
73125         Tau: 0x03A4,
73126         Upsilon: 0x03A5,
73127         Phi: 0x03A6,
73128         Chi: 0x03A7,
73129         Psi: 0x03A8,
73130         Omega: 0x03A9,
73131         alpha: 0x03B1,
73132         beta: 0x03B2,
73133         gamma: 0x03B3,
73134         delta: 0x03B4,
73135         epsilon: 0x03B5,
73136         zeta: 0x03B6,
73137         eta: 0x03B7,
73138         theta: 0x03B8,
73139         iota: 0x03B9,
73140         kappa: 0x03BA,
73141         lambda: 0x03BB,
73142         mu: 0x03BC,
73143         nu: 0x03BD,
73144         xi: 0x03BE,
73145         omicron: 0x03BF,
73146         pi: 0x03C0,
73147         rho: 0x03C1,
73148         sigmaf: 0x03C2,
73149         sigma: 0x03C3,
73150         tau: 0x03C4,
73151         upsilon: 0x03C5,
73152         phi: 0x03C6,
73153         chi: 0x03C7,
73154         psi: 0x03C8,
73155         omega: 0x03C9,
73156         thetasym: 0x03D1,
73157         upsih: 0x03D2,
73158         piv: 0x03D6,
73159         ensp: 0x2002,
73160         emsp: 0x2003,
73161         thinsp: 0x2009,
73162         zwnj: 0x200C,
73163         zwj: 0x200D,
73164         lrm: 0x200E,
73165         rlm: 0x200F,
73166         ndash: 0x2013,
73167         mdash: 0x2014,
73168         lsquo: 0x2018,
73169         rsquo: 0x2019,
73170         sbquo: 0x201A,
73171         ldquo: 0x201C,
73172         rdquo: 0x201D,
73173         bdquo: 0x201E,
73174         dagger: 0x2020,
73175         Dagger: 0x2021,
73176         bull: 0x2022,
73177         hellip: 0x2026,
73178         permil: 0x2030,
73179         prime: 0x2032,
73180         Prime: 0x2033,
73181         lsaquo: 0x2039,
73182         rsaquo: 0x203A,
73183         oline: 0x203E,
73184         frasl: 0x2044,
73185         euro: 0x20AC,
73186         image: 0x2111,
73187         weierp: 0x2118,
73188         real: 0x211C,
73189         trade: 0x2122,
73190         alefsym: 0x2135,
73191         larr: 0x2190,
73192         uarr: 0x2191,
73193         rarr: 0x2192,
73194         darr: 0x2193,
73195         harr: 0x2194,
73196         crarr: 0x21B5,
73197         lArr: 0x21D0,
73198         uArr: 0x21D1,
73199         rArr: 0x21D2,
73200         dArr: 0x21D3,
73201         hArr: 0x21D4,
73202         forall: 0x2200,
73203         part: 0x2202,
73204         exist: 0x2203,
73205         empty: 0x2205,
73206         nabla: 0x2207,
73207         isin: 0x2208,
73208         notin: 0x2209,
73209         ni: 0x220B,
73210         prod: 0x220F,
73211         sum: 0x2211,
73212         minus: 0x2212,
73213         lowast: 0x2217,
73214         radic: 0x221A,
73215         prop: 0x221D,
73216         infin: 0x221E,
73217         ang: 0x2220,
73218         and: 0x2227,
73219         or: 0x2228,
73220         cap: 0x2229,
73221         cup: 0x222A,
73222         int: 0x222B,
73223         there4: 0x2234,
73224         sim: 0x223C,
73225         cong: 0x2245,
73226         asymp: 0x2248,
73227         ne: 0x2260,
73228         equiv: 0x2261,
73229         le: 0x2264,
73230         ge: 0x2265,
73231         sub: 0x2282,
73232         sup: 0x2283,
73233         nsub: 0x2284,
73234         sube: 0x2286,
73235         supe: 0x2287,
73236         oplus: 0x2295,
73237         otimes: 0x2297,
73238         perp: 0x22A5,
73239         sdot: 0x22C5,
73240         lceil: 0x2308,
73241         rceil: 0x2309,
73242         lfloor: 0x230A,
73243         rfloor: 0x230B,
73244         lang: 0x2329,
73245         rang: 0x232A,
73246         loz: 0x25CA,
73247         spades: 0x2660,
73248         clubs: 0x2663,
73249         hearts: 0x2665,
73250         diams: 0x2666
73251     }));
73252 })(ts || (ts = {}));
73253 var ts;
73254 (function (ts) {
73255     function transformES2016(context) {
73256         var factory = context.factory, hoistVariableDeclaration = context.hoistVariableDeclaration;
73257         return ts.chainBundle(context, transformSourceFile);
73258         function transformSourceFile(node) {
73259             if (node.isDeclarationFile) {
73260                 return node;
73261             }
73262             return ts.visitEachChild(node, visitor, context);
73263         }
73264         function visitor(node) {
73265             if ((node.transformFlags & 128) === 0) {
73266                 return node;
73267             }
73268             switch (node.kind) {
73269                 case 216:
73270                     return visitBinaryExpression(node);
73271                 default:
73272                     return ts.visitEachChild(node, visitor, context);
73273             }
73274         }
73275         function visitBinaryExpression(node) {
73276             switch (node.operatorToken.kind) {
73277                 case 66:
73278                     return visitExponentiationAssignmentExpression(node);
73279                 case 42:
73280                     return visitExponentiationExpression(node);
73281                 default:
73282                     return ts.visitEachChild(node, visitor, context);
73283             }
73284         }
73285         function visitExponentiationAssignmentExpression(node) {
73286             var target;
73287             var value;
73288             var left = ts.visitNode(node.left, visitor, ts.isExpression);
73289             var right = ts.visitNode(node.right, visitor, ts.isExpression);
73290             if (ts.isElementAccessExpression(left)) {
73291                 var expressionTemp = factory.createTempVariable(hoistVariableDeclaration);
73292                 var argumentExpressionTemp = factory.createTempVariable(hoistVariableDeclaration);
73293                 target = ts.setTextRange(factory.createElementAccessExpression(ts.setTextRange(factory.createAssignment(expressionTemp, left.expression), left.expression), ts.setTextRange(factory.createAssignment(argumentExpressionTemp, left.argumentExpression), left.argumentExpression)), left);
73294                 value = ts.setTextRange(factory.createElementAccessExpression(expressionTemp, argumentExpressionTemp), left);
73295             }
73296             else if (ts.isPropertyAccessExpression(left)) {
73297                 var expressionTemp = factory.createTempVariable(hoistVariableDeclaration);
73298                 target = ts.setTextRange(factory.createPropertyAccessExpression(ts.setTextRange(factory.createAssignment(expressionTemp, left.expression), left.expression), left.name), left);
73299                 value = ts.setTextRange(factory.createPropertyAccessExpression(expressionTemp, left.name), left);
73300             }
73301             else {
73302                 target = left;
73303                 value = left;
73304             }
73305             return ts.setTextRange(factory.createAssignment(target, ts.setTextRange(factory.createGlobalMethodCall("Math", "pow", [value, right]), node)), node);
73306         }
73307         function visitExponentiationExpression(node) {
73308             var left = ts.visitNode(node.left, visitor, ts.isExpression);
73309             var right = ts.visitNode(node.right, visitor, ts.isExpression);
73310             return ts.setTextRange(factory.createGlobalMethodCall("Math", "pow", [left, right]), node);
73311         }
73312     }
73313     ts.transformES2016 = transformES2016;
73314 })(ts || (ts = {}));
73315 var ts;
73316 (function (ts) {
73317     function transformES2015(context) {
73318         var factory = context.factory, emitHelpers = context.getEmitHelperFactory, startLexicalEnvironment = context.startLexicalEnvironment, resumeLexicalEnvironment = context.resumeLexicalEnvironment, endLexicalEnvironment = context.endLexicalEnvironment, hoistVariableDeclaration = context.hoistVariableDeclaration;
73319         var compilerOptions = context.getCompilerOptions();
73320         var resolver = context.getEmitResolver();
73321         var previousOnSubstituteNode = context.onSubstituteNode;
73322         var previousOnEmitNode = context.onEmitNode;
73323         context.onEmitNode = onEmitNode;
73324         context.onSubstituteNode = onSubstituteNode;
73325         var currentSourceFile;
73326         var currentText;
73327         var hierarchyFacts;
73328         var taggedTemplateStringDeclarations;
73329         function recordTaggedTemplateString(temp) {
73330             taggedTemplateStringDeclarations = ts.append(taggedTemplateStringDeclarations, factory.createVariableDeclaration(temp));
73331         }
73332         var convertedLoopState;
73333         var enabledSubstitutions;
73334         return ts.chainBundle(context, transformSourceFile);
73335         function transformSourceFile(node) {
73336             if (node.isDeclarationFile) {
73337                 return node;
73338             }
73339             currentSourceFile = node;
73340             currentText = node.text;
73341             var visited = visitSourceFile(node);
73342             ts.addEmitHelpers(visited, context.readEmitHelpers());
73343             currentSourceFile = undefined;
73344             currentText = undefined;
73345             taggedTemplateStringDeclarations = undefined;
73346             hierarchyFacts = 0;
73347             return visited;
73348         }
73349         function enterSubtree(excludeFacts, includeFacts) {
73350             var ancestorFacts = hierarchyFacts;
73351             hierarchyFacts = (hierarchyFacts & ~excludeFacts | includeFacts) & 16383;
73352             return ancestorFacts;
73353         }
73354         function exitSubtree(ancestorFacts, excludeFacts, includeFacts) {
73355             hierarchyFacts = (hierarchyFacts & ~excludeFacts | includeFacts) & -16384 | ancestorFacts;
73356         }
73357         function isReturnVoidStatementInConstructorWithCapturedSuper(node) {
73358             return (hierarchyFacts & 8192) !== 0
73359                 && node.kind === 242
73360                 && !node.expression;
73361         }
73362         function isOrMayContainReturnCompletion(node) {
73363             return node.transformFlags & 1048576
73364                 && (ts.isReturnStatement(node)
73365                     || ts.isIfStatement(node)
73366                     || ts.isWithStatement(node)
73367                     || ts.isSwitchStatement(node)
73368                     || ts.isCaseBlock(node)
73369                     || ts.isCaseClause(node)
73370                     || ts.isDefaultClause(node)
73371                     || ts.isTryStatement(node)
73372                     || ts.isCatchClause(node)
73373                     || ts.isLabeledStatement(node)
73374                     || ts.isIterationStatement(node, false)
73375                     || ts.isBlock(node));
73376         }
73377         function shouldVisitNode(node) {
73378             return (node.transformFlags & 256) !== 0
73379                 || convertedLoopState !== undefined
73380                 || (hierarchyFacts & 8192 && isOrMayContainReturnCompletion(node))
73381                 || (ts.isIterationStatement(node, false) && shouldConvertIterationStatement(node))
73382                 || (ts.getEmitFlags(node) & 33554432) !== 0;
73383         }
73384         function visitor(node) {
73385             return shouldVisitNode(node) ? visitorWorker(node, false) : node;
73386         }
73387         function visitorWithUnusedExpressionResult(node) {
73388             return shouldVisitNode(node) ? visitorWorker(node, true) : node;
73389         }
73390         function callExpressionVisitor(node) {
73391             if (node.kind === 105) {
73392                 return visitSuperKeyword(true);
73393             }
73394             return visitor(node);
73395         }
73396         function visitorWorker(node, expressionResultIsUnused) {
73397             switch (node.kind) {
73398                 case 123:
73399                     return undefined;
73400                 case 252:
73401                     return visitClassDeclaration(node);
73402                 case 221:
73403                     return visitClassExpression(node);
73404                 case 160:
73405                     return visitParameter(node);
73406                 case 251:
73407                     return visitFunctionDeclaration(node);
73408                 case 209:
73409                     return visitArrowFunction(node);
73410                 case 208:
73411                     return visitFunctionExpression(node);
73412                 case 249:
73413                     return visitVariableDeclaration(node);
73414                 case 78:
73415                     return visitIdentifier(node);
73416                 case 250:
73417                     return visitVariableDeclarationList(node);
73418                 case 244:
73419                     return visitSwitchStatement(node);
73420                 case 258:
73421                     return visitCaseBlock(node);
73422                 case 230:
73423                     return visitBlock(node, false);
73424                 case 241:
73425                 case 240:
73426                     return visitBreakOrContinueStatement(node);
73427                 case 245:
73428                     return visitLabeledStatement(node);
73429                 case 235:
73430                 case 236:
73431                     return visitDoOrWhileStatement(node, undefined);
73432                 case 237:
73433                     return visitForStatement(node, undefined);
73434                 case 238:
73435                     return visitForInStatement(node, undefined);
73436                 case 239:
73437                     return visitForOfStatement(node, undefined);
73438                 case 233:
73439                     return visitExpressionStatement(node);
73440                 case 200:
73441                     return visitObjectLiteralExpression(node);
73442                 case 287:
73443                     return visitCatchClause(node);
73444                 case 289:
73445                     return visitShorthandPropertyAssignment(node);
73446                 case 158:
73447                     return visitComputedPropertyName(node);
73448                 case 199:
73449                     return visitArrayLiteralExpression(node);
73450                 case 203:
73451                     return visitCallExpression(node);
73452                 case 204:
73453                     return visitNewExpression(node);
73454                 case 207:
73455                     return visitParenthesizedExpression(node, expressionResultIsUnused);
73456                 case 216:
73457                     return visitBinaryExpression(node, expressionResultIsUnused);
73458                 case 337:
73459                     return visitCommaListExpression(node, expressionResultIsUnused);
73460                 case 14:
73461                 case 15:
73462                 case 16:
73463                 case 17:
73464                     return visitTemplateLiteral(node);
73465                 case 10:
73466                     return visitStringLiteral(node);
73467                 case 8:
73468                     return visitNumericLiteral(node);
73469                 case 205:
73470                     return visitTaggedTemplateExpression(node);
73471                 case 218:
73472                     return visitTemplateExpression(node);
73473                 case 219:
73474                     return visitYieldExpression(node);
73475                 case 220:
73476                     return visitSpreadElement(node);
73477                 case 105:
73478                     return visitSuperKeyword(false);
73479                 case 107:
73480                     return visitThisKeyword(node);
73481                 case 226:
73482                     return visitMetaProperty(node);
73483                 case 165:
73484                     return visitMethodDeclaration(node);
73485                 case 167:
73486                 case 168:
73487                     return visitAccessorDeclaration(node);
73488                 case 232:
73489                     return visitVariableStatement(node);
73490                 case 242:
73491                     return visitReturnStatement(node);
73492                 case 212:
73493                     return visitVoidExpression(node);
73494                 default:
73495                     return ts.visitEachChild(node, visitor, context);
73496             }
73497         }
73498         function visitSourceFile(node) {
73499             var ancestorFacts = enterSubtree(8064, 64);
73500             var prologue = [];
73501             var statements = [];
73502             startLexicalEnvironment();
73503             var statementOffset = factory.copyPrologue(node.statements, prologue, false, visitor);
73504             ts.addRange(statements, ts.visitNodes(node.statements, visitor, ts.isStatement, statementOffset));
73505             if (taggedTemplateStringDeclarations) {
73506                 statements.push(factory.createVariableStatement(undefined, factory.createVariableDeclarationList(taggedTemplateStringDeclarations)));
73507             }
73508             factory.mergeLexicalEnvironment(prologue, endLexicalEnvironment());
73509             insertCaptureThisForNodeIfNeeded(prologue, node);
73510             exitSubtree(ancestorFacts, 0, 0);
73511             return factory.updateSourceFile(node, ts.setTextRange(factory.createNodeArray(ts.concatenate(prologue, statements)), node.statements));
73512         }
73513         function visitSwitchStatement(node) {
73514             if (convertedLoopState !== undefined) {
73515                 var savedAllowedNonLabeledJumps = convertedLoopState.allowedNonLabeledJumps;
73516                 convertedLoopState.allowedNonLabeledJumps |= 2;
73517                 var result = ts.visitEachChild(node, visitor, context);
73518                 convertedLoopState.allowedNonLabeledJumps = savedAllowedNonLabeledJumps;
73519                 return result;
73520             }
73521             return ts.visitEachChild(node, visitor, context);
73522         }
73523         function visitCaseBlock(node) {
73524             var ancestorFacts = enterSubtree(7104, 0);
73525             var updated = ts.visitEachChild(node, visitor, context);
73526             exitSubtree(ancestorFacts, 0, 0);
73527             return updated;
73528         }
73529         function returnCapturedThis(node) {
73530             return ts.setOriginalNode(factory.createReturnStatement(factory.createUniqueName("_this", 16 | 32)), node);
73531         }
73532         function visitReturnStatement(node) {
73533             if (convertedLoopState) {
73534                 convertedLoopState.nonLocalJumps |= 8;
73535                 if (isReturnVoidStatementInConstructorWithCapturedSuper(node)) {
73536                     node = returnCapturedThis(node);
73537                 }
73538                 return factory.createReturnStatement(factory.createObjectLiteralExpression([
73539                     factory.createPropertyAssignment(factory.createIdentifier("value"), node.expression
73540                         ? ts.visitNode(node.expression, visitor, ts.isExpression)
73541                         : factory.createVoidZero())
73542                 ]));
73543             }
73544             else if (isReturnVoidStatementInConstructorWithCapturedSuper(node)) {
73545                 return returnCapturedThis(node);
73546             }
73547             return ts.visitEachChild(node, visitor, context);
73548         }
73549         function visitThisKeyword(node) {
73550             if (hierarchyFacts & 2) {
73551                 hierarchyFacts |= 32768;
73552             }
73553             if (convertedLoopState) {
73554                 if (hierarchyFacts & 2) {
73555                     convertedLoopState.containsLexicalThis = true;
73556                     return node;
73557                 }
73558                 return convertedLoopState.thisName || (convertedLoopState.thisName = factory.createUniqueName("this"));
73559             }
73560             return node;
73561         }
73562         function visitVoidExpression(node) {
73563             return ts.visitEachChild(node, visitorWithUnusedExpressionResult, context);
73564         }
73565         function visitIdentifier(node) {
73566             if (!convertedLoopState) {
73567                 return node;
73568             }
73569             if (resolver.isArgumentsLocalBinding(node)) {
73570                 return convertedLoopState.argumentsName || (convertedLoopState.argumentsName = factory.createUniqueName("arguments"));
73571             }
73572             return node;
73573         }
73574         function visitBreakOrContinueStatement(node) {
73575             if (convertedLoopState) {
73576                 var jump = node.kind === 241 ? 2 : 4;
73577                 var canUseBreakOrContinue = (node.label && convertedLoopState.labels && convertedLoopState.labels.get(ts.idText(node.label))) ||
73578                     (!node.label && (convertedLoopState.allowedNonLabeledJumps & jump));
73579                 if (!canUseBreakOrContinue) {
73580                     var labelMarker = void 0;
73581                     var label = node.label;
73582                     if (!label) {
73583                         if (node.kind === 241) {
73584                             convertedLoopState.nonLocalJumps |= 2;
73585                             labelMarker = "break";
73586                         }
73587                         else {
73588                             convertedLoopState.nonLocalJumps |= 4;
73589                             labelMarker = "continue";
73590                         }
73591                     }
73592                     else {
73593                         if (node.kind === 241) {
73594                             labelMarker = "break-" + label.escapedText;
73595                             setLabeledJump(convertedLoopState, true, ts.idText(label), labelMarker);
73596                         }
73597                         else {
73598                             labelMarker = "continue-" + label.escapedText;
73599                             setLabeledJump(convertedLoopState, false, ts.idText(label), labelMarker);
73600                         }
73601                     }
73602                     var returnExpression = factory.createStringLiteral(labelMarker);
73603                     if (convertedLoopState.loopOutParameters.length) {
73604                         var outParams = convertedLoopState.loopOutParameters;
73605                         var expr = void 0;
73606                         for (var i = 0; i < outParams.length; i++) {
73607                             var copyExpr = copyOutParameter(outParams[i], 1);
73608                             if (i === 0) {
73609                                 expr = copyExpr;
73610                             }
73611                             else {
73612                                 expr = factory.createBinaryExpression(expr, 27, copyExpr);
73613                             }
73614                         }
73615                         returnExpression = factory.createBinaryExpression(expr, 27, returnExpression);
73616                     }
73617                     return factory.createReturnStatement(returnExpression);
73618                 }
73619             }
73620             return ts.visitEachChild(node, visitor, context);
73621         }
73622         function visitClassDeclaration(node) {
73623             var variable = factory.createVariableDeclaration(factory.getLocalName(node, true), undefined, undefined, transformClassLikeDeclarationToExpression(node));
73624             ts.setOriginalNode(variable, node);
73625             var statements = [];
73626             var statement = factory.createVariableStatement(undefined, factory.createVariableDeclarationList([variable]));
73627             ts.setOriginalNode(statement, node);
73628             ts.setTextRange(statement, node);
73629             ts.startOnNewLine(statement);
73630             statements.push(statement);
73631             if (ts.hasSyntacticModifier(node, 1)) {
73632                 var exportStatement = ts.hasSyntacticModifier(node, 512)
73633                     ? factory.createExportDefault(factory.getLocalName(node))
73634                     : factory.createExternalModuleExport(factory.getLocalName(node));
73635                 ts.setOriginalNode(exportStatement, statement);
73636                 statements.push(exportStatement);
73637             }
73638             var emitFlags = ts.getEmitFlags(node);
73639             if ((emitFlags & 4194304) === 0) {
73640                 statements.push(factory.createEndOfDeclarationMarker(node));
73641                 ts.setEmitFlags(statement, emitFlags | 4194304);
73642             }
73643             return ts.singleOrMany(statements);
73644         }
73645         function visitClassExpression(node) {
73646             return transformClassLikeDeclarationToExpression(node);
73647         }
73648         function transformClassLikeDeclarationToExpression(node) {
73649             if (node.name) {
73650                 enableSubstitutionsForBlockScopedBindings();
73651             }
73652             var extendsClauseElement = ts.getClassExtendsHeritageElement(node);
73653             var classFunction = factory.createFunctionExpression(undefined, undefined, undefined, undefined, extendsClauseElement ? [factory.createParameterDeclaration(undefined, undefined, undefined, factory.createUniqueName("_super", 16 | 32))] : [], undefined, transformClassBody(node, extendsClauseElement));
73654             ts.setEmitFlags(classFunction, (ts.getEmitFlags(node) & 65536) | 524288);
73655             var inner = factory.createPartiallyEmittedExpression(classFunction);
73656             ts.setTextRangeEnd(inner, node.end);
73657             ts.setEmitFlags(inner, 1536);
73658             var outer = factory.createPartiallyEmittedExpression(inner);
73659             ts.setTextRangeEnd(outer, ts.skipTrivia(currentText, node.pos));
73660             ts.setEmitFlags(outer, 1536);
73661             var result = factory.createParenthesizedExpression(factory.createCallExpression(outer, undefined, extendsClauseElement
73662                 ? [ts.visitNode(extendsClauseElement.expression, visitor, ts.isExpression)]
73663                 : []));
73664             ts.addSyntheticLeadingComment(result, 3, "* @class ");
73665             return result;
73666         }
73667         function transformClassBody(node, extendsClauseElement) {
73668             var statements = [];
73669             var name = factory.getInternalName(node);
73670             var constructorLikeName = ts.isIdentifierANonContextualKeyword(name) ? factory.getGeneratedNameForNode(name) : name;
73671             startLexicalEnvironment();
73672             addExtendsHelperIfNeeded(statements, node, extendsClauseElement);
73673             addConstructor(statements, node, constructorLikeName, extendsClauseElement);
73674             addClassMembers(statements, node);
73675             var closingBraceLocation = ts.createTokenRange(ts.skipTrivia(currentText, node.members.end), 19);
73676             var outer = factory.createPartiallyEmittedExpression(constructorLikeName);
73677             ts.setTextRangeEnd(outer, closingBraceLocation.end);
73678             ts.setEmitFlags(outer, 1536);
73679             var statement = factory.createReturnStatement(outer);
73680             ts.setTextRangePos(statement, closingBraceLocation.pos);
73681             ts.setEmitFlags(statement, 1536 | 384);
73682             statements.push(statement);
73683             ts.insertStatementsAfterStandardPrologue(statements, endLexicalEnvironment());
73684             var block = factory.createBlock(ts.setTextRange(factory.createNodeArray(statements), node.members), true);
73685             ts.setEmitFlags(block, 1536);
73686             return block;
73687         }
73688         function addExtendsHelperIfNeeded(statements, node, extendsClauseElement) {
73689             if (extendsClauseElement) {
73690                 statements.push(ts.setTextRange(factory.createExpressionStatement(emitHelpers().createExtendsHelper(factory.getInternalName(node))), extendsClauseElement));
73691             }
73692         }
73693         function addConstructor(statements, node, name, extendsClauseElement) {
73694             var savedConvertedLoopState = convertedLoopState;
73695             convertedLoopState = undefined;
73696             var ancestorFacts = enterSubtree(16278, 73);
73697             var constructor = ts.getFirstConstructorWithBody(node);
73698             var hasSynthesizedSuper = hasSynthesizedDefaultSuperCall(constructor, extendsClauseElement !== undefined);
73699             var constructorFunction = factory.createFunctionDeclaration(undefined, undefined, undefined, name, undefined, transformConstructorParameters(constructor, hasSynthesizedSuper), undefined, transformConstructorBody(constructor, node, extendsClauseElement, hasSynthesizedSuper));
73700             ts.setTextRange(constructorFunction, constructor || node);
73701             if (extendsClauseElement) {
73702                 ts.setEmitFlags(constructorFunction, 8);
73703             }
73704             statements.push(constructorFunction);
73705             exitSubtree(ancestorFacts, 49152, 0);
73706             convertedLoopState = savedConvertedLoopState;
73707         }
73708         function transformConstructorParameters(constructor, hasSynthesizedSuper) {
73709             return ts.visitParameterList(constructor && !hasSynthesizedSuper ? constructor.parameters : undefined, visitor, context)
73710                 || [];
73711         }
73712         function createDefaultConstructorBody(node, isDerivedClass) {
73713             var statements = [];
73714             resumeLexicalEnvironment();
73715             factory.mergeLexicalEnvironment(statements, endLexicalEnvironment());
73716             if (isDerivedClass) {
73717                 statements.push(factory.createReturnStatement(createDefaultSuperCallOrThis()));
73718             }
73719             var statementsArray = factory.createNodeArray(statements);
73720             ts.setTextRange(statementsArray, node.members);
73721             var block = factory.createBlock(statementsArray, true);
73722             ts.setTextRange(block, node);
73723             ts.setEmitFlags(block, 1536);
73724             return block;
73725         }
73726         function transformConstructorBody(constructor, node, extendsClauseElement, hasSynthesizedSuper) {
73727             var isDerivedClass = !!extendsClauseElement && ts.skipOuterExpressions(extendsClauseElement.expression).kind !== 103;
73728             if (!constructor)
73729                 return createDefaultConstructorBody(node, isDerivedClass);
73730             var prologue = [];
73731             var statements = [];
73732             resumeLexicalEnvironment();
73733             var statementOffset = 0;
73734             if (!hasSynthesizedSuper)
73735                 statementOffset = factory.copyStandardPrologue(constructor.body.statements, prologue, false);
73736             addDefaultValueAssignmentsIfNeeded(statements, constructor);
73737             addRestParameterIfNeeded(statements, constructor, hasSynthesizedSuper);
73738             if (!hasSynthesizedSuper)
73739                 statementOffset = factory.copyCustomPrologue(constructor.body.statements, statements, statementOffset, visitor);
73740             var superCallExpression;
73741             if (hasSynthesizedSuper) {
73742                 superCallExpression = createDefaultSuperCallOrThis();
73743             }
73744             else if (isDerivedClass && statementOffset < constructor.body.statements.length) {
73745                 var firstStatement = constructor.body.statements[statementOffset];
73746                 if (ts.isExpressionStatement(firstStatement) && ts.isSuperCall(firstStatement.expression)) {
73747                     superCallExpression = visitImmediateSuperCallInBody(firstStatement.expression);
73748                 }
73749             }
73750             if (superCallExpression) {
73751                 hierarchyFacts |= 8192;
73752                 statementOffset++;
73753             }
73754             ts.addRange(statements, ts.visitNodes(constructor.body.statements, visitor, ts.isStatement, statementOffset));
73755             factory.mergeLexicalEnvironment(prologue, endLexicalEnvironment());
73756             insertCaptureNewTargetIfNeeded(prologue, constructor, false);
73757             if (isDerivedClass) {
73758                 if (superCallExpression && statementOffset === constructor.body.statements.length && !(constructor.body.transformFlags & 4096)) {
73759                     var superCall = ts.cast(ts.cast(superCallExpression, ts.isBinaryExpression).left, ts.isCallExpression);
73760                     var returnStatement = factory.createReturnStatement(superCallExpression);
73761                     ts.setCommentRange(returnStatement, ts.getCommentRange(superCall));
73762                     ts.setEmitFlags(superCall, 1536);
73763                     statements.push(returnStatement);
73764                 }
73765                 else {
73766                     insertCaptureThisForNode(statements, constructor, superCallExpression || createActualThis());
73767                     if (!isSufficientlyCoveredByReturnStatements(constructor.body)) {
73768                         statements.push(factory.createReturnStatement(factory.createUniqueName("_this", 16 | 32)));
73769                     }
73770                 }
73771             }
73772             else {
73773                 insertCaptureThisForNodeIfNeeded(prologue, constructor);
73774             }
73775             var block = factory.createBlock(ts.setTextRange(factory.createNodeArray(ts.concatenate(prologue, statements)), constructor.body.statements), true);
73776             ts.setTextRange(block, constructor.body);
73777             return block;
73778         }
73779         function isSufficientlyCoveredByReturnStatements(statement) {
73780             if (statement.kind === 242) {
73781                 return true;
73782             }
73783             else if (statement.kind === 234) {
73784                 var ifStatement = statement;
73785                 if (ifStatement.elseStatement) {
73786                     return isSufficientlyCoveredByReturnStatements(ifStatement.thenStatement) &&
73787                         isSufficientlyCoveredByReturnStatements(ifStatement.elseStatement);
73788                 }
73789             }
73790             else if (statement.kind === 230) {
73791                 var lastStatement = ts.lastOrUndefined(statement.statements);
73792                 if (lastStatement && isSufficientlyCoveredByReturnStatements(lastStatement)) {
73793                     return true;
73794                 }
73795             }
73796             return false;
73797         }
73798         function createActualThis() {
73799             return ts.setEmitFlags(factory.createThis(), 4);
73800         }
73801         function createDefaultSuperCallOrThis() {
73802             return factory.createLogicalOr(factory.createLogicalAnd(factory.createStrictInequality(factory.createUniqueName("_super", 16 | 32), factory.createNull()), factory.createFunctionApplyCall(factory.createUniqueName("_super", 16 | 32), createActualThis(), factory.createIdentifier("arguments"))), createActualThis());
73803         }
73804         function visitParameter(node) {
73805             if (node.dotDotDotToken) {
73806                 return undefined;
73807             }
73808             else if (ts.isBindingPattern(node.name)) {
73809                 return ts.setOriginalNode(ts.setTextRange(factory.createParameterDeclaration(undefined, undefined, undefined, factory.getGeneratedNameForNode(node), undefined, undefined, undefined), node), node);
73810             }
73811             else if (node.initializer) {
73812                 return ts.setOriginalNode(ts.setTextRange(factory.createParameterDeclaration(undefined, undefined, undefined, node.name, undefined, undefined, undefined), node), node);
73813             }
73814             else {
73815                 return node;
73816             }
73817         }
73818         function hasDefaultValueOrBindingPattern(node) {
73819             return node.initializer !== undefined
73820                 || ts.isBindingPattern(node.name);
73821         }
73822         function addDefaultValueAssignmentsIfNeeded(statements, node) {
73823             if (!ts.some(node.parameters, hasDefaultValueOrBindingPattern)) {
73824                 return false;
73825             }
73826             var added = false;
73827             for (var _i = 0, _a = node.parameters; _i < _a.length; _i++) {
73828                 var parameter = _a[_i];
73829                 var name = parameter.name, initializer = parameter.initializer, dotDotDotToken = parameter.dotDotDotToken;
73830                 if (dotDotDotToken) {
73831                     continue;
73832                 }
73833                 if (ts.isBindingPattern(name)) {
73834                     added = insertDefaultValueAssignmentForBindingPattern(statements, parameter, name, initializer) || added;
73835                 }
73836                 else if (initializer) {
73837                     insertDefaultValueAssignmentForInitializer(statements, parameter, name, initializer);
73838                     added = true;
73839                 }
73840             }
73841             return added;
73842         }
73843         function insertDefaultValueAssignmentForBindingPattern(statements, parameter, name, initializer) {
73844             if (name.elements.length > 0) {
73845                 ts.insertStatementAfterCustomPrologue(statements, ts.setEmitFlags(factory.createVariableStatement(undefined, factory.createVariableDeclarationList(ts.flattenDestructuringBinding(parameter, visitor, context, 0, factory.getGeneratedNameForNode(parameter)))), 1048576));
73846                 return true;
73847             }
73848             else if (initializer) {
73849                 ts.insertStatementAfterCustomPrologue(statements, ts.setEmitFlags(factory.createExpressionStatement(factory.createAssignment(factory.getGeneratedNameForNode(parameter), ts.visitNode(initializer, visitor, ts.isExpression))), 1048576));
73850                 return true;
73851             }
73852             return false;
73853         }
73854         function insertDefaultValueAssignmentForInitializer(statements, parameter, name, initializer) {
73855             initializer = ts.visitNode(initializer, visitor, ts.isExpression);
73856             var statement = factory.createIfStatement(factory.createTypeCheck(factory.cloneNode(name), "undefined"), ts.setEmitFlags(ts.setTextRange(factory.createBlock([
73857                 factory.createExpressionStatement(ts.setEmitFlags(ts.setTextRange(factory.createAssignment(ts.setEmitFlags(ts.setParent(ts.setTextRange(factory.cloneNode(name), name), name.parent), 48), ts.setEmitFlags(initializer, 48 | ts.getEmitFlags(initializer) | 1536)), parameter), 1536))
73858             ]), parameter), 1 | 32 | 384 | 1536));
73859             ts.startOnNewLine(statement);
73860             ts.setTextRange(statement, parameter);
73861             ts.setEmitFlags(statement, 384 | 32 | 1048576 | 1536);
73862             ts.insertStatementAfterCustomPrologue(statements, statement);
73863         }
73864         function shouldAddRestParameter(node, inConstructorWithSynthesizedSuper) {
73865             return !!(node && node.dotDotDotToken && !inConstructorWithSynthesizedSuper);
73866         }
73867         function addRestParameterIfNeeded(statements, node, inConstructorWithSynthesizedSuper) {
73868             var prologueStatements = [];
73869             var parameter = ts.lastOrUndefined(node.parameters);
73870             if (!shouldAddRestParameter(parameter, inConstructorWithSynthesizedSuper)) {
73871                 return false;
73872             }
73873             var declarationName = parameter.name.kind === 78 ? ts.setParent(ts.setTextRange(factory.cloneNode(parameter.name), parameter.name), parameter.name.parent) : factory.createTempVariable(undefined);
73874             ts.setEmitFlags(declarationName, 48);
73875             var expressionName = parameter.name.kind === 78 ? factory.cloneNode(parameter.name) : declarationName;
73876             var restIndex = node.parameters.length - 1;
73877             var temp = factory.createLoopVariable();
73878             prologueStatements.push(ts.setEmitFlags(ts.setTextRange(factory.createVariableStatement(undefined, factory.createVariableDeclarationList([
73879                 factory.createVariableDeclaration(declarationName, undefined, undefined, factory.createArrayLiteralExpression([]))
73880             ])), parameter), 1048576));
73881             var forStatement = factory.createForStatement(ts.setTextRange(factory.createVariableDeclarationList([
73882                 factory.createVariableDeclaration(temp, undefined, undefined, factory.createNumericLiteral(restIndex))
73883             ]), parameter), ts.setTextRange(factory.createLessThan(temp, factory.createPropertyAccessExpression(factory.createIdentifier("arguments"), "length")), parameter), ts.setTextRange(factory.createPostfixIncrement(temp), parameter), factory.createBlock([
73884                 ts.startOnNewLine(ts.setTextRange(factory.createExpressionStatement(factory.createAssignment(factory.createElementAccessExpression(expressionName, restIndex === 0
73885                     ? temp
73886                     : factory.createSubtract(temp, factory.createNumericLiteral(restIndex))), factory.createElementAccessExpression(factory.createIdentifier("arguments"), temp))), parameter))
73887             ]));
73888             ts.setEmitFlags(forStatement, 1048576);
73889             ts.startOnNewLine(forStatement);
73890             prologueStatements.push(forStatement);
73891             if (parameter.name.kind !== 78) {
73892                 prologueStatements.push(ts.setEmitFlags(ts.setTextRange(factory.createVariableStatement(undefined, factory.createVariableDeclarationList(ts.flattenDestructuringBinding(parameter, visitor, context, 0, expressionName))), parameter), 1048576));
73893             }
73894             ts.insertStatementsAfterCustomPrologue(statements, prologueStatements);
73895             return true;
73896         }
73897         function insertCaptureThisForNodeIfNeeded(statements, node) {
73898             if (hierarchyFacts & 32768 && node.kind !== 209) {
73899                 insertCaptureThisForNode(statements, node, factory.createThis());
73900                 return true;
73901             }
73902             return false;
73903         }
73904         function insertCaptureThisForNode(statements, node, initializer) {
73905             enableSubstitutionsForCapturedThis();
73906             var captureThisStatement = factory.createVariableStatement(undefined, factory.createVariableDeclarationList([
73907                 factory.createVariableDeclaration(factory.createUniqueName("_this", 16 | 32), undefined, undefined, initializer)
73908             ]));
73909             ts.setEmitFlags(captureThisStatement, 1536 | 1048576);
73910             ts.setSourceMapRange(captureThisStatement, node);
73911             ts.insertStatementAfterCustomPrologue(statements, captureThisStatement);
73912         }
73913         function insertCaptureNewTargetIfNeeded(statements, node, copyOnWrite) {
73914             if (hierarchyFacts & 16384) {
73915                 var newTarget = void 0;
73916                 switch (node.kind) {
73917                     case 209:
73918                         return statements;
73919                     case 165:
73920                     case 167:
73921                     case 168:
73922                         newTarget = factory.createVoidZero();
73923                         break;
73924                     case 166:
73925                         newTarget = factory.createPropertyAccessExpression(ts.setEmitFlags(factory.createThis(), 4), "constructor");
73926                         break;
73927                     case 251:
73928                     case 208:
73929                         newTarget = factory.createConditionalExpression(factory.createLogicalAnd(ts.setEmitFlags(factory.createThis(), 4), factory.createBinaryExpression(ts.setEmitFlags(factory.createThis(), 4), 101, factory.getLocalName(node))), undefined, factory.createPropertyAccessExpression(ts.setEmitFlags(factory.createThis(), 4), "constructor"), undefined, factory.createVoidZero());
73930                         break;
73931                     default:
73932                         return ts.Debug.failBadSyntaxKind(node);
73933                 }
73934                 var captureNewTargetStatement = factory.createVariableStatement(undefined, factory.createVariableDeclarationList([
73935                     factory.createVariableDeclaration(factory.createUniqueName("_newTarget", 16 | 32), undefined, undefined, newTarget)
73936                 ]));
73937                 ts.setEmitFlags(captureNewTargetStatement, 1536 | 1048576);
73938                 if (copyOnWrite) {
73939                     statements = statements.slice();
73940                 }
73941                 ts.insertStatementAfterCustomPrologue(statements, captureNewTargetStatement);
73942             }
73943             return statements;
73944         }
73945         function addClassMembers(statements, node) {
73946             for (var _i = 0, _a = node.members; _i < _a.length; _i++) {
73947                 var member = _a[_i];
73948                 switch (member.kind) {
73949                     case 229:
73950                         statements.push(transformSemicolonClassElementToStatement(member));
73951                         break;
73952                     case 165:
73953                         statements.push(transformClassMethodDeclarationToStatement(getClassMemberPrefix(node, member), member, node));
73954                         break;
73955                     case 167:
73956                     case 168:
73957                         var accessors = ts.getAllAccessorDeclarations(node.members, member);
73958                         if (member === accessors.firstAccessor) {
73959                             statements.push(transformAccessorsToStatement(getClassMemberPrefix(node, member), accessors, node));
73960                         }
73961                         break;
73962                     case 166:
73963                         break;
73964                     default:
73965                         ts.Debug.failBadSyntaxKind(member, currentSourceFile && currentSourceFile.fileName);
73966                         break;
73967                 }
73968             }
73969         }
73970         function transformSemicolonClassElementToStatement(member) {
73971             return ts.setTextRange(factory.createEmptyStatement(), member);
73972         }
73973         function transformClassMethodDeclarationToStatement(receiver, member, container) {
73974             var commentRange = ts.getCommentRange(member);
73975             var sourceMapRange = ts.getSourceMapRange(member);
73976             var memberFunction = transformFunctionLikeToExpression(member, member, undefined, container);
73977             var propertyName = ts.visitNode(member.name, visitor, ts.isPropertyName);
73978             var e;
73979             if (!ts.isPrivateIdentifier(propertyName) && context.getCompilerOptions().useDefineForClassFields) {
73980                 var name = ts.isComputedPropertyName(propertyName) ? propertyName.expression
73981                     : ts.isIdentifier(propertyName) ? factory.createStringLiteral(ts.unescapeLeadingUnderscores(propertyName.escapedText))
73982                         : propertyName;
73983                 e = factory.createObjectDefinePropertyCall(receiver, name, factory.createPropertyDescriptor({ value: memberFunction, enumerable: false, writable: true, configurable: true }));
73984             }
73985             else {
73986                 var memberName = ts.createMemberAccessForPropertyName(factory, receiver, propertyName, member.name);
73987                 e = factory.createAssignment(memberName, memberFunction);
73988             }
73989             ts.setEmitFlags(memberFunction, 1536);
73990             ts.setSourceMapRange(memberFunction, sourceMapRange);
73991             var statement = ts.setTextRange(factory.createExpressionStatement(e), member);
73992             ts.setOriginalNode(statement, member);
73993             ts.setCommentRange(statement, commentRange);
73994             ts.setEmitFlags(statement, 48);
73995             return statement;
73996         }
73997         function transformAccessorsToStatement(receiver, accessors, container) {
73998             var statement = factory.createExpressionStatement(transformAccessorsToExpression(receiver, accessors, container, false));
73999             ts.setEmitFlags(statement, 1536);
74000             ts.setSourceMapRange(statement, ts.getSourceMapRange(accessors.firstAccessor));
74001             return statement;
74002         }
74003         function transformAccessorsToExpression(receiver, _a, container, startsOnNewLine) {
74004             var firstAccessor = _a.firstAccessor, getAccessor = _a.getAccessor, setAccessor = _a.setAccessor;
74005             var target = ts.setParent(ts.setTextRange(factory.cloneNode(receiver), receiver), receiver.parent);
74006             ts.setEmitFlags(target, 1536 | 32);
74007             ts.setSourceMapRange(target, firstAccessor.name);
74008             var visitedAccessorName = ts.visitNode(firstAccessor.name, visitor, ts.isPropertyName);
74009             if (ts.isPrivateIdentifier(visitedAccessorName)) {
74010                 return ts.Debug.failBadSyntaxKind(visitedAccessorName, "Encountered unhandled private identifier while transforming ES2015.");
74011             }
74012             var propertyName = ts.createExpressionForPropertyName(factory, visitedAccessorName);
74013             ts.setEmitFlags(propertyName, 1536 | 16);
74014             ts.setSourceMapRange(propertyName, firstAccessor.name);
74015             var properties = [];
74016             if (getAccessor) {
74017                 var getterFunction = transformFunctionLikeToExpression(getAccessor, undefined, undefined, container);
74018                 ts.setSourceMapRange(getterFunction, ts.getSourceMapRange(getAccessor));
74019                 ts.setEmitFlags(getterFunction, 512);
74020                 var getter = factory.createPropertyAssignment("get", getterFunction);
74021                 ts.setCommentRange(getter, ts.getCommentRange(getAccessor));
74022                 properties.push(getter);
74023             }
74024             if (setAccessor) {
74025                 var setterFunction = transformFunctionLikeToExpression(setAccessor, undefined, undefined, container);
74026                 ts.setSourceMapRange(setterFunction, ts.getSourceMapRange(setAccessor));
74027                 ts.setEmitFlags(setterFunction, 512);
74028                 var setter = factory.createPropertyAssignment("set", setterFunction);
74029                 ts.setCommentRange(setter, ts.getCommentRange(setAccessor));
74030                 properties.push(setter);
74031             }
74032             properties.push(factory.createPropertyAssignment("enumerable", getAccessor || setAccessor ? factory.createFalse() : factory.createTrue()), factory.createPropertyAssignment("configurable", factory.createTrue()));
74033             var call = factory.createCallExpression(factory.createPropertyAccessExpression(factory.createIdentifier("Object"), "defineProperty"), undefined, [
74034                 target,
74035                 propertyName,
74036                 factory.createObjectLiteralExpression(properties, true)
74037             ]);
74038             if (startsOnNewLine) {
74039                 ts.startOnNewLine(call);
74040             }
74041             return call;
74042         }
74043         function visitArrowFunction(node) {
74044             if (node.transformFlags & 4096) {
74045                 hierarchyFacts |= 32768;
74046             }
74047             var savedConvertedLoopState = convertedLoopState;
74048             convertedLoopState = undefined;
74049             var ancestorFacts = enterSubtree(15232, 66);
74050             var func = factory.createFunctionExpression(undefined, undefined, undefined, undefined, ts.visitParameterList(node.parameters, visitor, context), undefined, transformFunctionBody(node));
74051             ts.setTextRange(func, node);
74052             ts.setOriginalNode(func, node);
74053             ts.setEmitFlags(func, 8);
74054             if (hierarchyFacts & 32768) {
74055                 enableSubstitutionsForCapturedThis();
74056             }
74057             exitSubtree(ancestorFacts, 0, 0);
74058             convertedLoopState = savedConvertedLoopState;
74059             return func;
74060         }
74061         function visitFunctionExpression(node) {
74062             var ancestorFacts = ts.getEmitFlags(node) & 262144
74063                 ? enterSubtree(16278, 69)
74064                 : enterSubtree(16286, 65);
74065             var savedConvertedLoopState = convertedLoopState;
74066             convertedLoopState = undefined;
74067             var parameters = ts.visitParameterList(node.parameters, visitor, context);
74068             var body = transformFunctionBody(node);
74069             var name = hierarchyFacts & 16384
74070                 ? factory.getLocalName(node)
74071                 : node.name;
74072             exitSubtree(ancestorFacts, 49152, 0);
74073             convertedLoopState = savedConvertedLoopState;
74074             return factory.updateFunctionExpression(node, undefined, node.asteriskToken, name, undefined, parameters, undefined, body);
74075         }
74076         function visitFunctionDeclaration(node) {
74077             var savedConvertedLoopState = convertedLoopState;
74078             convertedLoopState = undefined;
74079             var ancestorFacts = enterSubtree(16286, 65);
74080             var parameters = ts.visitParameterList(node.parameters, visitor, context);
74081             var body = transformFunctionBody(node);
74082             var name = hierarchyFacts & 16384
74083                 ? factory.getLocalName(node)
74084                 : node.name;
74085             exitSubtree(ancestorFacts, 49152, 0);
74086             convertedLoopState = savedConvertedLoopState;
74087             return factory.updateFunctionDeclaration(node, undefined, ts.visitNodes(node.modifiers, visitor, ts.isModifier), node.asteriskToken, name, undefined, parameters, undefined, body);
74088         }
74089         function transformFunctionLikeToExpression(node, location, name, container) {
74090             var savedConvertedLoopState = convertedLoopState;
74091             convertedLoopState = undefined;
74092             var ancestorFacts = container && ts.isClassLike(container) && !ts.hasSyntacticModifier(node, 32)
74093                 ? enterSubtree(16286, 65 | 8)
74094                 : enterSubtree(16286, 65);
74095             var parameters = ts.visitParameterList(node.parameters, visitor, context);
74096             var body = transformFunctionBody(node);
74097             if (hierarchyFacts & 16384 && !name && (node.kind === 251 || node.kind === 208)) {
74098                 name = factory.getGeneratedNameForNode(node);
74099             }
74100             exitSubtree(ancestorFacts, 49152, 0);
74101             convertedLoopState = savedConvertedLoopState;
74102             return ts.setOriginalNode(ts.setTextRange(factory.createFunctionExpression(undefined, node.asteriskToken, name, undefined, parameters, undefined, body), location), node);
74103         }
74104         function transformFunctionBody(node) {
74105             var multiLine = false;
74106             var singleLine = false;
74107             var statementsLocation;
74108             var closeBraceLocation;
74109             var prologue = [];
74110             var statements = [];
74111             var body = node.body;
74112             var statementOffset;
74113             resumeLexicalEnvironment();
74114             if (ts.isBlock(body)) {
74115                 statementOffset = factory.copyStandardPrologue(body.statements, prologue, false);
74116                 statementOffset = factory.copyCustomPrologue(body.statements, statements, statementOffset, visitor, ts.isHoistedFunction);
74117                 statementOffset = factory.copyCustomPrologue(body.statements, statements, statementOffset, visitor, ts.isHoistedVariableStatement);
74118             }
74119             multiLine = addDefaultValueAssignmentsIfNeeded(statements, node) || multiLine;
74120             multiLine = addRestParameterIfNeeded(statements, node, false) || multiLine;
74121             if (ts.isBlock(body)) {
74122                 statementOffset = factory.copyCustomPrologue(body.statements, statements, statementOffset, visitor);
74123                 statementsLocation = body.statements;
74124                 ts.addRange(statements, ts.visitNodes(body.statements, visitor, ts.isStatement, statementOffset));
74125                 if (!multiLine && body.multiLine) {
74126                     multiLine = true;
74127                 }
74128             }
74129             else {
74130                 ts.Debug.assert(node.kind === 209);
74131                 statementsLocation = ts.moveRangeEnd(body, -1);
74132                 var equalsGreaterThanToken = node.equalsGreaterThanToken;
74133                 if (!ts.nodeIsSynthesized(equalsGreaterThanToken) && !ts.nodeIsSynthesized(body)) {
74134                     if (ts.rangeEndIsOnSameLineAsRangeStart(equalsGreaterThanToken, body, currentSourceFile)) {
74135                         singleLine = true;
74136                     }
74137                     else {
74138                         multiLine = true;
74139                     }
74140                 }
74141                 var expression = ts.visitNode(body, visitor, ts.isExpression);
74142                 var returnStatement = factory.createReturnStatement(expression);
74143                 ts.setTextRange(returnStatement, body);
74144                 ts.moveSyntheticComments(returnStatement, body);
74145                 ts.setEmitFlags(returnStatement, 384 | 32 | 1024);
74146                 statements.push(returnStatement);
74147                 closeBraceLocation = body;
74148             }
74149             factory.mergeLexicalEnvironment(prologue, endLexicalEnvironment());
74150             insertCaptureNewTargetIfNeeded(prologue, node, false);
74151             insertCaptureThisForNodeIfNeeded(prologue, node);
74152             if (ts.some(prologue)) {
74153                 multiLine = true;
74154             }
74155             statements.unshift.apply(statements, prologue);
74156             if (ts.isBlock(body) && ts.arrayIsEqualTo(statements, body.statements)) {
74157                 return body;
74158             }
74159             var block = factory.createBlock(ts.setTextRange(factory.createNodeArray(statements), statementsLocation), multiLine);
74160             ts.setTextRange(block, node.body);
74161             if (!multiLine && singleLine) {
74162                 ts.setEmitFlags(block, 1);
74163             }
74164             if (closeBraceLocation) {
74165                 ts.setTokenSourceMapRange(block, 19, closeBraceLocation);
74166             }
74167             ts.setOriginalNode(block, node.body);
74168             return block;
74169         }
74170         function visitBlock(node, isFunctionBody) {
74171             if (isFunctionBody) {
74172                 return ts.visitEachChild(node, visitor, context);
74173             }
74174             var ancestorFacts = hierarchyFacts & 256
74175                 ? enterSubtree(7104, 512)
74176                 : enterSubtree(6976, 128);
74177             var updated = ts.visitEachChild(node, visitor, context);
74178             exitSubtree(ancestorFacts, 0, 0);
74179             return updated;
74180         }
74181         function visitExpressionStatement(node) {
74182             return ts.visitEachChild(node, visitorWithUnusedExpressionResult, context);
74183         }
74184         function visitParenthesizedExpression(node, expressionResultIsUnused) {
74185             return ts.visitEachChild(node, expressionResultIsUnused ? visitorWithUnusedExpressionResult : visitor, context);
74186         }
74187         function visitBinaryExpression(node, expressionResultIsUnused) {
74188             if (ts.isDestructuringAssignment(node)) {
74189                 return ts.flattenDestructuringAssignment(node, visitor, context, 0, !expressionResultIsUnused);
74190             }
74191             if (node.operatorToken.kind === 27) {
74192                 return factory.updateBinaryExpression(node, ts.visitNode(node.left, visitorWithUnusedExpressionResult, ts.isExpression), node.operatorToken, ts.visitNode(node.right, expressionResultIsUnused ? visitorWithUnusedExpressionResult : visitor, ts.isExpression));
74193             }
74194             return ts.visitEachChild(node, visitor, context);
74195         }
74196         function visitCommaListExpression(node, expressionResultIsUnused) {
74197             if (expressionResultIsUnused) {
74198                 return ts.visitEachChild(node, visitorWithUnusedExpressionResult, context);
74199             }
74200             var result;
74201             for (var i = 0; i < node.elements.length; i++) {
74202                 var element = node.elements[i];
74203                 var visited = ts.visitNode(element, i < node.elements.length - 1 ? visitorWithUnusedExpressionResult : visitor, ts.isExpression);
74204                 if (result || visited !== element) {
74205                     result || (result = node.elements.slice(0, i));
74206                     result.push(visited);
74207                 }
74208             }
74209             var elements = result ? ts.setTextRange(factory.createNodeArray(result), node.elements) : node.elements;
74210             return factory.updateCommaListExpression(node, elements);
74211         }
74212         function isVariableStatementOfTypeScriptClassWrapper(node) {
74213             return node.declarationList.declarations.length === 1
74214                 && !!node.declarationList.declarations[0].initializer
74215                 && !!(ts.getEmitFlags(node.declarationList.declarations[0].initializer) & 33554432);
74216         }
74217         function visitVariableStatement(node) {
74218             var ancestorFacts = enterSubtree(0, ts.hasSyntacticModifier(node, 1) ? 32 : 0);
74219             var updated;
74220             if (convertedLoopState && (node.declarationList.flags & 3) === 0 && !isVariableStatementOfTypeScriptClassWrapper(node)) {
74221                 var assignments = void 0;
74222                 for (var _i = 0, _a = node.declarationList.declarations; _i < _a.length; _i++) {
74223                     var decl = _a[_i];
74224                     hoistVariableDeclarationDeclaredInConvertedLoop(convertedLoopState, decl);
74225                     if (decl.initializer) {
74226                         var assignment = void 0;
74227                         if (ts.isBindingPattern(decl.name)) {
74228                             assignment = ts.flattenDestructuringAssignment(decl, visitor, context, 0);
74229                         }
74230                         else {
74231                             assignment = factory.createBinaryExpression(decl.name, 62, ts.visitNode(decl.initializer, visitor, ts.isExpression));
74232                             ts.setTextRange(assignment, decl);
74233                         }
74234                         assignments = ts.append(assignments, assignment);
74235                     }
74236                 }
74237                 if (assignments) {
74238                     updated = ts.setTextRange(factory.createExpressionStatement(factory.inlineExpressions(assignments)), node);
74239                 }
74240                 else {
74241                     updated = undefined;
74242                 }
74243             }
74244             else {
74245                 updated = ts.visitEachChild(node, visitor, context);
74246             }
74247             exitSubtree(ancestorFacts, 0, 0);
74248             return updated;
74249         }
74250         function visitVariableDeclarationList(node) {
74251             if (node.flags & 3 || node.transformFlags & 131072) {
74252                 if (node.flags & 3) {
74253                     enableSubstitutionsForBlockScopedBindings();
74254                 }
74255                 var declarations = ts.flatMap(node.declarations, node.flags & 1
74256                     ? visitVariableDeclarationInLetDeclarationList
74257                     : visitVariableDeclaration);
74258                 var declarationList = factory.createVariableDeclarationList(declarations);
74259                 ts.setOriginalNode(declarationList, node);
74260                 ts.setTextRange(declarationList, node);
74261                 ts.setCommentRange(declarationList, node);
74262                 if (node.transformFlags & 131072
74263                     && (ts.isBindingPattern(node.declarations[0].name) || ts.isBindingPattern(ts.last(node.declarations).name))) {
74264                     ts.setSourceMapRange(declarationList, getRangeUnion(declarations));
74265                 }
74266                 return declarationList;
74267             }
74268             return ts.visitEachChild(node, visitor, context);
74269         }
74270         function getRangeUnion(declarations) {
74271             var pos = -1, end = -1;
74272             for (var _i = 0, declarations_10 = declarations; _i < declarations_10.length; _i++) {
74273                 var node = declarations_10[_i];
74274                 pos = pos === -1 ? node.pos : node.pos === -1 ? pos : Math.min(pos, node.pos);
74275                 end = Math.max(end, node.end);
74276             }
74277             return ts.createRange(pos, end);
74278         }
74279         function shouldEmitExplicitInitializerForLetDeclaration(node) {
74280             var flags = resolver.getNodeCheckFlags(node);
74281             var isCapturedInFunction = flags & 262144;
74282             var isDeclaredInLoop = flags & 524288;
74283             var emittedAsTopLevel = (hierarchyFacts & 64) !== 0
74284                 || (isCapturedInFunction
74285                     && isDeclaredInLoop
74286                     && (hierarchyFacts & 512) !== 0);
74287             var emitExplicitInitializer = !emittedAsTopLevel
74288                 && (hierarchyFacts & 4096) === 0
74289                 && (!resolver.isDeclarationWithCollidingName(node)
74290                     || (isDeclaredInLoop
74291                         && !isCapturedInFunction
74292                         && (hierarchyFacts & (2048 | 4096)) === 0));
74293             return emitExplicitInitializer;
74294         }
74295         function visitVariableDeclarationInLetDeclarationList(node) {
74296             var name = node.name;
74297             if (ts.isBindingPattern(name)) {
74298                 return visitVariableDeclaration(node);
74299             }
74300             if (!node.initializer && shouldEmitExplicitInitializerForLetDeclaration(node)) {
74301                 return factory.updateVariableDeclaration(node, node.name, undefined, undefined, factory.createVoidZero());
74302             }
74303             return ts.visitEachChild(node, visitor, context);
74304         }
74305         function visitVariableDeclaration(node) {
74306             var ancestorFacts = enterSubtree(32, 0);
74307             var updated;
74308             if (ts.isBindingPattern(node.name)) {
74309                 updated = ts.flattenDestructuringBinding(node, visitor, context, 0, undefined, (ancestorFacts & 32) !== 0);
74310             }
74311             else {
74312                 updated = ts.visitEachChild(node, visitor, context);
74313             }
74314             exitSubtree(ancestorFacts, 0, 0);
74315             return updated;
74316         }
74317         function recordLabel(node) {
74318             convertedLoopState.labels.set(ts.idText(node.label), true);
74319         }
74320         function resetLabel(node) {
74321             convertedLoopState.labels.set(ts.idText(node.label), false);
74322         }
74323         function visitLabeledStatement(node) {
74324             if (convertedLoopState && !convertedLoopState.labels) {
74325                 convertedLoopState.labels = new ts.Map();
74326             }
74327             var statement = ts.unwrapInnermostStatementOfLabel(node, convertedLoopState && recordLabel);
74328             return ts.isIterationStatement(statement, false)
74329                 ? visitIterationStatement(statement, node)
74330                 : factory.restoreEnclosingLabel(ts.visitNode(statement, visitor, ts.isStatement, factory.liftToBlock), node, convertedLoopState && resetLabel);
74331         }
74332         function visitIterationStatement(node, outermostLabeledStatement) {
74333             switch (node.kind) {
74334                 case 235:
74335                 case 236:
74336                     return visitDoOrWhileStatement(node, outermostLabeledStatement);
74337                 case 237:
74338                     return visitForStatement(node, outermostLabeledStatement);
74339                 case 238:
74340                     return visitForInStatement(node, outermostLabeledStatement);
74341                 case 239:
74342                     return visitForOfStatement(node, outermostLabeledStatement);
74343             }
74344         }
74345         function visitIterationStatementWithFacts(excludeFacts, includeFacts, node, outermostLabeledStatement, convert) {
74346             var ancestorFacts = enterSubtree(excludeFacts, includeFacts);
74347             var updated = convertIterationStatementBodyIfNecessary(node, outermostLabeledStatement, ancestorFacts, convert);
74348             exitSubtree(ancestorFacts, 0, 0);
74349             return updated;
74350         }
74351         function visitDoOrWhileStatement(node, outermostLabeledStatement) {
74352             return visitIterationStatementWithFacts(0, 1280, node, outermostLabeledStatement);
74353         }
74354         function visitForStatement(node, outermostLabeledStatement) {
74355             return visitIterationStatementWithFacts(5056, 3328, node, outermostLabeledStatement);
74356         }
74357         function visitEachChildOfForStatement(node) {
74358             return factory.updateForStatement(node, ts.visitNode(node.initializer, visitorWithUnusedExpressionResult, ts.isForInitializer), ts.visitNode(node.condition, visitor, ts.isExpression), ts.visitNode(node.incrementor, visitorWithUnusedExpressionResult, ts.isExpression), ts.visitNode(node.statement, visitor, ts.isStatement, factory.liftToBlock));
74359         }
74360         function visitForInStatement(node, outermostLabeledStatement) {
74361             return visitIterationStatementWithFacts(3008, 5376, node, outermostLabeledStatement);
74362         }
74363         function visitForOfStatement(node, outermostLabeledStatement) {
74364             return visitIterationStatementWithFacts(3008, 5376, node, outermostLabeledStatement, compilerOptions.downlevelIteration ? convertForOfStatementForIterable : convertForOfStatementForArray);
74365         }
74366         function convertForOfStatementHead(node, boundValue, convertedLoopBodyStatements) {
74367             var statements = [];
74368             var initializer = node.initializer;
74369             if (ts.isVariableDeclarationList(initializer)) {
74370                 if (node.initializer.flags & 3) {
74371                     enableSubstitutionsForBlockScopedBindings();
74372                 }
74373                 var firstOriginalDeclaration = ts.firstOrUndefined(initializer.declarations);
74374                 if (firstOriginalDeclaration && ts.isBindingPattern(firstOriginalDeclaration.name)) {
74375                     var declarations = ts.flattenDestructuringBinding(firstOriginalDeclaration, visitor, context, 0, boundValue);
74376                     var declarationList = ts.setTextRange(factory.createVariableDeclarationList(declarations), node.initializer);
74377                     ts.setOriginalNode(declarationList, node.initializer);
74378                     ts.setSourceMapRange(declarationList, ts.createRange(declarations[0].pos, ts.last(declarations).end));
74379                     statements.push(factory.createVariableStatement(undefined, declarationList));
74380                 }
74381                 else {
74382                     statements.push(ts.setTextRange(factory.createVariableStatement(undefined, ts.setOriginalNode(ts.setTextRange(factory.createVariableDeclarationList([
74383                         factory.createVariableDeclaration(firstOriginalDeclaration ? firstOriginalDeclaration.name : factory.createTempVariable(undefined), undefined, undefined, boundValue)
74384                     ]), ts.moveRangePos(initializer, -1)), initializer)), ts.moveRangeEnd(initializer, -1)));
74385                 }
74386             }
74387             else {
74388                 var assignment = factory.createAssignment(initializer, boundValue);
74389                 if (ts.isDestructuringAssignment(assignment)) {
74390                     statements.push(factory.createExpressionStatement(visitBinaryExpression(assignment, true)));
74391                 }
74392                 else {
74393                     ts.setTextRangeEnd(assignment, initializer.end);
74394                     statements.push(ts.setTextRange(factory.createExpressionStatement(ts.visitNode(assignment, visitor, ts.isExpression)), ts.moveRangeEnd(initializer, -1)));
74395                 }
74396             }
74397             if (convertedLoopBodyStatements) {
74398                 return createSyntheticBlockForConvertedStatements(ts.addRange(statements, convertedLoopBodyStatements));
74399             }
74400             else {
74401                 var statement = ts.visitNode(node.statement, visitor, ts.isStatement, factory.liftToBlock);
74402                 if (ts.isBlock(statement)) {
74403                     return factory.updateBlock(statement, ts.setTextRange(factory.createNodeArray(ts.concatenate(statements, statement.statements)), statement.statements));
74404                 }
74405                 else {
74406                     statements.push(statement);
74407                     return createSyntheticBlockForConvertedStatements(statements);
74408                 }
74409             }
74410         }
74411         function createSyntheticBlockForConvertedStatements(statements) {
74412             return ts.setEmitFlags(factory.createBlock(factory.createNodeArray(statements), true), 48 | 384);
74413         }
74414         function convertForOfStatementForArray(node, outermostLabeledStatement, convertedLoopBodyStatements) {
74415             var expression = ts.visitNode(node.expression, visitor, ts.isExpression);
74416             var counter = factory.createLoopVariable();
74417             var rhsReference = ts.isIdentifier(expression) ? factory.getGeneratedNameForNode(expression) : factory.createTempVariable(undefined);
74418             ts.setEmitFlags(expression, 48 | ts.getEmitFlags(expression));
74419             var forStatement = ts.setTextRange(factory.createForStatement(ts.setEmitFlags(ts.setTextRange(factory.createVariableDeclarationList([
74420                 ts.setTextRange(factory.createVariableDeclaration(counter, undefined, undefined, factory.createNumericLiteral(0)), ts.moveRangePos(node.expression, -1)),
74421                 ts.setTextRange(factory.createVariableDeclaration(rhsReference, undefined, undefined, expression), node.expression)
74422             ]), node.expression), 2097152), ts.setTextRange(factory.createLessThan(counter, factory.createPropertyAccessExpression(rhsReference, "length")), node.expression), ts.setTextRange(factory.createPostfixIncrement(counter), node.expression), convertForOfStatementHead(node, factory.createElementAccessExpression(rhsReference, counter), convertedLoopBodyStatements)), node);
74423             ts.setEmitFlags(forStatement, 256);
74424             ts.setTextRange(forStatement, node);
74425             return factory.restoreEnclosingLabel(forStatement, outermostLabeledStatement, convertedLoopState && resetLabel);
74426         }
74427         function convertForOfStatementForIterable(node, outermostLabeledStatement, convertedLoopBodyStatements, ancestorFacts) {
74428             var expression = ts.visitNode(node.expression, visitor, ts.isExpression);
74429             var iterator = ts.isIdentifier(expression) ? factory.getGeneratedNameForNode(expression) : factory.createTempVariable(undefined);
74430             var result = ts.isIdentifier(expression) ? factory.getGeneratedNameForNode(iterator) : factory.createTempVariable(undefined);
74431             var errorRecord = factory.createUniqueName("e");
74432             var catchVariable = factory.getGeneratedNameForNode(errorRecord);
74433             var returnMethod = factory.createTempVariable(undefined);
74434             var values = ts.setTextRange(emitHelpers().createValuesHelper(expression), node.expression);
74435             var next = factory.createCallExpression(factory.createPropertyAccessExpression(iterator, "next"), undefined, []);
74436             hoistVariableDeclaration(errorRecord);
74437             hoistVariableDeclaration(returnMethod);
74438             var initializer = ancestorFacts & 1024
74439                 ? factory.inlineExpressions([factory.createAssignment(errorRecord, factory.createVoidZero()), values])
74440                 : values;
74441             var forStatement = ts.setEmitFlags(ts.setTextRange(factory.createForStatement(ts.setEmitFlags(ts.setTextRange(factory.createVariableDeclarationList([
74442                 ts.setTextRange(factory.createVariableDeclaration(iterator, undefined, undefined, initializer), node.expression),
74443                 factory.createVariableDeclaration(result, undefined, undefined, next)
74444             ]), node.expression), 2097152), factory.createLogicalNot(factory.createPropertyAccessExpression(result, "done")), factory.createAssignment(result, next), convertForOfStatementHead(node, factory.createPropertyAccessExpression(result, "value"), convertedLoopBodyStatements)), node), 256);
74445             return factory.createTryStatement(factory.createBlock([
74446                 factory.restoreEnclosingLabel(forStatement, outermostLabeledStatement, convertedLoopState && resetLabel)
74447             ]), factory.createCatchClause(factory.createVariableDeclaration(catchVariable), ts.setEmitFlags(factory.createBlock([
74448                 factory.createExpressionStatement(factory.createAssignment(errorRecord, factory.createObjectLiteralExpression([
74449                     factory.createPropertyAssignment("error", catchVariable)
74450                 ])))
74451             ]), 1)), factory.createBlock([
74452                 factory.createTryStatement(factory.createBlock([
74453                     ts.setEmitFlags(factory.createIfStatement(factory.createLogicalAnd(factory.createLogicalAnd(result, factory.createLogicalNot(factory.createPropertyAccessExpression(result, "done"))), factory.createAssignment(returnMethod, factory.createPropertyAccessExpression(iterator, "return"))), factory.createExpressionStatement(factory.createFunctionCallCall(returnMethod, iterator, []))), 1),
74454                 ]), undefined, ts.setEmitFlags(factory.createBlock([
74455                     ts.setEmitFlags(factory.createIfStatement(errorRecord, factory.createThrowStatement(factory.createPropertyAccessExpression(errorRecord, "error"))), 1)
74456                 ]), 1))
74457             ]));
74458         }
74459         function visitObjectLiteralExpression(node) {
74460             var properties = node.properties;
74461             var numInitialProperties = -1, hasComputed = false;
74462             for (var i = 0; i < properties.length; i++) {
74463                 var property = properties[i];
74464                 if ((property.transformFlags & 262144 &&
74465                     hierarchyFacts & 4)
74466                     || (hasComputed = ts.Debug.checkDefined(property.name).kind === 158)) {
74467                     numInitialProperties = i;
74468                     break;
74469                 }
74470             }
74471             if (numInitialProperties < 0) {
74472                 return ts.visitEachChild(node, visitor, context);
74473             }
74474             var temp = factory.createTempVariable(hoistVariableDeclaration);
74475             var expressions = [];
74476             var assignment = factory.createAssignment(temp, ts.setEmitFlags(factory.createObjectLiteralExpression(ts.visitNodes(properties, visitor, ts.isObjectLiteralElementLike, 0, numInitialProperties), node.multiLine), hasComputed ? 65536 : 0));
74477             if (node.multiLine) {
74478                 ts.startOnNewLine(assignment);
74479             }
74480             expressions.push(assignment);
74481             addObjectLiteralMembers(expressions, node, temp, numInitialProperties);
74482             expressions.push(node.multiLine ? ts.startOnNewLine(ts.setParent(ts.setTextRange(factory.cloneNode(temp), temp), temp.parent)) : temp);
74483             return factory.inlineExpressions(expressions);
74484         }
74485         function shouldConvertPartOfIterationStatement(node) {
74486             return (resolver.getNodeCheckFlags(node) & 131072) !== 0;
74487         }
74488         function shouldConvertInitializerOfForStatement(node) {
74489             return ts.isForStatement(node) && !!node.initializer && shouldConvertPartOfIterationStatement(node.initializer);
74490         }
74491         function shouldConvertConditionOfForStatement(node) {
74492             return ts.isForStatement(node) && !!node.condition && shouldConvertPartOfIterationStatement(node.condition);
74493         }
74494         function shouldConvertIncrementorOfForStatement(node) {
74495             return ts.isForStatement(node) && !!node.incrementor && shouldConvertPartOfIterationStatement(node.incrementor);
74496         }
74497         function shouldConvertIterationStatement(node) {
74498             return shouldConvertBodyOfIterationStatement(node)
74499                 || shouldConvertInitializerOfForStatement(node);
74500         }
74501         function shouldConvertBodyOfIterationStatement(node) {
74502             return (resolver.getNodeCheckFlags(node) & 65536) !== 0;
74503         }
74504         function hoistVariableDeclarationDeclaredInConvertedLoop(state, node) {
74505             if (!state.hoistedLocalVariables) {
74506                 state.hoistedLocalVariables = [];
74507             }
74508             visit(node.name);
74509             function visit(node) {
74510                 if (node.kind === 78) {
74511                     state.hoistedLocalVariables.push(node);
74512                 }
74513                 else {
74514                     for (var _i = 0, _a = node.elements; _i < _a.length; _i++) {
74515                         var element = _a[_i];
74516                         if (!ts.isOmittedExpression(element)) {
74517                             visit(element.name);
74518                         }
74519                     }
74520                 }
74521             }
74522         }
74523         function convertIterationStatementBodyIfNecessary(node, outermostLabeledStatement, ancestorFacts, convert) {
74524             if (!shouldConvertIterationStatement(node)) {
74525                 var saveAllowedNonLabeledJumps = void 0;
74526                 if (convertedLoopState) {
74527                     saveAllowedNonLabeledJumps = convertedLoopState.allowedNonLabeledJumps;
74528                     convertedLoopState.allowedNonLabeledJumps = 2 | 4;
74529                 }
74530                 var result = convert
74531                     ? convert(node, outermostLabeledStatement, undefined, ancestorFacts)
74532                     : factory.restoreEnclosingLabel(ts.isForStatement(node) ? visitEachChildOfForStatement(node) : ts.visitEachChild(node, visitor, context), outermostLabeledStatement, convertedLoopState && resetLabel);
74533                 if (convertedLoopState) {
74534                     convertedLoopState.allowedNonLabeledJumps = saveAllowedNonLabeledJumps;
74535                 }
74536                 return result;
74537             }
74538             var currentState = createConvertedLoopState(node);
74539             var statements = [];
74540             var outerConvertedLoopState = convertedLoopState;
74541             convertedLoopState = currentState;
74542             var initializerFunction = shouldConvertInitializerOfForStatement(node) ? createFunctionForInitializerOfForStatement(node, currentState) : undefined;
74543             var bodyFunction = shouldConvertBodyOfIterationStatement(node) ? createFunctionForBodyOfIterationStatement(node, currentState, outerConvertedLoopState) : undefined;
74544             convertedLoopState = outerConvertedLoopState;
74545             if (initializerFunction)
74546                 statements.push(initializerFunction.functionDeclaration);
74547             if (bodyFunction)
74548                 statements.push(bodyFunction.functionDeclaration);
74549             addExtraDeclarationsForConvertedLoop(statements, currentState, outerConvertedLoopState);
74550             if (initializerFunction) {
74551                 statements.push(generateCallToConvertedLoopInitializer(initializerFunction.functionName, initializerFunction.containsYield));
74552             }
74553             var loop;
74554             if (bodyFunction) {
74555                 if (convert) {
74556                     loop = convert(node, outermostLabeledStatement, bodyFunction.part, ancestorFacts);
74557                 }
74558                 else {
74559                     var clone_3 = convertIterationStatementCore(node, initializerFunction, factory.createBlock(bodyFunction.part, true));
74560                     loop = factory.restoreEnclosingLabel(clone_3, outermostLabeledStatement, convertedLoopState && resetLabel);
74561                 }
74562             }
74563             else {
74564                 var clone_4 = convertIterationStatementCore(node, initializerFunction, ts.visitNode(node.statement, visitor, ts.isStatement, factory.liftToBlock));
74565                 loop = factory.restoreEnclosingLabel(clone_4, outermostLabeledStatement, convertedLoopState && resetLabel);
74566             }
74567             statements.push(loop);
74568             return statements;
74569         }
74570         function convertIterationStatementCore(node, initializerFunction, convertedLoopBody) {
74571             switch (node.kind) {
74572                 case 237: return convertForStatement(node, initializerFunction, convertedLoopBody);
74573                 case 238: return convertForInStatement(node, convertedLoopBody);
74574                 case 239: return convertForOfStatement(node, convertedLoopBody);
74575                 case 235: return convertDoStatement(node, convertedLoopBody);
74576                 case 236: return convertWhileStatement(node, convertedLoopBody);
74577                 default: return ts.Debug.failBadSyntaxKind(node, "IterationStatement expected");
74578             }
74579         }
74580         function convertForStatement(node, initializerFunction, convertedLoopBody) {
74581             var shouldConvertCondition = node.condition && shouldConvertPartOfIterationStatement(node.condition);
74582             var shouldConvertIncrementor = shouldConvertCondition || node.incrementor && shouldConvertPartOfIterationStatement(node.incrementor);
74583             return factory.updateForStatement(node, ts.visitNode(initializerFunction ? initializerFunction.part : node.initializer, visitorWithUnusedExpressionResult, ts.isForInitializer), ts.visitNode(shouldConvertCondition ? undefined : node.condition, visitor, ts.isExpression), ts.visitNode(shouldConvertIncrementor ? undefined : node.incrementor, visitorWithUnusedExpressionResult, ts.isExpression), convertedLoopBody);
74584         }
74585         function convertForOfStatement(node, convertedLoopBody) {
74586             return factory.updateForOfStatement(node, undefined, ts.visitNode(node.initializer, visitor, ts.isForInitializer), ts.visitNode(node.expression, visitor, ts.isExpression), convertedLoopBody);
74587         }
74588         function convertForInStatement(node, convertedLoopBody) {
74589             return factory.updateForInStatement(node, ts.visitNode(node.initializer, visitor, ts.isForInitializer), ts.visitNode(node.expression, visitor, ts.isExpression), convertedLoopBody);
74590         }
74591         function convertDoStatement(node, convertedLoopBody) {
74592             return factory.updateDoStatement(node, convertedLoopBody, ts.visitNode(node.expression, visitor, ts.isExpression));
74593         }
74594         function convertWhileStatement(node, convertedLoopBody) {
74595             return factory.updateWhileStatement(node, ts.visitNode(node.expression, visitor, ts.isExpression), convertedLoopBody);
74596         }
74597         function createConvertedLoopState(node) {
74598             var loopInitializer;
74599             switch (node.kind) {
74600                 case 237:
74601                 case 238:
74602                 case 239:
74603                     var initializer = node.initializer;
74604                     if (initializer && initializer.kind === 250) {
74605                         loopInitializer = initializer;
74606                     }
74607                     break;
74608             }
74609             var loopParameters = [];
74610             var loopOutParameters = [];
74611             if (loopInitializer && (ts.getCombinedNodeFlags(loopInitializer) & 3)) {
74612                 var hasCapturedBindingsInForInitializer = shouldConvertInitializerOfForStatement(node);
74613                 for (var _i = 0, _a = loopInitializer.declarations; _i < _a.length; _i++) {
74614                     var decl = _a[_i];
74615                     processLoopVariableDeclaration(node, decl, loopParameters, loopOutParameters, hasCapturedBindingsInForInitializer);
74616                 }
74617             }
74618             var currentState = { loopParameters: loopParameters, loopOutParameters: loopOutParameters };
74619             if (convertedLoopState) {
74620                 if (convertedLoopState.argumentsName) {
74621                     currentState.argumentsName = convertedLoopState.argumentsName;
74622                 }
74623                 if (convertedLoopState.thisName) {
74624                     currentState.thisName = convertedLoopState.thisName;
74625                 }
74626                 if (convertedLoopState.hoistedLocalVariables) {
74627                     currentState.hoistedLocalVariables = convertedLoopState.hoistedLocalVariables;
74628                 }
74629             }
74630             return currentState;
74631         }
74632         function addExtraDeclarationsForConvertedLoop(statements, state, outerState) {
74633             var extraVariableDeclarations;
74634             if (state.argumentsName) {
74635                 if (outerState) {
74636                     outerState.argumentsName = state.argumentsName;
74637                 }
74638                 else {
74639                     (extraVariableDeclarations || (extraVariableDeclarations = [])).push(factory.createVariableDeclaration(state.argumentsName, undefined, undefined, factory.createIdentifier("arguments")));
74640                 }
74641             }
74642             if (state.thisName) {
74643                 if (outerState) {
74644                     outerState.thisName = state.thisName;
74645                 }
74646                 else {
74647                     (extraVariableDeclarations || (extraVariableDeclarations = [])).push(factory.createVariableDeclaration(state.thisName, undefined, undefined, factory.createIdentifier("this")));
74648                 }
74649             }
74650             if (state.hoistedLocalVariables) {
74651                 if (outerState) {
74652                     outerState.hoistedLocalVariables = state.hoistedLocalVariables;
74653                 }
74654                 else {
74655                     if (!extraVariableDeclarations) {
74656                         extraVariableDeclarations = [];
74657                     }
74658                     for (var _i = 0, _a = state.hoistedLocalVariables; _i < _a.length; _i++) {
74659                         var identifier = _a[_i];
74660                         extraVariableDeclarations.push(factory.createVariableDeclaration(identifier));
74661                     }
74662                 }
74663             }
74664             if (state.loopOutParameters.length) {
74665                 if (!extraVariableDeclarations) {
74666                     extraVariableDeclarations = [];
74667                 }
74668                 for (var _b = 0, _c = state.loopOutParameters; _b < _c.length; _b++) {
74669                     var outParam = _c[_b];
74670                     extraVariableDeclarations.push(factory.createVariableDeclaration(outParam.outParamName));
74671                 }
74672             }
74673             if (state.conditionVariable) {
74674                 if (!extraVariableDeclarations) {
74675                     extraVariableDeclarations = [];
74676                 }
74677                 extraVariableDeclarations.push(factory.createVariableDeclaration(state.conditionVariable, undefined, undefined, factory.createFalse()));
74678             }
74679             if (extraVariableDeclarations) {
74680                 statements.push(factory.createVariableStatement(undefined, factory.createVariableDeclarationList(extraVariableDeclarations)));
74681             }
74682         }
74683         function createOutVariable(p) {
74684             return factory.createVariableDeclaration(p.originalName, undefined, undefined, p.outParamName);
74685         }
74686         function createFunctionForInitializerOfForStatement(node, currentState) {
74687             var functionName = factory.createUniqueName("_loop_init");
74688             var containsYield = (node.initializer.transformFlags & 262144) !== 0;
74689             var emitFlags = 0;
74690             if (currentState.containsLexicalThis)
74691                 emitFlags |= 8;
74692             if (containsYield && hierarchyFacts & 4)
74693                 emitFlags |= 262144;
74694             var statements = [];
74695             statements.push(factory.createVariableStatement(undefined, node.initializer));
74696             copyOutParameters(currentState.loopOutParameters, 2, 1, statements);
74697             var functionDeclaration = factory.createVariableStatement(undefined, ts.setEmitFlags(factory.createVariableDeclarationList([
74698                 factory.createVariableDeclaration(functionName, undefined, undefined, ts.setEmitFlags(factory.createFunctionExpression(undefined, containsYield ? factory.createToken(41) : undefined, undefined, undefined, undefined, undefined, ts.visitNode(factory.createBlock(statements, true), visitor, ts.isBlock)), emitFlags))
74699             ]), 2097152));
74700             var part = factory.createVariableDeclarationList(ts.map(currentState.loopOutParameters, createOutVariable));
74701             return { functionName: functionName, containsYield: containsYield, functionDeclaration: functionDeclaration, part: part };
74702         }
74703         function createFunctionForBodyOfIterationStatement(node, currentState, outerState) {
74704             var functionName = factory.createUniqueName("_loop");
74705             startLexicalEnvironment();
74706             var statement = ts.visitNode(node.statement, visitor, ts.isStatement, factory.liftToBlock);
74707             var lexicalEnvironment = endLexicalEnvironment();
74708             var statements = [];
74709             if (shouldConvertConditionOfForStatement(node) || shouldConvertIncrementorOfForStatement(node)) {
74710                 currentState.conditionVariable = factory.createUniqueName("inc");
74711                 if (node.incrementor) {
74712                     statements.push(factory.createIfStatement(currentState.conditionVariable, factory.createExpressionStatement(ts.visitNode(node.incrementor, visitor, ts.isExpression)), factory.createExpressionStatement(factory.createAssignment(currentState.conditionVariable, factory.createTrue()))));
74713                 }
74714                 else {
74715                     statements.push(factory.createIfStatement(factory.createLogicalNot(currentState.conditionVariable), factory.createExpressionStatement(factory.createAssignment(currentState.conditionVariable, factory.createTrue()))));
74716                 }
74717                 if (shouldConvertConditionOfForStatement(node)) {
74718                     statements.push(factory.createIfStatement(factory.createPrefixUnaryExpression(53, ts.visitNode(node.condition, visitor, ts.isExpression)), ts.visitNode(factory.createBreakStatement(), visitor, ts.isStatement)));
74719                 }
74720             }
74721             if (ts.isBlock(statement)) {
74722                 ts.addRange(statements, statement.statements);
74723             }
74724             else {
74725                 statements.push(statement);
74726             }
74727             copyOutParameters(currentState.loopOutParameters, 1, 1, statements);
74728             ts.insertStatementsAfterStandardPrologue(statements, lexicalEnvironment);
74729             var loopBody = factory.createBlock(statements, true);
74730             if (ts.isBlock(statement))
74731                 ts.setOriginalNode(loopBody, statement);
74732             var containsYield = (node.statement.transformFlags & 262144) !== 0;
74733             var emitFlags = 0;
74734             if (currentState.containsLexicalThis)
74735                 emitFlags |= 8;
74736             if (containsYield && (hierarchyFacts & 4) !== 0)
74737                 emitFlags |= 262144;
74738             var functionDeclaration = factory.createVariableStatement(undefined, ts.setEmitFlags(factory.createVariableDeclarationList([
74739                 factory.createVariableDeclaration(functionName, undefined, undefined, ts.setEmitFlags(factory.createFunctionExpression(undefined, containsYield ? factory.createToken(41) : undefined, undefined, undefined, currentState.loopParameters, undefined, loopBody), emitFlags))
74740             ]), 2097152));
74741             var part = generateCallToConvertedLoop(functionName, currentState, outerState, containsYield);
74742             return { functionName: functionName, containsYield: containsYield, functionDeclaration: functionDeclaration, part: part };
74743         }
74744         function copyOutParameter(outParam, copyDirection) {
74745             var source = copyDirection === 0 ? outParam.outParamName : outParam.originalName;
74746             var target = copyDirection === 0 ? outParam.originalName : outParam.outParamName;
74747             return factory.createBinaryExpression(target, 62, source);
74748         }
74749         function copyOutParameters(outParams, partFlags, copyDirection, statements) {
74750             for (var _i = 0, outParams_1 = outParams; _i < outParams_1.length; _i++) {
74751                 var outParam = outParams_1[_i];
74752                 if (outParam.flags & partFlags) {
74753                     statements.push(factory.createExpressionStatement(copyOutParameter(outParam, copyDirection)));
74754                 }
74755             }
74756         }
74757         function generateCallToConvertedLoopInitializer(initFunctionExpressionName, containsYield) {
74758             var call = factory.createCallExpression(initFunctionExpressionName, undefined, []);
74759             var callResult = containsYield
74760                 ? factory.createYieldExpression(factory.createToken(41), ts.setEmitFlags(call, 8388608))
74761                 : call;
74762             return factory.createExpressionStatement(callResult);
74763         }
74764         function generateCallToConvertedLoop(loopFunctionExpressionName, state, outerState, containsYield) {
74765             var statements = [];
74766             var isSimpleLoop = !(state.nonLocalJumps & ~4) &&
74767                 !state.labeledNonLocalBreaks &&
74768                 !state.labeledNonLocalContinues;
74769             var call = factory.createCallExpression(loopFunctionExpressionName, undefined, ts.map(state.loopParameters, function (p) { return p.name; }));
74770             var callResult = containsYield
74771                 ? factory.createYieldExpression(factory.createToken(41), ts.setEmitFlags(call, 8388608))
74772                 : call;
74773             if (isSimpleLoop) {
74774                 statements.push(factory.createExpressionStatement(callResult));
74775                 copyOutParameters(state.loopOutParameters, 1, 0, statements);
74776             }
74777             else {
74778                 var loopResultName = factory.createUniqueName("state");
74779                 var stateVariable = factory.createVariableStatement(undefined, factory.createVariableDeclarationList([factory.createVariableDeclaration(loopResultName, undefined, undefined, callResult)]));
74780                 statements.push(stateVariable);
74781                 copyOutParameters(state.loopOutParameters, 1, 0, statements);
74782                 if (state.nonLocalJumps & 8) {
74783                     var returnStatement = void 0;
74784                     if (outerState) {
74785                         outerState.nonLocalJumps |= 8;
74786                         returnStatement = factory.createReturnStatement(loopResultName);
74787                     }
74788                     else {
74789                         returnStatement = factory.createReturnStatement(factory.createPropertyAccessExpression(loopResultName, "value"));
74790                     }
74791                     statements.push(factory.createIfStatement(factory.createTypeCheck(loopResultName, "object"), returnStatement));
74792                 }
74793                 if (state.nonLocalJumps & 2) {
74794                     statements.push(factory.createIfStatement(factory.createStrictEquality(loopResultName, factory.createStringLiteral("break")), factory.createBreakStatement()));
74795                 }
74796                 if (state.labeledNonLocalBreaks || state.labeledNonLocalContinues) {
74797                     var caseClauses = [];
74798                     processLabeledJumps(state.labeledNonLocalBreaks, true, loopResultName, outerState, caseClauses);
74799                     processLabeledJumps(state.labeledNonLocalContinues, false, loopResultName, outerState, caseClauses);
74800                     statements.push(factory.createSwitchStatement(loopResultName, factory.createCaseBlock(caseClauses)));
74801                 }
74802             }
74803             return statements;
74804         }
74805         function setLabeledJump(state, isBreak, labelText, labelMarker) {
74806             if (isBreak) {
74807                 if (!state.labeledNonLocalBreaks) {
74808                     state.labeledNonLocalBreaks = new ts.Map();
74809                 }
74810                 state.labeledNonLocalBreaks.set(labelText, labelMarker);
74811             }
74812             else {
74813                 if (!state.labeledNonLocalContinues) {
74814                     state.labeledNonLocalContinues = new ts.Map();
74815                 }
74816                 state.labeledNonLocalContinues.set(labelText, labelMarker);
74817             }
74818         }
74819         function processLabeledJumps(table, isBreak, loopResultName, outerLoop, caseClauses) {
74820             if (!table) {
74821                 return;
74822             }
74823             table.forEach(function (labelMarker, labelText) {
74824                 var statements = [];
74825                 if (!outerLoop || (outerLoop.labels && outerLoop.labels.get(labelText))) {
74826                     var label = factory.createIdentifier(labelText);
74827                     statements.push(isBreak ? factory.createBreakStatement(label) : factory.createContinueStatement(label));
74828                 }
74829                 else {
74830                     setLabeledJump(outerLoop, isBreak, labelText, labelMarker);
74831                     statements.push(factory.createReturnStatement(loopResultName));
74832                 }
74833                 caseClauses.push(factory.createCaseClause(factory.createStringLiteral(labelMarker), statements));
74834             });
74835         }
74836         function processLoopVariableDeclaration(container, decl, loopParameters, loopOutParameters, hasCapturedBindingsInForInitializer) {
74837             var name = decl.name;
74838             if (ts.isBindingPattern(name)) {
74839                 for (var _i = 0, _a = name.elements; _i < _a.length; _i++) {
74840                     var element = _a[_i];
74841                     if (!ts.isOmittedExpression(element)) {
74842                         processLoopVariableDeclaration(container, element, loopParameters, loopOutParameters, hasCapturedBindingsInForInitializer);
74843                     }
74844                 }
74845             }
74846             else {
74847                 loopParameters.push(factory.createParameterDeclaration(undefined, undefined, undefined, name));
74848                 var checkFlags = resolver.getNodeCheckFlags(decl);
74849                 if (checkFlags & 4194304 || hasCapturedBindingsInForInitializer) {
74850                     var outParamName = factory.createUniqueName("out_" + ts.idText(name));
74851                     var flags = 0;
74852                     if (checkFlags & 4194304) {
74853                         flags |= 1;
74854                     }
74855                     if (ts.isForStatement(container) && container.initializer && resolver.isBindingCapturedByNode(container.initializer, decl)) {
74856                         flags |= 2;
74857                     }
74858                     loopOutParameters.push({ flags: flags, originalName: name, outParamName: outParamName });
74859                 }
74860             }
74861         }
74862         function addObjectLiteralMembers(expressions, node, receiver, start) {
74863             var properties = node.properties;
74864             var numProperties = properties.length;
74865             for (var i = start; i < numProperties; i++) {
74866                 var property = properties[i];
74867                 switch (property.kind) {
74868                     case 167:
74869                     case 168:
74870                         var accessors = ts.getAllAccessorDeclarations(node.properties, property);
74871                         if (property === accessors.firstAccessor) {
74872                             expressions.push(transformAccessorsToExpression(receiver, accessors, node, !!node.multiLine));
74873                         }
74874                         break;
74875                     case 165:
74876                         expressions.push(transformObjectLiteralMethodDeclarationToExpression(property, receiver, node, node.multiLine));
74877                         break;
74878                     case 288:
74879                         expressions.push(transformPropertyAssignmentToExpression(property, receiver, node.multiLine));
74880                         break;
74881                     case 289:
74882                         expressions.push(transformShorthandPropertyAssignmentToExpression(property, receiver, node.multiLine));
74883                         break;
74884                     default:
74885                         ts.Debug.failBadSyntaxKind(node);
74886                         break;
74887                 }
74888             }
74889         }
74890         function transformPropertyAssignmentToExpression(property, receiver, startsOnNewLine) {
74891             var expression = factory.createAssignment(ts.createMemberAccessForPropertyName(factory, receiver, ts.visitNode(property.name, visitor, ts.isPropertyName)), ts.visitNode(property.initializer, visitor, ts.isExpression));
74892             ts.setTextRange(expression, property);
74893             if (startsOnNewLine) {
74894                 ts.startOnNewLine(expression);
74895             }
74896             return expression;
74897         }
74898         function transformShorthandPropertyAssignmentToExpression(property, receiver, startsOnNewLine) {
74899             var expression = factory.createAssignment(ts.createMemberAccessForPropertyName(factory, receiver, ts.visitNode(property.name, visitor, ts.isPropertyName)), factory.cloneNode(property.name));
74900             ts.setTextRange(expression, property);
74901             if (startsOnNewLine) {
74902                 ts.startOnNewLine(expression);
74903             }
74904             return expression;
74905         }
74906         function transformObjectLiteralMethodDeclarationToExpression(method, receiver, container, startsOnNewLine) {
74907             var expression = factory.createAssignment(ts.createMemberAccessForPropertyName(factory, receiver, ts.visitNode(method.name, visitor, ts.isPropertyName)), transformFunctionLikeToExpression(method, method, undefined, container));
74908             ts.setTextRange(expression, method);
74909             if (startsOnNewLine) {
74910                 ts.startOnNewLine(expression);
74911             }
74912             return expression;
74913         }
74914         function visitCatchClause(node) {
74915             var ancestorFacts = enterSubtree(7104, 0);
74916             var updated;
74917             ts.Debug.assert(!!node.variableDeclaration, "Catch clause variable should always be present when downleveling ES2015.");
74918             if (ts.isBindingPattern(node.variableDeclaration.name)) {
74919                 var temp = factory.createTempVariable(undefined);
74920                 var newVariableDeclaration = factory.createVariableDeclaration(temp);
74921                 ts.setTextRange(newVariableDeclaration, node.variableDeclaration);
74922                 var vars = ts.flattenDestructuringBinding(node.variableDeclaration, visitor, context, 0, temp);
74923                 var list = factory.createVariableDeclarationList(vars);
74924                 ts.setTextRange(list, node.variableDeclaration);
74925                 var destructure = factory.createVariableStatement(undefined, list);
74926                 updated = factory.updateCatchClause(node, newVariableDeclaration, addStatementToStartOfBlock(node.block, destructure));
74927             }
74928             else {
74929                 updated = ts.visitEachChild(node, visitor, context);
74930             }
74931             exitSubtree(ancestorFacts, 0, 0);
74932             return updated;
74933         }
74934         function addStatementToStartOfBlock(block, statement) {
74935             var transformedStatements = ts.visitNodes(block.statements, visitor, ts.isStatement);
74936             return factory.updateBlock(block, __spreadArrays([statement], transformedStatements));
74937         }
74938         function visitMethodDeclaration(node) {
74939             ts.Debug.assert(!ts.isComputedPropertyName(node.name));
74940             var functionExpression = transformFunctionLikeToExpression(node, ts.moveRangePos(node, -1), undefined, undefined);
74941             ts.setEmitFlags(functionExpression, 512 | ts.getEmitFlags(functionExpression));
74942             return ts.setTextRange(factory.createPropertyAssignment(node.name, functionExpression), node);
74943         }
74944         function visitAccessorDeclaration(node) {
74945             ts.Debug.assert(!ts.isComputedPropertyName(node.name));
74946             var savedConvertedLoopState = convertedLoopState;
74947             convertedLoopState = undefined;
74948             var ancestorFacts = enterSubtree(16286, 65);
74949             var updated;
74950             var parameters = ts.visitParameterList(node.parameters, visitor, context);
74951             var body = transformFunctionBody(node);
74952             if (node.kind === 167) {
74953                 updated = factory.updateGetAccessorDeclaration(node, node.decorators, node.modifiers, node.name, parameters, node.type, body);
74954             }
74955             else {
74956                 updated = factory.updateSetAccessorDeclaration(node, node.decorators, node.modifiers, node.name, parameters, body);
74957             }
74958             exitSubtree(ancestorFacts, 49152, 0);
74959             convertedLoopState = savedConvertedLoopState;
74960             return updated;
74961         }
74962         function visitShorthandPropertyAssignment(node) {
74963             return ts.setTextRange(factory.createPropertyAssignment(node.name, visitIdentifier(factory.cloneNode(node.name))), node);
74964         }
74965         function visitComputedPropertyName(node) {
74966             return ts.visitEachChild(node, visitor, context);
74967         }
74968         function visitYieldExpression(node) {
74969             return ts.visitEachChild(node, visitor, context);
74970         }
74971         function visitArrayLiteralExpression(node) {
74972             if (ts.some(node.elements, ts.isSpreadElement)) {
74973                 return transformAndSpreadElements(node.elements, true, !!node.multiLine, !!node.elements.hasTrailingComma);
74974             }
74975             return ts.visitEachChild(node, visitor, context);
74976         }
74977         function visitCallExpression(node) {
74978             if (ts.getEmitFlags(node) & 33554432) {
74979                 return visitTypeScriptClassWrapper(node);
74980             }
74981             var expression = ts.skipOuterExpressions(node.expression);
74982             if (expression.kind === 105 ||
74983                 ts.isSuperProperty(expression) ||
74984                 ts.some(node.arguments, ts.isSpreadElement)) {
74985                 return visitCallExpressionWithPotentialCapturedThisAssignment(node, true);
74986             }
74987             return factory.updateCallExpression(node, ts.visitNode(node.expression, callExpressionVisitor, ts.isExpression), undefined, ts.visitNodes(node.arguments, visitor, ts.isExpression));
74988         }
74989         function visitTypeScriptClassWrapper(node) {
74990             var body = ts.cast(ts.cast(ts.skipOuterExpressions(node.expression), ts.isArrowFunction).body, ts.isBlock);
74991             var isVariableStatementWithInitializer = function (stmt) { return ts.isVariableStatement(stmt) && !!ts.first(stmt.declarationList.declarations).initializer; };
74992             var savedConvertedLoopState = convertedLoopState;
74993             convertedLoopState = undefined;
74994             var bodyStatements = ts.visitNodes(body.statements, visitor, ts.isStatement);
74995             convertedLoopState = savedConvertedLoopState;
74996             var classStatements = ts.filter(bodyStatements, isVariableStatementWithInitializer);
74997             var remainingStatements = ts.filter(bodyStatements, function (stmt) { return !isVariableStatementWithInitializer(stmt); });
74998             var varStatement = ts.cast(ts.first(classStatements), ts.isVariableStatement);
74999             var variable = varStatement.declarationList.declarations[0];
75000             var initializer = ts.skipOuterExpressions(variable.initializer);
75001             var aliasAssignment = ts.tryCast(initializer, ts.isAssignmentExpression);
75002             var call = ts.cast(aliasAssignment ? ts.skipOuterExpressions(aliasAssignment.right) : initializer, ts.isCallExpression);
75003             var func = ts.cast(ts.skipOuterExpressions(call.expression), ts.isFunctionExpression);
75004             var funcStatements = func.body.statements;
75005             var classBodyStart = 0;
75006             var classBodyEnd = -1;
75007             var statements = [];
75008             if (aliasAssignment) {
75009                 var extendsCall = ts.tryCast(funcStatements[classBodyStart], ts.isExpressionStatement);
75010                 if (extendsCall) {
75011                     statements.push(extendsCall);
75012                     classBodyStart++;
75013                 }
75014                 statements.push(funcStatements[classBodyStart]);
75015                 classBodyStart++;
75016                 statements.push(factory.createExpressionStatement(factory.createAssignment(aliasAssignment.left, ts.cast(variable.name, ts.isIdentifier))));
75017             }
75018             while (!ts.isReturnStatement(ts.elementAt(funcStatements, classBodyEnd))) {
75019                 classBodyEnd--;
75020             }
75021             ts.addRange(statements, funcStatements, classBodyStart, classBodyEnd);
75022             if (classBodyEnd < -1) {
75023                 ts.addRange(statements, funcStatements, classBodyEnd + 1);
75024             }
75025             ts.addRange(statements, remainingStatements);
75026             ts.addRange(statements, classStatements, 1);
75027             return factory.restoreOuterExpressions(node.expression, factory.restoreOuterExpressions(variable.initializer, factory.restoreOuterExpressions(aliasAssignment && aliasAssignment.right, factory.updateCallExpression(call, factory.restoreOuterExpressions(call.expression, factory.updateFunctionExpression(func, undefined, undefined, undefined, undefined, func.parameters, undefined, factory.updateBlock(func.body, statements))), undefined, call.arguments))));
75028         }
75029         function visitImmediateSuperCallInBody(node) {
75030             return visitCallExpressionWithPotentialCapturedThisAssignment(node, false);
75031         }
75032         function visitCallExpressionWithPotentialCapturedThisAssignment(node, assignToCapturedThis) {
75033             if (node.transformFlags & 8192 ||
75034                 node.expression.kind === 105 ||
75035                 ts.isSuperProperty(ts.skipOuterExpressions(node.expression))) {
75036                 var _a = factory.createCallBinding(node.expression, hoistVariableDeclaration), target = _a.target, thisArg = _a.thisArg;
75037                 if (node.expression.kind === 105) {
75038                     ts.setEmitFlags(thisArg, 4);
75039                 }
75040                 var resultingCall = void 0;
75041                 if (node.transformFlags & 8192) {
75042                     resultingCall = factory.createFunctionApplyCall(ts.visitNode(target, callExpressionVisitor, ts.isExpression), node.expression.kind === 105 ? thisArg : ts.visitNode(thisArg, visitor, ts.isExpression), transformAndSpreadElements(node.arguments, false, false, false));
75043                 }
75044                 else {
75045                     resultingCall = ts.setTextRange(factory.createFunctionCallCall(ts.visitNode(target, callExpressionVisitor, ts.isExpression), node.expression.kind === 105 ? thisArg : ts.visitNode(thisArg, visitor, ts.isExpression), ts.visitNodes(node.arguments, visitor, ts.isExpression)), node);
75046                 }
75047                 if (node.expression.kind === 105) {
75048                     var initializer = factory.createLogicalOr(resultingCall, createActualThis());
75049                     resultingCall = assignToCapturedThis
75050                         ? factory.createAssignment(factory.createUniqueName("_this", 16 | 32), initializer)
75051                         : initializer;
75052                 }
75053                 return ts.setOriginalNode(resultingCall, node);
75054             }
75055             return ts.visitEachChild(node, visitor, context);
75056         }
75057         function visitNewExpression(node) {
75058             if (ts.some(node.arguments, ts.isSpreadElement)) {
75059                 var _a = factory.createCallBinding(factory.createPropertyAccessExpression(node.expression, "bind"), hoistVariableDeclaration), target = _a.target, thisArg = _a.thisArg;
75060                 return factory.createNewExpression(factory.createFunctionApplyCall(ts.visitNode(target, visitor, ts.isExpression), thisArg, transformAndSpreadElements(factory.createNodeArray(__spreadArrays([factory.createVoidZero()], node.arguments)), false, false, false)), undefined, []);
75061             }
75062             return ts.visitEachChild(node, visitor, context);
75063         }
75064         function transformAndSpreadElements(elements, needsUniqueCopy, multiLine, hasTrailingComma) {
75065             var numElements = elements.length;
75066             var segments = ts.flatten(ts.spanMap(elements, partitionSpread, function (partition, visitPartition, _start, end) {
75067                 return visitPartition(partition, multiLine, hasTrailingComma && end === numElements);
75068             }));
75069             if (compilerOptions.downlevelIteration) {
75070                 if (segments.length === 1) {
75071                     var firstSegment = segments[0];
75072                     if (isCallToHelper(firstSegment, "___spread")) {
75073                         return segments[0];
75074                     }
75075                 }
75076                 return emitHelpers().createSpreadHelper(segments);
75077             }
75078             else {
75079                 if (segments.length === 1) {
75080                     var firstSegment = segments[0];
75081                     if (!needsUniqueCopy
75082                         || isPackedArrayLiteral(firstSegment)
75083                         || isCallToHelper(firstSegment, "___spreadArrays")) {
75084                         return segments[0];
75085                     }
75086                 }
75087                 return emitHelpers().createSpreadArraysHelper(segments);
75088             }
75089         }
75090         function isPackedElement(node) {
75091             return !ts.isOmittedExpression(node);
75092         }
75093         function isPackedArrayLiteral(node) {
75094             return ts.isArrayLiteralExpression(node) && ts.every(node.elements, isPackedElement);
75095         }
75096         function isCallToHelper(firstSegment, helperName) {
75097             return ts.isCallExpression(firstSegment)
75098                 && ts.isIdentifier(firstSegment.expression)
75099                 && (ts.getEmitFlags(firstSegment.expression) & 4096)
75100                 && firstSegment.expression.escapedText === helperName;
75101         }
75102         function partitionSpread(node) {
75103             return ts.isSpreadElement(node)
75104                 ? visitSpanOfSpreads
75105                 : visitSpanOfNonSpreads;
75106         }
75107         function visitSpanOfSpreads(chunk) {
75108             return ts.map(chunk, visitExpressionOfSpread);
75109         }
75110         function visitSpanOfNonSpreads(chunk, multiLine, hasTrailingComma) {
75111             return factory.createArrayLiteralExpression(ts.visitNodes(factory.createNodeArray(chunk, hasTrailingComma), visitor, ts.isExpression), multiLine);
75112         }
75113         function visitSpreadElement(node) {
75114             return ts.visitNode(node.expression, visitor, ts.isExpression);
75115         }
75116         function visitExpressionOfSpread(node) {
75117             return ts.visitNode(node.expression, visitor, ts.isExpression);
75118         }
75119         function visitTemplateLiteral(node) {
75120             return ts.setTextRange(factory.createStringLiteral(node.text), node);
75121         }
75122         function visitStringLiteral(node) {
75123             if (node.hasExtendedUnicodeEscape) {
75124                 return ts.setTextRange(factory.createStringLiteral(node.text), node);
75125             }
75126             return node;
75127         }
75128         function visitNumericLiteral(node) {
75129             if (node.numericLiteralFlags & 384) {
75130                 return ts.setTextRange(factory.createNumericLiteral(node.text), node);
75131             }
75132             return node;
75133         }
75134         function visitTaggedTemplateExpression(node) {
75135             return ts.processTaggedTemplateExpression(context, node, visitor, currentSourceFile, recordTaggedTemplateString, ts.ProcessLevel.All);
75136         }
75137         function visitTemplateExpression(node) {
75138             var expressions = [];
75139             addTemplateHead(expressions, node);
75140             addTemplateSpans(expressions, node);
75141             var expression = ts.reduceLeft(expressions, factory.createAdd);
75142             if (ts.nodeIsSynthesized(expression)) {
75143                 ts.setTextRange(expression, node);
75144             }
75145             return expression;
75146         }
75147         function shouldAddTemplateHead(node) {
75148             ts.Debug.assert(node.templateSpans.length !== 0);
75149             return node.head.text.length !== 0 || node.templateSpans[0].literal.text.length === 0;
75150         }
75151         function addTemplateHead(expressions, node) {
75152             if (!shouldAddTemplateHead(node)) {
75153                 return;
75154             }
75155             expressions.push(factory.createStringLiteral(node.head.text));
75156         }
75157         function addTemplateSpans(expressions, node) {
75158             for (var _i = 0, _a = node.templateSpans; _i < _a.length; _i++) {
75159                 var span = _a[_i];
75160                 expressions.push(ts.visitNode(span.expression, visitor, ts.isExpression));
75161                 if (span.literal.text.length !== 0) {
75162                     expressions.push(factory.createStringLiteral(span.literal.text));
75163                 }
75164             }
75165         }
75166         function visitSuperKeyword(isExpressionOfCall) {
75167             return hierarchyFacts & 8
75168                 && !isExpressionOfCall
75169                 ? factory.createPropertyAccessExpression(factory.createUniqueName("_super", 16 | 32), "prototype")
75170                 : factory.createUniqueName("_super", 16 | 32);
75171         }
75172         function visitMetaProperty(node) {
75173             if (node.keywordToken === 102 && node.name.escapedText === "target") {
75174                 hierarchyFacts |= 16384;
75175                 return factory.createUniqueName("_newTarget", 16 | 32);
75176             }
75177             return node;
75178         }
75179         function onEmitNode(hint, node, emitCallback) {
75180             if (enabledSubstitutions & 1 && ts.isFunctionLike(node)) {
75181                 var ancestorFacts = enterSubtree(16286, ts.getEmitFlags(node) & 8
75182                     ? 65 | 16
75183                     : 65);
75184                 previousOnEmitNode(hint, node, emitCallback);
75185                 exitSubtree(ancestorFacts, 0, 0);
75186                 return;
75187             }
75188             previousOnEmitNode(hint, node, emitCallback);
75189         }
75190         function enableSubstitutionsForBlockScopedBindings() {
75191             if ((enabledSubstitutions & 2) === 0) {
75192                 enabledSubstitutions |= 2;
75193                 context.enableSubstitution(78);
75194             }
75195         }
75196         function enableSubstitutionsForCapturedThis() {
75197             if ((enabledSubstitutions & 1) === 0) {
75198                 enabledSubstitutions |= 1;
75199                 context.enableSubstitution(107);
75200                 context.enableEmitNotification(166);
75201                 context.enableEmitNotification(165);
75202                 context.enableEmitNotification(167);
75203                 context.enableEmitNotification(168);
75204                 context.enableEmitNotification(209);
75205                 context.enableEmitNotification(208);
75206                 context.enableEmitNotification(251);
75207             }
75208         }
75209         function onSubstituteNode(hint, node) {
75210             node = previousOnSubstituteNode(hint, node);
75211             if (hint === 1) {
75212                 return substituteExpression(node);
75213             }
75214             if (ts.isIdentifier(node)) {
75215                 return substituteIdentifier(node);
75216             }
75217             return node;
75218         }
75219         function substituteIdentifier(node) {
75220             if (enabledSubstitutions & 2 && !ts.isInternalName(node)) {
75221                 var original = ts.getParseTreeNode(node, ts.isIdentifier);
75222                 if (original && isNameOfDeclarationWithCollidingName(original)) {
75223                     return ts.setTextRange(factory.getGeneratedNameForNode(original), node);
75224                 }
75225             }
75226             return node;
75227         }
75228         function isNameOfDeclarationWithCollidingName(node) {
75229             switch (node.parent.kind) {
75230                 case 198:
75231                 case 252:
75232                 case 255:
75233                 case 249:
75234                     return node.parent.name === node
75235                         && resolver.isDeclarationWithCollidingName(node.parent);
75236             }
75237             return false;
75238         }
75239         function substituteExpression(node) {
75240             switch (node.kind) {
75241                 case 78:
75242                     return substituteExpressionIdentifier(node);
75243                 case 107:
75244                     return substituteThisKeyword(node);
75245             }
75246             return node;
75247         }
75248         function substituteExpressionIdentifier(node) {
75249             if (enabledSubstitutions & 2 && !ts.isInternalName(node)) {
75250                 var declaration = resolver.getReferencedDeclarationWithCollidingName(node);
75251                 if (declaration && !(ts.isClassLike(declaration) && isPartOfClassBody(declaration, node))) {
75252                     return ts.setTextRange(factory.getGeneratedNameForNode(ts.getNameOfDeclaration(declaration)), node);
75253                 }
75254             }
75255             return node;
75256         }
75257         function isPartOfClassBody(declaration, node) {
75258             var currentNode = ts.getParseTreeNode(node);
75259             if (!currentNode || currentNode === declaration || currentNode.end <= declaration.pos || currentNode.pos >= declaration.end) {
75260                 return false;
75261             }
75262             var blockScope = ts.getEnclosingBlockScopeContainer(declaration);
75263             while (currentNode) {
75264                 if (currentNode === blockScope || currentNode === declaration) {
75265                     return false;
75266                 }
75267                 if (ts.isClassElement(currentNode) && currentNode.parent === declaration) {
75268                     return true;
75269                 }
75270                 currentNode = currentNode.parent;
75271             }
75272             return false;
75273         }
75274         function substituteThisKeyword(node) {
75275             if (enabledSubstitutions & 1
75276                 && hierarchyFacts & 16) {
75277                 return ts.setTextRange(factory.createUniqueName("_this", 16 | 32), node);
75278             }
75279             return node;
75280         }
75281         function getClassMemberPrefix(node, member) {
75282             return ts.hasSyntacticModifier(member, 32)
75283                 ? factory.getInternalName(node)
75284                 : factory.createPropertyAccessExpression(factory.getInternalName(node), "prototype");
75285         }
75286         function hasSynthesizedDefaultSuperCall(constructor, hasExtendsClause) {
75287             if (!constructor || !hasExtendsClause) {
75288                 return false;
75289             }
75290             if (ts.some(constructor.parameters)) {
75291                 return false;
75292             }
75293             var statement = ts.firstOrUndefined(constructor.body.statements);
75294             if (!statement || !ts.nodeIsSynthesized(statement) || statement.kind !== 233) {
75295                 return false;
75296             }
75297             var statementExpression = statement.expression;
75298             if (!ts.nodeIsSynthesized(statementExpression) || statementExpression.kind !== 203) {
75299                 return false;
75300             }
75301             var callTarget = statementExpression.expression;
75302             if (!ts.nodeIsSynthesized(callTarget) || callTarget.kind !== 105) {
75303                 return false;
75304             }
75305             var callArgument = ts.singleOrUndefined(statementExpression.arguments);
75306             if (!callArgument || !ts.nodeIsSynthesized(callArgument) || callArgument.kind !== 220) {
75307                 return false;
75308             }
75309             var expression = callArgument.expression;
75310             return ts.isIdentifier(expression) && expression.escapedText === "arguments";
75311         }
75312     }
75313     ts.transformES2015 = transformES2015;
75314 })(ts || (ts = {}));
75315 var ts;
75316 (function (ts) {
75317     function transformES5(context) {
75318         var factory = context.factory;
75319         var compilerOptions = context.getCompilerOptions();
75320         var previousOnEmitNode;
75321         var noSubstitution;
75322         if (compilerOptions.jsx === 1 || compilerOptions.jsx === 3) {
75323             previousOnEmitNode = context.onEmitNode;
75324             context.onEmitNode = onEmitNode;
75325             context.enableEmitNotification(275);
75326             context.enableEmitNotification(276);
75327             context.enableEmitNotification(274);
75328             noSubstitution = [];
75329         }
75330         var previousOnSubstituteNode = context.onSubstituteNode;
75331         context.onSubstituteNode = onSubstituteNode;
75332         context.enableSubstitution(201);
75333         context.enableSubstitution(288);
75334         return ts.chainBundle(context, transformSourceFile);
75335         function transformSourceFile(node) {
75336             return node;
75337         }
75338         function onEmitNode(hint, node, emitCallback) {
75339             switch (node.kind) {
75340                 case 275:
75341                 case 276:
75342                 case 274:
75343                     var tagName = node.tagName;
75344                     noSubstitution[ts.getOriginalNodeId(tagName)] = true;
75345                     break;
75346             }
75347             previousOnEmitNode(hint, node, emitCallback);
75348         }
75349         function onSubstituteNode(hint, node) {
75350             if (node.id && noSubstitution && noSubstitution[node.id]) {
75351                 return previousOnSubstituteNode(hint, node);
75352             }
75353             node = previousOnSubstituteNode(hint, node);
75354             if (ts.isPropertyAccessExpression(node)) {
75355                 return substitutePropertyAccessExpression(node);
75356             }
75357             else if (ts.isPropertyAssignment(node)) {
75358                 return substitutePropertyAssignment(node);
75359             }
75360             return node;
75361         }
75362         function substitutePropertyAccessExpression(node) {
75363             if (ts.isPrivateIdentifier(node.name)) {
75364                 return node;
75365             }
75366             var literalName = trySubstituteReservedName(node.name);
75367             if (literalName) {
75368                 return ts.setTextRange(factory.createElementAccessExpression(node.expression, literalName), node);
75369             }
75370             return node;
75371         }
75372         function substitutePropertyAssignment(node) {
75373             var literalName = ts.isIdentifier(node.name) && trySubstituteReservedName(node.name);
75374             if (literalName) {
75375                 return factory.updatePropertyAssignment(node, literalName, node.initializer);
75376             }
75377             return node;
75378         }
75379         function trySubstituteReservedName(name) {
75380             var token = name.originalKeywordKind || (ts.nodeIsSynthesized(name) ? ts.stringToToken(ts.idText(name)) : undefined);
75381             if (token !== undefined && token >= 80 && token <= 115) {
75382                 return ts.setTextRange(factory.createStringLiteralFromNode(name), name);
75383             }
75384             return undefined;
75385         }
75386     }
75387     ts.transformES5 = transformES5;
75388 })(ts || (ts = {}));
75389 var ts;
75390 (function (ts) {
75391     function getInstructionName(instruction) {
75392         switch (instruction) {
75393             case 2: return "return";
75394             case 3: return "break";
75395             case 4: return "yield";
75396             case 5: return "yield*";
75397             case 7: return "endfinally";
75398             default: return undefined;
75399         }
75400     }
75401     function transformGenerators(context) {
75402         var factory = context.factory, emitHelpers = context.getEmitHelperFactory, resumeLexicalEnvironment = context.resumeLexicalEnvironment, endLexicalEnvironment = context.endLexicalEnvironment, hoistFunctionDeclaration = context.hoistFunctionDeclaration, hoistVariableDeclaration = context.hoistVariableDeclaration;
75403         var compilerOptions = context.getCompilerOptions();
75404         var languageVersion = ts.getEmitScriptTarget(compilerOptions);
75405         var resolver = context.getEmitResolver();
75406         var previousOnSubstituteNode = context.onSubstituteNode;
75407         context.onSubstituteNode = onSubstituteNode;
75408         var renamedCatchVariables;
75409         var renamedCatchVariableDeclarations;
75410         var inGeneratorFunctionBody;
75411         var inStatementContainingYield;
75412         var blocks;
75413         var blockOffsets;
75414         var blockActions;
75415         var blockStack;
75416         var labelOffsets;
75417         var labelExpressions;
75418         var nextLabelId = 1;
75419         var operations;
75420         var operationArguments;
75421         var operationLocations;
75422         var state;
75423         var blockIndex = 0;
75424         var labelNumber = 0;
75425         var labelNumbers;
75426         var lastOperationWasAbrupt;
75427         var lastOperationWasCompletion;
75428         var clauses;
75429         var statements;
75430         var exceptionBlockStack;
75431         var currentExceptionBlock;
75432         var withBlockStack;
75433         return ts.chainBundle(context, transformSourceFile);
75434         function transformSourceFile(node) {
75435             if (node.isDeclarationFile || (node.transformFlags & 512) === 0) {
75436                 return node;
75437             }
75438             var visited = ts.visitEachChild(node, visitor, context);
75439             ts.addEmitHelpers(visited, context.readEmitHelpers());
75440             return visited;
75441         }
75442         function visitor(node) {
75443             var transformFlags = node.transformFlags;
75444             if (inStatementContainingYield) {
75445                 return visitJavaScriptInStatementContainingYield(node);
75446             }
75447             else if (inGeneratorFunctionBody) {
75448                 return visitJavaScriptInGeneratorFunctionBody(node);
75449             }
75450             else if (ts.isFunctionLikeDeclaration(node) && node.asteriskToken) {
75451                 return visitGenerator(node);
75452             }
75453             else if (transformFlags & 512) {
75454                 return ts.visitEachChild(node, visitor, context);
75455             }
75456             else {
75457                 return node;
75458             }
75459         }
75460         function visitJavaScriptInStatementContainingYield(node) {
75461             switch (node.kind) {
75462                 case 235:
75463                     return visitDoStatement(node);
75464                 case 236:
75465                     return visitWhileStatement(node);
75466                 case 244:
75467                     return visitSwitchStatement(node);
75468                 case 245:
75469                     return visitLabeledStatement(node);
75470                 default:
75471                     return visitJavaScriptInGeneratorFunctionBody(node);
75472             }
75473         }
75474         function visitJavaScriptInGeneratorFunctionBody(node) {
75475             switch (node.kind) {
75476                 case 251:
75477                     return visitFunctionDeclaration(node);
75478                 case 208:
75479                     return visitFunctionExpression(node);
75480                 case 167:
75481                 case 168:
75482                     return visitAccessorDeclaration(node);
75483                 case 232:
75484                     return visitVariableStatement(node);
75485                 case 237:
75486                     return visitForStatement(node);
75487                 case 238:
75488                     return visitForInStatement(node);
75489                 case 241:
75490                     return visitBreakStatement(node);
75491                 case 240:
75492                     return visitContinueStatement(node);
75493                 case 242:
75494                     return visitReturnStatement(node);
75495                 default:
75496                     if (node.transformFlags & 262144) {
75497                         return visitJavaScriptContainingYield(node);
75498                     }
75499                     else if (node.transformFlags & (512 | 1048576)) {
75500                         return ts.visitEachChild(node, visitor, context);
75501                     }
75502                     else {
75503                         return node;
75504                     }
75505             }
75506         }
75507         function visitJavaScriptContainingYield(node) {
75508             switch (node.kind) {
75509                 case 216:
75510                     return visitBinaryExpression(node);
75511                 case 337:
75512                     return visitCommaListExpression(node);
75513                 case 217:
75514                     return visitConditionalExpression(node);
75515                 case 219:
75516                     return visitYieldExpression(node);
75517                 case 199:
75518                     return visitArrayLiteralExpression(node);
75519                 case 200:
75520                     return visitObjectLiteralExpression(node);
75521                 case 202:
75522                     return visitElementAccessExpression(node);
75523                 case 203:
75524                     return visitCallExpression(node);
75525                 case 204:
75526                     return visitNewExpression(node);
75527                 default:
75528                     return ts.visitEachChild(node, visitor, context);
75529             }
75530         }
75531         function visitGenerator(node) {
75532             switch (node.kind) {
75533                 case 251:
75534                     return visitFunctionDeclaration(node);
75535                 case 208:
75536                     return visitFunctionExpression(node);
75537                 default:
75538                     return ts.Debug.failBadSyntaxKind(node);
75539             }
75540         }
75541         function visitFunctionDeclaration(node) {
75542             if (node.asteriskToken) {
75543                 node = ts.setOriginalNode(ts.setTextRange(factory.createFunctionDeclaration(undefined, node.modifiers, undefined, node.name, undefined, ts.visitParameterList(node.parameters, visitor, context), undefined, transformGeneratorFunctionBody(node.body)), node), node);
75544             }
75545             else {
75546                 var savedInGeneratorFunctionBody = inGeneratorFunctionBody;
75547                 var savedInStatementContainingYield = inStatementContainingYield;
75548                 inGeneratorFunctionBody = false;
75549                 inStatementContainingYield = false;
75550                 node = ts.visitEachChild(node, visitor, context);
75551                 inGeneratorFunctionBody = savedInGeneratorFunctionBody;
75552                 inStatementContainingYield = savedInStatementContainingYield;
75553             }
75554             if (inGeneratorFunctionBody) {
75555                 hoistFunctionDeclaration(node);
75556                 return undefined;
75557             }
75558             else {
75559                 return node;
75560             }
75561         }
75562         function visitFunctionExpression(node) {
75563             if (node.asteriskToken) {
75564                 node = ts.setOriginalNode(ts.setTextRange(factory.createFunctionExpression(undefined, undefined, node.name, undefined, ts.visitParameterList(node.parameters, visitor, context), undefined, transformGeneratorFunctionBody(node.body)), node), node);
75565             }
75566             else {
75567                 var savedInGeneratorFunctionBody = inGeneratorFunctionBody;
75568                 var savedInStatementContainingYield = inStatementContainingYield;
75569                 inGeneratorFunctionBody = false;
75570                 inStatementContainingYield = false;
75571                 node = ts.visitEachChild(node, visitor, context);
75572                 inGeneratorFunctionBody = savedInGeneratorFunctionBody;
75573                 inStatementContainingYield = savedInStatementContainingYield;
75574             }
75575             return node;
75576         }
75577         function visitAccessorDeclaration(node) {
75578             var savedInGeneratorFunctionBody = inGeneratorFunctionBody;
75579             var savedInStatementContainingYield = inStatementContainingYield;
75580             inGeneratorFunctionBody = false;
75581             inStatementContainingYield = false;
75582             node = ts.visitEachChild(node, visitor, context);
75583             inGeneratorFunctionBody = savedInGeneratorFunctionBody;
75584             inStatementContainingYield = savedInStatementContainingYield;
75585             return node;
75586         }
75587         function transformGeneratorFunctionBody(body) {
75588             var statements = [];
75589             var savedInGeneratorFunctionBody = inGeneratorFunctionBody;
75590             var savedInStatementContainingYield = inStatementContainingYield;
75591             var savedBlocks = blocks;
75592             var savedBlockOffsets = blockOffsets;
75593             var savedBlockActions = blockActions;
75594             var savedBlockStack = blockStack;
75595             var savedLabelOffsets = labelOffsets;
75596             var savedLabelExpressions = labelExpressions;
75597             var savedNextLabelId = nextLabelId;
75598             var savedOperations = operations;
75599             var savedOperationArguments = operationArguments;
75600             var savedOperationLocations = operationLocations;
75601             var savedState = state;
75602             inGeneratorFunctionBody = true;
75603             inStatementContainingYield = false;
75604             blocks = undefined;
75605             blockOffsets = undefined;
75606             blockActions = undefined;
75607             blockStack = undefined;
75608             labelOffsets = undefined;
75609             labelExpressions = undefined;
75610             nextLabelId = 1;
75611             operations = undefined;
75612             operationArguments = undefined;
75613             operationLocations = undefined;
75614             state = factory.createTempVariable(undefined);
75615             resumeLexicalEnvironment();
75616             var statementOffset = factory.copyPrologue(body.statements, statements, false, visitor);
75617             transformAndEmitStatements(body.statements, statementOffset);
75618             var buildResult = build();
75619             ts.insertStatementsAfterStandardPrologue(statements, endLexicalEnvironment());
75620             statements.push(factory.createReturnStatement(buildResult));
75621             inGeneratorFunctionBody = savedInGeneratorFunctionBody;
75622             inStatementContainingYield = savedInStatementContainingYield;
75623             blocks = savedBlocks;
75624             blockOffsets = savedBlockOffsets;
75625             blockActions = savedBlockActions;
75626             blockStack = savedBlockStack;
75627             labelOffsets = savedLabelOffsets;
75628             labelExpressions = savedLabelExpressions;
75629             nextLabelId = savedNextLabelId;
75630             operations = savedOperations;
75631             operationArguments = savedOperationArguments;
75632             operationLocations = savedOperationLocations;
75633             state = savedState;
75634             return ts.setTextRange(factory.createBlock(statements, body.multiLine), body);
75635         }
75636         function visitVariableStatement(node) {
75637             if (node.transformFlags & 262144) {
75638                 transformAndEmitVariableDeclarationList(node.declarationList);
75639                 return undefined;
75640             }
75641             else {
75642                 if (ts.getEmitFlags(node) & 1048576) {
75643                     return node;
75644                 }
75645                 for (var _i = 0, _a = node.declarationList.declarations; _i < _a.length; _i++) {
75646                     var variable = _a[_i];
75647                     hoistVariableDeclaration(variable.name);
75648                 }
75649                 var variables = ts.getInitializedVariables(node.declarationList);
75650                 if (variables.length === 0) {
75651                     return undefined;
75652                 }
75653                 return ts.setSourceMapRange(factory.createExpressionStatement(factory.inlineExpressions(ts.map(variables, transformInitializedVariable))), node);
75654             }
75655         }
75656         function visitBinaryExpression(node) {
75657             var assoc = ts.getExpressionAssociativity(node);
75658             switch (assoc) {
75659                 case 0:
75660                     return visitLeftAssociativeBinaryExpression(node);
75661                 case 1:
75662                     return visitRightAssociativeBinaryExpression(node);
75663                 default:
75664                     return ts.Debug.assertNever(assoc);
75665             }
75666         }
75667         function visitRightAssociativeBinaryExpression(node) {
75668             var left = node.left, right = node.right;
75669             if (containsYield(right)) {
75670                 var target = void 0;
75671                 switch (left.kind) {
75672                     case 201:
75673                         target = factory.updatePropertyAccessExpression(left, cacheExpression(ts.visitNode(left.expression, visitor, ts.isLeftHandSideExpression)), left.name);
75674                         break;
75675                     case 202:
75676                         target = factory.updateElementAccessExpression(left, cacheExpression(ts.visitNode(left.expression, visitor, ts.isLeftHandSideExpression)), cacheExpression(ts.visitNode(left.argumentExpression, visitor, ts.isExpression)));
75677                         break;
75678                     default:
75679                         target = ts.visitNode(left, visitor, ts.isExpression);
75680                         break;
75681                 }
75682                 var operator = node.operatorToken.kind;
75683                 if (ts.isCompoundAssignment(operator)) {
75684                     return ts.setTextRange(factory.createAssignment(target, ts.setTextRange(factory.createBinaryExpression(cacheExpression(target), ts.getNonAssignmentOperatorForCompoundAssignment(operator), ts.visitNode(right, visitor, ts.isExpression)), node)), node);
75685                 }
75686                 else {
75687                     return factory.updateBinaryExpression(node, target, node.operatorToken, ts.visitNode(right, visitor, ts.isExpression));
75688                 }
75689             }
75690             return ts.visitEachChild(node, visitor, context);
75691         }
75692         function visitLeftAssociativeBinaryExpression(node) {
75693             if (containsYield(node.right)) {
75694                 if (ts.isLogicalOperator(node.operatorToken.kind)) {
75695                     return visitLogicalBinaryExpression(node);
75696                 }
75697                 else if (node.operatorToken.kind === 27) {
75698                     return visitCommaExpression(node);
75699                 }
75700                 return factory.updateBinaryExpression(node, cacheExpression(ts.visitNode(node.left, visitor, ts.isExpression)), node.operatorToken, ts.visitNode(node.right, visitor, ts.isExpression));
75701             }
75702             return ts.visitEachChild(node, visitor, context);
75703         }
75704         function visitCommaExpression(node) {
75705             var pendingExpressions = [];
75706             visit(node.left);
75707             visit(node.right);
75708             return factory.inlineExpressions(pendingExpressions);
75709             function visit(node) {
75710                 if (ts.isBinaryExpression(node) && node.operatorToken.kind === 27) {
75711                     visit(node.left);
75712                     visit(node.right);
75713                 }
75714                 else {
75715                     if (containsYield(node) && pendingExpressions.length > 0) {
75716                         emitWorker(1, [factory.createExpressionStatement(factory.inlineExpressions(pendingExpressions))]);
75717                         pendingExpressions = [];
75718                     }
75719                     pendingExpressions.push(ts.visitNode(node, visitor, ts.isExpression));
75720                 }
75721             }
75722         }
75723         function visitCommaListExpression(node) {
75724             var pendingExpressions = [];
75725             for (var _i = 0, _a = node.elements; _i < _a.length; _i++) {
75726                 var elem = _a[_i];
75727                 if (ts.isBinaryExpression(elem) && elem.operatorToken.kind === 27) {
75728                     pendingExpressions.push(visitCommaExpression(elem));
75729                 }
75730                 else {
75731                     if (containsYield(elem) && pendingExpressions.length > 0) {
75732                         emitWorker(1, [factory.createExpressionStatement(factory.inlineExpressions(pendingExpressions))]);
75733                         pendingExpressions = [];
75734                     }
75735                     pendingExpressions.push(ts.visitNode(elem, visitor, ts.isExpression));
75736                 }
75737             }
75738             return factory.inlineExpressions(pendingExpressions);
75739         }
75740         function visitLogicalBinaryExpression(node) {
75741             var resultLabel = defineLabel();
75742             var resultLocal = declareLocal();
75743             emitAssignment(resultLocal, ts.visitNode(node.left, visitor, ts.isExpression), node.left);
75744             if (node.operatorToken.kind === 55) {
75745                 emitBreakWhenFalse(resultLabel, resultLocal, node.left);
75746             }
75747             else {
75748                 emitBreakWhenTrue(resultLabel, resultLocal, node.left);
75749             }
75750             emitAssignment(resultLocal, ts.visitNode(node.right, visitor, ts.isExpression), node.right);
75751             markLabel(resultLabel);
75752             return resultLocal;
75753         }
75754         function visitConditionalExpression(node) {
75755             if (containsYield(node.whenTrue) || containsYield(node.whenFalse)) {
75756                 var whenFalseLabel = defineLabel();
75757                 var resultLabel = defineLabel();
75758                 var resultLocal = declareLocal();
75759                 emitBreakWhenFalse(whenFalseLabel, ts.visitNode(node.condition, visitor, ts.isExpression), node.condition);
75760                 emitAssignment(resultLocal, ts.visitNode(node.whenTrue, visitor, ts.isExpression), node.whenTrue);
75761                 emitBreak(resultLabel);
75762                 markLabel(whenFalseLabel);
75763                 emitAssignment(resultLocal, ts.visitNode(node.whenFalse, visitor, ts.isExpression), node.whenFalse);
75764                 markLabel(resultLabel);
75765                 return resultLocal;
75766             }
75767             return ts.visitEachChild(node, visitor, context);
75768         }
75769         function visitYieldExpression(node) {
75770             var resumeLabel = defineLabel();
75771             var expression = ts.visitNode(node.expression, visitor, ts.isExpression);
75772             if (node.asteriskToken) {
75773                 var iterator = (ts.getEmitFlags(node.expression) & 8388608) === 0
75774                     ? ts.setTextRange(emitHelpers().createValuesHelper(expression), node)
75775                     : expression;
75776                 emitYieldStar(iterator, node);
75777             }
75778             else {
75779                 emitYield(expression, node);
75780             }
75781             markLabel(resumeLabel);
75782             return createGeneratorResume(node);
75783         }
75784         function visitArrayLiteralExpression(node) {
75785             return visitElements(node.elements, undefined, undefined, node.multiLine);
75786         }
75787         function visitElements(elements, leadingElement, location, multiLine) {
75788             var numInitialElements = countInitialNodesWithoutYield(elements);
75789             var temp;
75790             if (numInitialElements > 0) {
75791                 temp = declareLocal();
75792                 var initialElements = ts.visitNodes(elements, visitor, ts.isExpression, 0, numInitialElements);
75793                 emitAssignment(temp, factory.createArrayLiteralExpression(leadingElement
75794                     ? __spreadArrays([leadingElement], initialElements) : initialElements));
75795                 leadingElement = undefined;
75796             }
75797             var expressions = ts.reduceLeft(elements, reduceElement, [], numInitialElements);
75798             return temp
75799                 ? factory.createArrayConcatCall(temp, [factory.createArrayLiteralExpression(expressions, multiLine)])
75800                 : ts.setTextRange(factory.createArrayLiteralExpression(leadingElement ? __spreadArrays([leadingElement], expressions) : expressions, multiLine), location);
75801             function reduceElement(expressions, element) {
75802                 if (containsYield(element) && expressions.length > 0) {
75803                     var hasAssignedTemp = temp !== undefined;
75804                     if (!temp) {
75805                         temp = declareLocal();
75806                     }
75807                     emitAssignment(temp, hasAssignedTemp
75808                         ? factory.createArrayConcatCall(temp, [factory.createArrayLiteralExpression(expressions, multiLine)])
75809                         : factory.createArrayLiteralExpression(leadingElement ? __spreadArrays([leadingElement], expressions) : expressions, multiLine));
75810                     leadingElement = undefined;
75811                     expressions = [];
75812                 }
75813                 expressions.push(ts.visitNode(element, visitor, ts.isExpression));
75814                 return expressions;
75815             }
75816         }
75817         function visitObjectLiteralExpression(node) {
75818             var properties = node.properties;
75819             var multiLine = node.multiLine;
75820             var numInitialProperties = countInitialNodesWithoutYield(properties);
75821             var temp = declareLocal();
75822             emitAssignment(temp, factory.createObjectLiteralExpression(ts.visitNodes(properties, visitor, ts.isObjectLiteralElementLike, 0, numInitialProperties), multiLine));
75823             var expressions = ts.reduceLeft(properties, reduceProperty, [], numInitialProperties);
75824             expressions.push(multiLine ? ts.startOnNewLine(ts.setParent(ts.setTextRange(factory.cloneNode(temp), temp), temp.parent)) : temp);
75825             return factory.inlineExpressions(expressions);
75826             function reduceProperty(expressions, property) {
75827                 if (containsYield(property) && expressions.length > 0) {
75828                     emitStatement(factory.createExpressionStatement(factory.inlineExpressions(expressions)));
75829                     expressions = [];
75830                 }
75831                 var expression = ts.createExpressionForObjectLiteralElementLike(factory, node, property, temp);
75832                 var visited = ts.visitNode(expression, visitor, ts.isExpression);
75833                 if (visited) {
75834                     if (multiLine) {
75835                         ts.startOnNewLine(visited);
75836                     }
75837                     expressions.push(visited);
75838                 }
75839                 return expressions;
75840             }
75841         }
75842         function visitElementAccessExpression(node) {
75843             if (containsYield(node.argumentExpression)) {
75844                 return factory.updateElementAccessExpression(node, cacheExpression(ts.visitNode(node.expression, visitor, ts.isLeftHandSideExpression)), ts.visitNode(node.argumentExpression, visitor, ts.isExpression));
75845             }
75846             return ts.visitEachChild(node, visitor, context);
75847         }
75848         function visitCallExpression(node) {
75849             if (!ts.isImportCall(node) && ts.forEach(node.arguments, containsYield)) {
75850                 var _a = factory.createCallBinding(node.expression, hoistVariableDeclaration, languageVersion, true), target = _a.target, thisArg = _a.thisArg;
75851                 return ts.setOriginalNode(ts.setTextRange(factory.createFunctionApplyCall(cacheExpression(ts.visitNode(target, visitor, ts.isLeftHandSideExpression)), thisArg, visitElements(node.arguments)), node), node);
75852             }
75853             return ts.visitEachChild(node, visitor, context);
75854         }
75855         function visitNewExpression(node) {
75856             if (ts.forEach(node.arguments, containsYield)) {
75857                 var _a = factory.createCallBinding(factory.createPropertyAccessExpression(node.expression, "bind"), hoistVariableDeclaration), target = _a.target, thisArg = _a.thisArg;
75858                 return ts.setOriginalNode(ts.setTextRange(factory.createNewExpression(factory.createFunctionApplyCall(cacheExpression(ts.visitNode(target, visitor, ts.isExpression)), thisArg, visitElements(node.arguments, factory.createVoidZero())), undefined, []), node), node);
75859             }
75860             return ts.visitEachChild(node, visitor, context);
75861         }
75862         function transformAndEmitStatements(statements, start) {
75863             if (start === void 0) { start = 0; }
75864             var numStatements = statements.length;
75865             for (var i = start; i < numStatements; i++) {
75866                 transformAndEmitStatement(statements[i]);
75867             }
75868         }
75869         function transformAndEmitEmbeddedStatement(node) {
75870             if (ts.isBlock(node)) {
75871                 transformAndEmitStatements(node.statements);
75872             }
75873             else {
75874                 transformAndEmitStatement(node);
75875             }
75876         }
75877         function transformAndEmitStatement(node) {
75878             var savedInStatementContainingYield = inStatementContainingYield;
75879             if (!inStatementContainingYield) {
75880                 inStatementContainingYield = containsYield(node);
75881             }
75882             transformAndEmitStatementWorker(node);
75883             inStatementContainingYield = savedInStatementContainingYield;
75884         }
75885         function transformAndEmitStatementWorker(node) {
75886             switch (node.kind) {
75887                 case 230:
75888                     return transformAndEmitBlock(node);
75889                 case 233:
75890                     return transformAndEmitExpressionStatement(node);
75891                 case 234:
75892                     return transformAndEmitIfStatement(node);
75893                 case 235:
75894                     return transformAndEmitDoStatement(node);
75895                 case 236:
75896                     return transformAndEmitWhileStatement(node);
75897                 case 237:
75898                     return transformAndEmitForStatement(node);
75899                 case 238:
75900                     return transformAndEmitForInStatement(node);
75901                 case 240:
75902                     return transformAndEmitContinueStatement(node);
75903                 case 241:
75904                     return transformAndEmitBreakStatement(node);
75905                 case 242:
75906                     return transformAndEmitReturnStatement(node);
75907                 case 243:
75908                     return transformAndEmitWithStatement(node);
75909                 case 244:
75910                     return transformAndEmitSwitchStatement(node);
75911                 case 245:
75912                     return transformAndEmitLabeledStatement(node);
75913                 case 246:
75914                     return transformAndEmitThrowStatement(node);
75915                 case 247:
75916                     return transformAndEmitTryStatement(node);
75917                 default:
75918                     return emitStatement(ts.visitNode(node, visitor, ts.isStatement));
75919             }
75920         }
75921         function transformAndEmitBlock(node) {
75922             if (containsYield(node)) {
75923                 transformAndEmitStatements(node.statements);
75924             }
75925             else {
75926                 emitStatement(ts.visitNode(node, visitor, ts.isStatement));
75927             }
75928         }
75929         function transformAndEmitExpressionStatement(node) {
75930             emitStatement(ts.visitNode(node, visitor, ts.isStatement));
75931         }
75932         function transformAndEmitVariableDeclarationList(node) {
75933             for (var _i = 0, _a = node.declarations; _i < _a.length; _i++) {
75934                 var variable = _a[_i];
75935                 var name = factory.cloneNode(variable.name);
75936                 ts.setCommentRange(name, variable.name);
75937                 hoistVariableDeclaration(name);
75938             }
75939             var variables = ts.getInitializedVariables(node);
75940             var numVariables = variables.length;
75941             var variablesWritten = 0;
75942             var pendingExpressions = [];
75943             while (variablesWritten < numVariables) {
75944                 for (var i = variablesWritten; i < numVariables; i++) {
75945                     var variable = variables[i];
75946                     if (containsYield(variable.initializer) && pendingExpressions.length > 0) {
75947                         break;
75948                     }
75949                     pendingExpressions.push(transformInitializedVariable(variable));
75950                 }
75951                 if (pendingExpressions.length) {
75952                     emitStatement(factory.createExpressionStatement(factory.inlineExpressions(pendingExpressions)));
75953                     variablesWritten += pendingExpressions.length;
75954                     pendingExpressions = [];
75955                 }
75956             }
75957             return undefined;
75958         }
75959         function transformInitializedVariable(node) {
75960             return ts.setSourceMapRange(factory.createAssignment(ts.setSourceMapRange(factory.cloneNode(node.name), node.name), ts.visitNode(node.initializer, visitor, ts.isExpression)), node);
75961         }
75962         function transformAndEmitIfStatement(node) {
75963             if (containsYield(node)) {
75964                 if (containsYield(node.thenStatement) || containsYield(node.elseStatement)) {
75965                     var endLabel = defineLabel();
75966                     var elseLabel = node.elseStatement ? defineLabel() : undefined;
75967                     emitBreakWhenFalse(node.elseStatement ? elseLabel : endLabel, ts.visitNode(node.expression, visitor, ts.isExpression), node.expression);
75968                     transformAndEmitEmbeddedStatement(node.thenStatement);
75969                     if (node.elseStatement) {
75970                         emitBreak(endLabel);
75971                         markLabel(elseLabel);
75972                         transformAndEmitEmbeddedStatement(node.elseStatement);
75973                     }
75974                     markLabel(endLabel);
75975                 }
75976                 else {
75977                     emitStatement(ts.visitNode(node, visitor, ts.isStatement));
75978                 }
75979             }
75980             else {
75981                 emitStatement(ts.visitNode(node, visitor, ts.isStatement));
75982             }
75983         }
75984         function transformAndEmitDoStatement(node) {
75985             if (containsYield(node)) {
75986                 var conditionLabel = defineLabel();
75987                 var loopLabel = defineLabel();
75988                 beginLoopBlock(conditionLabel);
75989                 markLabel(loopLabel);
75990                 transformAndEmitEmbeddedStatement(node.statement);
75991                 markLabel(conditionLabel);
75992                 emitBreakWhenTrue(loopLabel, ts.visitNode(node.expression, visitor, ts.isExpression));
75993                 endLoopBlock();
75994             }
75995             else {
75996                 emitStatement(ts.visitNode(node, visitor, ts.isStatement));
75997             }
75998         }
75999         function visitDoStatement(node) {
76000             if (inStatementContainingYield) {
76001                 beginScriptLoopBlock();
76002                 node = ts.visitEachChild(node, visitor, context);
76003                 endLoopBlock();
76004                 return node;
76005             }
76006             else {
76007                 return ts.visitEachChild(node, visitor, context);
76008             }
76009         }
76010         function transformAndEmitWhileStatement(node) {
76011             if (containsYield(node)) {
76012                 var loopLabel = defineLabel();
76013                 var endLabel = beginLoopBlock(loopLabel);
76014                 markLabel(loopLabel);
76015                 emitBreakWhenFalse(endLabel, ts.visitNode(node.expression, visitor, ts.isExpression));
76016                 transformAndEmitEmbeddedStatement(node.statement);
76017                 emitBreak(loopLabel);
76018                 endLoopBlock();
76019             }
76020             else {
76021                 emitStatement(ts.visitNode(node, visitor, ts.isStatement));
76022             }
76023         }
76024         function visitWhileStatement(node) {
76025             if (inStatementContainingYield) {
76026                 beginScriptLoopBlock();
76027                 node = ts.visitEachChild(node, visitor, context);
76028                 endLoopBlock();
76029                 return node;
76030             }
76031             else {
76032                 return ts.visitEachChild(node, visitor, context);
76033             }
76034         }
76035         function transformAndEmitForStatement(node) {
76036             if (containsYield(node)) {
76037                 var conditionLabel = defineLabel();
76038                 var incrementLabel = defineLabel();
76039                 var endLabel = beginLoopBlock(incrementLabel);
76040                 if (node.initializer) {
76041                     var initializer = node.initializer;
76042                     if (ts.isVariableDeclarationList(initializer)) {
76043                         transformAndEmitVariableDeclarationList(initializer);
76044                     }
76045                     else {
76046                         emitStatement(ts.setTextRange(factory.createExpressionStatement(ts.visitNode(initializer, visitor, ts.isExpression)), initializer));
76047                     }
76048                 }
76049                 markLabel(conditionLabel);
76050                 if (node.condition) {
76051                     emitBreakWhenFalse(endLabel, ts.visitNode(node.condition, visitor, ts.isExpression));
76052                 }
76053                 transformAndEmitEmbeddedStatement(node.statement);
76054                 markLabel(incrementLabel);
76055                 if (node.incrementor) {
76056                     emitStatement(ts.setTextRange(factory.createExpressionStatement(ts.visitNode(node.incrementor, visitor, ts.isExpression)), node.incrementor));
76057                 }
76058                 emitBreak(conditionLabel);
76059                 endLoopBlock();
76060             }
76061             else {
76062                 emitStatement(ts.visitNode(node, visitor, ts.isStatement));
76063             }
76064         }
76065         function visitForStatement(node) {
76066             if (inStatementContainingYield) {
76067                 beginScriptLoopBlock();
76068             }
76069             var initializer = node.initializer;
76070             if (initializer && ts.isVariableDeclarationList(initializer)) {
76071                 for (var _i = 0, _a = initializer.declarations; _i < _a.length; _i++) {
76072                     var variable = _a[_i];
76073                     hoistVariableDeclaration(variable.name);
76074                 }
76075                 var variables = ts.getInitializedVariables(initializer);
76076                 node = factory.updateForStatement(node, variables.length > 0
76077                     ? factory.inlineExpressions(ts.map(variables, transformInitializedVariable))
76078                     : undefined, ts.visitNode(node.condition, visitor, ts.isExpression), ts.visitNode(node.incrementor, visitor, ts.isExpression), ts.visitNode(node.statement, visitor, ts.isStatement, factory.liftToBlock));
76079             }
76080             else {
76081                 node = ts.visitEachChild(node, visitor, context);
76082             }
76083             if (inStatementContainingYield) {
76084                 endLoopBlock();
76085             }
76086             return node;
76087         }
76088         function transformAndEmitForInStatement(node) {
76089             if (containsYield(node)) {
76090                 var keysArray = declareLocal();
76091                 var key = declareLocal();
76092                 var keysIndex = factory.createLoopVariable();
76093                 var initializer = node.initializer;
76094                 hoistVariableDeclaration(keysIndex);
76095                 emitAssignment(keysArray, factory.createArrayLiteralExpression());
76096                 emitStatement(factory.createForInStatement(key, ts.visitNode(node.expression, visitor, ts.isExpression), factory.createExpressionStatement(factory.createCallExpression(factory.createPropertyAccessExpression(keysArray, "push"), undefined, [key]))));
76097                 emitAssignment(keysIndex, factory.createNumericLiteral(0));
76098                 var conditionLabel = defineLabel();
76099                 var incrementLabel = defineLabel();
76100                 var endLabel = beginLoopBlock(incrementLabel);
76101                 markLabel(conditionLabel);
76102                 emitBreakWhenFalse(endLabel, factory.createLessThan(keysIndex, factory.createPropertyAccessExpression(keysArray, "length")));
76103                 var variable = void 0;
76104                 if (ts.isVariableDeclarationList(initializer)) {
76105                     for (var _i = 0, _a = initializer.declarations; _i < _a.length; _i++) {
76106                         var variable_1 = _a[_i];
76107                         hoistVariableDeclaration(variable_1.name);
76108                     }
76109                     variable = factory.cloneNode(initializer.declarations[0].name);
76110                 }
76111                 else {
76112                     variable = ts.visitNode(initializer, visitor, ts.isExpression);
76113                     ts.Debug.assert(ts.isLeftHandSideExpression(variable));
76114                 }
76115                 emitAssignment(variable, factory.createElementAccessExpression(keysArray, keysIndex));
76116                 transformAndEmitEmbeddedStatement(node.statement);
76117                 markLabel(incrementLabel);
76118                 emitStatement(factory.createExpressionStatement(factory.createPostfixIncrement(keysIndex)));
76119                 emitBreak(conditionLabel);
76120                 endLoopBlock();
76121             }
76122             else {
76123                 emitStatement(ts.visitNode(node, visitor, ts.isStatement));
76124             }
76125         }
76126         function visitForInStatement(node) {
76127             if (inStatementContainingYield) {
76128                 beginScriptLoopBlock();
76129             }
76130             var initializer = node.initializer;
76131             if (ts.isVariableDeclarationList(initializer)) {
76132                 for (var _i = 0, _a = initializer.declarations; _i < _a.length; _i++) {
76133                     var variable = _a[_i];
76134                     hoistVariableDeclaration(variable.name);
76135                 }
76136                 node = factory.updateForInStatement(node, initializer.declarations[0].name, ts.visitNode(node.expression, visitor, ts.isExpression), ts.visitNode(node.statement, visitor, ts.isStatement, factory.liftToBlock));
76137             }
76138             else {
76139                 node = ts.visitEachChild(node, visitor, context);
76140             }
76141             if (inStatementContainingYield) {
76142                 endLoopBlock();
76143             }
76144             return node;
76145         }
76146         function transformAndEmitContinueStatement(node) {
76147             var label = findContinueTarget(node.label ? ts.idText(node.label) : undefined);
76148             if (label > 0) {
76149                 emitBreak(label, node);
76150             }
76151             else {
76152                 emitStatement(node);
76153             }
76154         }
76155         function visitContinueStatement(node) {
76156             if (inStatementContainingYield) {
76157                 var label = findContinueTarget(node.label && ts.idText(node.label));
76158                 if (label > 0) {
76159                     return createInlineBreak(label, node);
76160                 }
76161             }
76162             return ts.visitEachChild(node, visitor, context);
76163         }
76164         function transformAndEmitBreakStatement(node) {
76165             var label = findBreakTarget(node.label ? ts.idText(node.label) : undefined);
76166             if (label > 0) {
76167                 emitBreak(label, node);
76168             }
76169             else {
76170                 emitStatement(node);
76171             }
76172         }
76173         function visitBreakStatement(node) {
76174             if (inStatementContainingYield) {
76175                 var label = findBreakTarget(node.label && ts.idText(node.label));
76176                 if (label > 0) {
76177                     return createInlineBreak(label, node);
76178                 }
76179             }
76180             return ts.visitEachChild(node, visitor, context);
76181         }
76182         function transformAndEmitReturnStatement(node) {
76183             emitReturn(ts.visitNode(node.expression, visitor, ts.isExpression), node);
76184         }
76185         function visitReturnStatement(node) {
76186             return createInlineReturn(ts.visitNode(node.expression, visitor, ts.isExpression), node);
76187         }
76188         function transformAndEmitWithStatement(node) {
76189             if (containsYield(node)) {
76190                 beginWithBlock(cacheExpression(ts.visitNode(node.expression, visitor, ts.isExpression)));
76191                 transformAndEmitEmbeddedStatement(node.statement);
76192                 endWithBlock();
76193             }
76194             else {
76195                 emitStatement(ts.visitNode(node, visitor, ts.isStatement));
76196             }
76197         }
76198         function transformAndEmitSwitchStatement(node) {
76199             if (containsYield(node.caseBlock)) {
76200                 var caseBlock = node.caseBlock;
76201                 var numClauses = caseBlock.clauses.length;
76202                 var endLabel = beginSwitchBlock();
76203                 var expression = cacheExpression(ts.visitNode(node.expression, visitor, ts.isExpression));
76204                 var clauseLabels = [];
76205                 var defaultClauseIndex = -1;
76206                 for (var i = 0; i < numClauses; i++) {
76207                     var clause = caseBlock.clauses[i];
76208                     clauseLabels.push(defineLabel());
76209                     if (clause.kind === 285 && defaultClauseIndex === -1) {
76210                         defaultClauseIndex = i;
76211                     }
76212                 }
76213                 var clausesWritten = 0;
76214                 var pendingClauses = [];
76215                 while (clausesWritten < numClauses) {
76216                     var defaultClausesSkipped = 0;
76217                     for (var i = clausesWritten; i < numClauses; i++) {
76218                         var clause = caseBlock.clauses[i];
76219                         if (clause.kind === 284) {
76220                             if (containsYield(clause.expression) && pendingClauses.length > 0) {
76221                                 break;
76222                             }
76223                             pendingClauses.push(factory.createCaseClause(ts.visitNode(clause.expression, visitor, ts.isExpression), [
76224                                 createInlineBreak(clauseLabels[i], clause.expression)
76225                             ]));
76226                         }
76227                         else {
76228                             defaultClausesSkipped++;
76229                         }
76230                     }
76231                     if (pendingClauses.length) {
76232                         emitStatement(factory.createSwitchStatement(expression, factory.createCaseBlock(pendingClauses)));
76233                         clausesWritten += pendingClauses.length;
76234                         pendingClauses = [];
76235                     }
76236                     if (defaultClausesSkipped > 0) {
76237                         clausesWritten += defaultClausesSkipped;
76238                         defaultClausesSkipped = 0;
76239                     }
76240                 }
76241                 if (defaultClauseIndex >= 0) {
76242                     emitBreak(clauseLabels[defaultClauseIndex]);
76243                 }
76244                 else {
76245                     emitBreak(endLabel);
76246                 }
76247                 for (var i = 0; i < numClauses; i++) {
76248                     markLabel(clauseLabels[i]);
76249                     transformAndEmitStatements(caseBlock.clauses[i].statements);
76250                 }
76251                 endSwitchBlock();
76252             }
76253             else {
76254                 emitStatement(ts.visitNode(node, visitor, ts.isStatement));
76255             }
76256         }
76257         function visitSwitchStatement(node) {
76258             if (inStatementContainingYield) {
76259                 beginScriptSwitchBlock();
76260             }
76261             node = ts.visitEachChild(node, visitor, context);
76262             if (inStatementContainingYield) {
76263                 endSwitchBlock();
76264             }
76265             return node;
76266         }
76267         function transformAndEmitLabeledStatement(node) {
76268             if (containsYield(node)) {
76269                 beginLabeledBlock(ts.idText(node.label));
76270                 transformAndEmitEmbeddedStatement(node.statement);
76271                 endLabeledBlock();
76272             }
76273             else {
76274                 emitStatement(ts.visitNode(node, visitor, ts.isStatement));
76275             }
76276         }
76277         function visitLabeledStatement(node) {
76278             if (inStatementContainingYield) {
76279                 beginScriptLabeledBlock(ts.idText(node.label));
76280             }
76281             node = ts.visitEachChild(node, visitor, context);
76282             if (inStatementContainingYield) {
76283                 endLabeledBlock();
76284             }
76285             return node;
76286         }
76287         function transformAndEmitThrowStatement(node) {
76288             var _a;
76289             emitThrow(ts.visitNode((_a = node.expression) !== null && _a !== void 0 ? _a : factory.createVoidZero(), visitor, ts.isExpression), node);
76290         }
76291         function transformAndEmitTryStatement(node) {
76292             if (containsYield(node)) {
76293                 beginExceptionBlock();
76294                 transformAndEmitEmbeddedStatement(node.tryBlock);
76295                 if (node.catchClause) {
76296                     beginCatchBlock(node.catchClause.variableDeclaration);
76297                     transformAndEmitEmbeddedStatement(node.catchClause.block);
76298                 }
76299                 if (node.finallyBlock) {
76300                     beginFinallyBlock();
76301                     transformAndEmitEmbeddedStatement(node.finallyBlock);
76302                 }
76303                 endExceptionBlock();
76304             }
76305             else {
76306                 emitStatement(ts.visitEachChild(node, visitor, context));
76307             }
76308         }
76309         function containsYield(node) {
76310             return !!node && (node.transformFlags & 262144) !== 0;
76311         }
76312         function countInitialNodesWithoutYield(nodes) {
76313             var numNodes = nodes.length;
76314             for (var i = 0; i < numNodes; i++) {
76315                 if (containsYield(nodes[i])) {
76316                     return i;
76317                 }
76318             }
76319             return -1;
76320         }
76321         function onSubstituteNode(hint, node) {
76322             node = previousOnSubstituteNode(hint, node);
76323             if (hint === 1) {
76324                 return substituteExpression(node);
76325             }
76326             return node;
76327         }
76328         function substituteExpression(node) {
76329             if (ts.isIdentifier(node)) {
76330                 return substituteExpressionIdentifier(node);
76331             }
76332             return node;
76333         }
76334         function substituteExpressionIdentifier(node) {
76335             if (!ts.isGeneratedIdentifier(node) && renamedCatchVariables && renamedCatchVariables.has(ts.idText(node))) {
76336                 var original = ts.getOriginalNode(node);
76337                 if (ts.isIdentifier(original) && original.parent) {
76338                     var declaration = resolver.getReferencedValueDeclaration(original);
76339                     if (declaration) {
76340                         var name = renamedCatchVariableDeclarations[ts.getOriginalNodeId(declaration)];
76341                         if (name) {
76342                             var clone_5 = ts.setParent(ts.setTextRange(factory.cloneNode(name), name), name.parent);
76343                             ts.setSourceMapRange(clone_5, node);
76344                             ts.setCommentRange(clone_5, node);
76345                             return clone_5;
76346                         }
76347                     }
76348                 }
76349             }
76350             return node;
76351         }
76352         function cacheExpression(node) {
76353             if (ts.isGeneratedIdentifier(node) || ts.getEmitFlags(node) & 4096) {
76354                 return node;
76355             }
76356             var temp = factory.createTempVariable(hoistVariableDeclaration);
76357             emitAssignment(temp, node, node);
76358             return temp;
76359         }
76360         function declareLocal(name) {
76361             var temp = name
76362                 ? factory.createUniqueName(name)
76363                 : factory.createTempVariable(undefined);
76364             hoistVariableDeclaration(temp);
76365             return temp;
76366         }
76367         function defineLabel() {
76368             if (!labelOffsets) {
76369                 labelOffsets = [];
76370             }
76371             var label = nextLabelId;
76372             nextLabelId++;
76373             labelOffsets[label] = -1;
76374             return label;
76375         }
76376         function markLabel(label) {
76377             ts.Debug.assert(labelOffsets !== undefined, "No labels were defined.");
76378             labelOffsets[label] = operations ? operations.length : 0;
76379         }
76380         function beginBlock(block) {
76381             if (!blocks) {
76382                 blocks = [];
76383                 blockActions = [];
76384                 blockOffsets = [];
76385                 blockStack = [];
76386             }
76387             var index = blockActions.length;
76388             blockActions[index] = 0;
76389             blockOffsets[index] = operations ? operations.length : 0;
76390             blocks[index] = block;
76391             blockStack.push(block);
76392             return index;
76393         }
76394         function endBlock() {
76395             var block = peekBlock();
76396             if (block === undefined)
76397                 return ts.Debug.fail("beginBlock was never called.");
76398             var index = blockActions.length;
76399             blockActions[index] = 1;
76400             blockOffsets[index] = operations ? operations.length : 0;
76401             blocks[index] = block;
76402             blockStack.pop();
76403             return block;
76404         }
76405         function peekBlock() {
76406             return ts.lastOrUndefined(blockStack);
76407         }
76408         function peekBlockKind() {
76409             var block = peekBlock();
76410             return block && block.kind;
76411         }
76412         function beginWithBlock(expression) {
76413             var startLabel = defineLabel();
76414             var endLabel = defineLabel();
76415             markLabel(startLabel);
76416             beginBlock({
76417                 kind: 1,
76418                 expression: expression,
76419                 startLabel: startLabel,
76420                 endLabel: endLabel
76421             });
76422         }
76423         function endWithBlock() {
76424             ts.Debug.assert(peekBlockKind() === 1);
76425             var block = endBlock();
76426             markLabel(block.endLabel);
76427         }
76428         function beginExceptionBlock() {
76429             var startLabel = defineLabel();
76430             var endLabel = defineLabel();
76431             markLabel(startLabel);
76432             beginBlock({
76433                 kind: 0,
76434                 state: 0,
76435                 startLabel: startLabel,
76436                 endLabel: endLabel
76437             });
76438             emitNop();
76439             return endLabel;
76440         }
76441         function beginCatchBlock(variable) {
76442             ts.Debug.assert(peekBlockKind() === 0);
76443             var name;
76444             if (ts.isGeneratedIdentifier(variable.name)) {
76445                 name = variable.name;
76446                 hoistVariableDeclaration(variable.name);
76447             }
76448             else {
76449                 var text = ts.idText(variable.name);
76450                 name = declareLocal(text);
76451                 if (!renamedCatchVariables) {
76452                     renamedCatchVariables = new ts.Map();
76453                     renamedCatchVariableDeclarations = [];
76454                     context.enableSubstitution(78);
76455                 }
76456                 renamedCatchVariables.set(text, true);
76457                 renamedCatchVariableDeclarations[ts.getOriginalNodeId(variable)] = name;
76458             }
76459             var exception = peekBlock();
76460             ts.Debug.assert(exception.state < 1);
76461             var endLabel = exception.endLabel;
76462             emitBreak(endLabel);
76463             var catchLabel = defineLabel();
76464             markLabel(catchLabel);
76465             exception.state = 1;
76466             exception.catchVariable = name;
76467             exception.catchLabel = catchLabel;
76468             emitAssignment(name, factory.createCallExpression(factory.createPropertyAccessExpression(state, "sent"), undefined, []));
76469             emitNop();
76470         }
76471         function beginFinallyBlock() {
76472             ts.Debug.assert(peekBlockKind() === 0);
76473             var exception = peekBlock();
76474             ts.Debug.assert(exception.state < 2);
76475             var endLabel = exception.endLabel;
76476             emitBreak(endLabel);
76477             var finallyLabel = defineLabel();
76478             markLabel(finallyLabel);
76479             exception.state = 2;
76480             exception.finallyLabel = finallyLabel;
76481         }
76482         function endExceptionBlock() {
76483             ts.Debug.assert(peekBlockKind() === 0);
76484             var exception = endBlock();
76485             var state = exception.state;
76486             if (state < 2) {
76487                 emitBreak(exception.endLabel);
76488             }
76489             else {
76490                 emitEndfinally();
76491             }
76492             markLabel(exception.endLabel);
76493             emitNop();
76494             exception.state = 3;
76495         }
76496         function beginScriptLoopBlock() {
76497             beginBlock({
76498                 kind: 3,
76499                 isScript: true,
76500                 breakLabel: -1,
76501                 continueLabel: -1
76502             });
76503         }
76504         function beginLoopBlock(continueLabel) {
76505             var breakLabel = defineLabel();
76506             beginBlock({
76507                 kind: 3,
76508                 isScript: false,
76509                 breakLabel: breakLabel,
76510                 continueLabel: continueLabel,
76511             });
76512             return breakLabel;
76513         }
76514         function endLoopBlock() {
76515             ts.Debug.assert(peekBlockKind() === 3);
76516             var block = endBlock();
76517             var breakLabel = block.breakLabel;
76518             if (!block.isScript) {
76519                 markLabel(breakLabel);
76520             }
76521         }
76522         function beginScriptSwitchBlock() {
76523             beginBlock({
76524                 kind: 2,
76525                 isScript: true,
76526                 breakLabel: -1
76527             });
76528         }
76529         function beginSwitchBlock() {
76530             var breakLabel = defineLabel();
76531             beginBlock({
76532                 kind: 2,
76533                 isScript: false,
76534                 breakLabel: breakLabel,
76535             });
76536             return breakLabel;
76537         }
76538         function endSwitchBlock() {
76539             ts.Debug.assert(peekBlockKind() === 2);
76540             var block = endBlock();
76541             var breakLabel = block.breakLabel;
76542             if (!block.isScript) {
76543                 markLabel(breakLabel);
76544             }
76545         }
76546         function beginScriptLabeledBlock(labelText) {
76547             beginBlock({
76548                 kind: 4,
76549                 isScript: true,
76550                 labelText: labelText,
76551                 breakLabel: -1
76552             });
76553         }
76554         function beginLabeledBlock(labelText) {
76555             var breakLabel = defineLabel();
76556             beginBlock({
76557                 kind: 4,
76558                 isScript: false,
76559                 labelText: labelText,
76560                 breakLabel: breakLabel
76561             });
76562         }
76563         function endLabeledBlock() {
76564             ts.Debug.assert(peekBlockKind() === 4);
76565             var block = endBlock();
76566             if (!block.isScript) {
76567                 markLabel(block.breakLabel);
76568             }
76569         }
76570         function supportsUnlabeledBreak(block) {
76571             return block.kind === 2
76572                 || block.kind === 3;
76573         }
76574         function supportsLabeledBreakOrContinue(block) {
76575             return block.kind === 4;
76576         }
76577         function supportsUnlabeledContinue(block) {
76578             return block.kind === 3;
76579         }
76580         function hasImmediateContainingLabeledBlock(labelText, start) {
76581             for (var j = start; j >= 0; j--) {
76582                 var containingBlock = blockStack[j];
76583                 if (supportsLabeledBreakOrContinue(containingBlock)) {
76584                     if (containingBlock.labelText === labelText) {
76585                         return true;
76586                     }
76587                 }
76588                 else {
76589                     break;
76590                 }
76591             }
76592             return false;
76593         }
76594         function findBreakTarget(labelText) {
76595             if (blockStack) {
76596                 if (labelText) {
76597                     for (var i = blockStack.length - 1; i >= 0; i--) {
76598                         var block = blockStack[i];
76599                         if (supportsLabeledBreakOrContinue(block) && block.labelText === labelText) {
76600                             return block.breakLabel;
76601                         }
76602                         else if (supportsUnlabeledBreak(block) && hasImmediateContainingLabeledBlock(labelText, i - 1)) {
76603                             return block.breakLabel;
76604                         }
76605                     }
76606                 }
76607                 else {
76608                     for (var i = blockStack.length - 1; i >= 0; i--) {
76609                         var block = blockStack[i];
76610                         if (supportsUnlabeledBreak(block)) {
76611                             return block.breakLabel;
76612                         }
76613                     }
76614                 }
76615             }
76616             return 0;
76617         }
76618         function findContinueTarget(labelText) {
76619             if (blockStack) {
76620                 if (labelText) {
76621                     for (var i = blockStack.length - 1; i >= 0; i--) {
76622                         var block = blockStack[i];
76623                         if (supportsUnlabeledContinue(block) && hasImmediateContainingLabeledBlock(labelText, i - 1)) {
76624                             return block.continueLabel;
76625                         }
76626                     }
76627                 }
76628                 else {
76629                     for (var i = blockStack.length - 1; i >= 0; i--) {
76630                         var block = blockStack[i];
76631                         if (supportsUnlabeledContinue(block)) {
76632                             return block.continueLabel;
76633                         }
76634                     }
76635                 }
76636             }
76637             return 0;
76638         }
76639         function createLabel(label) {
76640             if (label !== undefined && label > 0) {
76641                 if (labelExpressions === undefined) {
76642                     labelExpressions = [];
76643                 }
76644                 var expression = factory.createNumericLiteral(-1);
76645                 if (labelExpressions[label] === undefined) {
76646                     labelExpressions[label] = [expression];
76647                 }
76648                 else {
76649                     labelExpressions[label].push(expression);
76650                 }
76651                 return expression;
76652             }
76653             return factory.createOmittedExpression();
76654         }
76655         function createInstruction(instruction) {
76656             var literal = factory.createNumericLiteral(instruction);
76657             ts.addSyntheticTrailingComment(literal, 3, getInstructionName(instruction));
76658             return literal;
76659         }
76660         function createInlineBreak(label, location) {
76661             ts.Debug.assertLessThan(0, label, "Invalid label");
76662             return ts.setTextRange(factory.createReturnStatement(factory.createArrayLiteralExpression([
76663                 createInstruction(3),
76664                 createLabel(label)
76665             ])), location);
76666         }
76667         function createInlineReturn(expression, location) {
76668             return ts.setTextRange(factory.createReturnStatement(factory.createArrayLiteralExpression(expression
76669                 ? [createInstruction(2), expression]
76670                 : [createInstruction(2)])), location);
76671         }
76672         function createGeneratorResume(location) {
76673             return ts.setTextRange(factory.createCallExpression(factory.createPropertyAccessExpression(state, "sent"), undefined, []), location);
76674         }
76675         function emitNop() {
76676             emitWorker(0);
76677         }
76678         function emitStatement(node) {
76679             if (node) {
76680                 emitWorker(1, [node]);
76681             }
76682             else {
76683                 emitNop();
76684             }
76685         }
76686         function emitAssignment(left, right, location) {
76687             emitWorker(2, [left, right], location);
76688         }
76689         function emitBreak(label, location) {
76690             emitWorker(3, [label], location);
76691         }
76692         function emitBreakWhenTrue(label, condition, location) {
76693             emitWorker(4, [label, condition], location);
76694         }
76695         function emitBreakWhenFalse(label, condition, location) {
76696             emitWorker(5, [label, condition], location);
76697         }
76698         function emitYieldStar(expression, location) {
76699             emitWorker(7, [expression], location);
76700         }
76701         function emitYield(expression, location) {
76702             emitWorker(6, [expression], location);
76703         }
76704         function emitReturn(expression, location) {
76705             emitWorker(8, [expression], location);
76706         }
76707         function emitThrow(expression, location) {
76708             emitWorker(9, [expression], location);
76709         }
76710         function emitEndfinally() {
76711             emitWorker(10);
76712         }
76713         function emitWorker(code, args, location) {
76714             if (operations === undefined) {
76715                 operations = [];
76716                 operationArguments = [];
76717                 operationLocations = [];
76718             }
76719             if (labelOffsets === undefined) {
76720                 markLabel(defineLabel());
76721             }
76722             var operationIndex = operations.length;
76723             operations[operationIndex] = code;
76724             operationArguments[operationIndex] = args;
76725             operationLocations[operationIndex] = location;
76726         }
76727         function build() {
76728             blockIndex = 0;
76729             labelNumber = 0;
76730             labelNumbers = undefined;
76731             lastOperationWasAbrupt = false;
76732             lastOperationWasCompletion = false;
76733             clauses = undefined;
76734             statements = undefined;
76735             exceptionBlockStack = undefined;
76736             currentExceptionBlock = undefined;
76737             withBlockStack = undefined;
76738             var buildResult = buildStatements();
76739             return emitHelpers().createGeneratorHelper(ts.setEmitFlags(factory.createFunctionExpression(undefined, undefined, undefined, undefined, [factory.createParameterDeclaration(undefined, undefined, undefined, state)], undefined, factory.createBlock(buildResult, buildResult.length > 0)), 524288));
76740         }
76741         function buildStatements() {
76742             if (operations) {
76743                 for (var operationIndex = 0; operationIndex < operations.length; operationIndex++) {
76744                     writeOperation(operationIndex);
76745                 }
76746                 flushFinalLabel(operations.length);
76747             }
76748             else {
76749                 flushFinalLabel(0);
76750             }
76751             if (clauses) {
76752                 var labelExpression = factory.createPropertyAccessExpression(state, "label");
76753                 var switchStatement = factory.createSwitchStatement(labelExpression, factory.createCaseBlock(clauses));
76754                 return [ts.startOnNewLine(switchStatement)];
76755             }
76756             if (statements) {
76757                 return statements;
76758             }
76759             return [];
76760         }
76761         function flushLabel() {
76762             if (!statements) {
76763                 return;
76764             }
76765             appendLabel(!lastOperationWasAbrupt);
76766             lastOperationWasAbrupt = false;
76767             lastOperationWasCompletion = false;
76768             labelNumber++;
76769         }
76770         function flushFinalLabel(operationIndex) {
76771             if (isFinalLabelReachable(operationIndex)) {
76772                 tryEnterLabel(operationIndex);
76773                 withBlockStack = undefined;
76774                 writeReturn(undefined, undefined);
76775             }
76776             if (statements && clauses) {
76777                 appendLabel(false);
76778             }
76779             updateLabelExpressions();
76780         }
76781         function isFinalLabelReachable(operationIndex) {
76782             if (!lastOperationWasCompletion) {
76783                 return true;
76784             }
76785             if (!labelOffsets || !labelExpressions) {
76786                 return false;
76787             }
76788             for (var label = 0; label < labelOffsets.length; label++) {
76789                 if (labelOffsets[label] === operationIndex && labelExpressions[label]) {
76790                     return true;
76791                 }
76792             }
76793             return false;
76794         }
76795         function appendLabel(markLabelEnd) {
76796             if (!clauses) {
76797                 clauses = [];
76798             }
76799             if (statements) {
76800                 if (withBlockStack) {
76801                     for (var i = withBlockStack.length - 1; i >= 0; i--) {
76802                         var withBlock = withBlockStack[i];
76803                         statements = [factory.createWithStatement(withBlock.expression, factory.createBlock(statements))];
76804                     }
76805                 }
76806                 if (currentExceptionBlock) {
76807                     var startLabel = currentExceptionBlock.startLabel, catchLabel = currentExceptionBlock.catchLabel, finallyLabel = currentExceptionBlock.finallyLabel, endLabel = currentExceptionBlock.endLabel;
76808                     statements.unshift(factory.createExpressionStatement(factory.createCallExpression(factory.createPropertyAccessExpression(factory.createPropertyAccessExpression(state, "trys"), "push"), undefined, [
76809                         factory.createArrayLiteralExpression([
76810                             createLabel(startLabel),
76811                             createLabel(catchLabel),
76812                             createLabel(finallyLabel),
76813                             createLabel(endLabel)
76814                         ])
76815                     ])));
76816                     currentExceptionBlock = undefined;
76817                 }
76818                 if (markLabelEnd) {
76819                     statements.push(factory.createExpressionStatement(factory.createAssignment(factory.createPropertyAccessExpression(state, "label"), factory.createNumericLiteral(labelNumber + 1))));
76820                 }
76821             }
76822             clauses.push(factory.createCaseClause(factory.createNumericLiteral(labelNumber), statements || []));
76823             statements = undefined;
76824         }
76825         function tryEnterLabel(operationIndex) {
76826             if (!labelOffsets) {
76827                 return;
76828             }
76829             for (var label = 0; label < labelOffsets.length; label++) {
76830                 if (labelOffsets[label] === operationIndex) {
76831                     flushLabel();
76832                     if (labelNumbers === undefined) {
76833                         labelNumbers = [];
76834                     }
76835                     if (labelNumbers[labelNumber] === undefined) {
76836                         labelNumbers[labelNumber] = [label];
76837                     }
76838                     else {
76839                         labelNumbers[labelNumber].push(label);
76840                     }
76841                 }
76842             }
76843         }
76844         function updateLabelExpressions() {
76845             if (labelExpressions !== undefined && labelNumbers !== undefined) {
76846                 for (var labelNumber_1 = 0; labelNumber_1 < labelNumbers.length; labelNumber_1++) {
76847                     var labels = labelNumbers[labelNumber_1];
76848                     if (labels !== undefined) {
76849                         for (var _i = 0, labels_1 = labels; _i < labels_1.length; _i++) {
76850                             var label = labels_1[_i];
76851                             var expressions = labelExpressions[label];
76852                             if (expressions !== undefined) {
76853                                 for (var _a = 0, expressions_1 = expressions; _a < expressions_1.length; _a++) {
76854                                     var expression = expressions_1[_a];
76855                                     expression.text = String(labelNumber_1);
76856                                 }
76857                             }
76858                         }
76859                     }
76860                 }
76861             }
76862         }
76863         function tryEnterOrLeaveBlock(operationIndex) {
76864             if (blocks) {
76865                 for (; blockIndex < blockActions.length && blockOffsets[blockIndex] <= operationIndex; blockIndex++) {
76866                     var block = blocks[blockIndex];
76867                     var blockAction = blockActions[blockIndex];
76868                     switch (block.kind) {
76869                         case 0:
76870                             if (blockAction === 0) {
76871                                 if (!exceptionBlockStack) {
76872                                     exceptionBlockStack = [];
76873                                 }
76874                                 if (!statements) {
76875                                     statements = [];
76876                                 }
76877                                 exceptionBlockStack.push(currentExceptionBlock);
76878                                 currentExceptionBlock = block;
76879                             }
76880                             else if (blockAction === 1) {
76881                                 currentExceptionBlock = exceptionBlockStack.pop();
76882                             }
76883                             break;
76884                         case 1:
76885                             if (blockAction === 0) {
76886                                 if (!withBlockStack) {
76887                                     withBlockStack = [];
76888                                 }
76889                                 withBlockStack.push(block);
76890                             }
76891                             else if (blockAction === 1) {
76892                                 withBlockStack.pop();
76893                             }
76894                             break;
76895                     }
76896                 }
76897             }
76898         }
76899         function writeOperation(operationIndex) {
76900             tryEnterLabel(operationIndex);
76901             tryEnterOrLeaveBlock(operationIndex);
76902             if (lastOperationWasAbrupt) {
76903                 return;
76904             }
76905             lastOperationWasAbrupt = false;
76906             lastOperationWasCompletion = false;
76907             var opcode = operations[operationIndex];
76908             if (opcode === 0) {
76909                 return;
76910             }
76911             else if (opcode === 10) {
76912                 return writeEndfinally();
76913             }
76914             var args = operationArguments[operationIndex];
76915             if (opcode === 1) {
76916                 return writeStatement(args[0]);
76917             }
76918             var location = operationLocations[operationIndex];
76919             switch (opcode) {
76920                 case 2:
76921                     return writeAssign(args[0], args[1], location);
76922                 case 3:
76923                     return writeBreak(args[0], location);
76924                 case 4:
76925                     return writeBreakWhenTrue(args[0], args[1], location);
76926                 case 5:
76927                     return writeBreakWhenFalse(args[0], args[1], location);
76928                 case 6:
76929                     return writeYield(args[0], location);
76930                 case 7:
76931                     return writeYieldStar(args[0], location);
76932                 case 8:
76933                     return writeReturn(args[0], location);
76934                 case 9:
76935                     return writeThrow(args[0], location);
76936             }
76937         }
76938         function writeStatement(statement) {
76939             if (statement) {
76940                 if (!statements) {
76941                     statements = [statement];
76942                 }
76943                 else {
76944                     statements.push(statement);
76945                 }
76946             }
76947         }
76948         function writeAssign(left, right, operationLocation) {
76949             writeStatement(ts.setTextRange(factory.createExpressionStatement(factory.createAssignment(left, right)), operationLocation));
76950         }
76951         function writeThrow(expression, operationLocation) {
76952             lastOperationWasAbrupt = true;
76953             lastOperationWasCompletion = true;
76954             writeStatement(ts.setTextRange(factory.createThrowStatement(expression), operationLocation));
76955         }
76956         function writeReturn(expression, operationLocation) {
76957             lastOperationWasAbrupt = true;
76958             lastOperationWasCompletion = true;
76959             writeStatement(ts.setEmitFlags(ts.setTextRange(factory.createReturnStatement(factory.createArrayLiteralExpression(expression
76960                 ? [createInstruction(2), expression]
76961                 : [createInstruction(2)])), operationLocation), 384));
76962         }
76963         function writeBreak(label, operationLocation) {
76964             lastOperationWasAbrupt = true;
76965             writeStatement(ts.setEmitFlags(ts.setTextRange(factory.createReturnStatement(factory.createArrayLiteralExpression([
76966                 createInstruction(3),
76967                 createLabel(label)
76968             ])), operationLocation), 384));
76969         }
76970         function writeBreakWhenTrue(label, condition, operationLocation) {
76971             writeStatement(ts.setEmitFlags(factory.createIfStatement(condition, ts.setEmitFlags(ts.setTextRange(factory.createReturnStatement(factory.createArrayLiteralExpression([
76972                 createInstruction(3),
76973                 createLabel(label)
76974             ])), operationLocation), 384)), 1));
76975         }
76976         function writeBreakWhenFalse(label, condition, operationLocation) {
76977             writeStatement(ts.setEmitFlags(factory.createIfStatement(factory.createLogicalNot(condition), ts.setEmitFlags(ts.setTextRange(factory.createReturnStatement(factory.createArrayLiteralExpression([
76978                 createInstruction(3),
76979                 createLabel(label)
76980             ])), operationLocation), 384)), 1));
76981         }
76982         function writeYield(expression, operationLocation) {
76983             lastOperationWasAbrupt = true;
76984             writeStatement(ts.setEmitFlags(ts.setTextRange(factory.createReturnStatement(factory.createArrayLiteralExpression(expression
76985                 ? [createInstruction(4), expression]
76986                 : [createInstruction(4)])), operationLocation), 384));
76987         }
76988         function writeYieldStar(expression, operationLocation) {
76989             lastOperationWasAbrupt = true;
76990             writeStatement(ts.setEmitFlags(ts.setTextRange(factory.createReturnStatement(factory.createArrayLiteralExpression([
76991                 createInstruction(5),
76992                 expression
76993             ])), operationLocation), 384));
76994         }
76995         function writeEndfinally() {
76996             lastOperationWasAbrupt = true;
76997             writeStatement(factory.createReturnStatement(factory.createArrayLiteralExpression([
76998                 createInstruction(7)
76999             ])));
77000         }
77001     }
77002     ts.transformGenerators = transformGenerators;
77003 })(ts || (ts = {}));
77004 var ts;
77005 (function (ts) {
77006     function transformModule(context) {
77007         function getTransformModuleDelegate(moduleKind) {
77008             switch (moduleKind) {
77009                 case ts.ModuleKind.AMD: return transformAMDModule;
77010                 case ts.ModuleKind.UMD: return transformUMDModule;
77011                 default: return transformCommonJSModule;
77012             }
77013         }
77014         var factory = context.factory, emitHelpers = context.getEmitHelperFactory, startLexicalEnvironment = context.startLexicalEnvironment, endLexicalEnvironment = context.endLexicalEnvironment, hoistVariableDeclaration = context.hoistVariableDeclaration;
77015         var compilerOptions = context.getCompilerOptions();
77016         var resolver = context.getEmitResolver();
77017         var host = context.getEmitHost();
77018         var languageVersion = ts.getEmitScriptTarget(compilerOptions);
77019         var moduleKind = ts.getEmitModuleKind(compilerOptions);
77020         var previousOnSubstituteNode = context.onSubstituteNode;
77021         var previousOnEmitNode = context.onEmitNode;
77022         context.onSubstituteNode = onSubstituteNode;
77023         context.onEmitNode = onEmitNode;
77024         context.enableSubstitution(78);
77025         context.enableSubstitution(216);
77026         context.enableSubstitution(214);
77027         context.enableSubstitution(215);
77028         context.enableSubstitution(289);
77029         context.enableEmitNotification(297);
77030         var moduleInfoMap = [];
77031         var deferredExports = [];
77032         var currentSourceFile;
77033         var currentModuleInfo;
77034         var noSubstitution;
77035         var needUMDDynamicImportHelper;
77036         return ts.chainBundle(context, transformSourceFile);
77037         function transformSourceFile(node) {
77038             if (node.isDeclarationFile ||
77039                 !(ts.isEffectiveExternalModule(node, compilerOptions) ||
77040                     node.transformFlags & 2097152 ||
77041                     (ts.isJsonSourceFile(node) && ts.hasJsonModuleEmitEnabled(compilerOptions) && ts.outFile(compilerOptions)))) {
77042                 return node;
77043             }
77044             currentSourceFile = node;
77045             currentModuleInfo = ts.collectExternalModuleInfo(context, node, resolver, compilerOptions);
77046             moduleInfoMap[ts.getOriginalNodeId(node)] = currentModuleInfo;
77047             var transformModule = getTransformModuleDelegate(moduleKind);
77048             var updated = transformModule(node);
77049             currentSourceFile = undefined;
77050             currentModuleInfo = undefined;
77051             needUMDDynamicImportHelper = false;
77052             return updated;
77053         }
77054         function shouldEmitUnderscoreUnderscoreESModule() {
77055             if (!currentModuleInfo.exportEquals && ts.isExternalModule(currentSourceFile)) {
77056                 return true;
77057             }
77058             return false;
77059         }
77060         function transformCommonJSModule(node) {
77061             startLexicalEnvironment();
77062             var statements = [];
77063             var ensureUseStrict = ts.getStrictOptionValue(compilerOptions, "alwaysStrict") || (!compilerOptions.noImplicitUseStrict && ts.isExternalModule(currentSourceFile));
77064             var statementOffset = factory.copyPrologue(node.statements, statements, ensureUseStrict && !ts.isJsonSourceFile(node), sourceElementVisitor);
77065             if (shouldEmitUnderscoreUnderscoreESModule()) {
77066                 ts.append(statements, createUnderscoreUnderscoreESModule());
77067             }
77068             if (ts.length(currentModuleInfo.exportedNames)) {
77069                 var chunkSize = 50;
77070                 for (var i = 0; i < currentModuleInfo.exportedNames.length; i += chunkSize) {
77071                     ts.append(statements, factory.createExpressionStatement(ts.reduceLeft(currentModuleInfo.exportedNames.slice(i, i + chunkSize), function (prev, nextId) { return factory.createAssignment(factory.createPropertyAccessExpression(factory.createIdentifier("exports"), factory.createIdentifier(ts.idText(nextId))), prev); }, factory.createVoidZero())));
77072                 }
77073             }
77074             ts.append(statements, ts.visitNode(currentModuleInfo.externalHelpersImportDeclaration, sourceElementVisitor, ts.isStatement));
77075             ts.addRange(statements, ts.visitNodes(node.statements, sourceElementVisitor, ts.isStatement, statementOffset));
77076             addExportEqualsIfNeeded(statements, false);
77077             ts.insertStatementsAfterStandardPrologue(statements, endLexicalEnvironment());
77078             var updated = factory.updateSourceFile(node, ts.setTextRange(factory.createNodeArray(statements), node.statements));
77079             ts.addEmitHelpers(updated, context.readEmitHelpers());
77080             return updated;
77081         }
77082         function transformAMDModule(node) {
77083             var define = factory.createIdentifier("define");
77084             var moduleName = ts.tryGetModuleNameFromFile(factory, node, host, compilerOptions);
77085             var jsonSourceFile = ts.isJsonSourceFile(node) && node;
77086             var _a = collectAsynchronousDependencies(node, true), aliasedModuleNames = _a.aliasedModuleNames, unaliasedModuleNames = _a.unaliasedModuleNames, importAliasNames = _a.importAliasNames;
77087             var updated = factory.updateSourceFile(node, ts.setTextRange(factory.createNodeArray([
77088                 factory.createExpressionStatement(factory.createCallExpression(define, undefined, __spreadArrays((moduleName ? [moduleName] : []), [
77089                     factory.createArrayLiteralExpression(jsonSourceFile ? ts.emptyArray : __spreadArrays([
77090                         factory.createStringLiteral("require"),
77091                         factory.createStringLiteral("exports")
77092                     ], aliasedModuleNames, unaliasedModuleNames)),
77093                     jsonSourceFile ?
77094                         jsonSourceFile.statements.length ? jsonSourceFile.statements[0].expression : factory.createObjectLiteralExpression() :
77095                         factory.createFunctionExpression(undefined, undefined, undefined, undefined, __spreadArrays([
77096                             factory.createParameterDeclaration(undefined, undefined, undefined, "require"),
77097                             factory.createParameterDeclaration(undefined, undefined, undefined, "exports")
77098                         ], importAliasNames), undefined, transformAsynchronousModuleBody(node))
77099                 ])))
77100             ]), node.statements));
77101             ts.addEmitHelpers(updated, context.readEmitHelpers());
77102             return updated;
77103         }
77104         function transformUMDModule(node) {
77105             var _a = collectAsynchronousDependencies(node, false), aliasedModuleNames = _a.aliasedModuleNames, unaliasedModuleNames = _a.unaliasedModuleNames, importAliasNames = _a.importAliasNames;
77106             var moduleName = ts.tryGetModuleNameFromFile(factory, node, host, compilerOptions);
77107             var umdHeader = factory.createFunctionExpression(undefined, undefined, undefined, undefined, [factory.createParameterDeclaration(undefined, undefined, undefined, "factory")], undefined, ts.setTextRange(factory.createBlock([
77108                 factory.createIfStatement(factory.createLogicalAnd(factory.createTypeCheck(factory.createIdentifier("module"), "object"), factory.createTypeCheck(factory.createPropertyAccessExpression(factory.createIdentifier("module"), "exports"), "object")), factory.createBlock([
77109                     factory.createVariableStatement(undefined, [
77110                         factory.createVariableDeclaration("v", undefined, undefined, factory.createCallExpression(factory.createIdentifier("factory"), undefined, [
77111                             factory.createIdentifier("require"),
77112                             factory.createIdentifier("exports")
77113                         ]))
77114                     ]),
77115                     ts.setEmitFlags(factory.createIfStatement(factory.createStrictInequality(factory.createIdentifier("v"), factory.createIdentifier("undefined")), factory.createExpressionStatement(factory.createAssignment(factory.createPropertyAccessExpression(factory.createIdentifier("module"), "exports"), factory.createIdentifier("v")))), 1)
77116                 ]), factory.createIfStatement(factory.createLogicalAnd(factory.createTypeCheck(factory.createIdentifier("define"), "function"), factory.createPropertyAccessExpression(factory.createIdentifier("define"), "amd")), factory.createBlock([
77117                     factory.createExpressionStatement(factory.createCallExpression(factory.createIdentifier("define"), undefined, __spreadArrays((moduleName ? [moduleName] : []), [
77118                         factory.createArrayLiteralExpression(__spreadArrays([
77119                             factory.createStringLiteral("require"),
77120                             factory.createStringLiteral("exports")
77121                         ], aliasedModuleNames, unaliasedModuleNames)),
77122                         factory.createIdentifier("factory")
77123                     ])))
77124                 ])))
77125             ], true), undefined));
77126             var updated = factory.updateSourceFile(node, ts.setTextRange(factory.createNodeArray([
77127                 factory.createExpressionStatement(factory.createCallExpression(umdHeader, undefined, [
77128                     factory.createFunctionExpression(undefined, undefined, undefined, undefined, __spreadArrays([
77129                         factory.createParameterDeclaration(undefined, undefined, undefined, "require"),
77130                         factory.createParameterDeclaration(undefined, undefined, undefined, "exports")
77131                     ], importAliasNames), undefined, transformAsynchronousModuleBody(node))
77132                 ]))
77133             ]), node.statements));
77134             ts.addEmitHelpers(updated, context.readEmitHelpers());
77135             return updated;
77136         }
77137         function collectAsynchronousDependencies(node, includeNonAmdDependencies) {
77138             var aliasedModuleNames = [];
77139             var unaliasedModuleNames = [];
77140             var importAliasNames = [];
77141             for (var _i = 0, _a = node.amdDependencies; _i < _a.length; _i++) {
77142                 var amdDependency = _a[_i];
77143                 if (amdDependency.name) {
77144                     aliasedModuleNames.push(factory.createStringLiteral(amdDependency.path));
77145                     importAliasNames.push(factory.createParameterDeclaration(undefined, undefined, undefined, amdDependency.name));
77146                 }
77147                 else {
77148                     unaliasedModuleNames.push(factory.createStringLiteral(amdDependency.path));
77149                 }
77150             }
77151             for (var _b = 0, _c = currentModuleInfo.externalImports; _b < _c.length; _b++) {
77152                 var importNode = _c[_b];
77153                 var externalModuleName = ts.getExternalModuleNameLiteral(factory, importNode, currentSourceFile, host, resolver, compilerOptions);
77154                 var importAliasName = ts.getLocalNameForExternalImport(factory, importNode, currentSourceFile);
77155                 if (externalModuleName) {
77156                     if (includeNonAmdDependencies && importAliasName) {
77157                         ts.setEmitFlags(importAliasName, 4);
77158                         aliasedModuleNames.push(externalModuleName);
77159                         importAliasNames.push(factory.createParameterDeclaration(undefined, undefined, undefined, importAliasName));
77160                     }
77161                     else {
77162                         unaliasedModuleNames.push(externalModuleName);
77163                     }
77164                 }
77165             }
77166             return { aliasedModuleNames: aliasedModuleNames, unaliasedModuleNames: unaliasedModuleNames, importAliasNames: importAliasNames };
77167         }
77168         function getAMDImportExpressionForImport(node) {
77169             if (ts.isImportEqualsDeclaration(node) || ts.isExportDeclaration(node) || !ts.getExternalModuleNameLiteral(factory, node, currentSourceFile, host, resolver, compilerOptions)) {
77170                 return undefined;
77171             }
77172             var name = ts.getLocalNameForExternalImport(factory, node, currentSourceFile);
77173             var expr = getHelperExpressionForImport(node, name);
77174             if (expr === name) {
77175                 return undefined;
77176             }
77177             return factory.createExpressionStatement(factory.createAssignment(name, expr));
77178         }
77179         function transformAsynchronousModuleBody(node) {
77180             startLexicalEnvironment();
77181             var statements = [];
77182             var statementOffset = factory.copyPrologue(node.statements, statements, !compilerOptions.noImplicitUseStrict, sourceElementVisitor);
77183             if (shouldEmitUnderscoreUnderscoreESModule()) {
77184                 ts.append(statements, createUnderscoreUnderscoreESModule());
77185             }
77186             if (ts.length(currentModuleInfo.exportedNames)) {
77187                 ts.append(statements, factory.createExpressionStatement(ts.reduceLeft(currentModuleInfo.exportedNames, function (prev, nextId) { return factory.createAssignment(factory.createPropertyAccessExpression(factory.createIdentifier("exports"), factory.createIdentifier(ts.idText(nextId))), prev); }, factory.createVoidZero())));
77188             }
77189             ts.append(statements, ts.visitNode(currentModuleInfo.externalHelpersImportDeclaration, sourceElementVisitor, ts.isStatement));
77190             if (moduleKind === ts.ModuleKind.AMD) {
77191                 ts.addRange(statements, ts.mapDefined(currentModuleInfo.externalImports, getAMDImportExpressionForImport));
77192             }
77193             ts.addRange(statements, ts.visitNodes(node.statements, sourceElementVisitor, ts.isStatement, statementOffset));
77194             addExportEqualsIfNeeded(statements, true);
77195             ts.insertStatementsAfterStandardPrologue(statements, endLexicalEnvironment());
77196             var body = factory.createBlock(statements, true);
77197             if (needUMDDynamicImportHelper) {
77198                 ts.addEmitHelper(body, dynamicImportUMDHelper);
77199             }
77200             return body;
77201         }
77202         function addExportEqualsIfNeeded(statements, emitAsReturn) {
77203             if (currentModuleInfo.exportEquals) {
77204                 var expressionResult = ts.visitNode(currentModuleInfo.exportEquals.expression, moduleExpressionElementVisitor);
77205                 if (expressionResult) {
77206                     if (emitAsReturn) {
77207                         var statement = factory.createReturnStatement(expressionResult);
77208                         ts.setTextRange(statement, currentModuleInfo.exportEquals);
77209                         ts.setEmitFlags(statement, 384 | 1536);
77210                         statements.push(statement);
77211                     }
77212                     else {
77213                         var statement = factory.createExpressionStatement(factory.createAssignment(factory.createPropertyAccessExpression(factory.createIdentifier("module"), "exports"), expressionResult));
77214                         ts.setTextRange(statement, currentModuleInfo.exportEquals);
77215                         ts.setEmitFlags(statement, 1536);
77216                         statements.push(statement);
77217                     }
77218                 }
77219             }
77220         }
77221         function sourceElementVisitor(node) {
77222             switch (node.kind) {
77223                 case 261:
77224                     return visitImportDeclaration(node);
77225                 case 260:
77226                     return visitImportEqualsDeclaration(node);
77227                 case 267:
77228                     return visitExportDeclaration(node);
77229                 case 266:
77230                     return visitExportAssignment(node);
77231                 case 232:
77232                     return visitVariableStatement(node);
77233                 case 251:
77234                     return visitFunctionDeclaration(node);
77235                 case 252:
77236                     return visitClassDeclaration(node);
77237                 case 338:
77238                     return visitMergeDeclarationMarker(node);
77239                 case 339:
77240                     return visitEndOfDeclarationMarker(node);
77241                 default:
77242                     return ts.visitEachChild(node, moduleExpressionElementVisitor, context);
77243             }
77244         }
77245         function moduleExpressionElementVisitor(node) {
77246             if (!(node.transformFlags & 2097152) && !(node.transformFlags & 1024)) {
77247                 return node;
77248             }
77249             if (ts.isImportCall(node)) {
77250                 return visitImportCallExpression(node);
77251             }
77252             else if (ts.isDestructuringAssignment(node)) {
77253                 return visitDestructuringAssignment(node);
77254             }
77255             else {
77256                 return ts.visitEachChild(node, moduleExpressionElementVisitor, context);
77257             }
77258         }
77259         function destructuringNeedsFlattening(node) {
77260             if (ts.isObjectLiteralExpression(node)) {
77261                 for (var _i = 0, _a = node.properties; _i < _a.length; _i++) {
77262                     var elem = _a[_i];
77263                     switch (elem.kind) {
77264                         case 288:
77265                             if (destructuringNeedsFlattening(elem.initializer)) {
77266                                 return true;
77267                             }
77268                             break;
77269                         case 289:
77270                             if (destructuringNeedsFlattening(elem.name)) {
77271                                 return true;
77272                             }
77273                             break;
77274                         case 290:
77275                             if (destructuringNeedsFlattening(elem.expression)) {
77276                                 return true;
77277                             }
77278                             break;
77279                         case 165:
77280                         case 167:
77281                         case 168:
77282                             return false;
77283                         default: ts.Debug.assertNever(elem, "Unhandled object member kind");
77284                     }
77285                 }
77286             }
77287             else if (ts.isArrayLiteralExpression(node)) {
77288                 for (var _b = 0, _c = node.elements; _b < _c.length; _b++) {
77289                     var elem = _c[_b];
77290                     if (ts.isSpreadElement(elem)) {
77291                         if (destructuringNeedsFlattening(elem.expression)) {
77292                             return true;
77293                         }
77294                     }
77295                     else if (destructuringNeedsFlattening(elem)) {
77296                         return true;
77297                     }
77298                 }
77299             }
77300             else if (ts.isIdentifier(node)) {
77301                 return ts.length(getExports(node)) > (ts.isExportName(node) ? 1 : 0);
77302             }
77303             return false;
77304         }
77305         function visitDestructuringAssignment(node) {
77306             if (destructuringNeedsFlattening(node.left)) {
77307                 return ts.flattenDestructuringAssignment(node, moduleExpressionElementVisitor, context, 0, false, createAllExportExpressions);
77308             }
77309             return ts.visitEachChild(node, moduleExpressionElementVisitor, context);
77310         }
77311         function visitImportCallExpression(node) {
77312             var argument = ts.visitNode(ts.firstOrUndefined(node.arguments), moduleExpressionElementVisitor);
77313             var containsLexicalThis = !!(node.transformFlags & 4096);
77314             switch (compilerOptions.module) {
77315                 case ts.ModuleKind.AMD:
77316                     return createImportCallExpressionAMD(argument, containsLexicalThis);
77317                 case ts.ModuleKind.UMD:
77318                     return createImportCallExpressionUMD(argument !== null && argument !== void 0 ? argument : factory.createVoidZero(), containsLexicalThis);
77319                 case ts.ModuleKind.CommonJS:
77320                 default:
77321                     return createImportCallExpressionCommonJS(argument, containsLexicalThis);
77322             }
77323         }
77324         function createImportCallExpressionUMD(arg, containsLexicalThis) {
77325             needUMDDynamicImportHelper = true;
77326             if (ts.isSimpleCopiableExpression(arg)) {
77327                 var argClone = ts.isGeneratedIdentifier(arg) ? arg : ts.isStringLiteral(arg) ? factory.createStringLiteralFromNode(arg) : ts.setEmitFlags(ts.setTextRange(factory.cloneNode(arg), arg), 1536);
77328                 return factory.createConditionalExpression(factory.createIdentifier("__syncRequire"), undefined, createImportCallExpressionCommonJS(arg, containsLexicalThis), undefined, createImportCallExpressionAMD(argClone, containsLexicalThis));
77329             }
77330             else {
77331                 var temp = factory.createTempVariable(hoistVariableDeclaration);
77332                 return factory.createComma(factory.createAssignment(temp, arg), factory.createConditionalExpression(factory.createIdentifier("__syncRequire"), undefined, createImportCallExpressionCommonJS(temp, containsLexicalThis), undefined, createImportCallExpressionAMD(temp, containsLexicalThis)));
77333             }
77334         }
77335         function createImportCallExpressionAMD(arg, containsLexicalThis) {
77336             var resolve = factory.createUniqueName("resolve");
77337             var reject = factory.createUniqueName("reject");
77338             var parameters = [
77339                 factory.createParameterDeclaration(undefined, undefined, undefined, resolve),
77340                 factory.createParameterDeclaration(undefined, undefined, undefined, reject)
77341             ];
77342             var body = factory.createBlock([
77343                 factory.createExpressionStatement(factory.createCallExpression(factory.createIdentifier("require"), undefined, [factory.createArrayLiteralExpression([arg || factory.createOmittedExpression()]), resolve, reject]))
77344             ]);
77345             var func;
77346             if (languageVersion >= 2) {
77347                 func = factory.createArrowFunction(undefined, undefined, parameters, undefined, undefined, body);
77348             }
77349             else {
77350                 func = factory.createFunctionExpression(undefined, undefined, undefined, undefined, parameters, undefined, body);
77351                 if (containsLexicalThis) {
77352                     ts.setEmitFlags(func, 8);
77353                 }
77354             }
77355             var promise = factory.createNewExpression(factory.createIdentifier("Promise"), undefined, [func]);
77356             if (compilerOptions.esModuleInterop) {
77357                 return factory.createCallExpression(factory.createPropertyAccessExpression(promise, factory.createIdentifier("then")), undefined, [emitHelpers().createImportStarCallbackHelper()]);
77358             }
77359             return promise;
77360         }
77361         function createImportCallExpressionCommonJS(arg, containsLexicalThis) {
77362             var promiseResolveCall = factory.createCallExpression(factory.createPropertyAccessExpression(factory.createIdentifier("Promise"), "resolve"), undefined, []);
77363             var requireCall = factory.createCallExpression(factory.createIdentifier("require"), undefined, arg ? [arg] : []);
77364             if (compilerOptions.esModuleInterop) {
77365                 requireCall = emitHelpers().createImportStarHelper(requireCall);
77366             }
77367             var func;
77368             if (languageVersion >= 2) {
77369                 func = factory.createArrowFunction(undefined, undefined, [], undefined, undefined, requireCall);
77370             }
77371             else {
77372                 func = factory.createFunctionExpression(undefined, undefined, undefined, undefined, [], undefined, factory.createBlock([factory.createReturnStatement(requireCall)]));
77373                 if (containsLexicalThis) {
77374                     ts.setEmitFlags(func, 8);
77375                 }
77376             }
77377             return factory.createCallExpression(factory.createPropertyAccessExpression(promiseResolveCall, "then"), undefined, [func]);
77378         }
77379         function getHelperExpressionForExport(node, innerExpr) {
77380             if (!compilerOptions.esModuleInterop || ts.getEmitFlags(node) & 67108864) {
77381                 return innerExpr;
77382             }
77383             if (ts.getExportNeedsImportStarHelper(node)) {
77384                 return emitHelpers().createImportStarHelper(innerExpr);
77385             }
77386             return innerExpr;
77387         }
77388         function getHelperExpressionForImport(node, innerExpr) {
77389             if (!compilerOptions.esModuleInterop || ts.getEmitFlags(node) & 67108864) {
77390                 return innerExpr;
77391             }
77392             if (ts.getImportNeedsImportStarHelper(node)) {
77393                 return emitHelpers().createImportStarHelper(innerExpr);
77394             }
77395             if (ts.getImportNeedsImportDefaultHelper(node)) {
77396                 return emitHelpers().createImportDefaultHelper(innerExpr);
77397             }
77398             return innerExpr;
77399         }
77400         function visitImportDeclaration(node) {
77401             var statements;
77402             var namespaceDeclaration = ts.getNamespaceDeclarationNode(node);
77403             if (moduleKind !== ts.ModuleKind.AMD) {
77404                 if (!node.importClause) {
77405                     return ts.setOriginalNode(ts.setTextRange(factory.createExpressionStatement(createRequireCall(node)), node), node);
77406                 }
77407                 else {
77408                     var variables = [];
77409                     if (namespaceDeclaration && !ts.isDefaultImport(node)) {
77410                         variables.push(factory.createVariableDeclaration(factory.cloneNode(namespaceDeclaration.name), undefined, undefined, getHelperExpressionForImport(node, createRequireCall(node))));
77411                     }
77412                     else {
77413                         variables.push(factory.createVariableDeclaration(factory.getGeneratedNameForNode(node), undefined, undefined, getHelperExpressionForImport(node, createRequireCall(node))));
77414                         if (namespaceDeclaration && ts.isDefaultImport(node)) {
77415                             variables.push(factory.createVariableDeclaration(factory.cloneNode(namespaceDeclaration.name), undefined, undefined, factory.getGeneratedNameForNode(node)));
77416                         }
77417                     }
77418                     statements = ts.append(statements, ts.setOriginalNode(ts.setTextRange(factory.createVariableStatement(undefined, factory.createVariableDeclarationList(variables, languageVersion >= 2 ? 2 : 0)), node), node));
77419                 }
77420             }
77421             else if (namespaceDeclaration && ts.isDefaultImport(node)) {
77422                 statements = ts.append(statements, factory.createVariableStatement(undefined, factory.createVariableDeclarationList([
77423                     ts.setOriginalNode(ts.setTextRange(factory.createVariableDeclaration(factory.cloneNode(namespaceDeclaration.name), undefined, undefined, factory.getGeneratedNameForNode(node)), node), node)
77424                 ], languageVersion >= 2 ? 2 : 0)));
77425             }
77426             if (hasAssociatedEndOfDeclarationMarker(node)) {
77427                 var id = ts.getOriginalNodeId(node);
77428                 deferredExports[id] = appendExportsOfImportDeclaration(deferredExports[id], node);
77429             }
77430             else {
77431                 statements = appendExportsOfImportDeclaration(statements, node);
77432             }
77433             return ts.singleOrMany(statements);
77434         }
77435         function createRequireCall(importNode) {
77436             var moduleName = ts.getExternalModuleNameLiteral(factory, importNode, currentSourceFile, host, resolver, compilerOptions);
77437             var args = [];
77438             if (moduleName) {
77439                 args.push(moduleName);
77440             }
77441             return factory.createCallExpression(factory.createIdentifier("require"), undefined, args);
77442         }
77443         function visitImportEqualsDeclaration(node) {
77444             ts.Debug.assert(ts.isExternalModuleImportEqualsDeclaration(node), "import= for internal module references should be handled in an earlier transformer.");
77445             var statements;
77446             if (moduleKind !== ts.ModuleKind.AMD) {
77447                 if (ts.hasSyntacticModifier(node, 1)) {
77448                     statements = ts.append(statements, ts.setOriginalNode(ts.setTextRange(factory.createExpressionStatement(createExportExpression(node.name, createRequireCall(node))), node), node));
77449                 }
77450                 else {
77451                     statements = ts.append(statements, ts.setOriginalNode(ts.setTextRange(factory.createVariableStatement(undefined, factory.createVariableDeclarationList([
77452                         factory.createVariableDeclaration(factory.cloneNode(node.name), undefined, undefined, createRequireCall(node))
77453                     ], languageVersion >= 2 ? 2 : 0)), node), node));
77454                 }
77455             }
77456             else {
77457                 if (ts.hasSyntacticModifier(node, 1)) {
77458                     statements = ts.append(statements, ts.setOriginalNode(ts.setTextRange(factory.createExpressionStatement(createExportExpression(factory.getExportName(node), factory.getLocalName(node))), node), node));
77459                 }
77460             }
77461             if (hasAssociatedEndOfDeclarationMarker(node)) {
77462                 var id = ts.getOriginalNodeId(node);
77463                 deferredExports[id] = appendExportsOfImportEqualsDeclaration(deferredExports[id], node);
77464             }
77465             else {
77466                 statements = appendExportsOfImportEqualsDeclaration(statements, node);
77467             }
77468             return ts.singleOrMany(statements);
77469         }
77470         function visitExportDeclaration(node) {
77471             if (!node.moduleSpecifier) {
77472                 return undefined;
77473             }
77474             var generatedName = factory.getGeneratedNameForNode(node);
77475             if (node.exportClause && ts.isNamedExports(node.exportClause)) {
77476                 var statements = [];
77477                 if (moduleKind !== ts.ModuleKind.AMD) {
77478                     statements.push(ts.setOriginalNode(ts.setTextRange(factory.createVariableStatement(undefined, factory.createVariableDeclarationList([
77479                         factory.createVariableDeclaration(generatedName, undefined, undefined, createRequireCall(node))
77480                     ])), node), node));
77481                 }
77482                 for (var _i = 0, _a = node.exportClause.elements; _i < _a.length; _i++) {
77483                     var specifier = _a[_i];
77484                     if (languageVersion === 0) {
77485                         statements.push(ts.setOriginalNode(ts.setTextRange(factory.createExpressionStatement(emitHelpers().createCreateBindingHelper(generatedName, factory.createStringLiteralFromNode(specifier.propertyName || specifier.name), specifier.propertyName ? factory.createStringLiteralFromNode(specifier.name) : undefined)), specifier), specifier));
77486                     }
77487                     else {
77488                         var exportNeedsImportDefault = !!compilerOptions.esModuleInterop &&
77489                             !(ts.getEmitFlags(node) & 67108864) &&
77490                             ts.idText(specifier.propertyName || specifier.name) === "default";
77491                         var exportedValue = factory.createPropertyAccessExpression(exportNeedsImportDefault ? emitHelpers().createImportDefaultHelper(generatedName) : generatedName, specifier.propertyName || specifier.name);
77492                         statements.push(ts.setOriginalNode(ts.setTextRange(factory.createExpressionStatement(createExportExpression(factory.getExportName(specifier), exportedValue, undefined, true)), specifier), specifier));
77493                     }
77494                 }
77495                 return ts.singleOrMany(statements);
77496             }
77497             else if (node.exportClause) {
77498                 var statements = [];
77499                 statements.push(ts.setOriginalNode(ts.setTextRange(factory.createExpressionStatement(createExportExpression(factory.cloneNode(node.exportClause.name), getHelperExpressionForExport(node, moduleKind !== ts.ModuleKind.AMD ?
77500                     createRequireCall(node) :
77501                     ts.isExportNamespaceAsDefaultDeclaration(node) ? generatedName :
77502                         factory.createIdentifier(ts.idText(node.exportClause.name))))), node), node));
77503                 return ts.singleOrMany(statements);
77504             }
77505             else {
77506                 return ts.setOriginalNode(ts.setTextRange(factory.createExpressionStatement(emitHelpers().createExportStarHelper(moduleKind !== ts.ModuleKind.AMD ? createRequireCall(node) : generatedName)), node), node);
77507             }
77508         }
77509         function visitExportAssignment(node) {
77510             if (node.isExportEquals) {
77511                 return undefined;
77512             }
77513             var statements;
77514             var original = node.original;
77515             if (original && hasAssociatedEndOfDeclarationMarker(original)) {
77516                 var id = ts.getOriginalNodeId(node);
77517                 deferredExports[id] = appendExportStatement(deferredExports[id], factory.createIdentifier("default"), ts.visitNode(node.expression, moduleExpressionElementVisitor), node, true);
77518             }
77519             else {
77520                 statements = appendExportStatement(statements, factory.createIdentifier("default"), ts.visitNode(node.expression, moduleExpressionElementVisitor), node, true);
77521             }
77522             return ts.singleOrMany(statements);
77523         }
77524         function visitFunctionDeclaration(node) {
77525             var statements;
77526             if (ts.hasSyntacticModifier(node, 1)) {
77527                 statements = ts.append(statements, ts.setOriginalNode(ts.setTextRange(factory.createFunctionDeclaration(undefined, ts.visitNodes(node.modifiers, modifierVisitor, ts.isModifier), node.asteriskToken, factory.getDeclarationName(node, true, true), undefined, ts.visitNodes(node.parameters, moduleExpressionElementVisitor), undefined, ts.visitEachChild(node.body, moduleExpressionElementVisitor, context)), node), node));
77528             }
77529             else {
77530                 statements = ts.append(statements, ts.visitEachChild(node, moduleExpressionElementVisitor, context));
77531             }
77532             if (hasAssociatedEndOfDeclarationMarker(node)) {
77533                 var id = ts.getOriginalNodeId(node);
77534                 deferredExports[id] = appendExportsOfHoistedDeclaration(deferredExports[id], node);
77535             }
77536             else {
77537                 statements = appendExportsOfHoistedDeclaration(statements, node);
77538             }
77539             return ts.singleOrMany(statements);
77540         }
77541         function visitClassDeclaration(node) {
77542             var statements;
77543             if (ts.hasSyntacticModifier(node, 1)) {
77544                 statements = ts.append(statements, ts.setOriginalNode(ts.setTextRange(factory.createClassDeclaration(undefined, ts.visitNodes(node.modifiers, modifierVisitor, ts.isModifier), factory.getDeclarationName(node, true, true), undefined, ts.visitNodes(node.heritageClauses, moduleExpressionElementVisitor), ts.visitNodes(node.members, moduleExpressionElementVisitor)), node), node));
77545             }
77546             else {
77547                 statements = ts.append(statements, ts.visitEachChild(node, moduleExpressionElementVisitor, context));
77548             }
77549             if (hasAssociatedEndOfDeclarationMarker(node)) {
77550                 var id = ts.getOriginalNodeId(node);
77551                 deferredExports[id] = appendExportsOfHoistedDeclaration(deferredExports[id], node);
77552             }
77553             else {
77554                 statements = appendExportsOfHoistedDeclaration(statements, node);
77555             }
77556             return ts.singleOrMany(statements);
77557         }
77558         function visitVariableStatement(node) {
77559             var statements;
77560             var variables;
77561             var expressions;
77562             if (ts.hasSyntacticModifier(node, 1)) {
77563                 var modifiers = void 0;
77564                 var removeCommentsOnExpressions = false;
77565                 for (var _i = 0, _a = node.declarationList.declarations; _i < _a.length; _i++) {
77566                     var variable = _a[_i];
77567                     if (ts.isIdentifier(variable.name) && ts.isLocalName(variable.name)) {
77568                         if (!modifiers) {
77569                             modifiers = ts.visitNodes(node.modifiers, modifierVisitor, ts.isModifier);
77570                         }
77571                         variables = ts.append(variables, variable);
77572                     }
77573                     else if (variable.initializer) {
77574                         if (!ts.isBindingPattern(variable.name) && (ts.isArrowFunction(variable.initializer) || ts.isFunctionExpression(variable.initializer) || ts.isClassExpression(variable.initializer))) {
77575                             var expression = factory.createAssignment(ts.setTextRange(factory.createPropertyAccessExpression(factory.createIdentifier("exports"), variable.name), variable.name), factory.createIdentifier(ts.getTextOfIdentifierOrLiteral(variable.name)));
77576                             var updatedVariable = factory.createVariableDeclaration(variable.name, variable.exclamationToken, variable.type, ts.visitNode(variable.initializer, moduleExpressionElementVisitor));
77577                             variables = ts.append(variables, updatedVariable);
77578                             expressions = ts.append(expressions, expression);
77579                             removeCommentsOnExpressions = true;
77580                         }
77581                         else {
77582                             expressions = ts.append(expressions, transformInitializedVariable(variable));
77583                         }
77584                     }
77585                 }
77586                 if (variables) {
77587                     statements = ts.append(statements, factory.updateVariableStatement(node, modifiers, factory.updateVariableDeclarationList(node.declarationList, variables)));
77588                 }
77589                 if (expressions) {
77590                     var statement = ts.setOriginalNode(ts.setTextRange(factory.createExpressionStatement(factory.inlineExpressions(expressions)), node), node);
77591                     if (removeCommentsOnExpressions) {
77592                         ts.removeAllComments(statement);
77593                     }
77594                     statements = ts.append(statements, statement);
77595                 }
77596             }
77597             else {
77598                 statements = ts.append(statements, ts.visitEachChild(node, moduleExpressionElementVisitor, context));
77599             }
77600             if (hasAssociatedEndOfDeclarationMarker(node)) {
77601                 var id = ts.getOriginalNodeId(node);
77602                 deferredExports[id] = appendExportsOfVariableStatement(deferredExports[id], node);
77603             }
77604             else {
77605                 statements = appendExportsOfVariableStatement(statements, node);
77606             }
77607             return ts.singleOrMany(statements);
77608         }
77609         function createAllExportExpressions(name, value, location) {
77610             var exportedNames = getExports(name);
77611             if (exportedNames) {
77612                 var expression = ts.isExportName(name) ? value : factory.createAssignment(name, value);
77613                 for (var _i = 0, exportedNames_1 = exportedNames; _i < exportedNames_1.length; _i++) {
77614                     var exportName = exportedNames_1[_i];
77615                     ts.setEmitFlags(expression, 4);
77616                     expression = createExportExpression(exportName, expression, location);
77617                 }
77618                 return expression;
77619             }
77620             return factory.createAssignment(name, value);
77621         }
77622         function transformInitializedVariable(node) {
77623             if (ts.isBindingPattern(node.name)) {
77624                 return ts.flattenDestructuringAssignment(ts.visitNode(node, moduleExpressionElementVisitor), undefined, context, 0, false, createAllExportExpressions);
77625             }
77626             else {
77627                 return factory.createAssignment(ts.setTextRange(factory.createPropertyAccessExpression(factory.createIdentifier("exports"), node.name), node.name), node.initializer ? ts.visitNode(node.initializer, moduleExpressionElementVisitor) : factory.createVoidZero());
77628             }
77629         }
77630         function visitMergeDeclarationMarker(node) {
77631             if (hasAssociatedEndOfDeclarationMarker(node) && node.original.kind === 232) {
77632                 var id = ts.getOriginalNodeId(node);
77633                 deferredExports[id] = appendExportsOfVariableStatement(deferredExports[id], node.original);
77634             }
77635             return node;
77636         }
77637         function hasAssociatedEndOfDeclarationMarker(node) {
77638             return (ts.getEmitFlags(node) & 4194304) !== 0;
77639         }
77640         function visitEndOfDeclarationMarker(node) {
77641             var id = ts.getOriginalNodeId(node);
77642             var statements = deferredExports[id];
77643             if (statements) {
77644                 delete deferredExports[id];
77645                 return ts.append(statements, node);
77646             }
77647             return node;
77648         }
77649         function appendExportsOfImportDeclaration(statements, decl) {
77650             if (currentModuleInfo.exportEquals) {
77651                 return statements;
77652             }
77653             var importClause = decl.importClause;
77654             if (!importClause) {
77655                 return statements;
77656             }
77657             if (importClause.name) {
77658                 statements = appendExportsOfDeclaration(statements, importClause);
77659             }
77660             var namedBindings = importClause.namedBindings;
77661             if (namedBindings) {
77662                 switch (namedBindings.kind) {
77663                     case 263:
77664                         statements = appendExportsOfDeclaration(statements, namedBindings);
77665                         break;
77666                     case 264:
77667                         for (var _i = 0, _a = namedBindings.elements; _i < _a.length; _i++) {
77668                             var importBinding = _a[_i];
77669                             statements = appendExportsOfDeclaration(statements, importBinding, true);
77670                         }
77671                         break;
77672                 }
77673             }
77674             return statements;
77675         }
77676         function appendExportsOfImportEqualsDeclaration(statements, decl) {
77677             if (currentModuleInfo.exportEquals) {
77678                 return statements;
77679             }
77680             return appendExportsOfDeclaration(statements, decl);
77681         }
77682         function appendExportsOfVariableStatement(statements, node) {
77683             if (currentModuleInfo.exportEquals) {
77684                 return statements;
77685             }
77686             for (var _i = 0, _a = node.declarationList.declarations; _i < _a.length; _i++) {
77687                 var decl = _a[_i];
77688                 statements = appendExportsOfBindingElement(statements, decl);
77689             }
77690             return statements;
77691         }
77692         function appendExportsOfBindingElement(statements, decl) {
77693             if (currentModuleInfo.exportEquals) {
77694                 return statements;
77695             }
77696             if (ts.isBindingPattern(decl.name)) {
77697                 for (var _i = 0, _a = decl.name.elements; _i < _a.length; _i++) {
77698                     var element = _a[_i];
77699                     if (!ts.isOmittedExpression(element)) {
77700                         statements = appendExportsOfBindingElement(statements, element);
77701                     }
77702                 }
77703             }
77704             else if (!ts.isGeneratedIdentifier(decl.name)) {
77705                 statements = appendExportsOfDeclaration(statements, decl);
77706             }
77707             return statements;
77708         }
77709         function appendExportsOfHoistedDeclaration(statements, decl) {
77710             if (currentModuleInfo.exportEquals) {
77711                 return statements;
77712             }
77713             if (ts.hasSyntacticModifier(decl, 1)) {
77714                 var exportName = ts.hasSyntacticModifier(decl, 512) ? factory.createIdentifier("default") : factory.getDeclarationName(decl);
77715                 statements = appendExportStatement(statements, exportName, factory.getLocalName(decl), decl);
77716             }
77717             if (decl.name) {
77718                 statements = appendExportsOfDeclaration(statements, decl);
77719             }
77720             return statements;
77721         }
77722         function appendExportsOfDeclaration(statements, decl, liveBinding) {
77723             var name = factory.getDeclarationName(decl);
77724             var exportSpecifiers = currentModuleInfo.exportSpecifiers.get(ts.idText(name));
77725             if (exportSpecifiers) {
77726                 for (var _i = 0, exportSpecifiers_1 = exportSpecifiers; _i < exportSpecifiers_1.length; _i++) {
77727                     var exportSpecifier = exportSpecifiers_1[_i];
77728                     statements = appendExportStatement(statements, exportSpecifier.name, name, exportSpecifier.name, undefined, liveBinding);
77729                 }
77730             }
77731             return statements;
77732         }
77733         function appendExportStatement(statements, exportName, expression, location, allowComments, liveBinding) {
77734             statements = ts.append(statements, createExportStatement(exportName, expression, location, allowComments, liveBinding));
77735             return statements;
77736         }
77737         function createUnderscoreUnderscoreESModule() {
77738             var statement;
77739             if (languageVersion === 0) {
77740                 statement = factory.createExpressionStatement(createExportExpression(factory.createIdentifier("__esModule"), factory.createTrue()));
77741             }
77742             else {
77743                 statement = factory.createExpressionStatement(factory.createCallExpression(factory.createPropertyAccessExpression(factory.createIdentifier("Object"), "defineProperty"), undefined, [
77744                     factory.createIdentifier("exports"),
77745                     factory.createStringLiteral("__esModule"),
77746                     factory.createObjectLiteralExpression([
77747                         factory.createPropertyAssignment("value", factory.createTrue())
77748                     ])
77749                 ]));
77750             }
77751             ts.setEmitFlags(statement, 1048576);
77752             return statement;
77753         }
77754         function createExportStatement(name, value, location, allowComments, liveBinding) {
77755             var statement = ts.setTextRange(factory.createExpressionStatement(createExportExpression(name, value, undefined, liveBinding)), location);
77756             ts.startOnNewLine(statement);
77757             if (!allowComments) {
77758                 ts.setEmitFlags(statement, 1536);
77759             }
77760             return statement;
77761         }
77762         function createExportExpression(name, value, location, liveBinding) {
77763             return ts.setTextRange(liveBinding && languageVersion !== 0 ? factory.createCallExpression(factory.createPropertyAccessExpression(factory.createIdentifier("Object"), "defineProperty"), undefined, [
77764                 factory.createIdentifier("exports"),
77765                 factory.createStringLiteralFromNode(name),
77766                 factory.createObjectLiteralExpression([
77767                     factory.createPropertyAssignment("enumerable", factory.createTrue()),
77768                     factory.createPropertyAssignment("get", factory.createFunctionExpression(undefined, undefined, undefined, undefined, [], undefined, factory.createBlock([factory.createReturnStatement(value)])))
77769                 ])
77770             ]) : factory.createAssignment(factory.createPropertyAccessExpression(factory.createIdentifier("exports"), factory.cloneNode(name)), value), location);
77771         }
77772         function modifierVisitor(node) {
77773             switch (node.kind) {
77774                 case 92:
77775                 case 87:
77776                     return undefined;
77777             }
77778             return node;
77779         }
77780         function onEmitNode(hint, node, emitCallback) {
77781             if (node.kind === 297) {
77782                 currentSourceFile = node;
77783                 currentModuleInfo = moduleInfoMap[ts.getOriginalNodeId(currentSourceFile)];
77784                 noSubstitution = [];
77785                 previousOnEmitNode(hint, node, emitCallback);
77786                 currentSourceFile = undefined;
77787                 currentModuleInfo = undefined;
77788                 noSubstitution = undefined;
77789             }
77790             else {
77791                 previousOnEmitNode(hint, node, emitCallback);
77792             }
77793         }
77794         function onSubstituteNode(hint, node) {
77795             node = previousOnSubstituteNode(hint, node);
77796             if (node.id && noSubstitution[node.id]) {
77797                 return node;
77798             }
77799             if (hint === 1) {
77800                 return substituteExpression(node);
77801             }
77802             else if (ts.isShorthandPropertyAssignment(node)) {
77803                 return substituteShorthandPropertyAssignment(node);
77804             }
77805             return node;
77806         }
77807         function substituteShorthandPropertyAssignment(node) {
77808             var name = node.name;
77809             var exportedOrImportedName = substituteExpressionIdentifier(name);
77810             if (exportedOrImportedName !== name) {
77811                 if (node.objectAssignmentInitializer) {
77812                     var initializer = factory.createAssignment(exportedOrImportedName, node.objectAssignmentInitializer);
77813                     return ts.setTextRange(factory.createPropertyAssignment(name, initializer), node);
77814                 }
77815                 return ts.setTextRange(factory.createPropertyAssignment(name, exportedOrImportedName), node);
77816             }
77817             return node;
77818         }
77819         function substituteExpression(node) {
77820             switch (node.kind) {
77821                 case 78:
77822                     return substituteExpressionIdentifier(node);
77823                 case 216:
77824                     return substituteBinaryExpression(node);
77825                 case 215:
77826                 case 214:
77827                     return substituteUnaryExpression(node);
77828             }
77829             return node;
77830         }
77831         function substituteExpressionIdentifier(node) {
77832             if (ts.getEmitFlags(node) & 4096) {
77833                 var externalHelpersModuleName = ts.getExternalHelpersModuleName(currentSourceFile);
77834                 if (externalHelpersModuleName) {
77835                     return factory.createPropertyAccessExpression(externalHelpersModuleName, node);
77836                 }
77837                 return node;
77838             }
77839             if (!(ts.isGeneratedIdentifier(node) && !(node.autoGenerateFlags & 64)) && !ts.isLocalName(node)) {
77840                 var exportContainer = resolver.getReferencedExportContainer(node, ts.isExportName(node));
77841                 if (exportContainer && exportContainer.kind === 297) {
77842                     return ts.setTextRange(factory.createPropertyAccessExpression(factory.createIdentifier("exports"), factory.cloneNode(node)), node);
77843                 }
77844                 var importDeclaration = resolver.getReferencedImportDeclaration(node);
77845                 if (importDeclaration) {
77846                     if (ts.isImportClause(importDeclaration)) {
77847                         return ts.setTextRange(factory.createPropertyAccessExpression(factory.getGeneratedNameForNode(importDeclaration.parent), factory.createIdentifier("default")), node);
77848                     }
77849                     else if (ts.isImportSpecifier(importDeclaration)) {
77850                         var name = importDeclaration.propertyName || importDeclaration.name;
77851                         return ts.setTextRange(factory.createPropertyAccessExpression(factory.getGeneratedNameForNode(importDeclaration.parent.parent.parent), factory.cloneNode(name)), node);
77852                     }
77853                 }
77854             }
77855             return node;
77856         }
77857         function substituteBinaryExpression(node) {
77858             if (ts.isAssignmentOperator(node.operatorToken.kind)
77859                 && ts.isIdentifier(node.left)
77860                 && !ts.isGeneratedIdentifier(node.left)
77861                 && !ts.isLocalName(node.left)
77862                 && !ts.isDeclarationNameOfEnumOrNamespace(node.left)) {
77863                 var exportedNames = getExports(node.left);
77864                 if (exportedNames) {
77865                     var expression = node;
77866                     for (var _i = 0, exportedNames_2 = exportedNames; _i < exportedNames_2.length; _i++) {
77867                         var exportName = exportedNames_2[_i];
77868                         noSubstitution[ts.getNodeId(expression)] = true;
77869                         expression = createExportExpression(exportName, expression, node);
77870                     }
77871                     return expression;
77872                 }
77873             }
77874             return node;
77875         }
77876         function substituteUnaryExpression(node) {
77877             if ((node.operator === 45 || node.operator === 46)
77878                 && ts.isIdentifier(node.operand)
77879                 && !ts.isGeneratedIdentifier(node.operand)
77880                 && !ts.isLocalName(node.operand)
77881                 && !ts.isDeclarationNameOfEnumOrNamespace(node.operand)) {
77882                 var exportedNames = getExports(node.operand);
77883                 if (exportedNames) {
77884                     var expression = node.kind === 215
77885                         ? ts.setTextRange(factory.createBinaryExpression(node.operand, factory.createToken(node.operator === 45 ? 63 : 64), factory.createNumericLiteral(1)), node)
77886                         : node;
77887                     for (var _i = 0, exportedNames_3 = exportedNames; _i < exportedNames_3.length; _i++) {
77888                         var exportName = exportedNames_3[_i];
77889                         noSubstitution[ts.getNodeId(expression)] = true;
77890                         expression = createExportExpression(exportName, expression);
77891                     }
77892                     return expression;
77893                 }
77894             }
77895             return node;
77896         }
77897         function getExports(name) {
77898             if (!ts.isGeneratedIdentifier(name)) {
77899                 var valueDeclaration = resolver.getReferencedImportDeclaration(name)
77900                     || resolver.getReferencedValueDeclaration(name);
77901                 if (valueDeclaration) {
77902                     return currentModuleInfo
77903                         && currentModuleInfo.exportedBindings[ts.getOriginalNodeId(valueDeclaration)];
77904                 }
77905             }
77906         }
77907     }
77908     ts.transformModule = transformModule;
77909     var dynamicImportUMDHelper = {
77910         name: "typescript:dynamicimport-sync-require",
77911         scoped: true,
77912         text: "\n            var __syncRequire = typeof module === \"object\" && typeof module.exports === \"object\";"
77913     };
77914 })(ts || (ts = {}));
77915 var ts;
77916 (function (ts) {
77917     function transformSystemModule(context) {
77918         var factory = context.factory, startLexicalEnvironment = context.startLexicalEnvironment, endLexicalEnvironment = context.endLexicalEnvironment, hoistVariableDeclaration = context.hoistVariableDeclaration;
77919         var compilerOptions = context.getCompilerOptions();
77920         var resolver = context.getEmitResolver();
77921         var host = context.getEmitHost();
77922         var previousOnSubstituteNode = context.onSubstituteNode;
77923         var previousOnEmitNode = context.onEmitNode;
77924         context.onSubstituteNode = onSubstituteNode;
77925         context.onEmitNode = onEmitNode;
77926         context.enableSubstitution(78);
77927         context.enableSubstitution(289);
77928         context.enableSubstitution(216);
77929         context.enableSubstitution(214);
77930         context.enableSubstitution(215);
77931         context.enableSubstitution(226);
77932         context.enableEmitNotification(297);
77933         var moduleInfoMap = [];
77934         var deferredExports = [];
77935         var exportFunctionsMap = [];
77936         var noSubstitutionMap = [];
77937         var contextObjectMap = [];
77938         var currentSourceFile;
77939         var moduleInfo;
77940         var exportFunction;
77941         var contextObject;
77942         var hoistedStatements;
77943         var enclosingBlockScopedContainer;
77944         var noSubstitution;
77945         return ts.chainBundle(context, transformSourceFile);
77946         function transformSourceFile(node) {
77947             if (node.isDeclarationFile || !(ts.isEffectiveExternalModule(node, compilerOptions) || node.transformFlags & 2097152)) {
77948                 return node;
77949             }
77950             var id = ts.getOriginalNodeId(node);
77951             currentSourceFile = node;
77952             enclosingBlockScopedContainer = node;
77953             moduleInfo = moduleInfoMap[id] = ts.collectExternalModuleInfo(context, node, resolver, compilerOptions);
77954             exportFunction = factory.createUniqueName("exports");
77955             exportFunctionsMap[id] = exportFunction;
77956             contextObject = contextObjectMap[id] = factory.createUniqueName("context");
77957             var dependencyGroups = collectDependencyGroups(moduleInfo.externalImports);
77958             var moduleBodyBlock = createSystemModuleBody(node, dependencyGroups);
77959             var moduleBodyFunction = factory.createFunctionExpression(undefined, undefined, undefined, undefined, [
77960                 factory.createParameterDeclaration(undefined, undefined, undefined, exportFunction),
77961                 factory.createParameterDeclaration(undefined, undefined, undefined, contextObject)
77962             ], undefined, moduleBodyBlock);
77963             var moduleName = ts.tryGetModuleNameFromFile(factory, node, host, compilerOptions);
77964             var dependencies = factory.createArrayLiteralExpression(ts.map(dependencyGroups, function (dependencyGroup) { return dependencyGroup.name; }));
77965             var updated = ts.setEmitFlags(factory.updateSourceFile(node, ts.setTextRange(factory.createNodeArray([
77966                 factory.createExpressionStatement(factory.createCallExpression(factory.createPropertyAccessExpression(factory.createIdentifier("System"), "register"), undefined, moduleName
77967                     ? [moduleName, dependencies, moduleBodyFunction]
77968                     : [dependencies, moduleBodyFunction]))
77969             ]), node.statements)), 1024);
77970             if (!ts.outFile(compilerOptions)) {
77971                 ts.moveEmitHelpers(updated, moduleBodyBlock, function (helper) { return !helper.scoped; });
77972             }
77973             if (noSubstitution) {
77974                 noSubstitutionMap[id] = noSubstitution;
77975                 noSubstitution = undefined;
77976             }
77977             currentSourceFile = undefined;
77978             moduleInfo = undefined;
77979             exportFunction = undefined;
77980             contextObject = undefined;
77981             hoistedStatements = undefined;
77982             enclosingBlockScopedContainer = undefined;
77983             return updated;
77984         }
77985         function collectDependencyGroups(externalImports) {
77986             var groupIndices = new ts.Map();
77987             var dependencyGroups = [];
77988             for (var _i = 0, externalImports_1 = externalImports; _i < externalImports_1.length; _i++) {
77989                 var externalImport = externalImports_1[_i];
77990                 var externalModuleName = ts.getExternalModuleNameLiteral(factory, externalImport, currentSourceFile, host, resolver, compilerOptions);
77991                 if (externalModuleName) {
77992                     var text = externalModuleName.text;
77993                     var groupIndex = groupIndices.get(text);
77994                     if (groupIndex !== undefined) {
77995                         dependencyGroups[groupIndex].externalImports.push(externalImport);
77996                     }
77997                     else {
77998                         groupIndices.set(text, dependencyGroups.length);
77999                         dependencyGroups.push({
78000                             name: externalModuleName,
78001                             externalImports: [externalImport]
78002                         });
78003                     }
78004                 }
78005             }
78006             return dependencyGroups;
78007         }
78008         function createSystemModuleBody(node, dependencyGroups) {
78009             var statements = [];
78010             startLexicalEnvironment();
78011             var ensureUseStrict = ts.getStrictOptionValue(compilerOptions, "alwaysStrict") || (!compilerOptions.noImplicitUseStrict && ts.isExternalModule(currentSourceFile));
78012             var statementOffset = factory.copyPrologue(node.statements, statements, ensureUseStrict, sourceElementVisitor);
78013             statements.push(factory.createVariableStatement(undefined, factory.createVariableDeclarationList([
78014                 factory.createVariableDeclaration("__moduleName", undefined, undefined, factory.createLogicalAnd(contextObject, factory.createPropertyAccessExpression(contextObject, "id")))
78015             ])));
78016             ts.visitNode(moduleInfo.externalHelpersImportDeclaration, sourceElementVisitor, ts.isStatement);
78017             var executeStatements = ts.visitNodes(node.statements, sourceElementVisitor, ts.isStatement, statementOffset);
78018             ts.addRange(statements, hoistedStatements);
78019             ts.insertStatementsAfterStandardPrologue(statements, endLexicalEnvironment());
78020             var exportStarFunction = addExportStarIfNeeded(statements);
78021             var modifiers = node.transformFlags & 524288 ?
78022                 factory.createModifiersFromModifierFlags(256) :
78023                 undefined;
78024             var moduleObject = factory.createObjectLiteralExpression([
78025                 factory.createPropertyAssignment("setters", createSettersArray(exportStarFunction, dependencyGroups)),
78026                 factory.createPropertyAssignment("execute", factory.createFunctionExpression(modifiers, undefined, undefined, undefined, [], undefined, factory.createBlock(executeStatements, true)))
78027             ], true);
78028             statements.push(factory.createReturnStatement(moduleObject));
78029             return factory.createBlock(statements, true);
78030         }
78031         function addExportStarIfNeeded(statements) {
78032             if (!moduleInfo.hasExportStarsToExportValues) {
78033                 return;
78034             }
78035             if (!moduleInfo.exportedNames && moduleInfo.exportSpecifiers.size === 0) {
78036                 var hasExportDeclarationWithExportClause = false;
78037                 for (var _i = 0, _a = moduleInfo.externalImports; _i < _a.length; _i++) {
78038                     var externalImport = _a[_i];
78039                     if (externalImport.kind === 267 && externalImport.exportClause) {
78040                         hasExportDeclarationWithExportClause = true;
78041                         break;
78042                     }
78043                 }
78044                 if (!hasExportDeclarationWithExportClause) {
78045                     var exportStarFunction_1 = createExportStarFunction(undefined);
78046                     statements.push(exportStarFunction_1);
78047                     return exportStarFunction_1.name;
78048                 }
78049             }
78050             var exportedNames = [];
78051             if (moduleInfo.exportedNames) {
78052                 for (var _b = 0, _c = moduleInfo.exportedNames; _b < _c.length; _b++) {
78053                     var exportedLocalName = _c[_b];
78054                     if (exportedLocalName.escapedText === "default") {
78055                         continue;
78056                     }
78057                     exportedNames.push(factory.createPropertyAssignment(factory.createStringLiteralFromNode(exportedLocalName), factory.createTrue()));
78058                 }
78059             }
78060             var exportedNamesStorageRef = factory.createUniqueName("exportedNames");
78061             statements.push(factory.createVariableStatement(undefined, factory.createVariableDeclarationList([
78062                 factory.createVariableDeclaration(exportedNamesStorageRef, undefined, undefined, factory.createObjectLiteralExpression(exportedNames, true))
78063             ])));
78064             var exportStarFunction = createExportStarFunction(exportedNamesStorageRef);
78065             statements.push(exportStarFunction);
78066             return exportStarFunction.name;
78067         }
78068         function createExportStarFunction(localNames) {
78069             var exportStarFunction = factory.createUniqueName("exportStar");
78070             var m = factory.createIdentifier("m");
78071             var n = factory.createIdentifier("n");
78072             var exports = factory.createIdentifier("exports");
78073             var condition = factory.createStrictInequality(n, factory.createStringLiteral("default"));
78074             if (localNames) {
78075                 condition = factory.createLogicalAnd(condition, factory.createLogicalNot(factory.createCallExpression(factory.createPropertyAccessExpression(localNames, "hasOwnProperty"), undefined, [n])));
78076             }
78077             return factory.createFunctionDeclaration(undefined, undefined, undefined, exportStarFunction, undefined, [factory.createParameterDeclaration(undefined, undefined, undefined, m)], undefined, factory.createBlock([
78078                 factory.createVariableStatement(undefined, factory.createVariableDeclarationList([
78079                     factory.createVariableDeclaration(exports, undefined, undefined, factory.createObjectLiteralExpression([]))
78080                 ])),
78081                 factory.createForInStatement(factory.createVariableDeclarationList([
78082                     factory.createVariableDeclaration(n)
78083                 ]), m, factory.createBlock([
78084                     ts.setEmitFlags(factory.createIfStatement(condition, factory.createExpressionStatement(factory.createAssignment(factory.createElementAccessExpression(exports, n), factory.createElementAccessExpression(m, n)))), 1)
78085                 ])),
78086                 factory.createExpressionStatement(factory.createCallExpression(exportFunction, undefined, [exports]))
78087             ], true));
78088         }
78089         function createSettersArray(exportStarFunction, dependencyGroups) {
78090             var setters = [];
78091             for (var _i = 0, dependencyGroups_1 = dependencyGroups; _i < dependencyGroups_1.length; _i++) {
78092                 var group_2 = dependencyGroups_1[_i];
78093                 var localName = ts.forEach(group_2.externalImports, function (i) { return ts.getLocalNameForExternalImport(factory, i, currentSourceFile); });
78094                 var parameterName = localName ? factory.getGeneratedNameForNode(localName) : factory.createUniqueName("");
78095                 var statements = [];
78096                 for (var _a = 0, _b = group_2.externalImports; _a < _b.length; _a++) {
78097                     var entry = _b[_a];
78098                     var importVariableName = ts.getLocalNameForExternalImport(factory, entry, currentSourceFile);
78099                     switch (entry.kind) {
78100                         case 261:
78101                             if (!entry.importClause) {
78102                                 break;
78103                             }
78104                         case 260:
78105                             ts.Debug.assert(importVariableName !== undefined);
78106                             statements.push(factory.createExpressionStatement(factory.createAssignment(importVariableName, parameterName)));
78107                             break;
78108                         case 267:
78109                             ts.Debug.assert(importVariableName !== undefined);
78110                             if (entry.exportClause) {
78111                                 if (ts.isNamedExports(entry.exportClause)) {
78112                                     var properties = [];
78113                                     for (var _c = 0, _d = entry.exportClause.elements; _c < _d.length; _c++) {
78114                                         var e = _d[_c];
78115                                         properties.push(factory.createPropertyAssignment(factory.createStringLiteral(ts.idText(e.name)), factory.createElementAccessExpression(parameterName, factory.createStringLiteral(ts.idText(e.propertyName || e.name)))));
78116                                     }
78117                                     statements.push(factory.createExpressionStatement(factory.createCallExpression(exportFunction, undefined, [factory.createObjectLiteralExpression(properties, true)])));
78118                                 }
78119                                 else {
78120                                     statements.push(factory.createExpressionStatement(factory.createCallExpression(exportFunction, undefined, [
78121                                         factory.createStringLiteral(ts.idText(entry.exportClause.name)),
78122                                         parameterName
78123                                     ])));
78124                                 }
78125                             }
78126                             else {
78127                                 statements.push(factory.createExpressionStatement(factory.createCallExpression(exportStarFunction, undefined, [parameterName])));
78128                             }
78129                             break;
78130                     }
78131                 }
78132                 setters.push(factory.createFunctionExpression(undefined, undefined, undefined, undefined, [factory.createParameterDeclaration(undefined, undefined, undefined, parameterName)], undefined, factory.createBlock(statements, true)));
78133             }
78134             return factory.createArrayLiteralExpression(setters, true);
78135         }
78136         function sourceElementVisitor(node) {
78137             switch (node.kind) {
78138                 case 261:
78139                     return visitImportDeclaration(node);
78140                 case 260:
78141                     return visitImportEqualsDeclaration(node);
78142                 case 267:
78143                     return visitExportDeclaration(node);
78144                 case 266:
78145                     return visitExportAssignment(node);
78146                 default:
78147                     return nestedElementVisitor(node);
78148             }
78149         }
78150         function visitImportDeclaration(node) {
78151             var statements;
78152             if (node.importClause) {
78153                 hoistVariableDeclaration(ts.getLocalNameForExternalImport(factory, node, currentSourceFile));
78154             }
78155             if (hasAssociatedEndOfDeclarationMarker(node)) {
78156                 var id = ts.getOriginalNodeId(node);
78157                 deferredExports[id] = appendExportsOfImportDeclaration(deferredExports[id], node);
78158             }
78159             else {
78160                 statements = appendExportsOfImportDeclaration(statements, node);
78161             }
78162             return ts.singleOrMany(statements);
78163         }
78164         function visitExportDeclaration(node) {
78165             ts.Debug.assertIsDefined(node);
78166             return undefined;
78167         }
78168         function visitImportEqualsDeclaration(node) {
78169             ts.Debug.assert(ts.isExternalModuleImportEqualsDeclaration(node), "import= for internal module references should be handled in an earlier transformer.");
78170             var statements;
78171             hoistVariableDeclaration(ts.getLocalNameForExternalImport(factory, node, currentSourceFile));
78172             if (hasAssociatedEndOfDeclarationMarker(node)) {
78173                 var id = ts.getOriginalNodeId(node);
78174                 deferredExports[id] = appendExportsOfImportEqualsDeclaration(deferredExports[id], node);
78175             }
78176             else {
78177                 statements = appendExportsOfImportEqualsDeclaration(statements, node);
78178             }
78179             return ts.singleOrMany(statements);
78180         }
78181         function visitExportAssignment(node) {
78182             if (node.isExportEquals) {
78183                 return undefined;
78184             }
78185             var expression = ts.visitNode(node.expression, destructuringAndImportCallVisitor, ts.isExpression);
78186             var original = node.original;
78187             if (original && hasAssociatedEndOfDeclarationMarker(original)) {
78188                 var id = ts.getOriginalNodeId(node);
78189                 deferredExports[id] = appendExportStatement(deferredExports[id], factory.createIdentifier("default"), expression, true);
78190             }
78191             else {
78192                 return createExportStatement(factory.createIdentifier("default"), expression, true);
78193             }
78194         }
78195         function visitFunctionDeclaration(node) {
78196             if (ts.hasSyntacticModifier(node, 1)) {
78197                 hoistedStatements = ts.append(hoistedStatements, factory.updateFunctionDeclaration(node, node.decorators, ts.visitNodes(node.modifiers, modifierVisitor, ts.isModifier), node.asteriskToken, factory.getDeclarationName(node, true, true), undefined, ts.visitNodes(node.parameters, destructuringAndImportCallVisitor, ts.isParameterDeclaration), undefined, ts.visitNode(node.body, destructuringAndImportCallVisitor, ts.isBlock)));
78198             }
78199             else {
78200                 hoistedStatements = ts.append(hoistedStatements, ts.visitEachChild(node, destructuringAndImportCallVisitor, context));
78201             }
78202             if (hasAssociatedEndOfDeclarationMarker(node)) {
78203                 var id = ts.getOriginalNodeId(node);
78204                 deferredExports[id] = appendExportsOfHoistedDeclaration(deferredExports[id], node);
78205             }
78206             else {
78207                 hoistedStatements = appendExportsOfHoistedDeclaration(hoistedStatements, node);
78208             }
78209             return undefined;
78210         }
78211         function visitClassDeclaration(node) {
78212             var statements;
78213             var name = factory.getLocalName(node);
78214             hoistVariableDeclaration(name);
78215             statements = ts.append(statements, ts.setTextRange(factory.createExpressionStatement(factory.createAssignment(name, ts.setTextRange(factory.createClassExpression(ts.visitNodes(node.decorators, destructuringAndImportCallVisitor, ts.isDecorator), undefined, node.name, undefined, ts.visitNodes(node.heritageClauses, destructuringAndImportCallVisitor, ts.isHeritageClause), ts.visitNodes(node.members, destructuringAndImportCallVisitor, ts.isClassElement)), node))), node));
78216             if (hasAssociatedEndOfDeclarationMarker(node)) {
78217                 var id = ts.getOriginalNodeId(node);
78218                 deferredExports[id] = appendExportsOfHoistedDeclaration(deferredExports[id], node);
78219             }
78220             else {
78221                 statements = appendExportsOfHoistedDeclaration(statements, node);
78222             }
78223             return ts.singleOrMany(statements);
78224         }
78225         function visitVariableStatement(node) {
78226             if (!shouldHoistVariableDeclarationList(node.declarationList)) {
78227                 return ts.visitNode(node, destructuringAndImportCallVisitor, ts.isStatement);
78228             }
78229             var expressions;
78230             var isExportedDeclaration = ts.hasSyntacticModifier(node, 1);
78231             var isMarkedDeclaration = hasAssociatedEndOfDeclarationMarker(node);
78232             for (var _i = 0, _a = node.declarationList.declarations; _i < _a.length; _i++) {
78233                 var variable = _a[_i];
78234                 if (variable.initializer) {
78235                     expressions = ts.append(expressions, transformInitializedVariable(variable, isExportedDeclaration && !isMarkedDeclaration));
78236                 }
78237                 else {
78238                     hoistBindingElement(variable);
78239                 }
78240             }
78241             var statements;
78242             if (expressions) {
78243                 statements = ts.append(statements, ts.setTextRange(factory.createExpressionStatement(factory.inlineExpressions(expressions)), node));
78244             }
78245             if (isMarkedDeclaration) {
78246                 var id = ts.getOriginalNodeId(node);
78247                 deferredExports[id] = appendExportsOfVariableStatement(deferredExports[id], node, isExportedDeclaration);
78248             }
78249             else {
78250                 statements = appendExportsOfVariableStatement(statements, node, false);
78251             }
78252             return ts.singleOrMany(statements);
78253         }
78254         function hoistBindingElement(node) {
78255             if (ts.isBindingPattern(node.name)) {
78256                 for (var _i = 0, _a = node.name.elements; _i < _a.length; _i++) {
78257                     var element = _a[_i];
78258                     if (!ts.isOmittedExpression(element)) {
78259                         hoistBindingElement(element);
78260                     }
78261                 }
78262             }
78263             else {
78264                 hoistVariableDeclaration(factory.cloneNode(node.name));
78265             }
78266         }
78267         function shouldHoistVariableDeclarationList(node) {
78268             return (ts.getEmitFlags(node) & 2097152) === 0
78269                 && (enclosingBlockScopedContainer.kind === 297
78270                     || (ts.getOriginalNode(node).flags & 3) === 0);
78271         }
78272         function transformInitializedVariable(node, isExportedDeclaration) {
78273             var createAssignment = isExportedDeclaration ? createExportedVariableAssignment : createNonExportedVariableAssignment;
78274             return ts.isBindingPattern(node.name)
78275                 ? ts.flattenDestructuringAssignment(node, destructuringAndImportCallVisitor, context, 0, false, createAssignment)
78276                 : node.initializer ? createAssignment(node.name, ts.visitNode(node.initializer, destructuringAndImportCallVisitor, ts.isExpression)) : node.name;
78277         }
78278         function createExportedVariableAssignment(name, value, location) {
78279             return createVariableAssignment(name, value, location, true);
78280         }
78281         function createNonExportedVariableAssignment(name, value, location) {
78282             return createVariableAssignment(name, value, location, false);
78283         }
78284         function createVariableAssignment(name, value, location, isExportedDeclaration) {
78285             hoistVariableDeclaration(factory.cloneNode(name));
78286             return isExportedDeclaration
78287                 ? createExportExpression(name, preventSubstitution(ts.setTextRange(factory.createAssignment(name, value), location)))
78288                 : preventSubstitution(ts.setTextRange(factory.createAssignment(name, value), location));
78289         }
78290         function visitMergeDeclarationMarker(node) {
78291             if (hasAssociatedEndOfDeclarationMarker(node) && node.original.kind === 232) {
78292                 var id = ts.getOriginalNodeId(node);
78293                 var isExportedDeclaration = ts.hasSyntacticModifier(node.original, 1);
78294                 deferredExports[id] = appendExportsOfVariableStatement(deferredExports[id], node.original, isExportedDeclaration);
78295             }
78296             return node;
78297         }
78298         function hasAssociatedEndOfDeclarationMarker(node) {
78299             return (ts.getEmitFlags(node) & 4194304) !== 0;
78300         }
78301         function visitEndOfDeclarationMarker(node) {
78302             var id = ts.getOriginalNodeId(node);
78303             var statements = deferredExports[id];
78304             if (statements) {
78305                 delete deferredExports[id];
78306                 return ts.append(statements, node);
78307             }
78308             else {
78309                 var original = ts.getOriginalNode(node);
78310                 if (ts.isModuleOrEnumDeclaration(original)) {
78311                     return ts.append(appendExportsOfDeclaration(statements, original), node);
78312                 }
78313             }
78314             return node;
78315         }
78316         function appendExportsOfImportDeclaration(statements, decl) {
78317             if (moduleInfo.exportEquals) {
78318                 return statements;
78319             }
78320             var importClause = decl.importClause;
78321             if (!importClause) {
78322                 return statements;
78323             }
78324             if (importClause.name) {
78325                 statements = appendExportsOfDeclaration(statements, importClause);
78326             }
78327             var namedBindings = importClause.namedBindings;
78328             if (namedBindings) {
78329                 switch (namedBindings.kind) {
78330                     case 263:
78331                         statements = appendExportsOfDeclaration(statements, namedBindings);
78332                         break;
78333                     case 264:
78334                         for (var _i = 0, _a = namedBindings.elements; _i < _a.length; _i++) {
78335                             var importBinding = _a[_i];
78336                             statements = appendExportsOfDeclaration(statements, importBinding);
78337                         }
78338                         break;
78339                 }
78340             }
78341             return statements;
78342         }
78343         function appendExportsOfImportEqualsDeclaration(statements, decl) {
78344             if (moduleInfo.exportEquals) {
78345                 return statements;
78346             }
78347             return appendExportsOfDeclaration(statements, decl);
78348         }
78349         function appendExportsOfVariableStatement(statements, node, exportSelf) {
78350             if (moduleInfo.exportEquals) {
78351                 return statements;
78352             }
78353             for (var _i = 0, _a = node.declarationList.declarations; _i < _a.length; _i++) {
78354                 var decl = _a[_i];
78355                 if (decl.initializer || exportSelf) {
78356                     statements = appendExportsOfBindingElement(statements, decl, exportSelf);
78357                 }
78358             }
78359             return statements;
78360         }
78361         function appendExportsOfBindingElement(statements, decl, exportSelf) {
78362             if (moduleInfo.exportEquals) {
78363                 return statements;
78364             }
78365             if (ts.isBindingPattern(decl.name)) {
78366                 for (var _i = 0, _a = decl.name.elements; _i < _a.length; _i++) {
78367                     var element = _a[_i];
78368                     if (!ts.isOmittedExpression(element)) {
78369                         statements = appendExportsOfBindingElement(statements, element, exportSelf);
78370                     }
78371                 }
78372             }
78373             else if (!ts.isGeneratedIdentifier(decl.name)) {
78374                 var excludeName = void 0;
78375                 if (exportSelf) {
78376                     statements = appendExportStatement(statements, decl.name, factory.getLocalName(decl));
78377                     excludeName = ts.idText(decl.name);
78378                 }
78379                 statements = appendExportsOfDeclaration(statements, decl, excludeName);
78380             }
78381             return statements;
78382         }
78383         function appendExportsOfHoistedDeclaration(statements, decl) {
78384             if (moduleInfo.exportEquals) {
78385                 return statements;
78386             }
78387             var excludeName;
78388             if (ts.hasSyntacticModifier(decl, 1)) {
78389                 var exportName = ts.hasSyntacticModifier(decl, 512) ? factory.createStringLiteral("default") : decl.name;
78390                 statements = appendExportStatement(statements, exportName, factory.getLocalName(decl));
78391                 excludeName = ts.getTextOfIdentifierOrLiteral(exportName);
78392             }
78393             if (decl.name) {
78394                 statements = appendExportsOfDeclaration(statements, decl, excludeName);
78395             }
78396             return statements;
78397         }
78398         function appendExportsOfDeclaration(statements, decl, excludeName) {
78399             if (moduleInfo.exportEquals) {
78400                 return statements;
78401             }
78402             var name = factory.getDeclarationName(decl);
78403             var exportSpecifiers = moduleInfo.exportSpecifiers.get(ts.idText(name));
78404             if (exportSpecifiers) {
78405                 for (var _i = 0, exportSpecifiers_2 = exportSpecifiers; _i < exportSpecifiers_2.length; _i++) {
78406                     var exportSpecifier = exportSpecifiers_2[_i];
78407                     if (exportSpecifier.name.escapedText !== excludeName) {
78408                         statements = appendExportStatement(statements, exportSpecifier.name, name);
78409                     }
78410                 }
78411             }
78412             return statements;
78413         }
78414         function appendExportStatement(statements, exportName, expression, allowComments) {
78415             statements = ts.append(statements, createExportStatement(exportName, expression, allowComments));
78416             return statements;
78417         }
78418         function createExportStatement(name, value, allowComments) {
78419             var statement = factory.createExpressionStatement(createExportExpression(name, value));
78420             ts.startOnNewLine(statement);
78421             if (!allowComments) {
78422                 ts.setEmitFlags(statement, 1536);
78423             }
78424             return statement;
78425         }
78426         function createExportExpression(name, value) {
78427             var exportName = ts.isIdentifier(name) ? factory.createStringLiteralFromNode(name) : name;
78428             ts.setEmitFlags(value, ts.getEmitFlags(value) | 1536);
78429             return ts.setCommentRange(factory.createCallExpression(exportFunction, undefined, [exportName, value]), value);
78430         }
78431         function nestedElementVisitor(node) {
78432             switch (node.kind) {
78433                 case 232:
78434                     return visitVariableStatement(node);
78435                 case 251:
78436                     return visitFunctionDeclaration(node);
78437                 case 252:
78438                     return visitClassDeclaration(node);
78439                 case 237:
78440                     return visitForStatement(node);
78441                 case 238:
78442                     return visitForInStatement(node);
78443                 case 239:
78444                     return visitForOfStatement(node);
78445                 case 235:
78446                     return visitDoStatement(node);
78447                 case 236:
78448                     return visitWhileStatement(node);
78449                 case 245:
78450                     return visitLabeledStatement(node);
78451                 case 243:
78452                     return visitWithStatement(node);
78453                 case 244:
78454                     return visitSwitchStatement(node);
78455                 case 258:
78456                     return visitCaseBlock(node);
78457                 case 284:
78458                     return visitCaseClause(node);
78459                 case 285:
78460                     return visitDefaultClause(node);
78461                 case 247:
78462                     return visitTryStatement(node);
78463                 case 287:
78464                     return visitCatchClause(node);
78465                 case 230:
78466                     return visitBlock(node);
78467                 case 338:
78468                     return visitMergeDeclarationMarker(node);
78469                 case 339:
78470                     return visitEndOfDeclarationMarker(node);
78471                 default:
78472                     return destructuringAndImportCallVisitor(node);
78473             }
78474         }
78475         function visitForStatement(node) {
78476             var savedEnclosingBlockScopedContainer = enclosingBlockScopedContainer;
78477             enclosingBlockScopedContainer = node;
78478             node = factory.updateForStatement(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));
78479             enclosingBlockScopedContainer = savedEnclosingBlockScopedContainer;
78480             return node;
78481         }
78482         function visitForInStatement(node) {
78483             var savedEnclosingBlockScopedContainer = enclosingBlockScopedContainer;
78484             enclosingBlockScopedContainer = node;
78485             node = factory.updateForInStatement(node, visitForInitializer(node.initializer), ts.visitNode(node.expression, destructuringAndImportCallVisitor, ts.isExpression), ts.visitNode(node.statement, nestedElementVisitor, ts.isStatement, factory.liftToBlock));
78486             enclosingBlockScopedContainer = savedEnclosingBlockScopedContainer;
78487             return node;
78488         }
78489         function visitForOfStatement(node) {
78490             var savedEnclosingBlockScopedContainer = enclosingBlockScopedContainer;
78491             enclosingBlockScopedContainer = node;
78492             node = factory.updateForOfStatement(node, node.awaitModifier, visitForInitializer(node.initializer), ts.visitNode(node.expression, destructuringAndImportCallVisitor, ts.isExpression), ts.visitNode(node.statement, nestedElementVisitor, ts.isStatement, factory.liftToBlock));
78493             enclosingBlockScopedContainer = savedEnclosingBlockScopedContainer;
78494             return node;
78495         }
78496         function shouldHoistForInitializer(node) {
78497             return ts.isVariableDeclarationList(node)
78498                 && shouldHoistVariableDeclarationList(node);
78499         }
78500         function visitForInitializer(node) {
78501             if (shouldHoistForInitializer(node)) {
78502                 var expressions = void 0;
78503                 for (var _i = 0, _a = node.declarations; _i < _a.length; _i++) {
78504                     var variable = _a[_i];
78505                     expressions = ts.append(expressions, transformInitializedVariable(variable, false));
78506                     if (!variable.initializer) {
78507                         hoistBindingElement(variable);
78508                     }
78509                 }
78510                 return expressions ? factory.inlineExpressions(expressions) : factory.createOmittedExpression();
78511             }
78512             else {
78513                 return ts.visitEachChild(node, nestedElementVisitor, context);
78514             }
78515         }
78516         function visitDoStatement(node) {
78517             return factory.updateDoStatement(node, ts.visitNode(node.statement, nestedElementVisitor, ts.isStatement, factory.liftToBlock), ts.visitNode(node.expression, destructuringAndImportCallVisitor, ts.isExpression));
78518         }
78519         function visitWhileStatement(node) {
78520             return factory.updateWhileStatement(node, ts.visitNode(node.expression, destructuringAndImportCallVisitor, ts.isExpression), ts.visitNode(node.statement, nestedElementVisitor, ts.isStatement, factory.liftToBlock));
78521         }
78522         function visitLabeledStatement(node) {
78523             return factory.updateLabeledStatement(node, node.label, ts.visitNode(node.statement, nestedElementVisitor, ts.isStatement, factory.liftToBlock));
78524         }
78525         function visitWithStatement(node) {
78526             return factory.updateWithStatement(node, ts.visitNode(node.expression, destructuringAndImportCallVisitor, ts.isExpression), ts.visitNode(node.statement, nestedElementVisitor, ts.isStatement, factory.liftToBlock));
78527         }
78528         function visitSwitchStatement(node) {
78529             return factory.updateSwitchStatement(node, ts.visitNode(node.expression, destructuringAndImportCallVisitor, ts.isExpression), ts.visitNode(node.caseBlock, nestedElementVisitor, ts.isCaseBlock));
78530         }
78531         function visitCaseBlock(node) {
78532             var savedEnclosingBlockScopedContainer = enclosingBlockScopedContainer;
78533             enclosingBlockScopedContainer = node;
78534             node = factory.updateCaseBlock(node, ts.visitNodes(node.clauses, nestedElementVisitor, ts.isCaseOrDefaultClause));
78535             enclosingBlockScopedContainer = savedEnclosingBlockScopedContainer;
78536             return node;
78537         }
78538         function visitCaseClause(node) {
78539             return factory.updateCaseClause(node, ts.visitNode(node.expression, destructuringAndImportCallVisitor, ts.isExpression), ts.visitNodes(node.statements, nestedElementVisitor, ts.isStatement));
78540         }
78541         function visitDefaultClause(node) {
78542             return ts.visitEachChild(node, nestedElementVisitor, context);
78543         }
78544         function visitTryStatement(node) {
78545             return ts.visitEachChild(node, nestedElementVisitor, context);
78546         }
78547         function visitCatchClause(node) {
78548             var savedEnclosingBlockScopedContainer = enclosingBlockScopedContainer;
78549             enclosingBlockScopedContainer = node;
78550             node = factory.updateCatchClause(node, node.variableDeclaration, ts.visitNode(node.block, nestedElementVisitor, ts.isBlock));
78551             enclosingBlockScopedContainer = savedEnclosingBlockScopedContainer;
78552             return node;
78553         }
78554         function visitBlock(node) {
78555             var savedEnclosingBlockScopedContainer = enclosingBlockScopedContainer;
78556             enclosingBlockScopedContainer = node;
78557             node = ts.visitEachChild(node, nestedElementVisitor, context);
78558             enclosingBlockScopedContainer = savedEnclosingBlockScopedContainer;
78559             return node;
78560         }
78561         function destructuringAndImportCallVisitor(node) {
78562             if (ts.isDestructuringAssignment(node)) {
78563                 return visitDestructuringAssignment(node);
78564             }
78565             else if (ts.isImportCall(node)) {
78566                 return visitImportCallExpression(node);
78567             }
78568             else if ((node.transformFlags & 1024) || (node.transformFlags & 2097152)) {
78569                 return ts.visitEachChild(node, destructuringAndImportCallVisitor, context);
78570             }
78571             else {
78572                 return node;
78573             }
78574         }
78575         function visitImportCallExpression(node) {
78576             return factory.createCallExpression(factory.createPropertyAccessExpression(contextObject, factory.createIdentifier("import")), undefined, ts.some(node.arguments) ? [ts.visitNode(node.arguments[0], destructuringAndImportCallVisitor)] : []);
78577         }
78578         function visitDestructuringAssignment(node) {
78579             if (hasExportedReferenceInDestructuringTarget(node.left)) {
78580                 return ts.flattenDestructuringAssignment(node, destructuringAndImportCallVisitor, context, 0, true);
78581             }
78582             return ts.visitEachChild(node, destructuringAndImportCallVisitor, context);
78583         }
78584         function hasExportedReferenceInDestructuringTarget(node) {
78585             if (ts.isAssignmentExpression(node, true)) {
78586                 return hasExportedReferenceInDestructuringTarget(node.left);
78587             }
78588             else if (ts.isSpreadElement(node)) {
78589                 return hasExportedReferenceInDestructuringTarget(node.expression);
78590             }
78591             else if (ts.isObjectLiteralExpression(node)) {
78592                 return ts.some(node.properties, hasExportedReferenceInDestructuringTarget);
78593             }
78594             else if (ts.isArrayLiteralExpression(node)) {
78595                 return ts.some(node.elements, hasExportedReferenceInDestructuringTarget);
78596             }
78597             else if (ts.isShorthandPropertyAssignment(node)) {
78598                 return hasExportedReferenceInDestructuringTarget(node.name);
78599             }
78600             else if (ts.isPropertyAssignment(node)) {
78601                 return hasExportedReferenceInDestructuringTarget(node.initializer);
78602             }
78603             else if (ts.isIdentifier(node)) {
78604                 var container = resolver.getReferencedExportContainer(node);
78605                 return container !== undefined && container.kind === 297;
78606             }
78607             else {
78608                 return false;
78609             }
78610         }
78611         function modifierVisitor(node) {
78612             switch (node.kind) {
78613                 case 92:
78614                 case 87:
78615                     return undefined;
78616             }
78617             return node;
78618         }
78619         function onEmitNode(hint, node, emitCallback) {
78620             if (node.kind === 297) {
78621                 var id = ts.getOriginalNodeId(node);
78622                 currentSourceFile = node;
78623                 moduleInfo = moduleInfoMap[id];
78624                 exportFunction = exportFunctionsMap[id];
78625                 noSubstitution = noSubstitutionMap[id];
78626                 contextObject = contextObjectMap[id];
78627                 if (noSubstitution) {
78628                     delete noSubstitutionMap[id];
78629                 }
78630                 previousOnEmitNode(hint, node, emitCallback);
78631                 currentSourceFile = undefined;
78632                 moduleInfo = undefined;
78633                 exportFunction = undefined;
78634                 contextObject = undefined;
78635                 noSubstitution = undefined;
78636             }
78637             else {
78638                 previousOnEmitNode(hint, node, emitCallback);
78639             }
78640         }
78641         function onSubstituteNode(hint, node) {
78642             node = previousOnSubstituteNode(hint, node);
78643             if (isSubstitutionPrevented(node)) {
78644                 return node;
78645             }
78646             if (hint === 1) {
78647                 return substituteExpression(node);
78648             }
78649             else if (hint === 4) {
78650                 return substituteUnspecified(node);
78651             }
78652             return node;
78653         }
78654         function substituteUnspecified(node) {
78655             switch (node.kind) {
78656                 case 289:
78657                     return substituteShorthandPropertyAssignment(node);
78658             }
78659             return node;
78660         }
78661         function substituteShorthandPropertyAssignment(node) {
78662             var name = node.name;
78663             if (!ts.isGeneratedIdentifier(name) && !ts.isLocalName(name)) {
78664                 var importDeclaration = resolver.getReferencedImportDeclaration(name);
78665                 if (importDeclaration) {
78666                     if (ts.isImportClause(importDeclaration)) {
78667                         return ts.setTextRange(factory.createPropertyAssignment(factory.cloneNode(name), factory.createPropertyAccessExpression(factory.getGeneratedNameForNode(importDeclaration.parent), factory.createIdentifier("default"))), node);
78668                     }
78669                     else if (ts.isImportSpecifier(importDeclaration)) {
78670                         return ts.setTextRange(factory.createPropertyAssignment(factory.cloneNode(name), factory.createPropertyAccessExpression(factory.getGeneratedNameForNode(importDeclaration.parent.parent.parent), factory.cloneNode(importDeclaration.propertyName || importDeclaration.name))), node);
78671                     }
78672                 }
78673             }
78674             return node;
78675         }
78676         function substituteExpression(node) {
78677             switch (node.kind) {
78678                 case 78:
78679                     return substituteExpressionIdentifier(node);
78680                 case 216:
78681                     return substituteBinaryExpression(node);
78682                 case 214:
78683                 case 215:
78684                     return substituteUnaryExpression(node);
78685                 case 226:
78686                     return substituteMetaProperty(node);
78687             }
78688             return node;
78689         }
78690         function substituteExpressionIdentifier(node) {
78691             if (ts.getEmitFlags(node) & 4096) {
78692                 var externalHelpersModuleName = ts.getExternalHelpersModuleName(currentSourceFile);
78693                 if (externalHelpersModuleName) {
78694                     return factory.createPropertyAccessExpression(externalHelpersModuleName, node);
78695                 }
78696                 return node;
78697             }
78698             if (!ts.isGeneratedIdentifier(node) && !ts.isLocalName(node)) {
78699                 var importDeclaration = resolver.getReferencedImportDeclaration(node);
78700                 if (importDeclaration) {
78701                     if (ts.isImportClause(importDeclaration)) {
78702                         return ts.setTextRange(factory.createPropertyAccessExpression(factory.getGeneratedNameForNode(importDeclaration.parent), factory.createIdentifier("default")), node);
78703                     }
78704                     else if (ts.isImportSpecifier(importDeclaration)) {
78705                         return ts.setTextRange(factory.createPropertyAccessExpression(factory.getGeneratedNameForNode(importDeclaration.parent.parent.parent), factory.cloneNode(importDeclaration.propertyName || importDeclaration.name)), node);
78706                     }
78707                 }
78708             }
78709             return node;
78710         }
78711         function substituteBinaryExpression(node) {
78712             if (ts.isAssignmentOperator(node.operatorToken.kind)
78713                 && ts.isIdentifier(node.left)
78714                 && !ts.isGeneratedIdentifier(node.left)
78715                 && !ts.isLocalName(node.left)
78716                 && !ts.isDeclarationNameOfEnumOrNamespace(node.left)) {
78717                 var exportedNames = getExports(node.left);
78718                 if (exportedNames) {
78719                     var expression = node;
78720                     for (var _i = 0, exportedNames_4 = exportedNames; _i < exportedNames_4.length; _i++) {
78721                         var exportName = exportedNames_4[_i];
78722                         expression = createExportExpression(exportName, preventSubstitution(expression));
78723                     }
78724                     return expression;
78725                 }
78726             }
78727             return node;
78728         }
78729         function substituteUnaryExpression(node) {
78730             if ((node.operator === 45 || node.operator === 46)
78731                 && ts.isIdentifier(node.operand)
78732                 && !ts.isGeneratedIdentifier(node.operand)
78733                 && !ts.isLocalName(node.operand)
78734                 && !ts.isDeclarationNameOfEnumOrNamespace(node.operand)) {
78735                 var exportedNames = getExports(node.operand);
78736                 if (exportedNames) {
78737                     var expression = node.kind === 215
78738                         ? ts.setTextRange(factory.createPrefixUnaryExpression(node.operator, node.operand), node)
78739                         : node;
78740                     for (var _i = 0, exportedNames_5 = exportedNames; _i < exportedNames_5.length; _i++) {
78741                         var exportName = exportedNames_5[_i];
78742                         expression = createExportExpression(exportName, preventSubstitution(expression));
78743                     }
78744                     if (node.kind === 215) {
78745                         expression = node.operator === 45
78746                             ? factory.createSubtract(preventSubstitution(expression), factory.createNumericLiteral(1))
78747                             : factory.createAdd(preventSubstitution(expression), factory.createNumericLiteral(1));
78748                     }
78749                     return expression;
78750                 }
78751             }
78752             return node;
78753         }
78754         function substituteMetaProperty(node) {
78755             if (ts.isImportMeta(node)) {
78756                 return factory.createPropertyAccessExpression(contextObject, factory.createIdentifier("meta"));
78757             }
78758             return node;
78759         }
78760         function getExports(name) {
78761             var exportedNames;
78762             if (!ts.isGeneratedIdentifier(name)) {
78763                 var valueDeclaration = resolver.getReferencedImportDeclaration(name)
78764                     || resolver.getReferencedValueDeclaration(name);
78765                 if (valueDeclaration) {
78766                     var exportContainer = resolver.getReferencedExportContainer(name, false);
78767                     if (exportContainer && exportContainer.kind === 297) {
78768                         exportedNames = ts.append(exportedNames, factory.getDeclarationName(valueDeclaration));
78769                     }
78770                     exportedNames = ts.addRange(exportedNames, moduleInfo && moduleInfo.exportedBindings[ts.getOriginalNodeId(valueDeclaration)]);
78771                 }
78772             }
78773             return exportedNames;
78774         }
78775         function preventSubstitution(node) {
78776             if (noSubstitution === undefined)
78777                 noSubstitution = [];
78778             noSubstitution[ts.getNodeId(node)] = true;
78779             return node;
78780         }
78781         function isSubstitutionPrevented(node) {
78782             return noSubstitution && node.id && noSubstitution[node.id];
78783         }
78784     }
78785     ts.transformSystemModule = transformSystemModule;
78786 })(ts || (ts = {}));
78787 var ts;
78788 (function (ts) {
78789     function transformECMAScriptModule(context) {
78790         var factory = context.factory, emitHelpers = context.getEmitHelperFactory;
78791         var compilerOptions = context.getCompilerOptions();
78792         var previousOnEmitNode = context.onEmitNode;
78793         var previousOnSubstituteNode = context.onSubstituteNode;
78794         context.onEmitNode = onEmitNode;
78795         context.onSubstituteNode = onSubstituteNode;
78796         context.enableEmitNotification(297);
78797         context.enableSubstitution(78);
78798         var helperNameSubstitutions;
78799         return ts.chainBundle(context, transformSourceFile);
78800         function transformSourceFile(node) {
78801             if (node.isDeclarationFile) {
78802                 return node;
78803             }
78804             if (ts.isExternalModule(node) || compilerOptions.isolatedModules) {
78805                 var result = updateExternalModule(node);
78806                 if (!ts.isExternalModule(node) || ts.some(result.statements, ts.isExternalModuleIndicator)) {
78807                     return result;
78808                 }
78809                 return factory.updateSourceFile(result, ts.setTextRange(factory.createNodeArray(__spreadArrays(result.statements, [ts.createEmptyExports(factory)])), result.statements));
78810             }
78811             return node;
78812         }
78813         function updateExternalModule(node) {
78814             var externalHelpersImportDeclaration = ts.createExternalHelpersImportDeclarationIfNeeded(factory, emitHelpers(), node, compilerOptions);
78815             if (externalHelpersImportDeclaration) {
78816                 var statements = [];
78817                 var statementOffset = factory.copyPrologue(node.statements, statements);
78818                 ts.append(statements, externalHelpersImportDeclaration);
78819                 ts.addRange(statements, ts.visitNodes(node.statements, visitor, ts.isStatement, statementOffset));
78820                 return factory.updateSourceFile(node, ts.setTextRange(factory.createNodeArray(statements), node.statements));
78821             }
78822             else {
78823                 return ts.visitEachChild(node, visitor, context);
78824             }
78825         }
78826         function visitor(node) {
78827             switch (node.kind) {
78828                 case 260:
78829                     return undefined;
78830                 case 266:
78831                     return visitExportAssignment(node);
78832                 case 267:
78833                     var exportDecl = node;
78834                     return visitExportDeclaration(exportDecl);
78835             }
78836             return node;
78837         }
78838         function visitExportAssignment(node) {
78839             return node.isExportEquals ? undefined : node;
78840         }
78841         function visitExportDeclaration(node) {
78842             if (compilerOptions.module !== undefined && compilerOptions.module > ts.ModuleKind.ES2015) {
78843                 return node;
78844             }
78845             if (!node.exportClause || !ts.isNamespaceExport(node.exportClause) || !node.moduleSpecifier) {
78846                 return node;
78847             }
78848             var oldIdentifier = node.exportClause.name;
78849             var synthName = factory.getGeneratedNameForNode(oldIdentifier);
78850             var importDecl = factory.createImportDeclaration(undefined, undefined, factory.createImportClause(false, undefined, factory.createNamespaceImport(synthName)), node.moduleSpecifier);
78851             ts.setOriginalNode(importDecl, node.exportClause);
78852             var exportDecl = ts.isExportNamespaceAsDefaultDeclaration(node) ? factory.createExportDefault(synthName) : factory.createExportDeclaration(undefined, undefined, false, factory.createNamedExports([factory.createExportSpecifier(synthName, oldIdentifier)]));
78853             ts.setOriginalNode(exportDecl, node);
78854             return [importDecl, exportDecl];
78855         }
78856         function onEmitNode(hint, node, emitCallback) {
78857             if (ts.isSourceFile(node)) {
78858                 if ((ts.isExternalModule(node) || compilerOptions.isolatedModules) && compilerOptions.importHelpers) {
78859                     helperNameSubstitutions = new ts.Map();
78860                 }
78861                 previousOnEmitNode(hint, node, emitCallback);
78862                 helperNameSubstitutions = undefined;
78863             }
78864             else {
78865                 previousOnEmitNode(hint, node, emitCallback);
78866             }
78867         }
78868         function onSubstituteNode(hint, node) {
78869             node = previousOnSubstituteNode(hint, node);
78870             if (helperNameSubstitutions && ts.isIdentifier(node) && ts.getEmitFlags(node) & 4096) {
78871                 return substituteHelperName(node);
78872             }
78873             return node;
78874         }
78875         function substituteHelperName(node) {
78876             var name = ts.idText(node);
78877             var substitution = helperNameSubstitutions.get(name);
78878             if (!substitution) {
78879                 helperNameSubstitutions.set(name, substitution = factory.createUniqueName(name, 16 | 32));
78880             }
78881             return substitution;
78882         }
78883     }
78884     ts.transformECMAScriptModule = transformECMAScriptModule;
78885 })(ts || (ts = {}));
78886 var ts;
78887 (function (ts) {
78888     function canProduceDiagnostics(node) {
78889         return ts.isVariableDeclaration(node) ||
78890             ts.isPropertyDeclaration(node) ||
78891             ts.isPropertySignature(node) ||
78892             ts.isBindingElement(node) ||
78893             ts.isSetAccessor(node) ||
78894             ts.isGetAccessor(node) ||
78895             ts.isConstructSignatureDeclaration(node) ||
78896             ts.isCallSignatureDeclaration(node) ||
78897             ts.isMethodDeclaration(node) ||
78898             ts.isMethodSignature(node) ||
78899             ts.isFunctionDeclaration(node) ||
78900             ts.isParameter(node) ||
78901             ts.isTypeParameterDeclaration(node) ||
78902             ts.isExpressionWithTypeArguments(node) ||
78903             ts.isImportEqualsDeclaration(node) ||
78904             ts.isTypeAliasDeclaration(node) ||
78905             ts.isConstructorDeclaration(node) ||
78906             ts.isIndexSignatureDeclaration(node) ||
78907             ts.isPropertyAccessExpression(node);
78908     }
78909     ts.canProduceDiagnostics = canProduceDiagnostics;
78910     function createGetSymbolAccessibilityDiagnosticForNodeName(node) {
78911         if (ts.isSetAccessor(node) || ts.isGetAccessor(node)) {
78912             return getAccessorNameVisibilityError;
78913         }
78914         else if (ts.isMethodSignature(node) || ts.isMethodDeclaration(node)) {
78915             return getMethodNameVisibilityError;
78916         }
78917         else {
78918             return createGetSymbolAccessibilityDiagnosticForNode(node);
78919         }
78920         function getAccessorNameVisibilityError(symbolAccessibilityResult) {
78921             var diagnosticMessage = getAccessorNameVisibilityDiagnosticMessage(symbolAccessibilityResult);
78922             return diagnosticMessage !== undefined ? {
78923                 diagnosticMessage: diagnosticMessage,
78924                 errorNode: node,
78925                 typeName: node.name
78926             } : undefined;
78927         }
78928         function getAccessorNameVisibilityDiagnosticMessage(symbolAccessibilityResult) {
78929             if (ts.hasSyntacticModifier(node, 32)) {
78930                 return symbolAccessibilityResult.errorModuleName ?
78931                     symbolAccessibilityResult.accessibility === 2 ?
78932                         ts.Diagnostics.Public_static_property_0_of_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named :
78933                         ts.Diagnostics.Public_static_property_0_of_exported_class_has_or_is_using_name_1_from_private_module_2 :
78934                     ts.Diagnostics.Public_static_property_0_of_exported_class_has_or_is_using_private_name_1;
78935             }
78936             else if (node.parent.kind === 252) {
78937                 return symbolAccessibilityResult.errorModuleName ?
78938                     symbolAccessibilityResult.accessibility === 2 ?
78939                         ts.Diagnostics.Public_property_0_of_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named :
78940                         ts.Diagnostics.Public_property_0_of_exported_class_has_or_is_using_name_1_from_private_module_2 :
78941                     ts.Diagnostics.Public_property_0_of_exported_class_has_or_is_using_private_name_1;
78942             }
78943             else {
78944                 return symbolAccessibilityResult.errorModuleName ?
78945                     ts.Diagnostics.Property_0_of_exported_interface_has_or_is_using_name_1_from_private_module_2 :
78946                     ts.Diagnostics.Property_0_of_exported_interface_has_or_is_using_private_name_1;
78947             }
78948         }
78949         function getMethodNameVisibilityError(symbolAccessibilityResult) {
78950             var diagnosticMessage = getMethodNameVisibilityDiagnosticMessage(symbolAccessibilityResult);
78951             return diagnosticMessage !== undefined ? {
78952                 diagnosticMessage: diagnosticMessage,
78953                 errorNode: node,
78954                 typeName: node.name
78955             } : undefined;
78956         }
78957         function getMethodNameVisibilityDiagnosticMessage(symbolAccessibilityResult) {
78958             if (ts.hasSyntacticModifier(node, 32)) {
78959                 return symbolAccessibilityResult.errorModuleName ?
78960                     symbolAccessibilityResult.accessibility === 2 ?
78961                         ts.Diagnostics.Public_static_method_0_of_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named :
78962                         ts.Diagnostics.Public_static_method_0_of_exported_class_has_or_is_using_name_1_from_private_module_2 :
78963                     ts.Diagnostics.Public_static_method_0_of_exported_class_has_or_is_using_private_name_1;
78964             }
78965             else if (node.parent.kind === 252) {
78966                 return symbolAccessibilityResult.errorModuleName ?
78967                     symbolAccessibilityResult.accessibility === 2 ?
78968                         ts.Diagnostics.Public_method_0_of_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named :
78969                         ts.Diagnostics.Public_method_0_of_exported_class_has_or_is_using_name_1_from_private_module_2 :
78970                     ts.Diagnostics.Public_method_0_of_exported_class_has_or_is_using_private_name_1;
78971             }
78972             else {
78973                 return symbolAccessibilityResult.errorModuleName ?
78974                     ts.Diagnostics.Method_0_of_exported_interface_has_or_is_using_name_1_from_private_module_2 :
78975                     ts.Diagnostics.Method_0_of_exported_interface_has_or_is_using_private_name_1;
78976             }
78977         }
78978     }
78979     ts.createGetSymbolAccessibilityDiagnosticForNodeName = createGetSymbolAccessibilityDiagnosticForNodeName;
78980     function createGetSymbolAccessibilityDiagnosticForNode(node) {
78981         if (ts.isVariableDeclaration(node) || ts.isPropertyDeclaration(node) || ts.isPropertySignature(node) || ts.isPropertyAccessExpression(node) || ts.isBindingElement(node) || ts.isConstructorDeclaration(node)) {
78982             return getVariableDeclarationTypeVisibilityError;
78983         }
78984         else if (ts.isSetAccessor(node) || ts.isGetAccessor(node)) {
78985             return getAccessorDeclarationTypeVisibilityError;
78986         }
78987         else if (ts.isConstructSignatureDeclaration(node) || ts.isCallSignatureDeclaration(node) || ts.isMethodDeclaration(node) || ts.isMethodSignature(node) || ts.isFunctionDeclaration(node) || ts.isIndexSignatureDeclaration(node)) {
78988             return getReturnTypeVisibilityError;
78989         }
78990         else if (ts.isParameter(node)) {
78991             if (ts.isParameterPropertyDeclaration(node, node.parent) && ts.hasSyntacticModifier(node.parent, 8)) {
78992                 return getVariableDeclarationTypeVisibilityError;
78993             }
78994             return getParameterDeclarationTypeVisibilityError;
78995         }
78996         else if (ts.isTypeParameterDeclaration(node)) {
78997             return getTypeParameterConstraintVisibilityError;
78998         }
78999         else if (ts.isExpressionWithTypeArguments(node)) {
79000             return getHeritageClauseVisibilityError;
79001         }
79002         else if (ts.isImportEqualsDeclaration(node)) {
79003             return getImportEntityNameVisibilityError;
79004         }
79005         else if (ts.isTypeAliasDeclaration(node)) {
79006             return getTypeAliasDeclarationVisibilityError;
79007         }
79008         else {
79009             return ts.Debug.assertNever(node, "Attempted to set a declaration diagnostic context for unhandled node kind: " + ts.SyntaxKind[node.kind]);
79010         }
79011         function getVariableDeclarationTypeVisibilityDiagnosticMessage(symbolAccessibilityResult) {
79012             if (node.kind === 249 || node.kind === 198) {
79013                 return symbolAccessibilityResult.errorModuleName ?
79014                     symbolAccessibilityResult.accessibility === 2 ?
79015                         ts.Diagnostics.Exported_variable_0_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named :
79016                         ts.Diagnostics.Exported_variable_0_has_or_is_using_name_1_from_private_module_2 :
79017                     ts.Diagnostics.Exported_variable_0_has_or_is_using_private_name_1;
79018             }
79019             else if (node.kind === 163 || node.kind === 201 || node.kind === 162 ||
79020                 (node.kind === 160 && ts.hasSyntacticModifier(node.parent, 8))) {
79021                 if (ts.hasSyntacticModifier(node, 32)) {
79022                     return symbolAccessibilityResult.errorModuleName ?
79023                         symbolAccessibilityResult.accessibility === 2 ?
79024                             ts.Diagnostics.Public_static_property_0_of_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named :
79025                             ts.Diagnostics.Public_static_property_0_of_exported_class_has_or_is_using_name_1_from_private_module_2 :
79026                         ts.Diagnostics.Public_static_property_0_of_exported_class_has_or_is_using_private_name_1;
79027                 }
79028                 else if (node.parent.kind === 252 || node.kind === 160) {
79029                     return symbolAccessibilityResult.errorModuleName ?
79030                         symbolAccessibilityResult.accessibility === 2 ?
79031                             ts.Diagnostics.Public_property_0_of_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named :
79032                             ts.Diagnostics.Public_property_0_of_exported_class_has_or_is_using_name_1_from_private_module_2 :
79033                         ts.Diagnostics.Public_property_0_of_exported_class_has_or_is_using_private_name_1;
79034                 }
79035                 else {
79036                     return symbolAccessibilityResult.errorModuleName ?
79037                         ts.Diagnostics.Property_0_of_exported_interface_has_or_is_using_name_1_from_private_module_2 :
79038                         ts.Diagnostics.Property_0_of_exported_interface_has_or_is_using_private_name_1;
79039                 }
79040             }
79041         }
79042         function getVariableDeclarationTypeVisibilityError(symbolAccessibilityResult) {
79043             var diagnosticMessage = getVariableDeclarationTypeVisibilityDiagnosticMessage(symbolAccessibilityResult);
79044             return diagnosticMessage !== undefined ? {
79045                 diagnosticMessage: diagnosticMessage,
79046                 errorNode: node,
79047                 typeName: node.name
79048             } : undefined;
79049         }
79050         function getAccessorDeclarationTypeVisibilityError(symbolAccessibilityResult) {
79051             var diagnosticMessage;
79052             if (node.kind === 168) {
79053                 if (ts.hasSyntacticModifier(node, 32)) {
79054                     diagnosticMessage = symbolAccessibilityResult.errorModuleName ?
79055                         ts.Diagnostics.Parameter_type_of_public_static_setter_0_from_exported_class_has_or_is_using_name_1_from_private_module_2 :
79056                         ts.Diagnostics.Parameter_type_of_public_static_setter_0_from_exported_class_has_or_is_using_private_name_1;
79057                 }
79058                 else {
79059                     diagnosticMessage = symbolAccessibilityResult.errorModuleName ?
79060                         ts.Diagnostics.Parameter_type_of_public_setter_0_from_exported_class_has_or_is_using_name_1_from_private_module_2 :
79061                         ts.Diagnostics.Parameter_type_of_public_setter_0_from_exported_class_has_or_is_using_private_name_1;
79062                 }
79063             }
79064             else {
79065                 if (ts.hasSyntacticModifier(node, 32)) {
79066                     diagnosticMessage = symbolAccessibilityResult.errorModuleName ?
79067                         symbolAccessibilityResult.accessibility === 2 ?
79068                             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 :
79069                             ts.Diagnostics.Return_type_of_public_static_getter_0_from_exported_class_has_or_is_using_name_1_from_private_module_2 :
79070                         ts.Diagnostics.Return_type_of_public_static_getter_0_from_exported_class_has_or_is_using_private_name_1;
79071                 }
79072                 else {
79073                     diagnosticMessage = symbolAccessibilityResult.errorModuleName ?
79074                         symbolAccessibilityResult.accessibility === 2 ?
79075                             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 :
79076                             ts.Diagnostics.Return_type_of_public_getter_0_from_exported_class_has_or_is_using_name_1_from_private_module_2 :
79077                         ts.Diagnostics.Return_type_of_public_getter_0_from_exported_class_has_or_is_using_private_name_1;
79078                 }
79079             }
79080             return {
79081                 diagnosticMessage: diagnosticMessage,
79082                 errorNode: node.name,
79083                 typeName: node.name
79084             };
79085         }
79086         function getReturnTypeVisibilityError(symbolAccessibilityResult) {
79087             var diagnosticMessage;
79088             switch (node.kind) {
79089                 case 170:
79090                     diagnosticMessage = symbolAccessibilityResult.errorModuleName ?
79091                         ts.Diagnostics.Return_type_of_constructor_signature_from_exported_interface_has_or_is_using_name_0_from_private_module_1 :
79092                         ts.Diagnostics.Return_type_of_constructor_signature_from_exported_interface_has_or_is_using_private_name_0;
79093                     break;
79094                 case 169:
79095                     diagnosticMessage = symbolAccessibilityResult.errorModuleName ?
79096                         ts.Diagnostics.Return_type_of_call_signature_from_exported_interface_has_or_is_using_name_0_from_private_module_1 :
79097                         ts.Diagnostics.Return_type_of_call_signature_from_exported_interface_has_or_is_using_private_name_0;
79098                     break;
79099                 case 171:
79100                     diagnosticMessage = symbolAccessibilityResult.errorModuleName ?
79101                         ts.Diagnostics.Return_type_of_index_signature_from_exported_interface_has_or_is_using_name_0_from_private_module_1 :
79102                         ts.Diagnostics.Return_type_of_index_signature_from_exported_interface_has_or_is_using_private_name_0;
79103                     break;
79104                 case 165:
79105                 case 164:
79106                     if (ts.hasSyntacticModifier(node, 32)) {
79107                         diagnosticMessage = symbolAccessibilityResult.errorModuleName ?
79108                             symbolAccessibilityResult.accessibility === 2 ?
79109                                 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 :
79110                                 ts.Diagnostics.Return_type_of_public_static_method_from_exported_class_has_or_is_using_name_0_from_private_module_1 :
79111                             ts.Diagnostics.Return_type_of_public_static_method_from_exported_class_has_or_is_using_private_name_0;
79112                     }
79113                     else if (node.parent.kind === 252) {
79114                         diagnosticMessage = symbolAccessibilityResult.errorModuleName ?
79115                             symbolAccessibilityResult.accessibility === 2 ?
79116                                 ts.Diagnostics.Return_type_of_public_method_from_exported_class_has_or_is_using_name_0_from_external_module_1_but_cannot_be_named :
79117                                 ts.Diagnostics.Return_type_of_public_method_from_exported_class_has_or_is_using_name_0_from_private_module_1 :
79118                             ts.Diagnostics.Return_type_of_public_method_from_exported_class_has_or_is_using_private_name_0;
79119                     }
79120                     else {
79121                         diagnosticMessage = symbolAccessibilityResult.errorModuleName ?
79122                             ts.Diagnostics.Return_type_of_method_from_exported_interface_has_or_is_using_name_0_from_private_module_1 :
79123                             ts.Diagnostics.Return_type_of_method_from_exported_interface_has_or_is_using_private_name_0;
79124                     }
79125                     break;
79126                 case 251:
79127                     diagnosticMessage = symbolAccessibilityResult.errorModuleName ?
79128                         symbolAccessibilityResult.accessibility === 2 ?
79129                             ts.Diagnostics.Return_type_of_exported_function_has_or_is_using_name_0_from_external_module_1_but_cannot_be_named :
79130                             ts.Diagnostics.Return_type_of_exported_function_has_or_is_using_name_0_from_private_module_1 :
79131                         ts.Diagnostics.Return_type_of_exported_function_has_or_is_using_private_name_0;
79132                     break;
79133                 default:
79134                     return ts.Debug.fail("This is unknown kind for signature: " + node.kind);
79135             }
79136             return {
79137                 diagnosticMessage: diagnosticMessage,
79138                 errorNode: node.name || node
79139             };
79140         }
79141         function getParameterDeclarationTypeVisibilityError(symbolAccessibilityResult) {
79142             var diagnosticMessage = getParameterDeclarationTypeVisibilityDiagnosticMessage(symbolAccessibilityResult);
79143             return diagnosticMessage !== undefined ? {
79144                 diagnosticMessage: diagnosticMessage,
79145                 errorNode: node,
79146                 typeName: node.name
79147             } : undefined;
79148         }
79149         function getParameterDeclarationTypeVisibilityDiagnosticMessage(symbolAccessibilityResult) {
79150             switch (node.parent.kind) {
79151                 case 166:
79152                     return symbolAccessibilityResult.errorModuleName ?
79153                         symbolAccessibilityResult.accessibility === 2 ?
79154                             ts.Diagnostics.Parameter_0_of_constructor_from_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named :
79155                             ts.Diagnostics.Parameter_0_of_constructor_from_exported_class_has_or_is_using_name_1_from_private_module_2 :
79156                         ts.Diagnostics.Parameter_0_of_constructor_from_exported_class_has_or_is_using_private_name_1;
79157                 case 170:
79158                 case 175:
79159                     return symbolAccessibilityResult.errorModuleName ?
79160                         ts.Diagnostics.Parameter_0_of_constructor_signature_from_exported_interface_has_or_is_using_name_1_from_private_module_2 :
79161                         ts.Diagnostics.Parameter_0_of_constructor_signature_from_exported_interface_has_or_is_using_private_name_1;
79162                 case 169:
79163                     return symbolAccessibilityResult.errorModuleName ?
79164                         ts.Diagnostics.Parameter_0_of_call_signature_from_exported_interface_has_or_is_using_name_1_from_private_module_2 :
79165                         ts.Diagnostics.Parameter_0_of_call_signature_from_exported_interface_has_or_is_using_private_name_1;
79166                 case 171:
79167                     return symbolAccessibilityResult.errorModuleName ?
79168                         ts.Diagnostics.Parameter_0_of_index_signature_from_exported_interface_has_or_is_using_name_1_from_private_module_2 :
79169                         ts.Diagnostics.Parameter_0_of_index_signature_from_exported_interface_has_or_is_using_private_name_1;
79170                 case 165:
79171                 case 164:
79172                     if (ts.hasSyntacticModifier(node.parent, 32)) {
79173                         return symbolAccessibilityResult.errorModuleName ?
79174                             symbolAccessibilityResult.accessibility === 2 ?
79175                                 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 :
79176                                 ts.Diagnostics.Parameter_0_of_public_static_method_from_exported_class_has_or_is_using_name_1_from_private_module_2 :
79177                             ts.Diagnostics.Parameter_0_of_public_static_method_from_exported_class_has_or_is_using_private_name_1;
79178                     }
79179                     else if (node.parent.parent.kind === 252) {
79180                         return symbolAccessibilityResult.errorModuleName ?
79181                             symbolAccessibilityResult.accessibility === 2 ?
79182                                 ts.Diagnostics.Parameter_0_of_public_method_from_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named :
79183                                 ts.Diagnostics.Parameter_0_of_public_method_from_exported_class_has_or_is_using_name_1_from_private_module_2 :
79184                             ts.Diagnostics.Parameter_0_of_public_method_from_exported_class_has_or_is_using_private_name_1;
79185                     }
79186                     else {
79187                         return symbolAccessibilityResult.errorModuleName ?
79188                             ts.Diagnostics.Parameter_0_of_method_from_exported_interface_has_or_is_using_name_1_from_private_module_2 :
79189                             ts.Diagnostics.Parameter_0_of_method_from_exported_interface_has_or_is_using_private_name_1;
79190                     }
79191                 case 251:
79192                 case 174:
79193                     return symbolAccessibilityResult.errorModuleName ?
79194                         symbolAccessibilityResult.accessibility === 2 ?
79195                             ts.Diagnostics.Parameter_0_of_exported_function_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named :
79196                             ts.Diagnostics.Parameter_0_of_exported_function_has_or_is_using_name_1_from_private_module_2 :
79197                         ts.Diagnostics.Parameter_0_of_exported_function_has_or_is_using_private_name_1;
79198                 case 168:
79199                 case 167:
79200                     return symbolAccessibilityResult.errorModuleName ?
79201                         symbolAccessibilityResult.accessibility === 2 ?
79202                             ts.Diagnostics.Parameter_0_of_accessor_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named :
79203                             ts.Diagnostics.Parameter_0_of_accessor_has_or_is_using_name_1_from_private_module_2 :
79204                         ts.Diagnostics.Parameter_0_of_accessor_has_or_is_using_private_name_1;
79205                 default:
79206                     return ts.Debug.fail("Unknown parent for parameter: " + ts.SyntaxKind[node.parent.kind]);
79207             }
79208         }
79209         function getTypeParameterConstraintVisibilityError() {
79210             var diagnosticMessage;
79211             switch (node.parent.kind) {
79212                 case 252:
79213                     diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_exported_class_has_or_is_using_private_name_1;
79214                     break;
79215                 case 253:
79216                     diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_exported_interface_has_or_is_using_private_name_1;
79217                     break;
79218                 case 190:
79219                     diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_exported_mapped_object_type_is_using_private_name_1;
79220                     break;
79221                 case 175:
79222                 case 170:
79223                     diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_constructor_signature_from_exported_interface_has_or_is_using_private_name_1;
79224                     break;
79225                 case 169:
79226                     diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_call_signature_from_exported_interface_has_or_is_using_private_name_1;
79227                     break;
79228                 case 165:
79229                 case 164:
79230                     if (ts.hasSyntacticModifier(node.parent, 32)) {
79231                         diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_public_static_method_from_exported_class_has_or_is_using_private_name_1;
79232                     }
79233                     else if (node.parent.parent.kind === 252) {
79234                         diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_public_method_from_exported_class_has_or_is_using_private_name_1;
79235                     }
79236                     else {
79237                         diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_method_from_exported_interface_has_or_is_using_private_name_1;
79238                     }
79239                     break;
79240                 case 174:
79241                 case 251:
79242                     diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_exported_function_has_or_is_using_private_name_1;
79243                     break;
79244                 case 254:
79245                     diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_exported_type_alias_has_or_is_using_private_name_1;
79246                     break;
79247                 default:
79248                     return ts.Debug.fail("This is unknown parent for type parameter: " + node.parent.kind);
79249             }
79250             return {
79251                 diagnosticMessage: diagnosticMessage,
79252                 errorNode: node,
79253                 typeName: node.name
79254             };
79255         }
79256         function getHeritageClauseVisibilityError() {
79257             var diagnosticMessage;
79258             if (ts.isClassDeclaration(node.parent.parent)) {
79259                 diagnosticMessage = ts.isHeritageClause(node.parent) && node.parent.token === 116 ?
79260                     ts.Diagnostics.Implements_clause_of_exported_class_0_has_or_is_using_private_name_1 :
79261                     node.parent.parent.name ? ts.Diagnostics.extends_clause_of_exported_class_0_has_or_is_using_private_name_1 :
79262                         ts.Diagnostics.extends_clause_of_exported_class_has_or_is_using_private_name_0;
79263             }
79264             else {
79265                 diagnosticMessage = ts.Diagnostics.extends_clause_of_exported_interface_0_has_or_is_using_private_name_1;
79266             }
79267             return {
79268                 diagnosticMessage: diagnosticMessage,
79269                 errorNode: node,
79270                 typeName: ts.getNameOfDeclaration(node.parent.parent)
79271             };
79272         }
79273         function getImportEntityNameVisibilityError() {
79274             return {
79275                 diagnosticMessage: ts.Diagnostics.Import_declaration_0_is_using_private_name_1,
79276                 errorNode: node,
79277                 typeName: node.name
79278             };
79279         }
79280         function getTypeAliasDeclarationVisibilityError() {
79281             return {
79282                 diagnosticMessage: ts.Diagnostics.Exported_type_alias_0_has_or_is_using_private_name_1,
79283                 errorNode: node.type,
79284                 typeName: node.name
79285             };
79286         }
79287     }
79288     ts.createGetSymbolAccessibilityDiagnosticForNode = createGetSymbolAccessibilityDiagnosticForNode;
79289 })(ts || (ts = {}));
79290 var ts;
79291 (function (ts) {
79292     function getDeclarationDiagnostics(host, resolver, file) {
79293         var compilerOptions = host.getCompilerOptions();
79294         var result = ts.transformNodes(resolver, host, ts.factory, compilerOptions, file ? [file] : ts.filter(host.getSourceFiles(), ts.isSourceFileNotJson), [transformDeclarations], false);
79295         return result.diagnostics;
79296     }
79297     ts.getDeclarationDiagnostics = getDeclarationDiagnostics;
79298     function hasInternalAnnotation(range, currentSourceFile) {
79299         var comment = currentSourceFile.text.substring(range.pos, range.end);
79300         return ts.stringContains(comment, "@internal");
79301     }
79302     function isInternalDeclaration(node, currentSourceFile) {
79303         var parseTreeNode = ts.getParseTreeNode(node);
79304         if (parseTreeNode && parseTreeNode.kind === 160) {
79305             var paramIdx = parseTreeNode.parent.parameters.indexOf(parseTreeNode);
79306             var previousSibling = paramIdx > 0 ? parseTreeNode.parent.parameters[paramIdx - 1] : undefined;
79307             var text = currentSourceFile.text;
79308             var commentRanges = previousSibling
79309                 ? ts.concatenate(ts.getTrailingCommentRanges(text, ts.skipTrivia(text, previousSibling.end + 1, false, true)), ts.getLeadingCommentRanges(text, node.pos))
79310                 : ts.getTrailingCommentRanges(text, ts.skipTrivia(text, node.pos, false, true));
79311             return commentRanges && commentRanges.length && hasInternalAnnotation(ts.last(commentRanges), currentSourceFile);
79312         }
79313         var leadingCommentRanges = parseTreeNode && ts.getLeadingCommentRangesOfNode(parseTreeNode, currentSourceFile);
79314         return !!ts.forEach(leadingCommentRanges, function (range) {
79315             return hasInternalAnnotation(range, currentSourceFile);
79316         });
79317     }
79318     ts.isInternalDeclaration = isInternalDeclaration;
79319     var declarationEmitNodeBuilderFlags = 1024 |
79320         2048 |
79321         4096 |
79322         8 |
79323         524288 |
79324         4 |
79325         1;
79326     function transformDeclarations(context) {
79327         var throwDiagnostic = function () { return ts.Debug.fail("Diagnostic emitted without context"); };
79328         var getSymbolAccessibilityDiagnostic = throwDiagnostic;
79329         var needsDeclare = true;
79330         var isBundledEmit = false;
79331         var resultHasExternalModuleIndicator = false;
79332         var needsScopeFixMarker = false;
79333         var resultHasScopeMarker = false;
79334         var enclosingDeclaration;
79335         var necessaryTypeReferences;
79336         var lateMarkedStatements;
79337         var lateStatementReplacementMap;
79338         var suppressNewDiagnosticContexts;
79339         var exportedModulesFromDeclarationEmit;
79340         var factory = context.factory;
79341         var host = context.getEmitHost();
79342         var symbolTracker = {
79343             trackSymbol: trackSymbol,
79344             reportInaccessibleThisError: reportInaccessibleThisError,
79345             reportInaccessibleUniqueSymbolError: reportInaccessibleUniqueSymbolError,
79346             reportCyclicStructureError: reportCyclicStructureError,
79347             reportPrivateInBaseOfClassExpression: reportPrivateInBaseOfClassExpression,
79348             reportLikelyUnsafeImportRequiredError: reportLikelyUnsafeImportRequiredError,
79349             reportTruncationError: reportTruncationError,
79350             moduleResolverHost: host,
79351             trackReferencedAmbientModule: trackReferencedAmbientModule,
79352             trackExternalModuleSymbolOfImportTypeNode: trackExternalModuleSymbolOfImportTypeNode,
79353             reportNonlocalAugmentation: reportNonlocalAugmentation
79354         };
79355         var errorNameNode;
79356         var currentSourceFile;
79357         var refs;
79358         var libs;
79359         var emittedImports;
79360         var resolver = context.getEmitResolver();
79361         var options = context.getCompilerOptions();
79362         var noResolve = options.noResolve, stripInternal = options.stripInternal;
79363         return transformRoot;
79364         function recordTypeReferenceDirectivesIfNecessary(typeReferenceDirectives) {
79365             if (!typeReferenceDirectives) {
79366                 return;
79367             }
79368             necessaryTypeReferences = necessaryTypeReferences || new ts.Set();
79369             for (var _i = 0, typeReferenceDirectives_2 = typeReferenceDirectives; _i < typeReferenceDirectives_2.length; _i++) {
79370                 var ref = typeReferenceDirectives_2[_i];
79371                 necessaryTypeReferences.add(ref);
79372             }
79373         }
79374         function trackReferencedAmbientModule(node, symbol) {
79375             var directives = resolver.getTypeReferenceDirectivesForSymbol(symbol, 67108863);
79376             if (ts.length(directives)) {
79377                 return recordTypeReferenceDirectivesIfNecessary(directives);
79378             }
79379             var container = ts.getSourceFileOfNode(node);
79380             refs.set(ts.getOriginalNodeId(container), container);
79381         }
79382         function handleSymbolAccessibilityError(symbolAccessibilityResult) {
79383             if (symbolAccessibilityResult.accessibility === 0) {
79384                 if (symbolAccessibilityResult && symbolAccessibilityResult.aliasesToMakeVisible) {
79385                     if (!lateMarkedStatements) {
79386                         lateMarkedStatements = symbolAccessibilityResult.aliasesToMakeVisible;
79387                     }
79388                     else {
79389                         for (var _i = 0, _a = symbolAccessibilityResult.aliasesToMakeVisible; _i < _a.length; _i++) {
79390                             var ref = _a[_i];
79391                             ts.pushIfUnique(lateMarkedStatements, ref);
79392                         }
79393                     }
79394                 }
79395             }
79396             else {
79397                 var errorInfo = getSymbolAccessibilityDiagnostic(symbolAccessibilityResult);
79398                 if (errorInfo) {
79399                     if (errorInfo.typeName) {
79400                         context.addDiagnostic(ts.createDiagnosticForNode(symbolAccessibilityResult.errorNode || errorInfo.errorNode, errorInfo.diagnosticMessage, ts.getTextOfNode(errorInfo.typeName), symbolAccessibilityResult.errorSymbolName, symbolAccessibilityResult.errorModuleName));
79401                     }
79402                     else {
79403                         context.addDiagnostic(ts.createDiagnosticForNode(symbolAccessibilityResult.errorNode || errorInfo.errorNode, errorInfo.diagnosticMessage, symbolAccessibilityResult.errorSymbolName, symbolAccessibilityResult.errorModuleName));
79404                     }
79405                 }
79406             }
79407         }
79408         function trackExternalModuleSymbolOfImportTypeNode(symbol) {
79409             if (!isBundledEmit) {
79410                 (exportedModulesFromDeclarationEmit || (exportedModulesFromDeclarationEmit = [])).push(symbol);
79411             }
79412         }
79413         function trackSymbol(symbol, enclosingDeclaration, meaning) {
79414             if (symbol.flags & 262144)
79415                 return;
79416             handleSymbolAccessibilityError(resolver.isSymbolAccessible(symbol, enclosingDeclaration, meaning, true));
79417             recordTypeReferenceDirectivesIfNecessary(resolver.getTypeReferenceDirectivesForSymbol(symbol, meaning));
79418         }
79419         function reportPrivateInBaseOfClassExpression(propertyName) {
79420             if (errorNameNode) {
79421                 context.addDiagnostic(ts.createDiagnosticForNode(errorNameNode, ts.Diagnostics.Property_0_of_exported_class_expression_may_not_be_private_or_protected, propertyName));
79422             }
79423         }
79424         function reportInaccessibleUniqueSymbolError() {
79425             if (errorNameNode) {
79426                 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"));
79427             }
79428         }
79429         function reportCyclicStructureError() {
79430             if (errorNameNode) {
79431                 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)));
79432             }
79433         }
79434         function reportInaccessibleThisError() {
79435             if (errorNameNode) {
79436                 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"));
79437             }
79438         }
79439         function reportLikelyUnsafeImportRequiredError(specifier) {
79440             if (errorNameNode) {
79441                 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));
79442             }
79443         }
79444         function reportTruncationError() {
79445             if (errorNameNode) {
79446                 context.addDiagnostic(ts.createDiagnosticForNode(errorNameNode, ts.Diagnostics.The_inferred_type_of_this_node_exceeds_the_maximum_length_the_compiler_will_serialize_An_explicit_type_annotation_is_needed));
79447             }
79448         }
79449         function reportNonlocalAugmentation(containingFile, parentSymbol, symbol) {
79450             var primaryDeclaration = ts.find(parentSymbol.declarations, function (d) { return ts.getSourceFileOfNode(d) === containingFile; });
79451             var augmentingDeclarations = ts.filter(symbol.declarations, function (d) { return ts.getSourceFileOfNode(d) !== containingFile; });
79452             for (var _i = 0, augmentingDeclarations_1 = augmentingDeclarations; _i < augmentingDeclarations_1.length; _i++) {
79453                 var augmentations = augmentingDeclarations_1[_i];
79454                 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)));
79455             }
79456         }
79457         function transformDeclarationsForJS(sourceFile, bundled) {
79458             var oldDiag = getSymbolAccessibilityDiagnostic;
79459             getSymbolAccessibilityDiagnostic = function (s) { return ({
79460                 diagnosticMessage: s.errorModuleName
79461                     ? ts.Diagnostics.Declaration_emit_for_this_file_requires_using_private_name_0_from_module_1_An_explicit_type_annotation_may_unblock_declaration_emit
79462                     : ts.Diagnostics.Declaration_emit_for_this_file_requires_using_private_name_0_An_explicit_type_annotation_may_unblock_declaration_emit,
79463                 errorNode: s.errorNode || sourceFile
79464             }); };
79465             var result = resolver.getDeclarationStatementsForSourceFile(sourceFile, declarationEmitNodeBuilderFlags, symbolTracker, bundled);
79466             getSymbolAccessibilityDiagnostic = oldDiag;
79467             return result;
79468         }
79469         function transformRoot(node) {
79470             if (node.kind === 297 && node.isDeclarationFile) {
79471                 return node;
79472             }
79473             if (node.kind === 298) {
79474                 isBundledEmit = true;
79475                 refs = new ts.Map();
79476                 libs = new ts.Map();
79477                 var hasNoDefaultLib_1 = false;
79478                 var bundle = factory.createBundle(ts.map(node.sourceFiles, function (sourceFile) {
79479                     if (sourceFile.isDeclarationFile)
79480                         return undefined;
79481                     hasNoDefaultLib_1 = hasNoDefaultLib_1 || sourceFile.hasNoDefaultLib;
79482                     currentSourceFile = sourceFile;
79483                     enclosingDeclaration = sourceFile;
79484                     lateMarkedStatements = undefined;
79485                     suppressNewDiagnosticContexts = false;
79486                     lateStatementReplacementMap = new ts.Map();
79487                     getSymbolAccessibilityDiagnostic = throwDiagnostic;
79488                     needsScopeFixMarker = false;
79489                     resultHasScopeMarker = false;
79490                     collectReferences(sourceFile, refs);
79491                     collectLibs(sourceFile, libs);
79492                     if (ts.isExternalOrCommonJsModule(sourceFile) || ts.isJsonSourceFile(sourceFile)) {
79493                         resultHasExternalModuleIndicator = false;
79494                         needsDeclare = false;
79495                         var statements = ts.isSourceFileJS(sourceFile) ? factory.createNodeArray(transformDeclarationsForJS(sourceFile, true)) : ts.visitNodes(sourceFile.statements, visitDeclarationStatements);
79496                         var newFile = factory.updateSourceFile(sourceFile, [factory.createModuleDeclaration([], [factory.createModifier(133)], factory.createStringLiteral(ts.getResolvedExternalModuleName(context.getEmitHost(), sourceFile)), factory.createModuleBlock(ts.setTextRange(factory.createNodeArray(transformAndReplaceLatePaintedStatements(statements)), sourceFile.statements)))], true, [], [], false, []);
79497                         return newFile;
79498                     }
79499                     needsDeclare = true;
79500                     var updated = ts.isSourceFileJS(sourceFile) ? factory.createNodeArray(transformDeclarationsForJS(sourceFile)) : ts.visitNodes(sourceFile.statements, visitDeclarationStatements);
79501                     return factory.updateSourceFile(sourceFile, transformAndReplaceLatePaintedStatements(updated), true, [], [], false, []);
79502                 }), ts.mapDefined(node.prepends, function (prepend) {
79503                     if (prepend.kind === 300) {
79504                         var sourceFile = ts.createUnparsedSourceFile(prepend, "dts", stripInternal);
79505                         hasNoDefaultLib_1 = hasNoDefaultLib_1 || !!sourceFile.hasNoDefaultLib;
79506                         collectReferences(sourceFile, refs);
79507                         recordTypeReferenceDirectivesIfNecessary(sourceFile.typeReferenceDirectives);
79508                         collectLibs(sourceFile, libs);
79509                         return sourceFile;
79510                     }
79511                     return prepend;
79512                 }));
79513                 bundle.syntheticFileReferences = [];
79514                 bundle.syntheticTypeReferences = getFileReferencesForUsedTypeReferences();
79515                 bundle.syntheticLibReferences = getLibReferences();
79516                 bundle.hasNoDefaultLib = hasNoDefaultLib_1;
79517                 var outputFilePath_1 = ts.getDirectoryPath(ts.normalizeSlashes(ts.getOutputPathsFor(node, host, true).declarationFilePath));
79518                 var referenceVisitor_1 = mapReferencesIntoArray(bundle.syntheticFileReferences, outputFilePath_1);
79519                 refs.forEach(referenceVisitor_1);
79520                 return bundle;
79521             }
79522             needsDeclare = true;
79523             needsScopeFixMarker = false;
79524             resultHasScopeMarker = false;
79525             enclosingDeclaration = node;
79526             currentSourceFile = node;
79527             getSymbolAccessibilityDiagnostic = throwDiagnostic;
79528             isBundledEmit = false;
79529             resultHasExternalModuleIndicator = false;
79530             suppressNewDiagnosticContexts = false;
79531             lateMarkedStatements = undefined;
79532             lateStatementReplacementMap = new ts.Map();
79533             necessaryTypeReferences = undefined;
79534             refs = collectReferences(currentSourceFile, new ts.Map());
79535             libs = collectLibs(currentSourceFile, new ts.Map());
79536             var references = [];
79537             var outputFilePath = ts.getDirectoryPath(ts.normalizeSlashes(ts.getOutputPathsFor(node, host, true).declarationFilePath));
79538             var referenceVisitor = mapReferencesIntoArray(references, outputFilePath);
79539             var combinedStatements;
79540             if (ts.isSourceFileJS(currentSourceFile)) {
79541                 combinedStatements = factory.createNodeArray(transformDeclarationsForJS(node));
79542                 refs.forEach(referenceVisitor);
79543                 emittedImports = ts.filter(combinedStatements, ts.isAnyImportSyntax);
79544             }
79545             else {
79546                 var statements = ts.visitNodes(node.statements, visitDeclarationStatements);
79547                 combinedStatements = ts.setTextRange(factory.createNodeArray(transformAndReplaceLatePaintedStatements(statements)), node.statements);
79548                 refs.forEach(referenceVisitor);
79549                 emittedImports = ts.filter(combinedStatements, ts.isAnyImportSyntax);
79550                 if (ts.isExternalModule(node) && (!resultHasExternalModuleIndicator || (needsScopeFixMarker && !resultHasScopeMarker))) {
79551                     combinedStatements = ts.setTextRange(factory.createNodeArray(__spreadArrays(combinedStatements, [ts.createEmptyExports(factory)])), combinedStatements);
79552                 }
79553             }
79554             var updated = factory.updateSourceFile(node, combinedStatements, true, references, getFileReferencesForUsedTypeReferences(), node.hasNoDefaultLib, getLibReferences());
79555             updated.exportedModulesFromDeclarationEmit = exportedModulesFromDeclarationEmit;
79556             return updated;
79557             function getLibReferences() {
79558                 return ts.map(ts.arrayFrom(libs.keys()), function (lib) { return ({ fileName: lib, pos: -1, end: -1 }); });
79559             }
79560             function getFileReferencesForUsedTypeReferences() {
79561                 return necessaryTypeReferences ? ts.mapDefined(ts.arrayFrom(necessaryTypeReferences.keys()), getFileReferenceForTypeName) : [];
79562             }
79563             function getFileReferenceForTypeName(typeName) {
79564                 if (emittedImports) {
79565                     for (var _i = 0, emittedImports_1 = emittedImports; _i < emittedImports_1.length; _i++) {
79566                         var importStatement = emittedImports_1[_i];
79567                         if (ts.isImportEqualsDeclaration(importStatement) && ts.isExternalModuleReference(importStatement.moduleReference)) {
79568                             var expr = importStatement.moduleReference.expression;
79569                             if (ts.isStringLiteralLike(expr) && expr.text === typeName) {
79570                                 return undefined;
79571                             }
79572                         }
79573                         else if (ts.isImportDeclaration(importStatement) && ts.isStringLiteral(importStatement.moduleSpecifier) && importStatement.moduleSpecifier.text === typeName) {
79574                             return undefined;
79575                         }
79576                     }
79577                 }
79578                 return { fileName: typeName, pos: -1, end: -1 };
79579             }
79580             function mapReferencesIntoArray(references, outputFilePath) {
79581                 return function (file) {
79582                     var declFileName;
79583                     if (file.isDeclarationFile) {
79584                         declFileName = file.fileName;
79585                     }
79586                     else {
79587                         if (isBundledEmit && ts.contains(node.sourceFiles, file))
79588                             return;
79589                         var paths = ts.getOutputPathsFor(file, host, true);
79590                         declFileName = paths.declarationFilePath || paths.jsFilePath || file.fileName;
79591                     }
79592                     if (declFileName) {
79593                         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);
79594                         if (!ts.pathIsRelative(specifier)) {
79595                             recordTypeReferenceDirectivesIfNecessary([specifier]);
79596                             return;
79597                         }
79598                         var fileName = ts.getRelativePathToDirectoryOrUrl(outputFilePath, declFileName, host.getCurrentDirectory(), host.getCanonicalFileName, false);
79599                         if (ts.startsWith(fileName, "./") && ts.hasExtension(fileName)) {
79600                             fileName = fileName.substring(2);
79601                         }
79602                         if (ts.startsWith(fileName, "node_modules/") || ts.pathContainsNodeModules(fileName)) {
79603                             return;
79604                         }
79605                         references.push({ pos: -1, end: -1, fileName: fileName });
79606                     }
79607                 };
79608             }
79609         }
79610         function collectReferences(sourceFile, ret) {
79611             if (noResolve || (!ts.isUnparsedSource(sourceFile) && ts.isSourceFileJS(sourceFile)))
79612                 return ret;
79613             ts.forEach(sourceFile.referencedFiles, function (f) {
79614                 var elem = host.getSourceFileFromReference(sourceFile, f);
79615                 if (elem) {
79616                     ret.set(ts.getOriginalNodeId(elem), elem);
79617                 }
79618             });
79619             return ret;
79620         }
79621         function collectLibs(sourceFile, ret) {
79622             ts.forEach(sourceFile.libReferenceDirectives, function (ref) {
79623                 var lib = host.getLibFileFromReference(ref);
79624                 if (lib) {
79625                     ret.set(ts.toFileNameLowerCase(ref.fileName), true);
79626                 }
79627             });
79628             return ret;
79629         }
79630         function filterBindingPatternInitializers(name) {
79631             if (name.kind === 78) {
79632                 return name;
79633             }
79634             else {
79635                 if (name.kind === 197) {
79636                     return factory.updateArrayBindingPattern(name, ts.visitNodes(name.elements, visitBindingElement));
79637                 }
79638                 else {
79639                     return factory.updateObjectBindingPattern(name, ts.visitNodes(name.elements, visitBindingElement));
79640                 }
79641             }
79642             function visitBindingElement(elem) {
79643                 if (elem.kind === 222) {
79644                     return elem;
79645                 }
79646                 return factory.updateBindingElement(elem, elem.dotDotDotToken, elem.propertyName, filterBindingPatternInitializers(elem.name), shouldPrintWithInitializer(elem) ? elem.initializer : undefined);
79647             }
79648         }
79649         function ensureParameter(p, modifierMask, type) {
79650             var oldDiag;
79651             if (!suppressNewDiagnosticContexts) {
79652                 oldDiag = getSymbolAccessibilityDiagnostic;
79653                 getSymbolAccessibilityDiagnostic = ts.createGetSymbolAccessibilityDiagnosticForNode(p);
79654             }
79655             var newParam = factory.updateParameterDeclaration(p, undefined, maskModifiers(p, modifierMask), p.dotDotDotToken, filterBindingPatternInitializers(p.name), resolver.isOptionalParameter(p) ? (p.questionToken || factory.createToken(57)) : undefined, ensureType(p, type || p.type, true), ensureNoInitializer(p));
79656             if (!suppressNewDiagnosticContexts) {
79657                 getSymbolAccessibilityDiagnostic = oldDiag;
79658             }
79659             return newParam;
79660         }
79661         function shouldPrintWithInitializer(node) {
79662             return canHaveLiteralInitializer(node) && resolver.isLiteralConstDeclaration(ts.getParseTreeNode(node));
79663         }
79664         function ensureNoInitializer(node) {
79665             if (shouldPrintWithInitializer(node)) {
79666                 return resolver.createLiteralConstValue(ts.getParseTreeNode(node), symbolTracker);
79667             }
79668             return undefined;
79669         }
79670         function ensureType(node, type, ignorePrivate) {
79671             if (!ignorePrivate && ts.hasEffectiveModifier(node, 8)) {
79672                 return;
79673             }
79674             if (shouldPrintWithInitializer(node)) {
79675                 return;
79676             }
79677             var shouldUseResolverType = node.kind === 160 &&
79678                 (resolver.isRequiredInitializedParameter(node) ||
79679                     resolver.isOptionalUninitializedParameterProperty(node));
79680             if (type && !shouldUseResolverType) {
79681                 return ts.visitNode(type, visitDeclarationSubtree);
79682             }
79683             if (!ts.getParseTreeNode(node)) {
79684                 return type ? ts.visitNode(type, visitDeclarationSubtree) : factory.createKeywordTypeNode(128);
79685             }
79686             if (node.kind === 168) {
79687                 return factory.createKeywordTypeNode(128);
79688             }
79689             errorNameNode = node.name;
79690             var oldDiag;
79691             if (!suppressNewDiagnosticContexts) {
79692                 oldDiag = getSymbolAccessibilityDiagnostic;
79693                 getSymbolAccessibilityDiagnostic = ts.createGetSymbolAccessibilityDiagnosticForNode(node);
79694             }
79695             if (node.kind === 249 || node.kind === 198) {
79696                 return cleanup(resolver.createTypeOfDeclaration(node, enclosingDeclaration, declarationEmitNodeBuilderFlags, symbolTracker));
79697             }
79698             if (node.kind === 160
79699                 || node.kind === 163
79700                 || node.kind === 162) {
79701                 if (!node.initializer)
79702                     return cleanup(resolver.createTypeOfDeclaration(node, enclosingDeclaration, declarationEmitNodeBuilderFlags, symbolTracker, shouldUseResolverType));
79703                 return cleanup(resolver.createTypeOfDeclaration(node, enclosingDeclaration, declarationEmitNodeBuilderFlags, symbolTracker, shouldUseResolverType) || resolver.createTypeOfExpression(node.initializer, enclosingDeclaration, declarationEmitNodeBuilderFlags, symbolTracker));
79704             }
79705             return cleanup(resolver.createReturnTypeOfSignatureDeclaration(node, enclosingDeclaration, declarationEmitNodeBuilderFlags, symbolTracker));
79706             function cleanup(returnValue) {
79707                 errorNameNode = undefined;
79708                 if (!suppressNewDiagnosticContexts) {
79709                     getSymbolAccessibilityDiagnostic = oldDiag;
79710                 }
79711                 return returnValue || factory.createKeywordTypeNode(128);
79712             }
79713         }
79714         function isDeclarationAndNotVisible(node) {
79715             node = ts.getParseTreeNode(node);
79716             switch (node.kind) {
79717                 case 251:
79718                 case 256:
79719                 case 253:
79720                 case 252:
79721                 case 254:
79722                 case 255:
79723                     return !resolver.isDeclarationVisible(node);
79724                 case 249:
79725                     return !getBindingNameVisible(node);
79726                 case 260:
79727                 case 261:
79728                 case 267:
79729                 case 266:
79730                     return false;
79731             }
79732             return false;
79733         }
79734         function getBindingNameVisible(elem) {
79735             if (ts.isOmittedExpression(elem)) {
79736                 return false;
79737             }
79738             if (ts.isBindingPattern(elem.name)) {
79739                 return ts.some(elem.name.elements, getBindingNameVisible);
79740             }
79741             else {
79742                 return resolver.isDeclarationVisible(elem);
79743             }
79744         }
79745         function updateParamsList(node, params, modifierMask) {
79746             if (ts.hasEffectiveModifier(node, 8)) {
79747                 return undefined;
79748             }
79749             var newParams = ts.map(params, function (p) { return ensureParameter(p, modifierMask); });
79750             if (!newParams) {
79751                 return undefined;
79752             }
79753             return factory.createNodeArray(newParams, params.hasTrailingComma);
79754         }
79755         function updateAccessorParamsList(input, isPrivate) {
79756             var newParams;
79757             if (!isPrivate) {
79758                 var thisParameter = ts.getThisParameter(input);
79759                 if (thisParameter) {
79760                     newParams = [ensureParameter(thisParameter)];
79761                 }
79762             }
79763             if (ts.isSetAccessorDeclaration(input)) {
79764                 var newValueParameter = void 0;
79765                 if (!isPrivate) {
79766                     var valueParameter = ts.getSetAccessorValueParameter(input);
79767                     if (valueParameter) {
79768                         var accessorType = getTypeAnnotationFromAllAccessorDeclarations(input, resolver.getAllAccessorDeclarations(input));
79769                         newValueParameter = ensureParameter(valueParameter, undefined, accessorType);
79770                     }
79771                 }
79772                 if (!newValueParameter) {
79773                     newValueParameter = factory.createParameterDeclaration(undefined, undefined, undefined, "value");
79774                 }
79775                 newParams = ts.append(newParams, newValueParameter);
79776             }
79777             return factory.createNodeArray(newParams || ts.emptyArray);
79778         }
79779         function ensureTypeParams(node, params) {
79780             return ts.hasEffectiveModifier(node, 8) ? undefined : ts.visitNodes(params, visitDeclarationSubtree);
79781         }
79782         function isEnclosingDeclaration(node) {
79783             return ts.isSourceFile(node)
79784                 || ts.isTypeAliasDeclaration(node)
79785                 || ts.isModuleDeclaration(node)
79786                 || ts.isClassDeclaration(node)
79787                 || ts.isInterfaceDeclaration(node)
79788                 || ts.isFunctionLike(node)
79789                 || ts.isIndexSignatureDeclaration(node)
79790                 || ts.isMappedTypeNode(node);
79791         }
79792         function checkEntityNameVisibility(entityName, enclosingDeclaration) {
79793             var visibilityResult = resolver.isEntityNameVisible(entityName, enclosingDeclaration);
79794             handleSymbolAccessibilityError(visibilityResult);
79795             recordTypeReferenceDirectivesIfNecessary(resolver.getTypeReferenceDirectivesForEntityName(entityName));
79796         }
79797         function preserveJsDoc(updated, original) {
79798             if (ts.hasJSDocNodes(updated) && ts.hasJSDocNodes(original)) {
79799                 updated.jsDoc = original.jsDoc;
79800             }
79801             return ts.setCommentRange(updated, ts.getCommentRange(original));
79802         }
79803         function rewriteModuleSpecifier(parent, input) {
79804             if (!input)
79805                 return undefined;
79806             resultHasExternalModuleIndicator = resultHasExternalModuleIndicator || (parent.kind !== 256 && parent.kind !== 195);
79807             if (ts.isStringLiteralLike(input)) {
79808                 if (isBundledEmit) {
79809                     var newName = ts.getExternalModuleNameFromDeclaration(context.getEmitHost(), resolver, parent);
79810                     if (newName) {
79811                         return factory.createStringLiteral(newName);
79812                     }
79813                 }
79814                 else {
79815                     var symbol = resolver.getSymbolOfExternalModuleSpecifier(input);
79816                     if (symbol) {
79817                         (exportedModulesFromDeclarationEmit || (exportedModulesFromDeclarationEmit = [])).push(symbol);
79818                     }
79819                 }
79820             }
79821             return input;
79822         }
79823         function transformImportEqualsDeclaration(decl) {
79824             if (!resolver.isDeclarationVisible(decl))
79825                 return;
79826             if (decl.moduleReference.kind === 272) {
79827                 var specifier = ts.getExternalModuleImportEqualsDeclarationExpression(decl);
79828                 return factory.updateImportEqualsDeclaration(decl, undefined, decl.modifiers, decl.name, factory.updateExternalModuleReference(decl.moduleReference, rewriteModuleSpecifier(decl, specifier)));
79829             }
79830             else {
79831                 var oldDiag = getSymbolAccessibilityDiagnostic;
79832                 getSymbolAccessibilityDiagnostic = ts.createGetSymbolAccessibilityDiagnosticForNode(decl);
79833                 checkEntityNameVisibility(decl.moduleReference, enclosingDeclaration);
79834                 getSymbolAccessibilityDiagnostic = oldDiag;
79835                 return decl;
79836             }
79837         }
79838         function transformImportDeclaration(decl) {
79839             if (!decl.importClause) {
79840                 return factory.updateImportDeclaration(decl, undefined, decl.modifiers, decl.importClause, rewriteModuleSpecifier(decl, decl.moduleSpecifier));
79841             }
79842             var visibleDefaultBinding = decl.importClause && decl.importClause.name && resolver.isDeclarationVisible(decl.importClause) ? decl.importClause.name : undefined;
79843             if (!decl.importClause.namedBindings) {
79844                 return visibleDefaultBinding && factory.updateImportDeclaration(decl, undefined, decl.modifiers, factory.updateImportClause(decl.importClause, decl.importClause.isTypeOnly, visibleDefaultBinding, undefined), rewriteModuleSpecifier(decl, decl.moduleSpecifier));
79845             }
79846             if (decl.importClause.namedBindings.kind === 263) {
79847                 var namedBindings = resolver.isDeclarationVisible(decl.importClause.namedBindings) ? decl.importClause.namedBindings : undefined;
79848                 return visibleDefaultBinding || namedBindings ? factory.updateImportDeclaration(decl, undefined, decl.modifiers, factory.updateImportClause(decl.importClause, decl.importClause.isTypeOnly, visibleDefaultBinding, namedBindings), rewriteModuleSpecifier(decl, decl.moduleSpecifier)) : undefined;
79849             }
79850             var bindingList = ts.mapDefined(decl.importClause.namedBindings.elements, function (b) { return resolver.isDeclarationVisible(b) ? b : undefined; });
79851             if ((bindingList && bindingList.length) || visibleDefaultBinding) {
79852                 return factory.updateImportDeclaration(decl, undefined, decl.modifiers, factory.updateImportClause(decl.importClause, decl.importClause.isTypeOnly, visibleDefaultBinding, bindingList && bindingList.length ? factory.updateNamedImports(decl.importClause.namedBindings, bindingList) : undefined), rewriteModuleSpecifier(decl, decl.moduleSpecifier));
79853             }
79854             if (resolver.isImportRequiredByAugmentation(decl)) {
79855                 return factory.updateImportDeclaration(decl, undefined, decl.modifiers, undefined, rewriteModuleSpecifier(decl, decl.moduleSpecifier));
79856             }
79857         }
79858         function transformAndReplaceLatePaintedStatements(statements) {
79859             while (ts.length(lateMarkedStatements)) {
79860                 var i = lateMarkedStatements.shift();
79861                 if (!ts.isLateVisibilityPaintedStatement(i)) {
79862                     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));
79863                 }
79864                 var priorNeedsDeclare = needsDeclare;
79865                 needsDeclare = i.parent && ts.isSourceFile(i.parent) && !(ts.isExternalModule(i.parent) && isBundledEmit);
79866                 var result = transformTopLevelDeclaration(i);
79867                 needsDeclare = priorNeedsDeclare;
79868                 lateStatementReplacementMap.set(ts.getOriginalNodeId(i), result);
79869             }
79870             return ts.visitNodes(statements, visitLateVisibilityMarkedStatements);
79871             function visitLateVisibilityMarkedStatements(statement) {
79872                 if (ts.isLateVisibilityPaintedStatement(statement)) {
79873                     var key = ts.getOriginalNodeId(statement);
79874                     if (lateStatementReplacementMap.has(key)) {
79875                         var result = lateStatementReplacementMap.get(key);
79876                         lateStatementReplacementMap.delete(key);
79877                         if (result) {
79878                             if (ts.isArray(result) ? ts.some(result, ts.needsScopeMarker) : ts.needsScopeMarker(result)) {
79879                                 needsScopeFixMarker = true;
79880                             }
79881                             if (ts.isSourceFile(statement.parent) && (ts.isArray(result) ? ts.some(result, ts.isExternalModuleIndicator) : ts.isExternalModuleIndicator(result))) {
79882                                 resultHasExternalModuleIndicator = true;
79883                             }
79884                         }
79885                         return result;
79886                     }
79887                 }
79888                 return statement;
79889             }
79890         }
79891         function visitDeclarationSubtree(input) {
79892             if (shouldStripInternal(input))
79893                 return;
79894             if (ts.isDeclaration(input)) {
79895                 if (isDeclarationAndNotVisible(input))
79896                     return;
79897                 if (ts.hasDynamicName(input) && !resolver.isLateBound(ts.getParseTreeNode(input))) {
79898                     return;
79899                 }
79900             }
79901             if (ts.isFunctionLike(input) && resolver.isImplementationOfOverload(input))
79902                 return;
79903             if (ts.isSemicolonClassElement(input))
79904                 return;
79905             var previousEnclosingDeclaration;
79906             if (isEnclosingDeclaration(input)) {
79907                 previousEnclosingDeclaration = enclosingDeclaration;
79908                 enclosingDeclaration = input;
79909             }
79910             var oldDiag = getSymbolAccessibilityDiagnostic;
79911             var canProduceDiagnostic = ts.canProduceDiagnostics(input);
79912             var oldWithinObjectLiteralType = suppressNewDiagnosticContexts;
79913             var shouldEnterSuppressNewDiagnosticsContextContext = ((input.kind === 177 || input.kind === 190) && input.parent.kind !== 254);
79914             if (ts.isMethodDeclaration(input) || ts.isMethodSignature(input)) {
79915                 if (ts.hasEffectiveModifier(input, 8)) {
79916                     if (input.symbol && input.symbol.declarations && input.symbol.declarations[0] !== input)
79917                         return;
79918                     return cleanup(factory.createPropertyDeclaration(undefined, ensureModifiers(input), input.name, undefined, undefined, undefined));
79919                 }
79920             }
79921             if (canProduceDiagnostic && !suppressNewDiagnosticContexts) {
79922                 getSymbolAccessibilityDiagnostic = ts.createGetSymbolAccessibilityDiagnosticForNode(input);
79923             }
79924             if (ts.isTypeQueryNode(input)) {
79925                 checkEntityNameVisibility(input.exprName, enclosingDeclaration);
79926             }
79927             if (shouldEnterSuppressNewDiagnosticsContextContext) {
79928                 suppressNewDiagnosticContexts = true;
79929             }
79930             if (isProcessedComponent(input)) {
79931                 switch (input.kind) {
79932                     case 223: {
79933                         if ((ts.isEntityName(input.expression) || ts.isEntityNameExpression(input.expression))) {
79934                             checkEntityNameVisibility(input.expression, enclosingDeclaration);
79935                         }
79936                         var node = ts.visitEachChild(input, visitDeclarationSubtree, context);
79937                         return cleanup(factory.updateExpressionWithTypeArguments(node, node.expression, node.typeArguments));
79938                     }
79939                     case 173: {
79940                         checkEntityNameVisibility(input.typeName, enclosingDeclaration);
79941                         var node = ts.visitEachChild(input, visitDeclarationSubtree, context);
79942                         return cleanup(factory.updateTypeReferenceNode(node, node.typeName, node.typeArguments));
79943                     }
79944                     case 170:
79945                         return cleanup(factory.updateConstructSignature(input, ensureTypeParams(input, input.typeParameters), updateParamsList(input, input.parameters), ensureType(input, input.type)));
79946                     case 166: {
79947                         var ctor = factory.createConstructorDeclaration(undefined, ensureModifiers(input), updateParamsList(input, input.parameters, 0), undefined);
79948                         return cleanup(ctor);
79949                     }
79950                     case 165: {
79951                         if (ts.isPrivateIdentifier(input.name)) {
79952                             return cleanup(undefined);
79953                         }
79954                         var sig = factory.createMethodDeclaration(undefined, ensureModifiers(input), undefined, input.name, input.questionToken, ensureTypeParams(input, input.typeParameters), updateParamsList(input, input.parameters), ensureType(input, input.type), undefined);
79955                         return cleanup(sig);
79956                     }
79957                     case 167: {
79958                         if (ts.isPrivateIdentifier(input.name)) {
79959                             return cleanup(undefined);
79960                         }
79961                         var accessorType = getTypeAnnotationFromAllAccessorDeclarations(input, resolver.getAllAccessorDeclarations(input));
79962                         return cleanup(factory.updateGetAccessorDeclaration(input, undefined, ensureModifiers(input), input.name, updateAccessorParamsList(input, ts.hasEffectiveModifier(input, 8)), ensureType(input, accessorType), undefined));
79963                     }
79964                     case 168: {
79965                         if (ts.isPrivateIdentifier(input.name)) {
79966                             return cleanup(undefined);
79967                         }
79968                         return cleanup(factory.updateSetAccessorDeclaration(input, undefined, ensureModifiers(input), input.name, updateAccessorParamsList(input, ts.hasEffectiveModifier(input, 8)), undefined));
79969                     }
79970                     case 163:
79971                         if (ts.isPrivateIdentifier(input.name)) {
79972                             return cleanup(undefined);
79973                         }
79974                         return cleanup(factory.updatePropertyDeclaration(input, undefined, ensureModifiers(input), input.name, input.questionToken, ensureType(input, input.type), ensureNoInitializer(input)));
79975                     case 162:
79976                         if (ts.isPrivateIdentifier(input.name)) {
79977                             return cleanup(undefined);
79978                         }
79979                         return cleanup(factory.updatePropertySignature(input, ensureModifiers(input), input.name, input.questionToken, ensureType(input, input.type)));
79980                     case 164: {
79981                         if (ts.isPrivateIdentifier(input.name)) {
79982                             return cleanup(undefined);
79983                         }
79984                         return cleanup(factory.updateMethodSignature(input, ensureModifiers(input), input.name, input.questionToken, ensureTypeParams(input, input.typeParameters), updateParamsList(input, input.parameters), ensureType(input, input.type)));
79985                     }
79986                     case 169: {
79987                         return cleanup(factory.updateCallSignature(input, ensureTypeParams(input, input.typeParameters), updateParamsList(input, input.parameters), ensureType(input, input.type)));
79988                     }
79989                     case 171: {
79990                         return cleanup(factory.updateIndexSignature(input, undefined, ensureModifiers(input), updateParamsList(input, input.parameters), ts.visitNode(input.type, visitDeclarationSubtree) || factory.createKeywordTypeNode(128)));
79991                     }
79992                     case 249: {
79993                         if (ts.isBindingPattern(input.name)) {
79994                             return recreateBindingPattern(input.name);
79995                         }
79996                         shouldEnterSuppressNewDiagnosticsContextContext = true;
79997                         suppressNewDiagnosticContexts = true;
79998                         return cleanup(factory.updateVariableDeclaration(input, input.name, undefined, ensureType(input, input.type), ensureNoInitializer(input)));
79999                     }
80000                     case 159: {
80001                         if (isPrivateMethodTypeParameter(input) && (input.default || input.constraint)) {
80002                             return cleanup(factory.updateTypeParameterDeclaration(input, input.name, undefined, undefined));
80003                         }
80004                         return cleanup(ts.visitEachChild(input, visitDeclarationSubtree, context));
80005                     }
80006                     case 184: {
80007                         var checkType = ts.visitNode(input.checkType, visitDeclarationSubtree);
80008                         var extendsType = ts.visitNode(input.extendsType, visitDeclarationSubtree);
80009                         var oldEnclosingDecl = enclosingDeclaration;
80010                         enclosingDeclaration = input.trueType;
80011                         var trueType = ts.visitNode(input.trueType, visitDeclarationSubtree);
80012                         enclosingDeclaration = oldEnclosingDecl;
80013                         var falseType = ts.visitNode(input.falseType, visitDeclarationSubtree);
80014                         return cleanup(factory.updateConditionalTypeNode(input, checkType, extendsType, trueType, falseType));
80015                     }
80016                     case 174: {
80017                         return cleanup(factory.updateFunctionTypeNode(input, ts.visitNodes(input.typeParameters, visitDeclarationSubtree), updateParamsList(input, input.parameters), ts.visitNode(input.type, visitDeclarationSubtree)));
80018                     }
80019                     case 175: {
80020                         return cleanup(factory.updateConstructorTypeNode(input, ts.visitNodes(input.typeParameters, visitDeclarationSubtree), updateParamsList(input, input.parameters), ts.visitNode(input.type, visitDeclarationSubtree)));
80021                     }
80022                     case 195: {
80023                         if (!ts.isLiteralImportTypeNode(input))
80024                             return cleanup(input);
80025                         return cleanup(factory.updateImportTypeNode(input, factory.updateLiteralTypeNode(input.argument, rewriteModuleSpecifier(input, input.argument.literal)), input.qualifier, ts.visitNodes(input.typeArguments, visitDeclarationSubtree, ts.isTypeNode), input.isTypeOf));
80026                     }
80027                     default: ts.Debug.assertNever(input, "Attempted to process unhandled node kind: " + ts.SyntaxKind[input.kind]);
80028                 }
80029             }
80030             if (ts.isTupleTypeNode(input) && (ts.getLineAndCharacterOfPosition(currentSourceFile, input.pos).line === ts.getLineAndCharacterOfPosition(currentSourceFile, input.end).line)) {
80031                 ts.setEmitFlags(input, 1);
80032             }
80033             return cleanup(ts.visitEachChild(input, visitDeclarationSubtree, context));
80034             function cleanup(returnValue) {
80035                 if (returnValue && canProduceDiagnostic && ts.hasDynamicName(input)) {
80036                     checkName(input);
80037                 }
80038                 if (isEnclosingDeclaration(input)) {
80039                     enclosingDeclaration = previousEnclosingDeclaration;
80040                 }
80041                 if (canProduceDiagnostic && !suppressNewDiagnosticContexts) {
80042                     getSymbolAccessibilityDiagnostic = oldDiag;
80043                 }
80044                 if (shouldEnterSuppressNewDiagnosticsContextContext) {
80045                     suppressNewDiagnosticContexts = oldWithinObjectLiteralType;
80046                 }
80047                 if (returnValue === input) {
80048                     return returnValue;
80049                 }
80050                 return returnValue && ts.setOriginalNode(preserveJsDoc(returnValue, input), input);
80051             }
80052         }
80053         function isPrivateMethodTypeParameter(node) {
80054             return node.parent.kind === 165 && ts.hasEffectiveModifier(node.parent, 8);
80055         }
80056         function visitDeclarationStatements(input) {
80057             if (!isPreservedDeclarationStatement(input)) {
80058                 return;
80059             }
80060             if (shouldStripInternal(input))
80061                 return;
80062             switch (input.kind) {
80063                 case 267: {
80064                     if (ts.isSourceFile(input.parent)) {
80065                         resultHasExternalModuleIndicator = true;
80066                     }
80067                     resultHasScopeMarker = true;
80068                     return factory.updateExportDeclaration(input, undefined, input.modifiers, input.isTypeOnly, input.exportClause, rewriteModuleSpecifier(input, input.moduleSpecifier));
80069                 }
80070                 case 266: {
80071                     if (ts.isSourceFile(input.parent)) {
80072                         resultHasExternalModuleIndicator = true;
80073                     }
80074                     resultHasScopeMarker = true;
80075                     if (input.expression.kind === 78) {
80076                         return input;
80077                     }
80078                     else {
80079                         var newId = factory.createUniqueName("_default", 16);
80080                         getSymbolAccessibilityDiagnostic = function () { return ({
80081                             diagnosticMessage: ts.Diagnostics.Default_export_of_the_module_has_or_is_using_private_name_0,
80082                             errorNode: input
80083                         }); };
80084                         var varDecl = factory.createVariableDeclaration(newId, undefined, resolver.createTypeOfExpression(input.expression, input, declarationEmitNodeBuilderFlags, symbolTracker), undefined);
80085                         var statement = factory.createVariableStatement(needsDeclare ? [factory.createModifier(133)] : [], factory.createVariableDeclarationList([varDecl], 2));
80086                         return [statement, factory.updateExportAssignment(input, input.decorators, input.modifiers, newId)];
80087                     }
80088                 }
80089             }
80090             var result = transformTopLevelDeclaration(input);
80091             lateStatementReplacementMap.set(ts.getOriginalNodeId(input), result);
80092             return input;
80093         }
80094         function stripExportModifiers(statement) {
80095             if (ts.isImportEqualsDeclaration(statement) || ts.hasEffectiveModifier(statement, 512) || !ts.canHaveModifiers(statement)) {
80096                 return statement;
80097             }
80098             var modifiers = factory.createModifiersFromModifierFlags(ts.getEffectiveModifierFlags(statement) & (11263 ^ 1));
80099             return factory.updateModifiers(statement, modifiers);
80100         }
80101         function transformTopLevelDeclaration(input) {
80102             if (shouldStripInternal(input))
80103                 return;
80104             switch (input.kind) {
80105                 case 260: {
80106                     return transformImportEqualsDeclaration(input);
80107                 }
80108                 case 261: {
80109                     return transformImportDeclaration(input);
80110                 }
80111             }
80112             if (ts.isDeclaration(input) && isDeclarationAndNotVisible(input))
80113                 return;
80114             if (ts.isFunctionLike(input) && resolver.isImplementationOfOverload(input))
80115                 return;
80116             var previousEnclosingDeclaration;
80117             if (isEnclosingDeclaration(input)) {
80118                 previousEnclosingDeclaration = enclosingDeclaration;
80119                 enclosingDeclaration = input;
80120             }
80121             var canProdiceDiagnostic = ts.canProduceDiagnostics(input);
80122             var oldDiag = getSymbolAccessibilityDiagnostic;
80123             if (canProdiceDiagnostic) {
80124                 getSymbolAccessibilityDiagnostic = ts.createGetSymbolAccessibilityDiagnosticForNode(input);
80125             }
80126             var previousNeedsDeclare = needsDeclare;
80127             switch (input.kind) {
80128                 case 254:
80129                     return cleanup(factory.updateTypeAliasDeclaration(input, undefined, ensureModifiers(input), input.name, ts.visitNodes(input.typeParameters, visitDeclarationSubtree, ts.isTypeParameterDeclaration), ts.visitNode(input.type, visitDeclarationSubtree, ts.isTypeNode)));
80130                 case 253: {
80131                     return cleanup(factory.updateInterfaceDeclaration(input, undefined, ensureModifiers(input), input.name, ensureTypeParams(input, input.typeParameters), transformHeritageClauses(input.heritageClauses), ts.visitNodes(input.members, visitDeclarationSubtree)));
80132                 }
80133                 case 251: {
80134                     var clean = cleanup(factory.updateFunctionDeclaration(input, undefined, ensureModifiers(input), undefined, input.name, ensureTypeParams(input, input.typeParameters), updateParamsList(input, input.parameters), ensureType(input, input.type), undefined));
80135                     if (clean && resolver.isExpandoFunctionDeclaration(input)) {
80136                         var props = resolver.getPropertiesOfContainerFunction(input);
80137                         var fakespace_1 = ts.parseNodeFactory.createModuleDeclaration(undefined, undefined, clean.name || factory.createIdentifier("_default"), factory.createModuleBlock([]), 16);
80138                         ts.setParent(fakespace_1, enclosingDeclaration);
80139                         fakespace_1.locals = ts.createSymbolTable(props);
80140                         fakespace_1.symbol = props[0].parent;
80141                         var exportMappings_1 = [];
80142                         var declarations = ts.mapDefined(props, function (p) {
80143                             if (!ts.isPropertyAccessExpression(p.valueDeclaration)) {
80144                                 return undefined;
80145                             }
80146                             getSymbolAccessibilityDiagnostic = ts.createGetSymbolAccessibilityDiagnosticForNode(p.valueDeclaration);
80147                             var type = resolver.createTypeOfDeclaration(p.valueDeclaration, fakespace_1, declarationEmitNodeBuilderFlags, symbolTracker);
80148                             getSymbolAccessibilityDiagnostic = oldDiag;
80149                             var nameStr = ts.unescapeLeadingUnderscores(p.escapedName);
80150                             var isNonContextualKeywordName = ts.isStringANonContextualKeyword(nameStr);
80151                             var name = isNonContextualKeywordName ? factory.getGeneratedNameForNode(p.valueDeclaration) : factory.createIdentifier(nameStr);
80152                             if (isNonContextualKeywordName) {
80153                                 exportMappings_1.push([name, nameStr]);
80154                             }
80155                             var varDecl = factory.createVariableDeclaration(name, undefined, type, undefined);
80156                             return factory.createVariableStatement(isNonContextualKeywordName ? undefined : [factory.createToken(92)], factory.createVariableDeclarationList([varDecl]));
80157                         });
80158                         if (!exportMappings_1.length) {
80159                             declarations = ts.mapDefined(declarations, function (declaration) { return factory.updateModifiers(declaration, 0); });
80160                         }
80161                         else {
80162                             declarations.push(factory.createExportDeclaration(undefined, undefined, false, factory.createNamedExports(ts.map(exportMappings_1, function (_a) {
80163                                 var gen = _a[0], exp = _a[1];
80164                                 return factory.createExportSpecifier(gen, exp);
80165                             }))));
80166                         }
80167                         var namespaceDecl = factory.createModuleDeclaration(undefined, ensureModifiers(input), input.name, factory.createModuleBlock(declarations), 16);
80168                         if (!ts.hasEffectiveModifier(clean, 512)) {
80169                             return [clean, namespaceDecl];
80170                         }
80171                         var modifiers = factory.createModifiersFromModifierFlags((ts.getEffectiveModifierFlags(clean) & ~513) | 2);
80172                         var cleanDeclaration = factory.updateFunctionDeclaration(clean, undefined, modifiers, undefined, clean.name, clean.typeParameters, clean.parameters, clean.type, undefined);
80173                         var namespaceDeclaration = factory.updateModuleDeclaration(namespaceDecl, undefined, modifiers, namespaceDecl.name, namespaceDecl.body);
80174                         var exportDefaultDeclaration = factory.createExportAssignment(undefined, undefined, false, namespaceDecl.name);
80175                         if (ts.isSourceFile(input.parent)) {
80176                             resultHasExternalModuleIndicator = true;
80177                         }
80178                         resultHasScopeMarker = true;
80179                         return [cleanDeclaration, namespaceDeclaration, exportDefaultDeclaration];
80180                     }
80181                     else {
80182                         return clean;
80183                     }
80184                 }
80185                 case 256: {
80186                     needsDeclare = false;
80187                     var inner = input.body;
80188                     if (inner && inner.kind === 257) {
80189                         var oldNeedsScopeFix = needsScopeFixMarker;
80190                         var oldHasScopeFix = resultHasScopeMarker;
80191                         resultHasScopeMarker = false;
80192                         needsScopeFixMarker = false;
80193                         var statements = ts.visitNodes(inner.statements, visitDeclarationStatements);
80194                         var lateStatements = transformAndReplaceLatePaintedStatements(statements);
80195                         if (input.flags & 8388608) {
80196                             needsScopeFixMarker = false;
80197                         }
80198                         if (!ts.isGlobalScopeAugmentation(input) && !hasScopeMarker(lateStatements) && !resultHasScopeMarker) {
80199                             if (needsScopeFixMarker) {
80200                                 lateStatements = factory.createNodeArray(__spreadArrays(lateStatements, [ts.createEmptyExports(factory)]));
80201                             }
80202                             else {
80203                                 lateStatements = ts.visitNodes(lateStatements, stripExportModifiers);
80204                             }
80205                         }
80206                         var body = factory.updateModuleBlock(inner, lateStatements);
80207                         needsDeclare = previousNeedsDeclare;
80208                         needsScopeFixMarker = oldNeedsScopeFix;
80209                         resultHasScopeMarker = oldHasScopeFix;
80210                         var mods = ensureModifiers(input);
80211                         return cleanup(factory.updateModuleDeclaration(input, undefined, mods, ts.isExternalModuleAugmentation(input) ? rewriteModuleSpecifier(input, input.name) : input.name, body));
80212                     }
80213                     else {
80214                         needsDeclare = previousNeedsDeclare;
80215                         var mods = ensureModifiers(input);
80216                         needsDeclare = false;
80217                         ts.visitNode(inner, visitDeclarationStatements);
80218                         var id = ts.getOriginalNodeId(inner);
80219                         var body = lateStatementReplacementMap.get(id);
80220                         lateStatementReplacementMap.delete(id);
80221                         return cleanup(factory.updateModuleDeclaration(input, undefined, mods, input.name, body));
80222                     }
80223                 }
80224                 case 252: {
80225                     var modifiers = factory.createNodeArray(ensureModifiers(input));
80226                     var typeParameters = ensureTypeParams(input, input.typeParameters);
80227                     var ctor = ts.getFirstConstructorWithBody(input);
80228                     var parameterProperties = void 0;
80229                     if (ctor) {
80230                         var oldDiag_1 = getSymbolAccessibilityDiagnostic;
80231                         parameterProperties = ts.compact(ts.flatMap(ctor.parameters, function (param) {
80232                             if (!ts.hasSyntacticModifier(param, 92) || shouldStripInternal(param))
80233                                 return;
80234                             getSymbolAccessibilityDiagnostic = ts.createGetSymbolAccessibilityDiagnosticForNode(param);
80235                             if (param.name.kind === 78) {
80236                                 return preserveJsDoc(factory.createPropertyDeclaration(undefined, ensureModifiers(param), param.name, param.questionToken, ensureType(param, param.type), ensureNoInitializer(param)), param);
80237                             }
80238                             else {
80239                                 return walkBindingPattern(param.name);
80240                             }
80241                             function walkBindingPattern(pattern) {
80242                                 var elems;
80243                                 for (var _i = 0, _a = pattern.elements; _i < _a.length; _i++) {
80244                                     var elem = _a[_i];
80245                                     if (ts.isOmittedExpression(elem))
80246                                         continue;
80247                                     if (ts.isBindingPattern(elem.name)) {
80248                                         elems = ts.concatenate(elems, walkBindingPattern(elem.name));
80249                                     }
80250                                     elems = elems || [];
80251                                     elems.push(factory.createPropertyDeclaration(undefined, ensureModifiers(param), elem.name, undefined, ensureType(elem, undefined), undefined));
80252                                 }
80253                                 return elems;
80254                             }
80255                         }));
80256                         getSymbolAccessibilityDiagnostic = oldDiag_1;
80257                     }
80258                     var hasPrivateIdentifier = ts.some(input.members, function (member) { return !!member.name && ts.isPrivateIdentifier(member.name); });
80259                     var privateIdentifier = hasPrivateIdentifier ? [
80260                         factory.createPropertyDeclaration(undefined, undefined, factory.createPrivateIdentifier("#private"), undefined, undefined, undefined)
80261                     ] : undefined;
80262                     var memberNodes = ts.concatenate(ts.concatenate(privateIdentifier, parameterProperties), ts.visitNodes(input.members, visitDeclarationSubtree));
80263                     var members = factory.createNodeArray(memberNodes);
80264                     var extendsClause_1 = ts.getEffectiveBaseTypeNode(input);
80265                     if (extendsClause_1 && !ts.isEntityNameExpression(extendsClause_1.expression) && extendsClause_1.expression.kind !== 103) {
80266                         var oldId = input.name ? ts.unescapeLeadingUnderscores(input.name.escapedText) : "default";
80267                         var newId_1 = factory.createUniqueName(oldId + "_base", 16);
80268                         getSymbolAccessibilityDiagnostic = function () { return ({
80269                             diagnosticMessage: ts.Diagnostics.extends_clause_of_exported_class_0_has_or_is_using_private_name_1,
80270                             errorNode: extendsClause_1,
80271                             typeName: input.name
80272                         }); };
80273                         var varDecl = factory.createVariableDeclaration(newId_1, undefined, resolver.createTypeOfExpression(extendsClause_1.expression, input, declarationEmitNodeBuilderFlags, symbolTracker), undefined);
80274                         var statement = factory.createVariableStatement(needsDeclare ? [factory.createModifier(133)] : [], factory.createVariableDeclarationList([varDecl], 2));
80275                         var heritageClauses = factory.createNodeArray(ts.map(input.heritageClauses, function (clause) {
80276                             if (clause.token === 93) {
80277                                 var oldDiag_2 = getSymbolAccessibilityDiagnostic;
80278                                 getSymbolAccessibilityDiagnostic = ts.createGetSymbolAccessibilityDiagnosticForNode(clause.types[0]);
80279                                 var newClause = factory.updateHeritageClause(clause, ts.map(clause.types, function (t) { return factory.updateExpressionWithTypeArguments(t, newId_1, ts.visitNodes(t.typeArguments, visitDeclarationSubtree)); }));
80280                                 getSymbolAccessibilityDiagnostic = oldDiag_2;
80281                                 return newClause;
80282                             }
80283                             return factory.updateHeritageClause(clause, ts.visitNodes(factory.createNodeArray(ts.filter(clause.types, function (t) { return ts.isEntityNameExpression(t.expression) || t.expression.kind === 103; })), visitDeclarationSubtree));
80284                         }));
80285                         return [statement, cleanup(factory.updateClassDeclaration(input, undefined, modifiers, input.name, typeParameters, heritageClauses, members))];
80286                     }
80287                     else {
80288                         var heritageClauses = transformHeritageClauses(input.heritageClauses);
80289                         return cleanup(factory.updateClassDeclaration(input, undefined, modifiers, input.name, typeParameters, heritageClauses, members));
80290                     }
80291                 }
80292                 case 232: {
80293                     return cleanup(transformVariableStatement(input));
80294                 }
80295                 case 255: {
80296                     return cleanup(factory.updateEnumDeclaration(input, undefined, factory.createNodeArray(ensureModifiers(input)), input.name, factory.createNodeArray(ts.mapDefined(input.members, function (m) {
80297                         if (shouldStripInternal(m))
80298                             return;
80299                         var constValue = resolver.getConstantValue(m);
80300                         return preserveJsDoc(factory.updateEnumMember(m, m.name, constValue !== undefined ? typeof constValue === "string" ? factory.createStringLiteral(constValue) : factory.createNumericLiteral(constValue) : undefined), m);
80301                     }))));
80302                 }
80303             }
80304             return ts.Debug.assertNever(input, "Unhandled top-level node in declaration emit: " + ts.SyntaxKind[input.kind]);
80305             function cleanup(node) {
80306                 if (isEnclosingDeclaration(input)) {
80307                     enclosingDeclaration = previousEnclosingDeclaration;
80308                 }
80309                 if (canProdiceDiagnostic) {
80310                     getSymbolAccessibilityDiagnostic = oldDiag;
80311                 }
80312                 if (input.kind === 256) {
80313                     needsDeclare = previousNeedsDeclare;
80314                 }
80315                 if (node === input) {
80316                     return node;
80317                 }
80318                 return node && ts.setOriginalNode(preserveJsDoc(node, input), input);
80319             }
80320         }
80321         function transformVariableStatement(input) {
80322             if (!ts.forEach(input.declarationList.declarations, getBindingNameVisible))
80323                 return;
80324             var nodes = ts.visitNodes(input.declarationList.declarations, visitDeclarationSubtree);
80325             if (!ts.length(nodes))
80326                 return;
80327             return factory.updateVariableStatement(input, factory.createNodeArray(ensureModifiers(input)), factory.updateVariableDeclarationList(input.declarationList, nodes));
80328         }
80329         function recreateBindingPattern(d) {
80330             return ts.flatten(ts.mapDefined(d.elements, function (e) { return recreateBindingElement(e); }));
80331         }
80332         function recreateBindingElement(e) {
80333             if (e.kind === 222) {
80334                 return;
80335             }
80336             if (e.name) {
80337                 if (!getBindingNameVisible(e))
80338                     return;
80339                 if (ts.isBindingPattern(e.name)) {
80340                     return recreateBindingPattern(e.name);
80341                 }
80342                 else {
80343                     return factory.createVariableDeclaration(e.name, undefined, ensureType(e, undefined), undefined);
80344                 }
80345             }
80346         }
80347         function checkName(node) {
80348             var oldDiag;
80349             if (!suppressNewDiagnosticContexts) {
80350                 oldDiag = getSymbolAccessibilityDiagnostic;
80351                 getSymbolAccessibilityDiagnostic = ts.createGetSymbolAccessibilityDiagnosticForNodeName(node);
80352             }
80353             errorNameNode = node.name;
80354             ts.Debug.assert(resolver.isLateBound(ts.getParseTreeNode(node)));
80355             var decl = node;
80356             var entityName = decl.name.expression;
80357             checkEntityNameVisibility(entityName, enclosingDeclaration);
80358             if (!suppressNewDiagnosticContexts) {
80359                 getSymbolAccessibilityDiagnostic = oldDiag;
80360             }
80361             errorNameNode = undefined;
80362         }
80363         function shouldStripInternal(node) {
80364             return !!stripInternal && !!node && isInternalDeclaration(node, currentSourceFile);
80365         }
80366         function isScopeMarker(node) {
80367             return ts.isExportAssignment(node) || ts.isExportDeclaration(node);
80368         }
80369         function hasScopeMarker(statements) {
80370             return ts.some(statements, isScopeMarker);
80371         }
80372         function ensureModifiers(node) {
80373             var currentFlags = ts.getEffectiveModifierFlags(node);
80374             var newFlags = ensureModifierFlags(node);
80375             if (currentFlags === newFlags) {
80376                 return node.modifiers;
80377             }
80378             return factory.createModifiersFromModifierFlags(newFlags);
80379         }
80380         function ensureModifierFlags(node) {
80381             var mask = 11263 ^ (4 | 256);
80382             var additions = (needsDeclare && !isAlwaysType(node)) ? 2 : 0;
80383             var parentIsFile = node.parent.kind === 297;
80384             if (!parentIsFile || (isBundledEmit && parentIsFile && ts.isExternalModule(node.parent))) {
80385                 mask ^= 2;
80386                 additions = 0;
80387             }
80388             return maskModifierFlags(node, mask, additions);
80389         }
80390         function getTypeAnnotationFromAllAccessorDeclarations(node, accessors) {
80391             var accessorType = getTypeAnnotationFromAccessor(node);
80392             if (!accessorType && node !== accessors.firstAccessor) {
80393                 accessorType = getTypeAnnotationFromAccessor(accessors.firstAccessor);
80394                 getSymbolAccessibilityDiagnostic = ts.createGetSymbolAccessibilityDiagnosticForNode(accessors.firstAccessor);
80395             }
80396             if (!accessorType && accessors.secondAccessor && node !== accessors.secondAccessor) {
80397                 accessorType = getTypeAnnotationFromAccessor(accessors.secondAccessor);
80398                 getSymbolAccessibilityDiagnostic = ts.createGetSymbolAccessibilityDiagnosticForNode(accessors.secondAccessor);
80399             }
80400             return accessorType;
80401         }
80402         function transformHeritageClauses(nodes) {
80403             return factory.createNodeArray(ts.filter(ts.map(nodes, function (clause) { return factory.updateHeritageClause(clause, ts.visitNodes(factory.createNodeArray(ts.filter(clause.types, function (t) {
80404                 return ts.isEntityNameExpression(t.expression) || (clause.token === 93 && t.expression.kind === 103);
80405             })), visitDeclarationSubtree)); }), function (clause) { return clause.types && !!clause.types.length; }));
80406         }
80407     }
80408     ts.transformDeclarations = transformDeclarations;
80409     function isAlwaysType(node) {
80410         if (node.kind === 253) {
80411             return true;
80412         }
80413         return false;
80414     }
80415     function maskModifiers(node, modifierMask, modifierAdditions) {
80416         return ts.factory.createModifiersFromModifierFlags(maskModifierFlags(node, modifierMask, modifierAdditions));
80417     }
80418     function maskModifierFlags(node, modifierMask, modifierAdditions) {
80419         if (modifierMask === void 0) { modifierMask = 11263 ^ 4; }
80420         if (modifierAdditions === void 0) { modifierAdditions = 0; }
80421         var flags = (ts.getEffectiveModifierFlags(node) & modifierMask) | modifierAdditions;
80422         if (flags & 512 && !(flags & 1)) {
80423             flags ^= 1;
80424         }
80425         if (flags & 512 && flags & 2) {
80426             flags ^= 2;
80427         }
80428         return flags;
80429     }
80430     function getTypeAnnotationFromAccessor(accessor) {
80431         if (accessor) {
80432             return accessor.kind === 167
80433                 ? accessor.type
80434                 : accessor.parameters.length > 0
80435                     ? accessor.parameters[0].type
80436                     : undefined;
80437         }
80438     }
80439     function canHaveLiteralInitializer(node) {
80440         switch (node.kind) {
80441             case 163:
80442             case 162:
80443                 return !ts.hasEffectiveModifier(node, 8);
80444             case 160:
80445             case 249:
80446                 return true;
80447         }
80448         return false;
80449     }
80450     function isPreservedDeclarationStatement(node) {
80451         switch (node.kind) {
80452             case 251:
80453             case 256:
80454             case 260:
80455             case 253:
80456             case 252:
80457             case 254:
80458             case 255:
80459             case 232:
80460             case 261:
80461             case 267:
80462             case 266:
80463                 return true;
80464         }
80465         return false;
80466     }
80467     function isProcessedComponent(node) {
80468         switch (node.kind) {
80469             case 170:
80470             case 166:
80471             case 165:
80472             case 167:
80473             case 168:
80474             case 163:
80475             case 162:
80476             case 164:
80477             case 169:
80478             case 171:
80479             case 249:
80480             case 159:
80481             case 223:
80482             case 173:
80483             case 184:
80484             case 174:
80485             case 175:
80486             case 195:
80487                 return true;
80488         }
80489         return false;
80490     }
80491 })(ts || (ts = {}));
80492 var ts;
80493 (function (ts) {
80494     function getModuleTransformer(moduleKind) {
80495         switch (moduleKind) {
80496             case ts.ModuleKind.ESNext:
80497             case ts.ModuleKind.ES2020:
80498             case ts.ModuleKind.ES2015:
80499                 return ts.transformECMAScriptModule;
80500             case ts.ModuleKind.System:
80501                 return ts.transformSystemModule;
80502             default:
80503                 return ts.transformModule;
80504         }
80505     }
80506     ts.noTransformers = { scriptTransformers: ts.emptyArray, declarationTransformers: ts.emptyArray };
80507     function getTransformers(compilerOptions, customTransformers, emitOnlyDtsFiles) {
80508         return {
80509             scriptTransformers: getScriptTransformers(compilerOptions, customTransformers, emitOnlyDtsFiles),
80510             declarationTransformers: getDeclarationTransformers(customTransformers),
80511         };
80512     }
80513     ts.getTransformers = getTransformers;
80514     function getScriptTransformers(compilerOptions, customTransformers, emitOnlyDtsFiles) {
80515         if (emitOnlyDtsFiles)
80516             return ts.emptyArray;
80517         var languageVersion = ts.getEmitScriptTarget(compilerOptions);
80518         var moduleKind = ts.getEmitModuleKind(compilerOptions);
80519         var transformers = [];
80520         ts.addRange(transformers, customTransformers && ts.map(customTransformers.before, wrapScriptTransformerFactory));
80521         transformers.push(ts.transformTypeScript);
80522         transformers.push(ts.transformClassFields);
80523         if (ts.getJSXTransformEnabled(compilerOptions)) {
80524             transformers.push(ts.transformJsx);
80525         }
80526         if (languageVersion < 99) {
80527             transformers.push(ts.transformESNext);
80528         }
80529         if (languageVersion < 7) {
80530             transformers.push(ts.transformES2020);
80531         }
80532         if (languageVersion < 6) {
80533             transformers.push(ts.transformES2019);
80534         }
80535         if (languageVersion < 5) {
80536             transformers.push(ts.transformES2018);
80537         }
80538         if (languageVersion < 4) {
80539             transformers.push(ts.transformES2017);
80540         }
80541         if (languageVersion < 3) {
80542             transformers.push(ts.transformES2016);
80543         }
80544         if (languageVersion < 2) {
80545             transformers.push(ts.transformES2015);
80546             transformers.push(ts.transformGenerators);
80547         }
80548         transformers.push(getModuleTransformer(moduleKind));
80549         if (languageVersion < 1) {
80550             transformers.push(ts.transformES5);
80551         }
80552         ts.addRange(transformers, customTransformers && ts.map(customTransformers.after, wrapScriptTransformerFactory));
80553         return transformers;
80554     }
80555     function getDeclarationTransformers(customTransformers) {
80556         var transformers = [];
80557         transformers.push(ts.transformDeclarations);
80558         ts.addRange(transformers, customTransformers && ts.map(customTransformers.afterDeclarations, wrapDeclarationTransformerFactory));
80559         return transformers;
80560     }
80561     function wrapCustomTransformer(transformer) {
80562         return function (node) { return ts.isBundle(node) ? transformer.transformBundle(node) : transformer.transformSourceFile(node); };
80563     }
80564     function wrapCustomTransformerFactory(transformer, handleDefault) {
80565         return function (context) {
80566             var customTransformer = transformer(context);
80567             return typeof customTransformer === "function"
80568                 ? handleDefault(context, customTransformer)
80569                 : wrapCustomTransformer(customTransformer);
80570         };
80571     }
80572     function wrapScriptTransformerFactory(transformer) {
80573         return wrapCustomTransformerFactory(transformer, ts.chainBundle);
80574     }
80575     function wrapDeclarationTransformerFactory(transformer) {
80576         return wrapCustomTransformerFactory(transformer, function (_, node) { return node; });
80577     }
80578     function noEmitSubstitution(_hint, node) {
80579         return node;
80580     }
80581     ts.noEmitSubstitution = noEmitSubstitution;
80582     function noEmitNotification(hint, node, callback) {
80583         callback(hint, node);
80584     }
80585     ts.noEmitNotification = noEmitNotification;
80586     function transformNodes(resolver, host, factory, options, nodes, transformers, allowDtsFiles) {
80587         var enabledSyntaxKindFeatures = new Array(341);
80588         var lexicalEnvironmentVariableDeclarations;
80589         var lexicalEnvironmentFunctionDeclarations;
80590         var lexicalEnvironmentStatements;
80591         var lexicalEnvironmentFlags = 0;
80592         var lexicalEnvironmentVariableDeclarationsStack = [];
80593         var lexicalEnvironmentFunctionDeclarationsStack = [];
80594         var lexicalEnvironmentStatementsStack = [];
80595         var lexicalEnvironmentFlagsStack = [];
80596         var lexicalEnvironmentStackOffset = 0;
80597         var lexicalEnvironmentSuspended = false;
80598         var emitHelpers;
80599         var onSubstituteNode = noEmitSubstitution;
80600         var onEmitNode = noEmitNotification;
80601         var state = 0;
80602         var diagnostics = [];
80603         var context = {
80604             factory: factory,
80605             getCompilerOptions: function () { return options; },
80606             getEmitResolver: function () { return resolver; },
80607             getEmitHost: function () { return host; },
80608             getEmitHelperFactory: ts.memoize(function () { return ts.createEmitHelperFactory(context); }),
80609             startLexicalEnvironment: startLexicalEnvironment,
80610             suspendLexicalEnvironment: suspendLexicalEnvironment,
80611             resumeLexicalEnvironment: resumeLexicalEnvironment,
80612             endLexicalEnvironment: endLexicalEnvironment,
80613             setLexicalEnvironmentFlags: setLexicalEnvironmentFlags,
80614             getLexicalEnvironmentFlags: getLexicalEnvironmentFlags,
80615             hoistVariableDeclaration: hoistVariableDeclaration,
80616             hoistFunctionDeclaration: hoistFunctionDeclaration,
80617             addInitializationStatement: addInitializationStatement,
80618             requestEmitHelper: requestEmitHelper,
80619             readEmitHelpers: readEmitHelpers,
80620             enableSubstitution: enableSubstitution,
80621             enableEmitNotification: enableEmitNotification,
80622             isSubstitutionEnabled: isSubstitutionEnabled,
80623             isEmitNotificationEnabled: isEmitNotificationEnabled,
80624             get onSubstituteNode() { return onSubstituteNode; },
80625             set onSubstituteNode(value) {
80626                 ts.Debug.assert(state < 1, "Cannot modify transformation hooks after initialization has completed.");
80627                 ts.Debug.assert(value !== undefined, "Value must not be 'undefined'");
80628                 onSubstituteNode = value;
80629             },
80630             get onEmitNode() { return onEmitNode; },
80631             set onEmitNode(value) {
80632                 ts.Debug.assert(state < 1, "Cannot modify transformation hooks after initialization has completed.");
80633                 ts.Debug.assert(value !== undefined, "Value must not be 'undefined'");
80634                 onEmitNode = value;
80635             },
80636             addDiagnostic: function (diag) {
80637                 diagnostics.push(diag);
80638             }
80639         };
80640         for (var _i = 0, nodes_2 = nodes; _i < nodes_2.length; _i++) {
80641             var node = nodes_2[_i];
80642             ts.disposeEmitNodes(ts.getSourceFileOfNode(ts.getParseTreeNode(node)));
80643         }
80644         ts.performance.mark("beforeTransform");
80645         var transformersWithContext = transformers.map(function (t) { return t(context); });
80646         var transformation = function (node) {
80647             for (var _i = 0, transformersWithContext_1 = transformersWithContext; _i < transformersWithContext_1.length; _i++) {
80648                 var transform = transformersWithContext_1[_i];
80649                 node = transform(node);
80650             }
80651             return node;
80652         };
80653         state = 1;
80654         var transformed = [];
80655         for (var _a = 0, nodes_3 = nodes; _a < nodes_3.length; _a++) {
80656             var node = nodes_3[_a];
80657             ts.tracing.push("emit", "transformNodes", node.kind === 297 ? { path: node.path } : { kind: node.kind, pos: node.pos, end: node.end });
80658             transformed.push((allowDtsFiles ? transformation : transformRoot)(node));
80659             ts.tracing.pop();
80660         }
80661         state = 2;
80662         ts.performance.mark("afterTransform");
80663         ts.performance.measure("transformTime", "beforeTransform", "afterTransform");
80664         return {
80665             transformed: transformed,
80666             substituteNode: substituteNode,
80667             emitNodeWithNotification: emitNodeWithNotification,
80668             isEmitNotificationEnabled: isEmitNotificationEnabled,
80669             dispose: dispose,
80670             diagnostics: diagnostics
80671         };
80672         function transformRoot(node) {
80673             return node && (!ts.isSourceFile(node) || !node.isDeclarationFile) ? transformation(node) : node;
80674         }
80675         function enableSubstitution(kind) {
80676             ts.Debug.assert(state < 2, "Cannot modify the transformation context after transformation has completed.");
80677             enabledSyntaxKindFeatures[kind] |= 1;
80678         }
80679         function isSubstitutionEnabled(node) {
80680             return (enabledSyntaxKindFeatures[node.kind] & 1) !== 0
80681                 && (ts.getEmitFlags(node) & 4) === 0;
80682         }
80683         function substituteNode(hint, node) {
80684             ts.Debug.assert(state < 3, "Cannot substitute a node after the result is disposed.");
80685             return node && isSubstitutionEnabled(node) && onSubstituteNode(hint, node) || node;
80686         }
80687         function enableEmitNotification(kind) {
80688             ts.Debug.assert(state < 2, "Cannot modify the transformation context after transformation has completed.");
80689             enabledSyntaxKindFeatures[kind] |= 2;
80690         }
80691         function isEmitNotificationEnabled(node) {
80692             return (enabledSyntaxKindFeatures[node.kind] & 2) !== 0
80693                 || (ts.getEmitFlags(node) & 2) !== 0;
80694         }
80695         function emitNodeWithNotification(hint, node, emitCallback) {
80696             ts.Debug.assert(state < 3, "Cannot invoke TransformationResult callbacks after the result is disposed.");
80697             if (node) {
80698                 if (isEmitNotificationEnabled(node)) {
80699                     onEmitNode(hint, node, emitCallback);
80700                 }
80701                 else {
80702                     emitCallback(hint, node);
80703                 }
80704             }
80705         }
80706         function hoistVariableDeclaration(name) {
80707             ts.Debug.assert(state > 0, "Cannot modify the lexical environment during initialization.");
80708             ts.Debug.assert(state < 2, "Cannot modify the lexical environment after transformation has completed.");
80709             var decl = ts.setEmitFlags(factory.createVariableDeclaration(name), 64);
80710             if (!lexicalEnvironmentVariableDeclarations) {
80711                 lexicalEnvironmentVariableDeclarations = [decl];
80712             }
80713             else {
80714                 lexicalEnvironmentVariableDeclarations.push(decl);
80715             }
80716             if (lexicalEnvironmentFlags & 1) {
80717                 lexicalEnvironmentFlags |= 2;
80718             }
80719         }
80720         function hoistFunctionDeclaration(func) {
80721             ts.Debug.assert(state > 0, "Cannot modify the lexical environment during initialization.");
80722             ts.Debug.assert(state < 2, "Cannot modify the lexical environment after transformation has completed.");
80723             ts.setEmitFlags(func, 1048576);
80724             if (!lexicalEnvironmentFunctionDeclarations) {
80725                 lexicalEnvironmentFunctionDeclarations = [func];
80726             }
80727             else {
80728                 lexicalEnvironmentFunctionDeclarations.push(func);
80729             }
80730         }
80731         function addInitializationStatement(node) {
80732             ts.Debug.assert(state > 0, "Cannot modify the lexical environment during initialization.");
80733             ts.Debug.assert(state < 2, "Cannot modify the lexical environment after transformation has completed.");
80734             ts.setEmitFlags(node, 1048576);
80735             if (!lexicalEnvironmentStatements) {
80736                 lexicalEnvironmentStatements = [node];
80737             }
80738             else {
80739                 lexicalEnvironmentStatements.push(node);
80740             }
80741         }
80742         function startLexicalEnvironment() {
80743             ts.Debug.assert(state > 0, "Cannot modify the lexical environment during initialization.");
80744             ts.Debug.assert(state < 2, "Cannot modify the lexical environment after transformation has completed.");
80745             ts.Debug.assert(!lexicalEnvironmentSuspended, "Lexical environment is suspended.");
80746             lexicalEnvironmentVariableDeclarationsStack[lexicalEnvironmentStackOffset] = lexicalEnvironmentVariableDeclarations;
80747             lexicalEnvironmentFunctionDeclarationsStack[lexicalEnvironmentStackOffset] = lexicalEnvironmentFunctionDeclarations;
80748             lexicalEnvironmentStatementsStack[lexicalEnvironmentStackOffset] = lexicalEnvironmentStatements;
80749             lexicalEnvironmentFlagsStack[lexicalEnvironmentStackOffset] = lexicalEnvironmentFlags;
80750             lexicalEnvironmentStackOffset++;
80751             lexicalEnvironmentVariableDeclarations = undefined;
80752             lexicalEnvironmentFunctionDeclarations = undefined;
80753             lexicalEnvironmentStatements = undefined;
80754             lexicalEnvironmentFlags = 0;
80755         }
80756         function suspendLexicalEnvironment() {
80757             ts.Debug.assert(state > 0, "Cannot modify the lexical environment during initialization.");
80758             ts.Debug.assert(state < 2, "Cannot modify the lexical environment after transformation has completed.");
80759             ts.Debug.assert(!lexicalEnvironmentSuspended, "Lexical environment is already suspended.");
80760             lexicalEnvironmentSuspended = true;
80761         }
80762         function resumeLexicalEnvironment() {
80763             ts.Debug.assert(state > 0, "Cannot modify the lexical environment during initialization.");
80764             ts.Debug.assert(state < 2, "Cannot modify the lexical environment after transformation has completed.");
80765             ts.Debug.assert(lexicalEnvironmentSuspended, "Lexical environment is not suspended.");
80766             lexicalEnvironmentSuspended = false;
80767         }
80768         function endLexicalEnvironment() {
80769             ts.Debug.assert(state > 0, "Cannot modify the lexical environment during initialization.");
80770             ts.Debug.assert(state < 2, "Cannot modify the lexical environment after transformation has completed.");
80771             ts.Debug.assert(!lexicalEnvironmentSuspended, "Lexical environment is suspended.");
80772             var statements;
80773             if (lexicalEnvironmentVariableDeclarations ||
80774                 lexicalEnvironmentFunctionDeclarations ||
80775                 lexicalEnvironmentStatements) {
80776                 if (lexicalEnvironmentFunctionDeclarations) {
80777                     statements = __spreadArrays(lexicalEnvironmentFunctionDeclarations);
80778                 }
80779                 if (lexicalEnvironmentVariableDeclarations) {
80780                     var statement = factory.createVariableStatement(undefined, factory.createVariableDeclarationList(lexicalEnvironmentVariableDeclarations));
80781                     ts.setEmitFlags(statement, 1048576);
80782                     if (!statements) {
80783                         statements = [statement];
80784                     }
80785                     else {
80786                         statements.push(statement);
80787                     }
80788                 }
80789                 if (lexicalEnvironmentStatements) {
80790                     if (!statements) {
80791                         statements = __spreadArrays(lexicalEnvironmentStatements);
80792                     }
80793                     else {
80794                         statements = __spreadArrays(statements, lexicalEnvironmentStatements);
80795                     }
80796                 }
80797             }
80798             lexicalEnvironmentStackOffset--;
80799             lexicalEnvironmentVariableDeclarations = lexicalEnvironmentVariableDeclarationsStack[lexicalEnvironmentStackOffset];
80800             lexicalEnvironmentFunctionDeclarations = lexicalEnvironmentFunctionDeclarationsStack[lexicalEnvironmentStackOffset];
80801             lexicalEnvironmentStatements = lexicalEnvironmentStatementsStack[lexicalEnvironmentStackOffset];
80802             lexicalEnvironmentFlags = lexicalEnvironmentFlagsStack[lexicalEnvironmentStackOffset];
80803             if (lexicalEnvironmentStackOffset === 0) {
80804                 lexicalEnvironmentVariableDeclarationsStack = [];
80805                 lexicalEnvironmentFunctionDeclarationsStack = [];
80806                 lexicalEnvironmentStatementsStack = [];
80807                 lexicalEnvironmentFlagsStack = [];
80808             }
80809             return statements;
80810         }
80811         function setLexicalEnvironmentFlags(flags, value) {
80812             lexicalEnvironmentFlags = value ?
80813                 lexicalEnvironmentFlags | flags :
80814                 lexicalEnvironmentFlags & ~flags;
80815         }
80816         function getLexicalEnvironmentFlags() {
80817             return lexicalEnvironmentFlags;
80818         }
80819         function requestEmitHelper(helper) {
80820             ts.Debug.assert(state > 0, "Cannot modify the transformation context during initialization.");
80821             ts.Debug.assert(state < 2, "Cannot modify the transformation context after transformation has completed.");
80822             ts.Debug.assert(!helper.scoped, "Cannot request a scoped emit helper.");
80823             if (helper.dependencies) {
80824                 for (var _i = 0, _a = helper.dependencies; _i < _a.length; _i++) {
80825                     var h = _a[_i];
80826                     requestEmitHelper(h);
80827                 }
80828             }
80829             emitHelpers = ts.append(emitHelpers, helper);
80830         }
80831         function readEmitHelpers() {
80832             ts.Debug.assert(state > 0, "Cannot modify the transformation context during initialization.");
80833             ts.Debug.assert(state < 2, "Cannot modify the transformation context after transformation has completed.");
80834             var helpers = emitHelpers;
80835             emitHelpers = undefined;
80836             return helpers;
80837         }
80838         function dispose() {
80839             if (state < 3) {
80840                 for (var _i = 0, nodes_4 = nodes; _i < nodes_4.length; _i++) {
80841                     var node = nodes_4[_i];
80842                     ts.disposeEmitNodes(ts.getSourceFileOfNode(ts.getParseTreeNode(node)));
80843                 }
80844                 lexicalEnvironmentVariableDeclarations = undefined;
80845                 lexicalEnvironmentVariableDeclarationsStack = undefined;
80846                 lexicalEnvironmentFunctionDeclarations = undefined;
80847                 lexicalEnvironmentFunctionDeclarationsStack = undefined;
80848                 onSubstituteNode = undefined;
80849                 onEmitNode = undefined;
80850                 emitHelpers = undefined;
80851                 state = 3;
80852             }
80853         }
80854     }
80855     ts.transformNodes = transformNodes;
80856     ts.nullTransformationContext = {
80857         get factory() { return ts.factory; },
80858         enableEmitNotification: ts.noop,
80859         enableSubstitution: ts.noop,
80860         endLexicalEnvironment: ts.returnUndefined,
80861         getCompilerOptions: function () { return ({}); },
80862         getEmitHost: ts.notImplemented,
80863         getEmitResolver: ts.notImplemented,
80864         getEmitHelperFactory: ts.notImplemented,
80865         setLexicalEnvironmentFlags: ts.noop,
80866         getLexicalEnvironmentFlags: function () { return 0; },
80867         hoistFunctionDeclaration: ts.noop,
80868         hoistVariableDeclaration: ts.noop,
80869         addInitializationStatement: ts.noop,
80870         isEmitNotificationEnabled: ts.notImplemented,
80871         isSubstitutionEnabled: ts.notImplemented,
80872         onEmitNode: ts.noop,
80873         onSubstituteNode: ts.notImplemented,
80874         readEmitHelpers: ts.notImplemented,
80875         requestEmitHelper: ts.noop,
80876         resumeLexicalEnvironment: ts.noop,
80877         startLexicalEnvironment: ts.noop,
80878         suspendLexicalEnvironment: ts.noop,
80879         addDiagnostic: ts.noop,
80880     };
80881 })(ts || (ts = {}));
80882 var ts;
80883 (function (ts) {
80884     var brackets = createBracketsMap();
80885     var syntheticParent = { pos: -1, end: -1 };
80886     function isBuildInfoFile(file) {
80887         return ts.fileExtensionIs(file, ".tsbuildinfo");
80888     }
80889     ts.isBuildInfoFile = isBuildInfoFile;
80890     function forEachEmittedFile(host, action, sourceFilesOrTargetSourceFile, forceDtsEmit, onlyBuildInfo, includeBuildInfo) {
80891         if (forceDtsEmit === void 0) { forceDtsEmit = false; }
80892         var sourceFiles = ts.isArray(sourceFilesOrTargetSourceFile) ? sourceFilesOrTargetSourceFile : ts.getSourceFilesToEmit(host, sourceFilesOrTargetSourceFile, forceDtsEmit);
80893         var options = host.getCompilerOptions();
80894         if (ts.outFile(options)) {
80895             var prepends = host.getPrependNodes();
80896             if (sourceFiles.length || prepends.length) {
80897                 var bundle = ts.factory.createBundle(sourceFiles, prepends);
80898                 var result = action(getOutputPathsFor(bundle, host, forceDtsEmit), bundle);
80899                 if (result) {
80900                     return result;
80901                 }
80902             }
80903         }
80904         else {
80905             if (!onlyBuildInfo) {
80906                 for (var _a = 0, sourceFiles_1 = sourceFiles; _a < sourceFiles_1.length; _a++) {
80907                     var sourceFile = sourceFiles_1[_a];
80908                     var result = action(getOutputPathsFor(sourceFile, host, forceDtsEmit), sourceFile);
80909                     if (result) {
80910                         return result;
80911                     }
80912                 }
80913             }
80914             if (includeBuildInfo) {
80915                 var buildInfoPath = getTsBuildInfoEmitOutputFilePath(options);
80916                 if (buildInfoPath)
80917                     return action({ buildInfoPath: buildInfoPath }, undefined);
80918             }
80919         }
80920     }
80921     ts.forEachEmittedFile = forEachEmittedFile;
80922     function getTsBuildInfoEmitOutputFilePath(options) {
80923         var configFile = options.configFilePath;
80924         if (!ts.isIncrementalCompilation(options))
80925             return undefined;
80926         if (options.tsBuildInfoFile)
80927             return options.tsBuildInfoFile;
80928         var outPath = ts.outFile(options);
80929         var buildInfoExtensionLess;
80930         if (outPath) {
80931             buildInfoExtensionLess = ts.removeFileExtension(outPath);
80932         }
80933         else {
80934             if (!configFile)
80935                 return undefined;
80936             var configFileExtensionLess = ts.removeFileExtension(configFile);
80937             buildInfoExtensionLess = options.outDir ?
80938                 options.rootDir ?
80939                     ts.resolvePath(options.outDir, ts.getRelativePathFromDirectory(options.rootDir, configFileExtensionLess, true)) :
80940                     ts.combinePaths(options.outDir, ts.getBaseFileName(configFileExtensionLess)) :
80941                 configFileExtensionLess;
80942         }
80943         return buildInfoExtensionLess + ".tsbuildinfo";
80944     }
80945     ts.getTsBuildInfoEmitOutputFilePath = getTsBuildInfoEmitOutputFilePath;
80946     function getOutputPathsForBundle(options, forceDtsPaths) {
80947         var outPath = ts.outFile(options);
80948         var jsFilePath = options.emitDeclarationOnly ? undefined : outPath;
80949         var sourceMapFilePath = jsFilePath && getSourceMapFilePath(jsFilePath, options);
80950         var declarationFilePath = (forceDtsPaths || ts.getEmitDeclarations(options)) ? ts.removeFileExtension(outPath) + ".d.ts" : undefined;
80951         var declarationMapPath = declarationFilePath && ts.getAreDeclarationMapsEnabled(options) ? declarationFilePath + ".map" : undefined;
80952         var buildInfoPath = getTsBuildInfoEmitOutputFilePath(options);
80953         return { jsFilePath: jsFilePath, sourceMapFilePath: sourceMapFilePath, declarationFilePath: declarationFilePath, declarationMapPath: declarationMapPath, buildInfoPath: buildInfoPath };
80954     }
80955     ts.getOutputPathsForBundle = getOutputPathsForBundle;
80956     function getOutputPathsFor(sourceFile, host, forceDtsPaths) {
80957         var options = host.getCompilerOptions();
80958         if (sourceFile.kind === 298) {
80959             return getOutputPathsForBundle(options, forceDtsPaths);
80960         }
80961         else {
80962             var ownOutputFilePath = ts.getOwnEmitOutputFilePath(sourceFile.fileName, host, getOutputExtension(sourceFile, options));
80963             var isJsonFile = ts.isJsonSourceFile(sourceFile);
80964             var isJsonEmittedToSameLocation = isJsonFile &&
80965                 ts.comparePaths(sourceFile.fileName, ownOutputFilePath, host.getCurrentDirectory(), !host.useCaseSensitiveFileNames()) === 0;
80966             var jsFilePath = options.emitDeclarationOnly || isJsonEmittedToSameLocation ? undefined : ownOutputFilePath;
80967             var sourceMapFilePath = !jsFilePath || ts.isJsonSourceFile(sourceFile) ? undefined : getSourceMapFilePath(jsFilePath, options);
80968             var declarationFilePath = (forceDtsPaths || (ts.getEmitDeclarations(options) && !isJsonFile)) ? ts.getDeclarationEmitOutputFilePath(sourceFile.fileName, host) : undefined;
80969             var declarationMapPath = declarationFilePath && ts.getAreDeclarationMapsEnabled(options) ? declarationFilePath + ".map" : undefined;
80970             return { jsFilePath: jsFilePath, sourceMapFilePath: sourceMapFilePath, declarationFilePath: declarationFilePath, declarationMapPath: declarationMapPath, buildInfoPath: undefined };
80971         }
80972     }
80973     ts.getOutputPathsFor = getOutputPathsFor;
80974     function getSourceMapFilePath(jsFilePath, options) {
80975         return (options.sourceMap && !options.inlineSourceMap) ? jsFilePath + ".map" : undefined;
80976     }
80977     function getOutputExtension(sourceFile, options) {
80978         if (ts.isJsonSourceFile(sourceFile)) {
80979             return ".json";
80980         }
80981         if (options.jsx === 1) {
80982             if (ts.isSourceFileJS(sourceFile)) {
80983                 if (ts.fileExtensionIs(sourceFile.fileName, ".jsx")) {
80984                     return ".jsx";
80985                 }
80986             }
80987             else if (sourceFile.languageVariant === 1) {
80988                 return ".jsx";
80989             }
80990         }
80991         return ".js";
80992     }
80993     ts.getOutputExtension = getOutputExtension;
80994     function rootDirOfOptions(configFile) {
80995         return configFile.options.rootDir || ts.getDirectoryPath(ts.Debug.checkDefined(configFile.options.configFilePath));
80996     }
80997     function getOutputPathWithoutChangingExt(inputFileName, configFile, ignoreCase, outputDir) {
80998         return outputDir ?
80999             ts.resolvePath(outputDir, ts.getRelativePathFromDirectory(rootDirOfOptions(configFile), inputFileName, ignoreCase)) :
81000             inputFileName;
81001     }
81002     function getOutputDeclarationFileName(inputFileName, configFile, ignoreCase) {
81003         ts.Debug.assert(!ts.fileExtensionIs(inputFileName, ".d.ts") && !ts.fileExtensionIs(inputFileName, ".json"));
81004         return ts.changeExtension(getOutputPathWithoutChangingExt(inputFileName, configFile, ignoreCase, configFile.options.declarationDir || configFile.options.outDir), ".d.ts");
81005     }
81006     ts.getOutputDeclarationFileName = getOutputDeclarationFileName;
81007     function getOutputJSFileName(inputFileName, configFile, ignoreCase) {
81008         if (configFile.options.emitDeclarationOnly)
81009             return undefined;
81010         var isJsonFile = ts.fileExtensionIs(inputFileName, ".json");
81011         var outputFileName = ts.changeExtension(getOutputPathWithoutChangingExt(inputFileName, configFile, ignoreCase, configFile.options.outDir), isJsonFile ?
81012             ".json" :
81013             ts.fileExtensionIs(inputFileName, ".tsx") && configFile.options.jsx === 1 ?
81014                 ".jsx" :
81015                 ".js");
81016         return !isJsonFile || ts.comparePaths(inputFileName, outputFileName, ts.Debug.checkDefined(configFile.options.configFilePath), ignoreCase) !== 0 ?
81017             outputFileName :
81018             undefined;
81019     }
81020     function createAddOutput() {
81021         var outputs;
81022         return { addOutput: addOutput, getOutputs: getOutputs };
81023         function addOutput(path) {
81024             if (path) {
81025                 (outputs || (outputs = [])).push(path);
81026             }
81027         }
81028         function getOutputs() {
81029             return outputs || ts.emptyArray;
81030         }
81031     }
81032     function getSingleOutputFileNames(configFile, addOutput) {
81033         var _a = getOutputPathsForBundle(configFile.options, false), jsFilePath = _a.jsFilePath, sourceMapFilePath = _a.sourceMapFilePath, declarationFilePath = _a.declarationFilePath, declarationMapPath = _a.declarationMapPath, buildInfoPath = _a.buildInfoPath;
81034         addOutput(jsFilePath);
81035         addOutput(sourceMapFilePath);
81036         addOutput(declarationFilePath);
81037         addOutput(declarationMapPath);
81038         addOutput(buildInfoPath);
81039     }
81040     function getOwnOutputFileNames(configFile, inputFileName, ignoreCase, addOutput) {
81041         if (ts.fileExtensionIs(inputFileName, ".d.ts"))
81042             return;
81043         var js = getOutputJSFileName(inputFileName, configFile, ignoreCase);
81044         addOutput(js);
81045         if (ts.fileExtensionIs(inputFileName, ".json"))
81046             return;
81047         if (js && configFile.options.sourceMap) {
81048             addOutput(js + ".map");
81049         }
81050         if (ts.getEmitDeclarations(configFile.options)) {
81051             var dts = getOutputDeclarationFileName(inputFileName, configFile, ignoreCase);
81052             addOutput(dts);
81053             if (configFile.options.declarationMap) {
81054                 addOutput(dts + ".map");
81055             }
81056         }
81057     }
81058     function getAllProjectOutputs(configFile, ignoreCase) {
81059         var _a = createAddOutput(), addOutput = _a.addOutput, getOutputs = _a.getOutputs;
81060         if (ts.outFile(configFile.options)) {
81061             getSingleOutputFileNames(configFile, addOutput);
81062         }
81063         else {
81064             for (var _b = 0, _c = configFile.fileNames; _b < _c.length; _b++) {
81065                 var inputFileName = _c[_b];
81066                 getOwnOutputFileNames(configFile, inputFileName, ignoreCase, addOutput);
81067             }
81068             addOutput(getTsBuildInfoEmitOutputFilePath(configFile.options));
81069         }
81070         return getOutputs();
81071     }
81072     ts.getAllProjectOutputs = getAllProjectOutputs;
81073     function getOutputFileNames(commandLine, inputFileName, ignoreCase) {
81074         inputFileName = ts.normalizePath(inputFileName);
81075         ts.Debug.assert(ts.contains(commandLine.fileNames, inputFileName), "Expected fileName to be present in command line");
81076         var _a = createAddOutput(), addOutput = _a.addOutput, getOutputs = _a.getOutputs;
81077         if (ts.outFile(commandLine.options)) {
81078             getSingleOutputFileNames(commandLine, addOutput);
81079         }
81080         else {
81081             getOwnOutputFileNames(commandLine, inputFileName, ignoreCase, addOutput);
81082         }
81083         return getOutputs();
81084     }
81085     ts.getOutputFileNames = getOutputFileNames;
81086     function getFirstProjectOutput(configFile, ignoreCase) {
81087         if (ts.outFile(configFile.options)) {
81088             var jsFilePath = getOutputPathsForBundle(configFile.options, false).jsFilePath;
81089             return ts.Debug.checkDefined(jsFilePath, "project " + configFile.options.configFilePath + " expected to have at least one output");
81090         }
81091         for (var _a = 0, _b = configFile.fileNames; _a < _b.length; _a++) {
81092             var inputFileName = _b[_a];
81093             if (ts.fileExtensionIs(inputFileName, ".d.ts"))
81094                 continue;
81095             var jsFilePath = getOutputJSFileName(inputFileName, configFile, ignoreCase);
81096             if (jsFilePath)
81097                 return jsFilePath;
81098             if (ts.fileExtensionIs(inputFileName, ".json"))
81099                 continue;
81100             if (ts.getEmitDeclarations(configFile.options)) {
81101                 return getOutputDeclarationFileName(inputFileName, configFile, ignoreCase);
81102             }
81103         }
81104         var buildInfoPath = getTsBuildInfoEmitOutputFilePath(configFile.options);
81105         if (buildInfoPath)
81106             return buildInfoPath;
81107         return ts.Debug.fail("project " + configFile.options.configFilePath + " expected to have at least one output");
81108     }
81109     ts.getFirstProjectOutput = getFirstProjectOutput;
81110     function emitFiles(resolver, host, targetSourceFile, _a, emitOnlyDtsFiles, onlyBuildInfo, forceDtsEmit) {
81111         var scriptTransformers = _a.scriptTransformers, declarationTransformers = _a.declarationTransformers;
81112         var compilerOptions = host.getCompilerOptions();
81113         var sourceMapDataList = (compilerOptions.sourceMap || compilerOptions.inlineSourceMap || ts.getAreDeclarationMapsEnabled(compilerOptions)) ? [] : undefined;
81114         var emittedFilesList = compilerOptions.listEmittedFiles ? [] : undefined;
81115         var emitterDiagnostics = ts.createDiagnosticCollection();
81116         var newLine = ts.getNewLineCharacter(compilerOptions, function () { return host.getNewLine(); });
81117         var writer = ts.createTextWriter(newLine);
81118         var _b = ts.performance.createTimer("printTime", "beforePrint", "afterPrint"), enter = _b.enter, exit = _b.exit;
81119         var bundleBuildInfo;
81120         var emitSkipped = false;
81121         var exportedModulesFromDeclarationEmit;
81122         enter();
81123         forEachEmittedFile(host, emitSourceFileOrBundle, ts.getSourceFilesToEmit(host, targetSourceFile, forceDtsEmit), forceDtsEmit, onlyBuildInfo, !targetSourceFile);
81124         exit();
81125         return {
81126             emitSkipped: emitSkipped,
81127             diagnostics: emitterDiagnostics.getDiagnostics(),
81128             emittedFiles: emittedFilesList,
81129             sourceMaps: sourceMapDataList,
81130             exportedModulesFromDeclarationEmit: exportedModulesFromDeclarationEmit
81131         };
81132         function emitSourceFileOrBundle(_a, sourceFileOrBundle) {
81133             var jsFilePath = _a.jsFilePath, sourceMapFilePath = _a.sourceMapFilePath, declarationFilePath = _a.declarationFilePath, declarationMapPath = _a.declarationMapPath, buildInfoPath = _a.buildInfoPath;
81134             var buildInfoDirectory;
81135             if (buildInfoPath && sourceFileOrBundle && ts.isBundle(sourceFileOrBundle)) {
81136                 buildInfoDirectory = ts.getDirectoryPath(ts.getNormalizedAbsolutePath(buildInfoPath, host.getCurrentDirectory()));
81137                 bundleBuildInfo = {
81138                     commonSourceDirectory: relativeToBuildInfo(host.getCommonSourceDirectory()),
81139                     sourceFiles: sourceFileOrBundle.sourceFiles.map(function (file) { return relativeToBuildInfo(ts.getNormalizedAbsolutePath(file.fileName, host.getCurrentDirectory())); })
81140                 };
81141             }
81142             ts.tracing.push("emit", "emitJsFileOrBundle", { jsFilePath: jsFilePath });
81143             emitJsFileOrBundle(sourceFileOrBundle, jsFilePath, sourceMapFilePath, relativeToBuildInfo);
81144             ts.tracing.pop();
81145             ts.tracing.push("emit", "emitDeclarationFileOrBundle", { declarationFilePath: declarationFilePath });
81146             emitDeclarationFileOrBundle(sourceFileOrBundle, declarationFilePath, declarationMapPath, relativeToBuildInfo);
81147             ts.tracing.pop();
81148             ts.tracing.push("emit", "emitBuildInfo", { buildInfoPath: buildInfoPath });
81149             emitBuildInfo(bundleBuildInfo, buildInfoPath);
81150             ts.tracing.pop();
81151             if (!emitSkipped && emittedFilesList) {
81152                 if (!emitOnlyDtsFiles) {
81153                     if (jsFilePath) {
81154                         emittedFilesList.push(jsFilePath);
81155                     }
81156                     if (sourceMapFilePath) {
81157                         emittedFilesList.push(sourceMapFilePath);
81158                     }
81159                     if (buildInfoPath) {
81160                         emittedFilesList.push(buildInfoPath);
81161                     }
81162                 }
81163                 if (declarationFilePath) {
81164                     emittedFilesList.push(declarationFilePath);
81165                 }
81166                 if (declarationMapPath) {
81167                     emittedFilesList.push(declarationMapPath);
81168                 }
81169             }
81170             function relativeToBuildInfo(path) {
81171                 return ts.ensurePathIsNonModuleName(ts.getRelativePathFromDirectory(buildInfoDirectory, path, host.getCanonicalFileName));
81172             }
81173         }
81174         function emitBuildInfo(bundle, buildInfoPath) {
81175             if (!buildInfoPath || targetSourceFile || emitSkipped)
81176                 return;
81177             var program = host.getProgramBuildInfo();
81178             if (host.isEmitBlocked(buildInfoPath)) {
81179                 emitSkipped = true;
81180                 return;
81181             }
81182             var version = ts.version;
81183             ts.writeFile(host, emitterDiagnostics, buildInfoPath, getBuildInfoText({ bundle: bundle, program: program, version: version }), false);
81184         }
81185         function emitJsFileOrBundle(sourceFileOrBundle, jsFilePath, sourceMapFilePath, relativeToBuildInfo) {
81186             if (!sourceFileOrBundle || emitOnlyDtsFiles || !jsFilePath) {
81187                 return;
81188             }
81189             if ((jsFilePath && host.isEmitBlocked(jsFilePath)) || compilerOptions.noEmit) {
81190                 emitSkipped = true;
81191                 return;
81192             }
81193             var transform = ts.transformNodes(resolver, host, ts.factory, compilerOptions, [sourceFileOrBundle], scriptTransformers, false);
81194             var printerOptions = {
81195                 removeComments: compilerOptions.removeComments,
81196                 newLine: compilerOptions.newLine,
81197                 noEmitHelpers: compilerOptions.noEmitHelpers,
81198                 module: compilerOptions.module,
81199                 target: compilerOptions.target,
81200                 sourceMap: compilerOptions.sourceMap,
81201                 inlineSourceMap: compilerOptions.inlineSourceMap,
81202                 inlineSources: compilerOptions.inlineSources,
81203                 extendedDiagnostics: compilerOptions.extendedDiagnostics,
81204                 writeBundleFileInfo: !!bundleBuildInfo,
81205                 relativeToBuildInfo: relativeToBuildInfo
81206             };
81207             var printer = createPrinter(printerOptions, {
81208                 hasGlobalName: resolver.hasGlobalName,
81209                 onEmitNode: transform.emitNodeWithNotification,
81210                 isEmitNotificationEnabled: transform.isEmitNotificationEnabled,
81211                 substituteNode: transform.substituteNode,
81212             });
81213             ts.Debug.assert(transform.transformed.length === 1, "Should only see one output from the transform");
81214             printSourceFileOrBundle(jsFilePath, sourceMapFilePath, transform.transformed[0], printer, compilerOptions);
81215             transform.dispose();
81216             if (bundleBuildInfo)
81217                 bundleBuildInfo.js = printer.bundleFileInfo;
81218         }
81219         function emitDeclarationFileOrBundle(sourceFileOrBundle, declarationFilePath, declarationMapPath, relativeToBuildInfo) {
81220             if (!sourceFileOrBundle)
81221                 return;
81222             if (!declarationFilePath) {
81223                 if (emitOnlyDtsFiles || compilerOptions.emitDeclarationOnly)
81224                     emitSkipped = true;
81225                 return;
81226             }
81227             var sourceFiles = ts.isSourceFile(sourceFileOrBundle) ? [sourceFileOrBundle] : sourceFileOrBundle.sourceFiles;
81228             var filesForEmit = forceDtsEmit ? sourceFiles : ts.filter(sourceFiles, ts.isSourceFileNotJson);
81229             var inputListOrBundle = ts.outFile(compilerOptions) ? [ts.factory.createBundle(filesForEmit, !ts.isSourceFile(sourceFileOrBundle) ? sourceFileOrBundle.prepends : undefined)] : filesForEmit;
81230             if (emitOnlyDtsFiles && !ts.getEmitDeclarations(compilerOptions)) {
81231                 filesForEmit.forEach(collectLinkedAliases);
81232             }
81233             var declarationTransform = ts.transformNodes(resolver, host, ts.factory, compilerOptions, inputListOrBundle, declarationTransformers, false);
81234             if (ts.length(declarationTransform.diagnostics)) {
81235                 for (var _a = 0, _b = declarationTransform.diagnostics; _a < _b.length; _a++) {
81236                     var diagnostic = _b[_a];
81237                     emitterDiagnostics.add(diagnostic);
81238                 }
81239             }
81240             var printerOptions = {
81241                 removeComments: compilerOptions.removeComments,
81242                 newLine: compilerOptions.newLine,
81243                 noEmitHelpers: true,
81244                 module: compilerOptions.module,
81245                 target: compilerOptions.target,
81246                 sourceMap: compilerOptions.sourceMap,
81247                 inlineSourceMap: compilerOptions.inlineSourceMap,
81248                 extendedDiagnostics: compilerOptions.extendedDiagnostics,
81249                 onlyPrintJsDocStyle: true,
81250                 writeBundleFileInfo: !!bundleBuildInfo,
81251                 recordInternalSection: !!bundleBuildInfo,
81252                 relativeToBuildInfo: relativeToBuildInfo
81253             };
81254             var declarationPrinter = createPrinter(printerOptions, {
81255                 hasGlobalName: resolver.hasGlobalName,
81256                 onEmitNode: declarationTransform.emitNodeWithNotification,
81257                 isEmitNotificationEnabled: declarationTransform.isEmitNotificationEnabled,
81258                 substituteNode: declarationTransform.substituteNode,
81259             });
81260             var declBlocked = (!!declarationTransform.diagnostics && !!declarationTransform.diagnostics.length) || !!host.isEmitBlocked(declarationFilePath) || !!compilerOptions.noEmit;
81261             emitSkipped = emitSkipped || declBlocked;
81262             if (!declBlocked || forceDtsEmit) {
81263                 ts.Debug.assert(declarationTransform.transformed.length === 1, "Should only see one output from the decl transform");
81264                 printSourceFileOrBundle(declarationFilePath, declarationMapPath, declarationTransform.transformed[0], declarationPrinter, {
81265                     sourceMap: compilerOptions.declarationMap,
81266                     sourceRoot: compilerOptions.sourceRoot,
81267                     mapRoot: compilerOptions.mapRoot,
81268                     extendedDiagnostics: compilerOptions.extendedDiagnostics,
81269                 });
81270                 if (forceDtsEmit && declarationTransform.transformed[0].kind === 297) {
81271                     var sourceFile = declarationTransform.transformed[0];
81272                     exportedModulesFromDeclarationEmit = sourceFile.exportedModulesFromDeclarationEmit;
81273                 }
81274             }
81275             declarationTransform.dispose();
81276             if (bundleBuildInfo)
81277                 bundleBuildInfo.dts = declarationPrinter.bundleFileInfo;
81278         }
81279         function collectLinkedAliases(node) {
81280             if (ts.isExportAssignment(node)) {
81281                 if (node.expression.kind === 78) {
81282                     resolver.collectLinkedAliases(node.expression, true);
81283                 }
81284                 return;
81285             }
81286             else if (ts.isExportSpecifier(node)) {
81287                 resolver.collectLinkedAliases(node.propertyName || node.name, true);
81288                 return;
81289             }
81290             ts.forEachChild(node, collectLinkedAliases);
81291         }
81292         function printSourceFileOrBundle(jsFilePath, sourceMapFilePath, sourceFileOrBundle, printer, mapOptions) {
81293             var bundle = sourceFileOrBundle.kind === 298 ? sourceFileOrBundle : undefined;
81294             var sourceFile = sourceFileOrBundle.kind === 297 ? sourceFileOrBundle : undefined;
81295             var sourceFiles = bundle ? bundle.sourceFiles : [sourceFile];
81296             var sourceMapGenerator;
81297             if (shouldEmitSourceMaps(mapOptions, sourceFileOrBundle)) {
81298                 sourceMapGenerator = ts.createSourceMapGenerator(host, ts.getBaseFileName(ts.normalizeSlashes(jsFilePath)), getSourceRoot(mapOptions), getSourceMapDirectory(mapOptions, jsFilePath, sourceFile), mapOptions);
81299             }
81300             if (bundle) {
81301                 printer.writeBundle(bundle, writer, sourceMapGenerator);
81302             }
81303             else {
81304                 printer.writeFile(sourceFile, writer, sourceMapGenerator);
81305             }
81306             if (sourceMapGenerator) {
81307                 if (sourceMapDataList) {
81308                     sourceMapDataList.push({
81309                         inputSourceFileNames: sourceMapGenerator.getSources(),
81310                         sourceMap: sourceMapGenerator.toJSON()
81311                     });
81312                 }
81313                 var sourceMappingURL = getSourceMappingURL(mapOptions, sourceMapGenerator, jsFilePath, sourceMapFilePath, sourceFile);
81314                 if (sourceMappingURL) {
81315                     if (!writer.isAtStartOfLine())
81316                         writer.rawWrite(newLine);
81317                     writer.writeComment("//# " + "sourceMappingURL" + "=" + sourceMappingURL);
81318                 }
81319                 if (sourceMapFilePath) {
81320                     var sourceMap = sourceMapGenerator.toString();
81321                     ts.writeFile(host, emitterDiagnostics, sourceMapFilePath, sourceMap, false, sourceFiles);
81322                 }
81323             }
81324             else {
81325                 writer.writeLine();
81326             }
81327             ts.writeFile(host, emitterDiagnostics, jsFilePath, writer.getText(), !!compilerOptions.emitBOM, sourceFiles);
81328             writer.clear();
81329         }
81330         function shouldEmitSourceMaps(mapOptions, sourceFileOrBundle) {
81331             return (mapOptions.sourceMap || mapOptions.inlineSourceMap)
81332                 && (sourceFileOrBundle.kind !== 297 || !ts.fileExtensionIs(sourceFileOrBundle.fileName, ".json"));
81333         }
81334         function getSourceRoot(mapOptions) {
81335             var sourceRoot = ts.normalizeSlashes(mapOptions.sourceRoot || "");
81336             return sourceRoot ? ts.ensureTrailingDirectorySeparator(sourceRoot) : sourceRoot;
81337         }
81338         function getSourceMapDirectory(mapOptions, filePath, sourceFile) {
81339             if (mapOptions.sourceRoot)
81340                 return host.getCommonSourceDirectory();
81341             if (mapOptions.mapRoot) {
81342                 var sourceMapDir = ts.normalizeSlashes(mapOptions.mapRoot);
81343                 if (sourceFile) {
81344                     sourceMapDir = ts.getDirectoryPath(ts.getSourceFilePathInNewDir(sourceFile.fileName, host, sourceMapDir));
81345                 }
81346                 if (ts.getRootLength(sourceMapDir) === 0) {
81347                     sourceMapDir = ts.combinePaths(host.getCommonSourceDirectory(), sourceMapDir);
81348                 }
81349                 return sourceMapDir;
81350             }
81351             return ts.getDirectoryPath(ts.normalizePath(filePath));
81352         }
81353         function getSourceMappingURL(mapOptions, sourceMapGenerator, filePath, sourceMapFilePath, sourceFile) {
81354             if (mapOptions.inlineSourceMap) {
81355                 var sourceMapText = sourceMapGenerator.toString();
81356                 var base64SourceMapText = ts.base64encode(ts.sys, sourceMapText);
81357                 return "data:application/json;base64," + base64SourceMapText;
81358             }
81359             var sourceMapFile = ts.getBaseFileName(ts.normalizeSlashes(ts.Debug.checkDefined(sourceMapFilePath)));
81360             if (mapOptions.mapRoot) {
81361                 var sourceMapDir = ts.normalizeSlashes(mapOptions.mapRoot);
81362                 if (sourceFile) {
81363                     sourceMapDir = ts.getDirectoryPath(ts.getSourceFilePathInNewDir(sourceFile.fileName, host, sourceMapDir));
81364                 }
81365                 if (ts.getRootLength(sourceMapDir) === 0) {
81366                     sourceMapDir = ts.combinePaths(host.getCommonSourceDirectory(), sourceMapDir);
81367                     return encodeURI(ts.getRelativePathToDirectoryOrUrl(ts.getDirectoryPath(ts.normalizePath(filePath)), ts.combinePaths(sourceMapDir, sourceMapFile), host.getCurrentDirectory(), host.getCanonicalFileName, true));
81368                 }
81369                 else {
81370                     return encodeURI(ts.combinePaths(sourceMapDir, sourceMapFile));
81371                 }
81372             }
81373             return encodeURI(sourceMapFile);
81374         }
81375     }
81376     ts.emitFiles = emitFiles;
81377     function getBuildInfoText(buildInfo) {
81378         return JSON.stringify(buildInfo, undefined, 2);
81379     }
81380     ts.getBuildInfoText = getBuildInfoText;
81381     function getBuildInfo(buildInfoText) {
81382         return JSON.parse(buildInfoText);
81383     }
81384     ts.getBuildInfo = getBuildInfo;
81385     ts.notImplementedResolver = {
81386         hasGlobalName: ts.notImplemented,
81387         getReferencedExportContainer: ts.notImplemented,
81388         getReferencedImportDeclaration: ts.notImplemented,
81389         getReferencedDeclarationWithCollidingName: ts.notImplemented,
81390         isDeclarationWithCollidingName: ts.notImplemented,
81391         isValueAliasDeclaration: ts.notImplemented,
81392         isReferencedAliasDeclaration: ts.notImplemented,
81393         isTopLevelValueImportEqualsWithEntityName: ts.notImplemented,
81394         getNodeCheckFlags: ts.notImplemented,
81395         isDeclarationVisible: ts.notImplemented,
81396         isLateBound: function (_node) { return false; },
81397         collectLinkedAliases: ts.notImplemented,
81398         isImplementationOfOverload: ts.notImplemented,
81399         isRequiredInitializedParameter: ts.notImplemented,
81400         isOptionalUninitializedParameterProperty: ts.notImplemented,
81401         isExpandoFunctionDeclaration: ts.notImplemented,
81402         getPropertiesOfContainerFunction: ts.notImplemented,
81403         createTypeOfDeclaration: ts.notImplemented,
81404         createReturnTypeOfSignatureDeclaration: ts.notImplemented,
81405         createTypeOfExpression: ts.notImplemented,
81406         createLiteralConstValue: ts.notImplemented,
81407         isSymbolAccessible: ts.notImplemented,
81408         isEntityNameVisible: ts.notImplemented,
81409         getConstantValue: ts.notImplemented,
81410         getReferencedValueDeclaration: ts.notImplemented,
81411         getTypeReferenceSerializationKind: ts.notImplemented,
81412         isOptionalParameter: ts.notImplemented,
81413         moduleExportsSomeValue: ts.notImplemented,
81414         isArgumentsLocalBinding: ts.notImplemented,
81415         getExternalModuleFileFromDeclaration: ts.notImplemented,
81416         getTypeReferenceDirectivesForEntityName: ts.notImplemented,
81417         getTypeReferenceDirectivesForSymbol: ts.notImplemented,
81418         isLiteralConstDeclaration: ts.notImplemented,
81419         getJsxFactoryEntity: ts.notImplemented,
81420         getJsxFragmentFactoryEntity: ts.notImplemented,
81421         getAllAccessorDeclarations: ts.notImplemented,
81422         getSymbolOfExternalModuleSpecifier: ts.notImplemented,
81423         isBindingCapturedByNode: ts.notImplemented,
81424         getDeclarationStatementsForSourceFile: ts.notImplemented,
81425         isImportRequiredByAugmentation: ts.notImplemented,
81426     };
81427     function createSourceFilesFromBundleBuildInfo(bundle, buildInfoDirectory, host) {
81428         var _a;
81429         var jsBundle = ts.Debug.checkDefined(bundle.js);
81430         var prologueMap = ((_a = jsBundle.sources) === null || _a === void 0 ? void 0 : _a.prologues) && ts.arrayToMap(jsBundle.sources.prologues, function (prologueInfo) { return prologueInfo.file; });
81431         return bundle.sourceFiles.map(function (fileName, index) {
81432             var _a, _b;
81433             var prologueInfo = prologueMap === null || prologueMap === void 0 ? void 0 : prologueMap.get(index);
81434             var statements = prologueInfo === null || prologueInfo === void 0 ? void 0 : prologueInfo.directives.map(function (directive) {
81435                 var literal = ts.setTextRange(ts.factory.createStringLiteral(directive.expression.text), directive.expression);
81436                 var statement = ts.setTextRange(ts.factory.createExpressionStatement(literal), directive);
81437                 ts.setParent(literal, statement);
81438                 return statement;
81439             });
81440             var eofToken = ts.factory.createToken(1);
81441             var sourceFile = ts.factory.createSourceFile(statements !== null && statements !== void 0 ? statements : [], eofToken, 0);
81442             sourceFile.fileName = ts.getRelativePathFromDirectory(host.getCurrentDirectory(), ts.getNormalizedAbsolutePath(fileName, buildInfoDirectory), !host.useCaseSensitiveFileNames());
81443             sourceFile.text = (_a = prologueInfo === null || prologueInfo === void 0 ? void 0 : prologueInfo.text) !== null && _a !== void 0 ? _a : "";
81444             ts.setTextRangePosWidth(sourceFile, 0, (_b = prologueInfo === null || prologueInfo === void 0 ? void 0 : prologueInfo.text.length) !== null && _b !== void 0 ? _b : 0);
81445             ts.setEachParent(sourceFile.statements, sourceFile);
81446             ts.setTextRangePosWidth(eofToken, sourceFile.end, 0);
81447             ts.setParent(eofToken, sourceFile);
81448             return sourceFile;
81449         });
81450     }
81451     function emitUsingBuildInfo(config, host, getCommandLine, customTransformers) {
81452         var _a = getOutputPathsForBundle(config.options, false), buildInfoPath = _a.buildInfoPath, jsFilePath = _a.jsFilePath, sourceMapFilePath = _a.sourceMapFilePath, declarationFilePath = _a.declarationFilePath, declarationMapPath = _a.declarationMapPath;
81453         var buildInfoText = host.readFile(ts.Debug.checkDefined(buildInfoPath));
81454         if (!buildInfoText)
81455             return buildInfoPath;
81456         var jsFileText = host.readFile(ts.Debug.checkDefined(jsFilePath));
81457         if (!jsFileText)
81458             return jsFilePath;
81459         var sourceMapText = sourceMapFilePath && host.readFile(sourceMapFilePath);
81460         if ((sourceMapFilePath && !sourceMapText) || config.options.inlineSourceMap)
81461             return sourceMapFilePath || "inline sourcemap decoding";
81462         var declarationText = declarationFilePath && host.readFile(declarationFilePath);
81463         if (declarationFilePath && !declarationText)
81464             return declarationFilePath;
81465         var declarationMapText = declarationMapPath && host.readFile(declarationMapPath);
81466         if ((declarationMapPath && !declarationMapText) || config.options.inlineSourceMap)
81467             return declarationMapPath || "inline sourcemap decoding";
81468         var buildInfo = getBuildInfo(buildInfoText);
81469         if (!buildInfo.bundle || !buildInfo.bundle.js || (declarationText && !buildInfo.bundle.dts))
81470             return buildInfoPath;
81471         var buildInfoDirectory = ts.getDirectoryPath(ts.getNormalizedAbsolutePath(buildInfoPath, host.getCurrentDirectory()));
81472         var ownPrependInput = ts.createInputFiles(jsFileText, declarationText, sourceMapFilePath, sourceMapText, declarationMapPath, declarationMapText, jsFilePath, declarationFilePath, buildInfoPath, buildInfo, true);
81473         var outputFiles = [];
81474         var prependNodes = ts.createPrependNodes(config.projectReferences, getCommandLine, function (f) { return host.readFile(f); });
81475         var sourceFilesForJsEmit = createSourceFilesFromBundleBuildInfo(buildInfo.bundle, buildInfoDirectory, host);
81476         var emitHost = {
81477             getPrependNodes: ts.memoize(function () { return __spreadArrays(prependNodes, [ownPrependInput]); }),
81478             getCanonicalFileName: host.getCanonicalFileName,
81479             getCommonSourceDirectory: function () { return ts.getNormalizedAbsolutePath(buildInfo.bundle.commonSourceDirectory, buildInfoDirectory); },
81480             getCompilerOptions: function () { return config.options; },
81481             getCurrentDirectory: function () { return host.getCurrentDirectory(); },
81482             getNewLine: function () { return host.getNewLine(); },
81483             getSourceFile: ts.returnUndefined,
81484             getSourceFileByPath: ts.returnUndefined,
81485             getSourceFiles: function () { return sourceFilesForJsEmit; },
81486             getLibFileFromReference: ts.notImplemented,
81487             isSourceFileFromExternalLibrary: ts.returnFalse,
81488             getResolvedProjectReferenceToRedirect: ts.returnUndefined,
81489             getProjectReferenceRedirect: ts.returnUndefined,
81490             isSourceOfProjectReferenceRedirect: ts.returnFalse,
81491             writeFile: function (name, text, writeByteOrderMark) {
81492                 switch (name) {
81493                     case jsFilePath:
81494                         if (jsFileText === text)
81495                             return;
81496                         break;
81497                     case sourceMapFilePath:
81498                         if (sourceMapText === text)
81499                             return;
81500                         break;
81501                     case buildInfoPath:
81502                         var newBuildInfo = getBuildInfo(text);
81503                         newBuildInfo.program = buildInfo.program;
81504                         var _a = buildInfo.bundle, js = _a.js, dts = _a.dts, sourceFiles = _a.sourceFiles;
81505                         newBuildInfo.bundle.js.sources = js.sources;
81506                         if (dts) {
81507                             newBuildInfo.bundle.dts.sources = dts.sources;
81508                         }
81509                         newBuildInfo.bundle.sourceFiles = sourceFiles;
81510                         outputFiles.push({ name: name, text: getBuildInfoText(newBuildInfo), writeByteOrderMark: writeByteOrderMark });
81511                         return;
81512                     case declarationFilePath:
81513                         if (declarationText === text)
81514                             return;
81515                         break;
81516                     case declarationMapPath:
81517                         if (declarationMapText === text)
81518                             return;
81519                         break;
81520                     default:
81521                         ts.Debug.fail("Unexpected path: " + name);
81522                 }
81523                 outputFiles.push({ name: name, text: text, writeByteOrderMark: writeByteOrderMark });
81524             },
81525             isEmitBlocked: ts.returnFalse,
81526             readFile: function (f) { return host.readFile(f); },
81527             fileExists: function (f) { return host.fileExists(f); },
81528             useCaseSensitiveFileNames: function () { return host.useCaseSensitiveFileNames(); },
81529             getProgramBuildInfo: ts.returnUndefined,
81530             getSourceFileFromReference: ts.returnUndefined,
81531             redirectTargetsMap: ts.createMultiMap()
81532         };
81533         emitFiles(ts.notImplementedResolver, emitHost, undefined, ts.getTransformers(config.options, customTransformers));
81534         return outputFiles;
81535     }
81536     ts.emitUsingBuildInfo = emitUsingBuildInfo;
81537     function createPrinter(printerOptions, handlers) {
81538         if (printerOptions === void 0) { printerOptions = {}; }
81539         if (handlers === void 0) { handlers = {}; }
81540         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;
81541         var extendedDiagnostics = !!printerOptions.extendedDiagnostics;
81542         var newLine = ts.getNewLineCharacter(printerOptions);
81543         var moduleKind = ts.getEmitModuleKind(printerOptions);
81544         var bundledHelpers = new ts.Map();
81545         var currentSourceFile;
81546         var nodeIdToGeneratedName;
81547         var autoGeneratedIdToGeneratedName;
81548         var generatedNames;
81549         var tempFlagsStack;
81550         var tempFlags;
81551         var reservedNamesStack;
81552         var reservedNames;
81553         var preserveSourceNewlines = printerOptions.preserveSourceNewlines;
81554         var nextListElementPos;
81555         var writer;
81556         var ownWriter;
81557         var write = writeBase;
81558         var isOwnFileEmit;
81559         var bundleFileInfo = printerOptions.writeBundleFileInfo ? { sections: [] } : undefined;
81560         var relativeToBuildInfo = bundleFileInfo ? ts.Debug.checkDefined(printerOptions.relativeToBuildInfo) : undefined;
81561         var recordInternalSection = printerOptions.recordInternalSection;
81562         var sourceFileTextPos = 0;
81563         var sourceFileTextKind = "text";
81564         var sourceMapsDisabled = true;
81565         var sourceMapGenerator;
81566         var sourceMapSource;
81567         var sourceMapSourceIndex = -1;
81568         var mostRecentlyAddedSourceMapSource;
81569         var mostRecentlyAddedSourceMapSourceIndex = -1;
81570         var containerPos = -1;
81571         var containerEnd = -1;
81572         var declarationListContainerEnd = -1;
81573         var currentLineMap;
81574         var detachedCommentsInfo;
81575         var hasWrittenComment = false;
81576         var commentsDisabled = !!printerOptions.removeComments;
81577         var lastNode;
81578         var lastSubstitution;
81579         var _c = ts.performance.createTimerIf(extendedDiagnostics, "commentTime", "beforeComment", "afterComment"), enterComment = _c.enter, exitComment = _c.exit;
81580         reset();
81581         return {
81582             printNode: printNode,
81583             printList: printList,
81584             printFile: printFile,
81585             printBundle: printBundle,
81586             writeNode: writeNode,
81587             writeList: writeList,
81588             writeFile: writeFile,
81589             writeBundle: writeBundle,
81590             bundleFileInfo: bundleFileInfo
81591         };
81592         function printNode(hint, node, sourceFile) {
81593             switch (hint) {
81594                 case 0:
81595                     ts.Debug.assert(ts.isSourceFile(node), "Expected a SourceFile node.");
81596                     break;
81597                 case 2:
81598                     ts.Debug.assert(ts.isIdentifier(node), "Expected an Identifier node.");
81599                     break;
81600                 case 1:
81601                     ts.Debug.assert(ts.isExpression(node), "Expected an Expression node.");
81602                     break;
81603             }
81604             switch (node.kind) {
81605                 case 297: return printFile(node);
81606                 case 298: return printBundle(node);
81607                 case 299: return printUnparsedSource(node);
81608             }
81609             writeNode(hint, node, sourceFile, beginPrint());
81610             return endPrint();
81611         }
81612         function printList(format, nodes, sourceFile) {
81613             writeList(format, nodes, sourceFile, beginPrint());
81614             return endPrint();
81615         }
81616         function printBundle(bundle) {
81617             writeBundle(bundle, beginPrint(), undefined);
81618             return endPrint();
81619         }
81620         function printFile(sourceFile) {
81621             writeFile(sourceFile, beginPrint(), undefined);
81622             return endPrint();
81623         }
81624         function printUnparsedSource(unparsed) {
81625             writeUnparsedSource(unparsed, beginPrint());
81626             return endPrint();
81627         }
81628         function writeNode(hint, node, sourceFile, output) {
81629             var previousWriter = writer;
81630             setWriter(output, undefined);
81631             print(hint, node, sourceFile);
81632             reset();
81633             writer = previousWriter;
81634         }
81635         function writeList(format, nodes, sourceFile, output) {
81636             var previousWriter = writer;
81637             setWriter(output, undefined);
81638             if (sourceFile) {
81639                 setSourceFile(sourceFile);
81640             }
81641             emitList(syntheticParent, nodes, format);
81642             reset();
81643             writer = previousWriter;
81644         }
81645         function getTextPosWithWriteLine() {
81646             return writer.getTextPosWithWriteLine ? writer.getTextPosWithWriteLine() : writer.getTextPos();
81647         }
81648         function updateOrPushBundleFileTextLike(pos, end, kind) {
81649             var last = ts.lastOrUndefined(bundleFileInfo.sections);
81650             if (last && last.kind === kind) {
81651                 last.end = end;
81652             }
81653             else {
81654                 bundleFileInfo.sections.push({ pos: pos, end: end, kind: kind });
81655             }
81656         }
81657         function recordBundleFileInternalSectionStart(node) {
81658             if (recordInternalSection &&
81659                 bundleFileInfo &&
81660                 currentSourceFile &&
81661                 (ts.isDeclaration(node) || ts.isVariableStatement(node)) &&
81662                 ts.isInternalDeclaration(node, currentSourceFile) &&
81663                 sourceFileTextKind !== "internal") {
81664                 var prevSourceFileTextKind = sourceFileTextKind;
81665                 recordBundleFileTextLikeSection(writer.getTextPos());
81666                 sourceFileTextPos = getTextPosWithWriteLine();
81667                 sourceFileTextKind = "internal";
81668                 return prevSourceFileTextKind;
81669             }
81670             return undefined;
81671         }
81672         function recordBundleFileInternalSectionEnd(prevSourceFileTextKind) {
81673             if (prevSourceFileTextKind) {
81674                 recordBundleFileTextLikeSection(writer.getTextPos());
81675                 sourceFileTextPos = getTextPosWithWriteLine();
81676                 sourceFileTextKind = prevSourceFileTextKind;
81677             }
81678         }
81679         function recordBundleFileTextLikeSection(end) {
81680             if (sourceFileTextPos < end) {
81681                 updateOrPushBundleFileTextLike(sourceFileTextPos, end, sourceFileTextKind);
81682                 return true;
81683             }
81684             return false;
81685         }
81686         function writeBundle(bundle, output, sourceMapGenerator) {
81687             var _a;
81688             isOwnFileEmit = false;
81689             var previousWriter = writer;
81690             setWriter(output, sourceMapGenerator);
81691             emitShebangIfNeeded(bundle);
81692             emitPrologueDirectivesIfNeeded(bundle);
81693             emitHelpers(bundle);
81694             emitSyntheticTripleSlashReferencesIfNeeded(bundle);
81695             for (var _b = 0, _c = bundle.prepends; _b < _c.length; _b++) {
81696                 var prepend = _c[_b];
81697                 writeLine();
81698                 var pos = writer.getTextPos();
81699                 var savedSections = bundleFileInfo && bundleFileInfo.sections;
81700                 if (savedSections)
81701                     bundleFileInfo.sections = [];
81702                 print(4, prepend, undefined);
81703                 if (bundleFileInfo) {
81704                     var newSections = bundleFileInfo.sections;
81705                     bundleFileInfo.sections = savedSections;
81706                     if (prepend.oldFileOfCurrentEmit)
81707                         (_a = bundleFileInfo.sections).push.apply(_a, newSections);
81708                     else {
81709                         newSections.forEach(function (section) { return ts.Debug.assert(ts.isBundleFileTextLike(section)); });
81710                         bundleFileInfo.sections.push({
81711                             pos: pos,
81712                             end: writer.getTextPos(),
81713                             kind: "prepend",
81714                             data: relativeToBuildInfo(prepend.fileName),
81715                             texts: newSections
81716                         });
81717                     }
81718                 }
81719             }
81720             sourceFileTextPos = getTextPosWithWriteLine();
81721             for (var _d = 0, _e = bundle.sourceFiles; _d < _e.length; _d++) {
81722                 var sourceFile = _e[_d];
81723                 print(0, sourceFile, sourceFile);
81724             }
81725             if (bundleFileInfo && bundle.sourceFiles.length) {
81726                 var end = writer.getTextPos();
81727                 if (recordBundleFileTextLikeSection(end)) {
81728                     var prologues = getPrologueDirectivesFromBundledSourceFiles(bundle);
81729                     if (prologues) {
81730                         if (!bundleFileInfo.sources)
81731                             bundleFileInfo.sources = {};
81732                         bundleFileInfo.sources.prologues = prologues;
81733                     }
81734                     var helpers = getHelpersFromBundledSourceFiles(bundle);
81735                     if (helpers) {
81736                         if (!bundleFileInfo.sources)
81737                             bundleFileInfo.sources = {};
81738                         bundleFileInfo.sources.helpers = helpers;
81739                     }
81740                 }
81741             }
81742             reset();
81743             writer = previousWriter;
81744         }
81745         function writeUnparsedSource(unparsed, output) {
81746             var previousWriter = writer;
81747             setWriter(output, undefined);
81748             print(4, unparsed, undefined);
81749             reset();
81750             writer = previousWriter;
81751         }
81752         function writeFile(sourceFile, output, sourceMapGenerator) {
81753             isOwnFileEmit = true;
81754             var previousWriter = writer;
81755             setWriter(output, sourceMapGenerator);
81756             emitShebangIfNeeded(sourceFile);
81757             emitPrologueDirectivesIfNeeded(sourceFile);
81758             print(0, sourceFile, sourceFile);
81759             reset();
81760             writer = previousWriter;
81761         }
81762         function beginPrint() {
81763             return ownWriter || (ownWriter = ts.createTextWriter(newLine));
81764         }
81765         function endPrint() {
81766             var text = ownWriter.getText();
81767             ownWriter.clear();
81768             return text;
81769         }
81770         function print(hint, node, sourceFile) {
81771             if (sourceFile) {
81772                 setSourceFile(sourceFile);
81773             }
81774             pipelineEmit(hint, node);
81775         }
81776         function setSourceFile(sourceFile) {
81777             currentSourceFile = sourceFile;
81778             currentLineMap = undefined;
81779             detachedCommentsInfo = undefined;
81780             if (sourceFile) {
81781                 setSourceMapSource(sourceFile);
81782             }
81783         }
81784         function setWriter(_writer, _sourceMapGenerator) {
81785             if (_writer && printerOptions.omitTrailingSemicolon) {
81786                 _writer = ts.getTrailingSemicolonDeferringWriter(_writer);
81787             }
81788             writer = _writer;
81789             sourceMapGenerator = _sourceMapGenerator;
81790             sourceMapsDisabled = !writer || !sourceMapGenerator;
81791         }
81792         function reset() {
81793             nodeIdToGeneratedName = [];
81794             autoGeneratedIdToGeneratedName = [];
81795             generatedNames = new ts.Set();
81796             tempFlagsStack = [];
81797             tempFlags = 0;
81798             reservedNamesStack = [];
81799             currentSourceFile = undefined;
81800             currentLineMap = undefined;
81801             detachedCommentsInfo = undefined;
81802             lastNode = undefined;
81803             lastSubstitution = undefined;
81804             setWriter(undefined, undefined);
81805         }
81806         function getCurrentLineMap() {
81807             return currentLineMap || (currentLineMap = ts.getLineStarts(currentSourceFile));
81808         }
81809         function emit(node) {
81810             if (node === undefined)
81811                 return;
81812             var prevSourceFileTextKind = recordBundleFileInternalSectionStart(node);
81813             var substitute = pipelineEmit(4, node);
81814             recordBundleFileInternalSectionEnd(prevSourceFileTextKind);
81815             return substitute;
81816         }
81817         function emitIdentifierName(node) {
81818             if (node === undefined)
81819                 return;
81820             return pipelineEmit(2, node);
81821         }
81822         function emitExpression(node) {
81823             if (node === undefined)
81824                 return;
81825             return pipelineEmit(1, node);
81826         }
81827         function emitJsxAttributeValue(node) {
81828             return pipelineEmit(ts.isStringLiteral(node) ? 6 : 4, node);
81829         }
81830         function pipelineEmit(emitHint, node) {
81831             var savedLastNode = lastNode;
81832             var savedLastSubstitution = lastSubstitution;
81833             var savedPreserveSourceNewlines = preserveSourceNewlines;
81834             lastNode = node;
81835             lastSubstitution = undefined;
81836             if (preserveSourceNewlines && !!(ts.getEmitFlags(node) & 134217728)) {
81837                 preserveSourceNewlines = false;
81838             }
81839             var pipelinePhase = getPipelinePhase(0, emitHint, node);
81840             pipelinePhase(emitHint, node);
81841             ts.Debug.assert(lastNode === node);
81842             var substitute = lastSubstitution;
81843             lastNode = savedLastNode;
81844             lastSubstitution = savedLastSubstitution;
81845             preserveSourceNewlines = savedPreserveSourceNewlines;
81846             return substitute || node;
81847         }
81848         function getPipelinePhase(phase, emitHint, node) {
81849             switch (phase) {
81850                 case 0:
81851                     if (onEmitNode !== ts.noEmitNotification && (!isEmitNotificationEnabled || isEmitNotificationEnabled(node))) {
81852                         return pipelineEmitWithNotification;
81853                     }
81854                 case 1:
81855                     if (substituteNode !== ts.noEmitSubstitution && (lastSubstitution = substituteNode(emitHint, node)) !== node) {
81856                         return pipelineEmitWithSubstitution;
81857                     }
81858                 case 2:
81859                     if (!commentsDisabled && node.kind !== 297) {
81860                         return pipelineEmitWithComments;
81861                     }
81862                 case 3:
81863                     if (!sourceMapsDisabled && node.kind !== 297 && !ts.isInJsonFile(node)) {
81864                         return pipelineEmitWithSourceMap;
81865                     }
81866                 case 4:
81867                     return pipelineEmitWithHint;
81868                 default:
81869                     return ts.Debug.assertNever(phase);
81870             }
81871         }
81872         function getNextPipelinePhase(currentPhase, emitHint, node) {
81873             return getPipelinePhase(currentPhase + 1, emitHint, node);
81874         }
81875         function pipelineEmitWithNotification(hint, node) {
81876             ts.Debug.assert(lastNode === node);
81877             var pipelinePhase = getNextPipelinePhase(0, hint, node);
81878             onEmitNode(hint, node, pipelinePhase);
81879             ts.Debug.assert(lastNode === node);
81880         }
81881         function pipelineEmitWithHint(hint, node) {
81882             ts.Debug.assert(lastNode === node || lastSubstitution === node);
81883             if (hint === 0)
81884                 return emitSourceFile(ts.cast(node, ts.isSourceFile));
81885             if (hint === 2)
81886                 return emitIdentifier(ts.cast(node, ts.isIdentifier));
81887             if (hint === 6)
81888                 return emitLiteral(ts.cast(node, ts.isStringLiteral), true);
81889             if (hint === 3)
81890                 return emitMappedTypeParameter(ts.cast(node, ts.isTypeParameterDeclaration));
81891             if (hint === 5) {
81892                 ts.Debug.assertNode(node, ts.isEmptyStatement);
81893                 return emitEmptyStatement(true);
81894             }
81895             if (hint === 4) {
81896                 if (ts.isKeyword(node.kind))
81897                     return writeTokenNode(node, writeKeyword);
81898                 switch (node.kind) {
81899                     case 15:
81900                     case 16:
81901                     case 17:
81902                         return emitLiteral(node, false);
81903                     case 299:
81904                     case 293:
81905                         return emitUnparsedSourceOrPrepend(node);
81906                     case 292:
81907                         return writeUnparsedNode(node);
81908                     case 294:
81909                     case 295:
81910                         return emitUnparsedTextLike(node);
81911                     case 296:
81912                         return emitUnparsedSyntheticReference(node);
81913                     case 78:
81914                         return emitIdentifier(node);
81915                     case 79:
81916                         return emitPrivateIdentifier(node);
81917                     case 157:
81918                         return emitQualifiedName(node);
81919                     case 158:
81920                         return emitComputedPropertyName(node);
81921                     case 159:
81922                         return emitTypeParameter(node);
81923                     case 160:
81924                         return emitParameter(node);
81925                     case 161:
81926                         return emitDecorator(node);
81927                     case 162:
81928                         return emitPropertySignature(node);
81929                     case 163:
81930                         return emitPropertyDeclaration(node);
81931                     case 164:
81932                         return emitMethodSignature(node);
81933                     case 165:
81934                         return emitMethodDeclaration(node);
81935                     case 166:
81936                         return emitConstructor(node);
81937                     case 167:
81938                     case 168:
81939                         return emitAccessorDeclaration(node);
81940                     case 169:
81941                         return emitCallSignature(node);
81942                     case 170:
81943                         return emitConstructSignature(node);
81944                     case 171:
81945                         return emitIndexSignature(node);
81946                     case 194:
81947                         return emitTemplateTypeSpan(node);
81948                     case 172:
81949                         return emitTypePredicate(node);
81950                     case 173:
81951                         return emitTypeReference(node);
81952                     case 174:
81953                         return emitFunctionType(node);
81954                     case 308:
81955                         return emitJSDocFunctionType(node);
81956                     case 175:
81957                         return emitConstructorType(node);
81958                     case 176:
81959                         return emitTypeQuery(node);
81960                     case 177:
81961                         return emitTypeLiteral(node);
81962                     case 178:
81963                         return emitArrayType(node);
81964                     case 179:
81965                         return emitTupleType(node);
81966                     case 180:
81967                         return emitOptionalType(node);
81968                     case 182:
81969                         return emitUnionType(node);
81970                     case 183:
81971                         return emitIntersectionType(node);
81972                     case 184:
81973                         return emitConditionalType(node);
81974                     case 185:
81975                         return emitInferType(node);
81976                     case 186:
81977                         return emitParenthesizedType(node);
81978                     case 223:
81979                         return emitExpressionWithTypeArguments(node);
81980                     case 187:
81981                         return emitThisType();
81982                     case 188:
81983                         return emitTypeOperator(node);
81984                     case 189:
81985                         return emitIndexedAccessType(node);
81986                     case 190:
81987                         return emitMappedType(node);
81988                     case 191:
81989                         return emitLiteralType(node);
81990                     case 193:
81991                         return emitTemplateType(node);
81992                     case 195:
81993                         return emitImportTypeNode(node);
81994                     case 303:
81995                         writePunctuation("*");
81996                         return;
81997                     case 304:
81998                         writePunctuation("?");
81999                         return;
82000                     case 305:
82001                         return emitJSDocNullableType(node);
82002                     case 306:
82003                         return emitJSDocNonNullableType(node);
82004                     case 307:
82005                         return emitJSDocOptionalType(node);
82006                     case 181:
82007                     case 309:
82008                         return emitRestOrJSDocVariadicType(node);
82009                     case 192:
82010                         return emitNamedTupleMember(node);
82011                     case 196:
82012                         return emitObjectBindingPattern(node);
82013                     case 197:
82014                         return emitArrayBindingPattern(node);
82015                     case 198:
82016                         return emitBindingElement(node);
82017                     case 228:
82018                         return emitTemplateSpan(node);
82019                     case 229:
82020                         return emitSemicolonClassElement();
82021                     case 230:
82022                         return emitBlock(node);
82023                     case 232:
82024                         return emitVariableStatement(node);
82025                     case 231:
82026                         return emitEmptyStatement(false);
82027                     case 233:
82028                         return emitExpressionStatement(node);
82029                     case 234:
82030                         return emitIfStatement(node);
82031                     case 235:
82032                         return emitDoStatement(node);
82033                     case 236:
82034                         return emitWhileStatement(node);
82035                     case 237:
82036                         return emitForStatement(node);
82037                     case 238:
82038                         return emitForInStatement(node);
82039                     case 239:
82040                         return emitForOfStatement(node);
82041                     case 240:
82042                         return emitContinueStatement(node);
82043                     case 241:
82044                         return emitBreakStatement(node);
82045                     case 242:
82046                         return emitReturnStatement(node);
82047                     case 243:
82048                         return emitWithStatement(node);
82049                     case 244:
82050                         return emitSwitchStatement(node);
82051                     case 245:
82052                         return emitLabeledStatement(node);
82053                     case 246:
82054                         return emitThrowStatement(node);
82055                     case 247:
82056                         return emitTryStatement(node);
82057                     case 248:
82058                         return emitDebuggerStatement(node);
82059                     case 249:
82060                         return emitVariableDeclaration(node);
82061                     case 250:
82062                         return emitVariableDeclarationList(node);
82063                     case 251:
82064                         return emitFunctionDeclaration(node);
82065                     case 252:
82066                         return emitClassDeclaration(node);
82067                     case 253:
82068                         return emitInterfaceDeclaration(node);
82069                     case 254:
82070                         return emitTypeAliasDeclaration(node);
82071                     case 255:
82072                         return emitEnumDeclaration(node);
82073                     case 256:
82074                         return emitModuleDeclaration(node);
82075                     case 257:
82076                         return emitModuleBlock(node);
82077                     case 258:
82078                         return emitCaseBlock(node);
82079                     case 259:
82080                         return emitNamespaceExportDeclaration(node);
82081                     case 260:
82082                         return emitImportEqualsDeclaration(node);
82083                     case 261:
82084                         return emitImportDeclaration(node);
82085                     case 262:
82086                         return emitImportClause(node);
82087                     case 263:
82088                         return emitNamespaceImport(node);
82089                     case 269:
82090                         return emitNamespaceExport(node);
82091                     case 264:
82092                         return emitNamedImports(node);
82093                     case 265:
82094                         return emitImportSpecifier(node);
82095                     case 266:
82096                         return emitExportAssignment(node);
82097                     case 267:
82098                         return emitExportDeclaration(node);
82099                     case 268:
82100                         return emitNamedExports(node);
82101                     case 270:
82102                         return emitExportSpecifier(node);
82103                     case 271:
82104                         return;
82105                     case 272:
82106                         return emitExternalModuleReference(node);
82107                     case 11:
82108                         return emitJsxText(node);
82109                     case 275:
82110                     case 278:
82111                         return emitJsxOpeningElementOrFragment(node);
82112                     case 276:
82113                     case 279:
82114                         return emitJsxClosingElementOrFragment(node);
82115                     case 280:
82116                         return emitJsxAttribute(node);
82117                     case 281:
82118                         return emitJsxAttributes(node);
82119                     case 282:
82120                         return emitJsxSpreadAttribute(node);
82121                     case 283:
82122                         return emitJsxExpression(node);
82123                     case 284:
82124                         return emitCaseClause(node);
82125                     case 285:
82126                         return emitDefaultClause(node);
82127                     case 286:
82128                         return emitHeritageClause(node);
82129                     case 287:
82130                         return emitCatchClause(node);
82131                     case 288:
82132                         return emitPropertyAssignment(node);
82133                     case 289:
82134                         return emitShorthandPropertyAssignment(node);
82135                     case 290:
82136                         return emitSpreadAssignment(node);
82137                     case 291:
82138                         return emitEnumMember(node);
82139                     case 326:
82140                     case 333:
82141                         return emitJSDocPropertyLikeTag(node);
82142                     case 327:
82143                     case 329:
82144                     case 328:
82145                     case 325:
82146                         return emitJSDocSimpleTypedTag(node);
82147                     case 316:
82148                     case 315:
82149                         return emitJSDocHeritageTag(node);
82150                     case 330:
82151                         return emitJSDocTemplateTag(node);
82152                     case 331:
82153                         return emitJSDocTypedefTag(node);
82154                     case 324:
82155                         return emitJSDocCallbackTag(node);
82156                     case 313:
82157                         return emitJSDocSignature(node);
82158                     case 312:
82159                         return emitJSDocTypeLiteral(node);
82160                     case 319:
82161                     case 314:
82162                         return emitJSDocSimpleTag(node);
82163                     case 332:
82164                         return emitJSDocSeeTag(node);
82165                     case 302:
82166                         return emitJSDocNameReference(node);
82167                     case 311:
82168                         return emitJSDoc(node);
82169                 }
82170                 if (ts.isExpression(node)) {
82171                     hint = 1;
82172                     if (substituteNode !== ts.noEmitSubstitution) {
82173                         lastSubstitution = node = substituteNode(hint, node);
82174                     }
82175                 }
82176                 else if (ts.isToken(node)) {
82177                     return writeTokenNode(node, writePunctuation);
82178                 }
82179             }
82180             if (hint === 1) {
82181                 switch (node.kind) {
82182                     case 8:
82183                     case 9:
82184                         return emitNumericOrBigIntLiteral(node);
82185                     case 10:
82186                     case 13:
82187                     case 14:
82188                         return emitLiteral(node, false);
82189                     case 78:
82190                         return emitIdentifier(node);
82191                     case 94:
82192                     case 103:
82193                     case 105:
82194                     case 109:
82195                     case 107:
82196                     case 99:
82197                         writeTokenNode(node, writeKeyword);
82198                         return;
82199                     case 199:
82200                         return emitArrayLiteralExpression(node);
82201                     case 200:
82202                         return emitObjectLiteralExpression(node);
82203                     case 201:
82204                         return emitPropertyAccessExpression(node);
82205                     case 202:
82206                         return emitElementAccessExpression(node);
82207                     case 203:
82208                         return emitCallExpression(node);
82209                     case 204:
82210                         return emitNewExpression(node);
82211                     case 205:
82212                         return emitTaggedTemplateExpression(node);
82213                     case 206:
82214                         return emitTypeAssertionExpression(node);
82215                     case 207:
82216                         return emitParenthesizedExpression(node);
82217                     case 208:
82218                         return emitFunctionExpression(node);
82219                     case 209:
82220                         return emitArrowFunction(node);
82221                     case 210:
82222                         return emitDeleteExpression(node);
82223                     case 211:
82224                         return emitTypeOfExpression(node);
82225                     case 212:
82226                         return emitVoidExpression(node);
82227                     case 213:
82228                         return emitAwaitExpression(node);
82229                     case 214:
82230                         return emitPrefixUnaryExpression(node);
82231                     case 215:
82232                         return emitPostfixUnaryExpression(node);
82233                     case 216:
82234                         return emitBinaryExpression(node);
82235                     case 217:
82236                         return emitConditionalExpression(node);
82237                     case 218:
82238                         return emitTemplateExpression(node);
82239                     case 219:
82240                         return emitYieldExpression(node);
82241                     case 220:
82242                         return emitSpreadExpression(node);
82243                     case 221:
82244                         return emitClassExpression(node);
82245                     case 222:
82246                         return;
82247                     case 224:
82248                         return emitAsExpression(node);
82249                     case 225:
82250                         return emitNonNullExpression(node);
82251                     case 226:
82252                         return emitMetaProperty(node);
82253                     case 273:
82254                         return emitJsxElement(node);
82255                     case 274:
82256                         return emitJsxSelfClosingElement(node);
82257                     case 277:
82258                         return emitJsxFragment(node);
82259                     case 336:
82260                         return emitPartiallyEmittedExpression(node);
82261                     case 337:
82262                         return emitCommaList(node);
82263                 }
82264             }
82265         }
82266         function emitMappedTypeParameter(node) {
82267             emit(node.name);
82268             writeSpace();
82269             writeKeyword("in");
82270             writeSpace();
82271             emit(node.constraint);
82272         }
82273         function pipelineEmitWithSubstitution(hint, node) {
82274             ts.Debug.assert(lastNode === node || lastSubstitution === node);
82275             var pipelinePhase = getNextPipelinePhase(1, hint, node);
82276             pipelinePhase(hint, lastSubstitution);
82277             ts.Debug.assert(lastNode === node || lastSubstitution === node);
82278         }
82279         function getHelpersFromBundledSourceFiles(bundle) {
82280             var result;
82281             if (moduleKind === ts.ModuleKind.None || printerOptions.noEmitHelpers) {
82282                 return undefined;
82283             }
82284             var bundledHelpers = new ts.Map();
82285             for (var _a = 0, _b = bundle.sourceFiles; _a < _b.length; _a++) {
82286                 var sourceFile = _b[_a];
82287                 var shouldSkip = ts.getExternalHelpersModuleName(sourceFile) !== undefined;
82288                 var helpers = getSortedEmitHelpers(sourceFile);
82289                 if (!helpers)
82290                     continue;
82291                 for (var _c = 0, helpers_5 = helpers; _c < helpers_5.length; _c++) {
82292                     var helper = helpers_5[_c];
82293                     if (!helper.scoped && !shouldSkip && !bundledHelpers.get(helper.name)) {
82294                         bundledHelpers.set(helper.name, true);
82295                         (result || (result = [])).push(helper.name);
82296                     }
82297                 }
82298             }
82299             return result;
82300         }
82301         function emitHelpers(node) {
82302             var helpersEmitted = false;
82303             var bundle = node.kind === 298 ? node : undefined;
82304             if (bundle && moduleKind === ts.ModuleKind.None) {
82305                 return;
82306             }
82307             var numPrepends = bundle ? bundle.prepends.length : 0;
82308             var numNodes = bundle ? bundle.sourceFiles.length + numPrepends : 1;
82309             for (var i = 0; i < numNodes; i++) {
82310                 var currentNode = bundle ? i < numPrepends ? bundle.prepends[i] : bundle.sourceFiles[i - numPrepends] : node;
82311                 var sourceFile = ts.isSourceFile(currentNode) ? currentNode : ts.isUnparsedSource(currentNode) ? undefined : currentSourceFile;
82312                 var shouldSkip = printerOptions.noEmitHelpers || (!!sourceFile && ts.hasRecordedExternalHelpers(sourceFile));
82313                 var shouldBundle = (ts.isSourceFile(currentNode) || ts.isUnparsedSource(currentNode)) && !isOwnFileEmit;
82314                 var helpers = ts.isUnparsedSource(currentNode) ? currentNode.helpers : getSortedEmitHelpers(currentNode);
82315                 if (helpers) {
82316                     for (var _a = 0, helpers_6 = helpers; _a < helpers_6.length; _a++) {
82317                         var helper = helpers_6[_a];
82318                         if (!helper.scoped) {
82319                             if (shouldSkip)
82320                                 continue;
82321                             if (shouldBundle) {
82322                                 if (bundledHelpers.get(helper.name)) {
82323                                     continue;
82324                                 }
82325                                 bundledHelpers.set(helper.name, true);
82326                             }
82327                         }
82328                         else if (bundle) {
82329                             continue;
82330                         }
82331                         var pos = getTextPosWithWriteLine();
82332                         if (typeof helper.text === "string") {
82333                             writeLines(helper.text);
82334                         }
82335                         else {
82336                             writeLines(helper.text(makeFileLevelOptimisticUniqueName));
82337                         }
82338                         if (bundleFileInfo)
82339                             bundleFileInfo.sections.push({ pos: pos, end: writer.getTextPos(), kind: "emitHelpers", data: helper.name });
82340                         helpersEmitted = true;
82341                     }
82342                 }
82343             }
82344             return helpersEmitted;
82345         }
82346         function getSortedEmitHelpers(node) {
82347             var helpers = ts.getEmitHelpers(node);
82348             return helpers && ts.stableSort(helpers, ts.compareEmitHelpers);
82349         }
82350         function emitNumericOrBigIntLiteral(node) {
82351             emitLiteral(node, false);
82352         }
82353         function emitLiteral(node, jsxAttributeEscape) {
82354             var text = getLiteralTextOfNode(node, printerOptions.neverAsciiEscape, jsxAttributeEscape);
82355             if ((printerOptions.sourceMap || printerOptions.inlineSourceMap)
82356                 && (node.kind === 10 || ts.isTemplateLiteralKind(node.kind))) {
82357                 writeLiteral(text);
82358             }
82359             else {
82360                 writeStringLiteral(text);
82361             }
82362         }
82363         function emitUnparsedSourceOrPrepend(unparsed) {
82364             for (var _a = 0, _b = unparsed.texts; _a < _b.length; _a++) {
82365                 var text = _b[_a];
82366                 writeLine();
82367                 emit(text);
82368             }
82369         }
82370         function writeUnparsedNode(unparsed) {
82371             writer.rawWrite(unparsed.parent.text.substring(unparsed.pos, unparsed.end));
82372         }
82373         function emitUnparsedTextLike(unparsed) {
82374             var pos = getTextPosWithWriteLine();
82375             writeUnparsedNode(unparsed);
82376             if (bundleFileInfo) {
82377                 updateOrPushBundleFileTextLike(pos, writer.getTextPos(), unparsed.kind === 294 ?
82378                     "text" :
82379                     "internal");
82380             }
82381         }
82382         function emitUnparsedSyntheticReference(unparsed) {
82383             var pos = getTextPosWithWriteLine();
82384             writeUnparsedNode(unparsed);
82385             if (bundleFileInfo) {
82386                 var section = ts.clone(unparsed.section);
82387                 section.pos = pos;
82388                 section.end = writer.getTextPos();
82389                 bundleFileInfo.sections.push(section);
82390             }
82391         }
82392         function emitIdentifier(node) {
82393             var writeText = node.symbol ? writeSymbol : write;
82394             writeText(getTextOfNode(node, false), node.symbol);
82395             emitList(node, node.typeArguments, 53776);
82396         }
82397         function emitPrivateIdentifier(node) {
82398             var writeText = node.symbol ? writeSymbol : write;
82399             writeText(getTextOfNode(node, false), node.symbol);
82400         }
82401         function emitQualifiedName(node) {
82402             emitEntityName(node.left);
82403             writePunctuation(".");
82404             emit(node.right);
82405         }
82406         function emitEntityName(node) {
82407             if (node.kind === 78) {
82408                 emitExpression(node);
82409             }
82410             else {
82411                 emit(node);
82412             }
82413         }
82414         function emitComputedPropertyName(node) {
82415             writePunctuation("[");
82416             emitExpression(node.expression);
82417             writePunctuation("]");
82418         }
82419         function emitTypeParameter(node) {
82420             emit(node.name);
82421             if (node.constraint) {
82422                 writeSpace();
82423                 writeKeyword("extends");
82424                 writeSpace();
82425                 emit(node.constraint);
82426             }
82427             if (node.default) {
82428                 writeSpace();
82429                 writeOperator("=");
82430                 writeSpace();
82431                 emit(node.default);
82432             }
82433         }
82434         function emitParameter(node) {
82435             emitDecorators(node, node.decorators);
82436             emitModifiers(node, node.modifiers);
82437             emit(node.dotDotDotToken);
82438             emitNodeWithWriter(node.name, writeParameter);
82439             emit(node.questionToken);
82440             if (node.parent && node.parent.kind === 308 && !node.name) {
82441                 emit(node.type);
82442             }
82443             else {
82444                 emitTypeAnnotation(node.type);
82445             }
82446             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);
82447         }
82448         function emitDecorator(decorator) {
82449             writePunctuation("@");
82450             emitExpression(decorator.expression);
82451         }
82452         function emitPropertySignature(node) {
82453             emitDecorators(node, node.decorators);
82454             emitModifiers(node, node.modifiers);
82455             emitNodeWithWriter(node.name, writeProperty);
82456             emit(node.questionToken);
82457             emitTypeAnnotation(node.type);
82458             writeTrailingSemicolon();
82459         }
82460         function emitPropertyDeclaration(node) {
82461             emitDecorators(node, node.decorators);
82462             emitModifiers(node, node.modifiers);
82463             emit(node.name);
82464             emit(node.questionToken);
82465             emit(node.exclamationToken);
82466             emitTypeAnnotation(node.type);
82467             emitInitializer(node.initializer, node.type ? node.type.end : node.questionToken ? node.questionToken.end : node.name.end, node);
82468             writeTrailingSemicolon();
82469         }
82470         function emitMethodSignature(node) {
82471             pushNameGenerationScope(node);
82472             emitDecorators(node, node.decorators);
82473             emitModifiers(node, node.modifiers);
82474             emit(node.name);
82475             emit(node.questionToken);
82476             emitTypeParameters(node, node.typeParameters);
82477             emitParameters(node, node.parameters);
82478             emitTypeAnnotation(node.type);
82479             writeTrailingSemicolon();
82480             popNameGenerationScope(node);
82481         }
82482         function emitMethodDeclaration(node) {
82483             emitDecorators(node, node.decorators);
82484             emitModifiers(node, node.modifiers);
82485             emit(node.asteriskToken);
82486             emit(node.name);
82487             emit(node.questionToken);
82488             emitSignatureAndBody(node, emitSignatureHead);
82489         }
82490         function emitConstructor(node) {
82491             emitModifiers(node, node.modifiers);
82492             writeKeyword("constructor");
82493             emitSignatureAndBody(node, emitSignatureHead);
82494         }
82495         function emitAccessorDeclaration(node) {
82496             emitDecorators(node, node.decorators);
82497             emitModifiers(node, node.modifiers);
82498             writeKeyword(node.kind === 167 ? "get" : "set");
82499             writeSpace();
82500             emit(node.name);
82501             emitSignatureAndBody(node, emitSignatureHead);
82502         }
82503         function emitCallSignature(node) {
82504             pushNameGenerationScope(node);
82505             emitDecorators(node, node.decorators);
82506             emitModifiers(node, node.modifiers);
82507             emitTypeParameters(node, node.typeParameters);
82508             emitParameters(node, node.parameters);
82509             emitTypeAnnotation(node.type);
82510             writeTrailingSemicolon();
82511             popNameGenerationScope(node);
82512         }
82513         function emitConstructSignature(node) {
82514             pushNameGenerationScope(node);
82515             emitDecorators(node, node.decorators);
82516             emitModifiers(node, node.modifiers);
82517             writeKeyword("new");
82518             writeSpace();
82519             emitTypeParameters(node, node.typeParameters);
82520             emitParameters(node, node.parameters);
82521             emitTypeAnnotation(node.type);
82522             writeTrailingSemicolon();
82523             popNameGenerationScope(node);
82524         }
82525         function emitIndexSignature(node) {
82526             emitDecorators(node, node.decorators);
82527             emitModifiers(node, node.modifiers);
82528             emitParametersForIndexSignature(node, node.parameters);
82529             emitTypeAnnotation(node.type);
82530             writeTrailingSemicolon();
82531         }
82532         function emitTemplateTypeSpan(node) {
82533             emit(node.type);
82534             emit(node.literal);
82535         }
82536         function emitSemicolonClassElement() {
82537             writeTrailingSemicolon();
82538         }
82539         function emitTypePredicate(node) {
82540             if (node.assertsModifier) {
82541                 emit(node.assertsModifier);
82542                 writeSpace();
82543             }
82544             emit(node.parameterName);
82545             if (node.type) {
82546                 writeSpace();
82547                 writeKeyword("is");
82548                 writeSpace();
82549                 emit(node.type);
82550             }
82551         }
82552         function emitTypeReference(node) {
82553             emit(node.typeName);
82554             emitTypeArguments(node, node.typeArguments);
82555         }
82556         function emitFunctionType(node) {
82557             pushNameGenerationScope(node);
82558             emitTypeParameters(node, node.typeParameters);
82559             emitParametersForArrow(node, node.parameters);
82560             writeSpace();
82561             writePunctuation("=>");
82562             writeSpace();
82563             emit(node.type);
82564             popNameGenerationScope(node);
82565         }
82566         function emitJSDocFunctionType(node) {
82567             writeKeyword("function");
82568             emitParameters(node, node.parameters);
82569             writePunctuation(":");
82570             emit(node.type);
82571         }
82572         function emitJSDocNullableType(node) {
82573             writePunctuation("?");
82574             emit(node.type);
82575         }
82576         function emitJSDocNonNullableType(node) {
82577             writePunctuation("!");
82578             emit(node.type);
82579         }
82580         function emitJSDocOptionalType(node) {
82581             emit(node.type);
82582             writePunctuation("=");
82583         }
82584         function emitConstructorType(node) {
82585             pushNameGenerationScope(node);
82586             writeKeyword("new");
82587             writeSpace();
82588             emitTypeParameters(node, node.typeParameters);
82589             emitParameters(node, node.parameters);
82590             writeSpace();
82591             writePunctuation("=>");
82592             writeSpace();
82593             emit(node.type);
82594             popNameGenerationScope(node);
82595         }
82596         function emitTypeQuery(node) {
82597             writeKeyword("typeof");
82598             writeSpace();
82599             emit(node.exprName);
82600         }
82601         function emitTypeLiteral(node) {
82602             writePunctuation("{");
82603             var flags = ts.getEmitFlags(node) & 1 ? 768 : 32897;
82604             emitList(node, node.members, flags | 524288);
82605             writePunctuation("}");
82606         }
82607         function emitArrayType(node) {
82608             emit(node.elementType);
82609             writePunctuation("[");
82610             writePunctuation("]");
82611         }
82612         function emitRestOrJSDocVariadicType(node) {
82613             writePunctuation("...");
82614             emit(node.type);
82615         }
82616         function emitTupleType(node) {
82617             emitTokenWithComment(22, node.pos, writePunctuation, node);
82618             var flags = ts.getEmitFlags(node) & 1 ? 528 : 657;
82619             emitList(node, node.elements, flags | 524288);
82620             emitTokenWithComment(23, node.elements.end, writePunctuation, node);
82621         }
82622         function emitNamedTupleMember(node) {
82623             emit(node.dotDotDotToken);
82624             emit(node.name);
82625             emit(node.questionToken);
82626             emitTokenWithComment(58, node.name.end, writePunctuation, node);
82627             writeSpace();
82628             emit(node.type);
82629         }
82630         function emitOptionalType(node) {
82631             emit(node.type);
82632             writePunctuation("?");
82633         }
82634         function emitUnionType(node) {
82635             emitList(node, node.types, 516);
82636         }
82637         function emitIntersectionType(node) {
82638             emitList(node, node.types, 520);
82639         }
82640         function emitConditionalType(node) {
82641             emit(node.checkType);
82642             writeSpace();
82643             writeKeyword("extends");
82644             writeSpace();
82645             emit(node.extendsType);
82646             writeSpace();
82647             writePunctuation("?");
82648             writeSpace();
82649             emit(node.trueType);
82650             writeSpace();
82651             writePunctuation(":");
82652             writeSpace();
82653             emit(node.falseType);
82654         }
82655         function emitInferType(node) {
82656             writeKeyword("infer");
82657             writeSpace();
82658             emit(node.typeParameter);
82659         }
82660         function emitParenthesizedType(node) {
82661             writePunctuation("(");
82662             emit(node.type);
82663             writePunctuation(")");
82664         }
82665         function emitThisType() {
82666             writeKeyword("this");
82667         }
82668         function emitTypeOperator(node) {
82669             writeTokenText(node.operator, writeKeyword);
82670             writeSpace();
82671             emit(node.type);
82672         }
82673         function emitIndexedAccessType(node) {
82674             emit(node.objectType);
82675             writePunctuation("[");
82676             emit(node.indexType);
82677             writePunctuation("]");
82678         }
82679         function emitMappedType(node) {
82680             var emitFlags = ts.getEmitFlags(node);
82681             writePunctuation("{");
82682             if (emitFlags & 1) {
82683                 writeSpace();
82684             }
82685             else {
82686                 writeLine();
82687                 increaseIndent();
82688             }
82689             if (node.readonlyToken) {
82690                 emit(node.readonlyToken);
82691                 if (node.readonlyToken.kind !== 142) {
82692                     writeKeyword("readonly");
82693                 }
82694                 writeSpace();
82695             }
82696             writePunctuation("[");
82697             pipelineEmit(3, node.typeParameter);
82698             if (node.nameType) {
82699                 writeSpace();
82700                 writeKeyword("as");
82701                 writeSpace();
82702                 emit(node.nameType);
82703             }
82704             writePunctuation("]");
82705             if (node.questionToken) {
82706                 emit(node.questionToken);
82707                 if (node.questionToken.kind !== 57) {
82708                     writePunctuation("?");
82709                 }
82710             }
82711             writePunctuation(":");
82712             writeSpace();
82713             emit(node.type);
82714             writeTrailingSemicolon();
82715             if (emitFlags & 1) {
82716                 writeSpace();
82717             }
82718             else {
82719                 writeLine();
82720                 decreaseIndent();
82721             }
82722             writePunctuation("}");
82723         }
82724         function emitLiteralType(node) {
82725             emitExpression(node.literal);
82726         }
82727         function emitTemplateType(node) {
82728             emit(node.head);
82729             emitList(node, node.templateSpans, 262144);
82730         }
82731         function emitImportTypeNode(node) {
82732             if (node.isTypeOf) {
82733                 writeKeyword("typeof");
82734                 writeSpace();
82735             }
82736             writeKeyword("import");
82737             writePunctuation("(");
82738             emit(node.argument);
82739             writePunctuation(")");
82740             if (node.qualifier) {
82741                 writePunctuation(".");
82742                 emit(node.qualifier);
82743             }
82744             emitTypeArguments(node, node.typeArguments);
82745         }
82746         function emitObjectBindingPattern(node) {
82747             writePunctuation("{");
82748             emitList(node, node.elements, 525136);
82749             writePunctuation("}");
82750         }
82751         function emitArrayBindingPattern(node) {
82752             writePunctuation("[");
82753             emitList(node, node.elements, 524880);
82754             writePunctuation("]");
82755         }
82756         function emitBindingElement(node) {
82757             emit(node.dotDotDotToken);
82758             if (node.propertyName) {
82759                 emit(node.propertyName);
82760                 writePunctuation(":");
82761                 writeSpace();
82762             }
82763             emit(node.name);
82764             emitInitializer(node.initializer, node.name.end, node);
82765         }
82766         function emitArrayLiteralExpression(node) {
82767             var elements = node.elements;
82768             var preferNewLine = node.multiLine ? 65536 : 0;
82769             emitExpressionList(node, elements, 8914 | preferNewLine);
82770         }
82771         function emitObjectLiteralExpression(node) {
82772             ts.forEach(node.properties, generateMemberNames);
82773             var indentedFlag = ts.getEmitFlags(node) & 65536;
82774             if (indentedFlag) {
82775                 increaseIndent();
82776             }
82777             var preferNewLine = node.multiLine ? 65536 : 0;
82778             var allowTrailingComma = currentSourceFile.languageVersion >= 1 && !ts.isJsonSourceFile(currentSourceFile) ? 64 : 0;
82779             emitList(node, node.properties, 526226 | allowTrailingComma | preferNewLine);
82780             if (indentedFlag) {
82781                 decreaseIndent();
82782             }
82783         }
82784         function emitPropertyAccessExpression(node) {
82785             var expression = ts.cast(emitExpression(node.expression), ts.isExpression);
82786             var token = node.questionDotToken || ts.setTextRangePosEnd(ts.factory.createToken(24), node.expression.end, node.name.pos);
82787             var linesBeforeDot = getLinesBetweenNodes(node, node.expression, token);
82788             var linesAfterDot = getLinesBetweenNodes(node, token, node.name);
82789             writeLinesAndIndent(linesBeforeDot, false);
82790             var shouldEmitDotDot = token.kind !== 28 &&
82791                 mayNeedDotDotForPropertyAccess(expression) &&
82792                 !writer.hasTrailingComment() &&
82793                 !writer.hasTrailingWhitespace();
82794             if (shouldEmitDotDot) {
82795                 writePunctuation(".");
82796             }
82797             if (node.questionDotToken) {
82798                 emit(token);
82799             }
82800             else {
82801                 emitTokenWithComment(token.kind, node.expression.end, writePunctuation, node);
82802             }
82803             writeLinesAndIndent(linesAfterDot, false);
82804             emit(node.name);
82805             decreaseIndentIf(linesBeforeDot, linesAfterDot);
82806         }
82807         function mayNeedDotDotForPropertyAccess(expression) {
82808             expression = ts.skipPartiallyEmittedExpressions(expression);
82809             if (ts.isNumericLiteral(expression)) {
82810                 var text = getLiteralTextOfNode(expression, true, false);
82811                 return !expression.numericLiteralFlags && !ts.stringContains(text, ts.tokenToString(24));
82812             }
82813             else if (ts.isAccessExpression(expression)) {
82814                 var constantValue = ts.getConstantValue(expression);
82815                 return typeof constantValue === "number" && isFinite(constantValue)
82816                     && Math.floor(constantValue) === constantValue;
82817             }
82818         }
82819         function emitElementAccessExpression(node) {
82820             emitExpression(node.expression);
82821             emit(node.questionDotToken);
82822             emitTokenWithComment(22, node.expression.end, writePunctuation, node);
82823             emitExpression(node.argumentExpression);
82824             emitTokenWithComment(23, node.argumentExpression.end, writePunctuation, node);
82825         }
82826         function emitCallExpression(node) {
82827             emitExpression(node.expression);
82828             emit(node.questionDotToken);
82829             emitTypeArguments(node, node.typeArguments);
82830             emitExpressionList(node, node.arguments, 2576);
82831         }
82832         function emitNewExpression(node) {
82833             emitTokenWithComment(102, node.pos, writeKeyword, node);
82834             writeSpace();
82835             emitExpression(node.expression);
82836             emitTypeArguments(node, node.typeArguments);
82837             emitExpressionList(node, node.arguments, 18960);
82838         }
82839         function emitTaggedTemplateExpression(node) {
82840             emitExpression(node.tag);
82841             emitTypeArguments(node, node.typeArguments);
82842             writeSpace();
82843             emitExpression(node.template);
82844         }
82845         function emitTypeAssertionExpression(node) {
82846             writePunctuation("<");
82847             emit(node.type);
82848             writePunctuation(">");
82849             emitExpression(node.expression);
82850         }
82851         function emitParenthesizedExpression(node) {
82852             var openParenPos = emitTokenWithComment(20, node.pos, writePunctuation, node);
82853             var indented = writeLineSeparatorsAndIndentBefore(node.expression, node);
82854             emitExpression(node.expression);
82855             writeLineSeparatorsAfter(node.expression, node);
82856             decreaseIndentIf(indented);
82857             emitTokenWithComment(21, node.expression ? node.expression.end : openParenPos, writePunctuation, node);
82858         }
82859         function emitFunctionExpression(node) {
82860             generateNameIfNeeded(node.name);
82861             emitFunctionDeclarationOrExpression(node);
82862         }
82863         function emitArrowFunction(node) {
82864             emitDecorators(node, node.decorators);
82865             emitModifiers(node, node.modifiers);
82866             emitSignatureAndBody(node, emitArrowFunctionHead);
82867         }
82868         function emitArrowFunctionHead(node) {
82869             emitTypeParameters(node, node.typeParameters);
82870             emitParametersForArrow(node, node.parameters);
82871             emitTypeAnnotation(node.type);
82872             writeSpace();
82873             emit(node.equalsGreaterThanToken);
82874         }
82875         function emitDeleteExpression(node) {
82876             emitTokenWithComment(88, node.pos, writeKeyword, node);
82877             writeSpace();
82878             emitExpression(node.expression);
82879         }
82880         function emitTypeOfExpression(node) {
82881             emitTokenWithComment(111, node.pos, writeKeyword, node);
82882             writeSpace();
82883             emitExpression(node.expression);
82884         }
82885         function emitVoidExpression(node) {
82886             emitTokenWithComment(113, node.pos, writeKeyword, node);
82887             writeSpace();
82888             emitExpression(node.expression);
82889         }
82890         function emitAwaitExpression(node) {
82891             emitTokenWithComment(130, node.pos, writeKeyword, node);
82892             writeSpace();
82893             emitExpression(node.expression);
82894         }
82895         function emitPrefixUnaryExpression(node) {
82896             writeTokenText(node.operator, writeOperator);
82897             if (shouldEmitWhitespaceBeforeOperand(node)) {
82898                 writeSpace();
82899             }
82900             emitExpression(node.operand);
82901         }
82902         function shouldEmitWhitespaceBeforeOperand(node) {
82903             var operand = node.operand;
82904             return operand.kind === 214
82905                 && ((node.operator === 39 && (operand.operator === 39 || operand.operator === 45))
82906                     || (node.operator === 40 && (operand.operator === 40 || operand.operator === 46)));
82907         }
82908         function emitPostfixUnaryExpression(node) {
82909             emitExpression(node.operand);
82910             writeTokenText(node.operator, writeOperator);
82911         }
82912         function emitBinaryExpression(node) {
82913             var nodeStack = [node];
82914             var stateStack = [0];
82915             var stackIndex = 0;
82916             while (stackIndex >= 0) {
82917                 node = nodeStack[stackIndex];
82918                 switch (stateStack[stackIndex]) {
82919                     case 0: {
82920                         maybePipelineEmitExpression(node.left);
82921                         break;
82922                     }
82923                     case 1: {
82924                         var isCommaOperator = node.operatorToken.kind !== 27;
82925                         var linesBeforeOperator = getLinesBetweenNodes(node, node.left, node.operatorToken);
82926                         var linesAfterOperator = getLinesBetweenNodes(node, node.operatorToken, node.right);
82927                         writeLinesAndIndent(linesBeforeOperator, isCommaOperator);
82928                         emitLeadingCommentsOfPosition(node.operatorToken.pos);
82929                         writeTokenNode(node.operatorToken, node.operatorToken.kind === 100 ? writeKeyword : writeOperator);
82930                         emitTrailingCommentsOfPosition(node.operatorToken.end, true);
82931                         writeLinesAndIndent(linesAfterOperator, true);
82932                         maybePipelineEmitExpression(node.right);
82933                         break;
82934                     }
82935                     case 2: {
82936                         var linesBeforeOperator = getLinesBetweenNodes(node, node.left, node.operatorToken);
82937                         var linesAfterOperator = getLinesBetweenNodes(node, node.operatorToken, node.right);
82938                         decreaseIndentIf(linesBeforeOperator, linesAfterOperator);
82939                         stackIndex--;
82940                         break;
82941                     }
82942                     default: return ts.Debug.fail("Invalid state " + stateStack[stackIndex] + " for emitBinaryExpressionWorker");
82943                 }
82944             }
82945             function maybePipelineEmitExpression(next) {
82946                 stateStack[stackIndex]++;
82947                 var savedLastNode = lastNode;
82948                 var savedLastSubstitution = lastSubstitution;
82949                 lastNode = next;
82950                 lastSubstitution = undefined;
82951                 var pipelinePhase = getPipelinePhase(0, 1, next);
82952                 if (pipelinePhase === pipelineEmitWithHint && ts.isBinaryExpression(next)) {
82953                     stackIndex++;
82954                     stateStack[stackIndex] = 0;
82955                     nodeStack[stackIndex] = next;
82956                 }
82957                 else {
82958                     pipelinePhase(1, next);
82959                 }
82960                 ts.Debug.assert(lastNode === next);
82961                 lastNode = savedLastNode;
82962                 lastSubstitution = savedLastSubstitution;
82963             }
82964         }
82965         function emitConditionalExpression(node) {
82966             var linesBeforeQuestion = getLinesBetweenNodes(node, node.condition, node.questionToken);
82967             var linesAfterQuestion = getLinesBetweenNodes(node, node.questionToken, node.whenTrue);
82968             var linesBeforeColon = getLinesBetweenNodes(node, node.whenTrue, node.colonToken);
82969             var linesAfterColon = getLinesBetweenNodes(node, node.colonToken, node.whenFalse);
82970             emitExpression(node.condition);
82971             writeLinesAndIndent(linesBeforeQuestion, true);
82972             emit(node.questionToken);
82973             writeLinesAndIndent(linesAfterQuestion, true);
82974             emitExpression(node.whenTrue);
82975             decreaseIndentIf(linesBeforeQuestion, linesAfterQuestion);
82976             writeLinesAndIndent(linesBeforeColon, true);
82977             emit(node.colonToken);
82978             writeLinesAndIndent(linesAfterColon, true);
82979             emitExpression(node.whenFalse);
82980             decreaseIndentIf(linesBeforeColon, linesAfterColon);
82981         }
82982         function emitTemplateExpression(node) {
82983             emit(node.head);
82984             emitList(node, node.templateSpans, 262144);
82985         }
82986         function emitYieldExpression(node) {
82987             emitTokenWithComment(124, node.pos, writeKeyword, node);
82988             emit(node.asteriskToken);
82989             emitExpressionWithLeadingSpace(node.expression);
82990         }
82991         function emitSpreadExpression(node) {
82992             emitTokenWithComment(25, node.pos, writePunctuation, node);
82993             emitExpression(node.expression);
82994         }
82995         function emitClassExpression(node) {
82996             generateNameIfNeeded(node.name);
82997             emitClassDeclarationOrExpression(node);
82998         }
82999         function emitExpressionWithTypeArguments(node) {
83000             emitExpression(node.expression);
83001             emitTypeArguments(node, node.typeArguments);
83002         }
83003         function emitAsExpression(node) {
83004             emitExpression(node.expression);
83005             if (node.type) {
83006                 writeSpace();
83007                 writeKeyword("as");
83008                 writeSpace();
83009                 emit(node.type);
83010             }
83011         }
83012         function emitNonNullExpression(node) {
83013             emitExpression(node.expression);
83014             writeOperator("!");
83015         }
83016         function emitMetaProperty(node) {
83017             writeToken(node.keywordToken, node.pos, writePunctuation);
83018             writePunctuation(".");
83019             emit(node.name);
83020         }
83021         function emitTemplateSpan(node) {
83022             emitExpression(node.expression);
83023             emit(node.literal);
83024         }
83025         function emitBlock(node) {
83026             emitBlockStatements(node, !node.multiLine && isEmptyBlock(node));
83027         }
83028         function emitBlockStatements(node, forceSingleLine) {
83029             emitTokenWithComment(18, node.pos, writePunctuation, node);
83030             var format = forceSingleLine || ts.getEmitFlags(node) & 1 ? 768 : 129;
83031             emitList(node, node.statements, format);
83032             emitTokenWithComment(19, node.statements.end, writePunctuation, node, !!(format & 1));
83033         }
83034         function emitVariableStatement(node) {
83035             emitModifiers(node, node.modifiers);
83036             emit(node.declarationList);
83037             writeTrailingSemicolon();
83038         }
83039         function emitEmptyStatement(isEmbeddedStatement) {
83040             if (isEmbeddedStatement) {
83041                 writePunctuation(";");
83042             }
83043             else {
83044                 writeTrailingSemicolon();
83045             }
83046         }
83047         function emitExpressionStatement(node) {
83048             emitExpression(node.expression);
83049             if (!ts.isJsonSourceFile(currentSourceFile) || ts.nodeIsSynthesized(node.expression)) {
83050                 writeTrailingSemicolon();
83051             }
83052         }
83053         function emitIfStatement(node) {
83054             var openParenPos = emitTokenWithComment(98, node.pos, writeKeyword, node);
83055             writeSpace();
83056             emitTokenWithComment(20, openParenPos, writePunctuation, node);
83057             emitExpression(node.expression);
83058             emitTokenWithComment(21, node.expression.end, writePunctuation, node);
83059             emitEmbeddedStatement(node, node.thenStatement);
83060             if (node.elseStatement) {
83061                 writeLineOrSpace(node, node.thenStatement, node.elseStatement);
83062                 emitTokenWithComment(90, node.thenStatement.end, writeKeyword, node);
83063                 if (node.elseStatement.kind === 234) {
83064                     writeSpace();
83065                     emit(node.elseStatement);
83066                 }
83067                 else {
83068                     emitEmbeddedStatement(node, node.elseStatement);
83069                 }
83070             }
83071         }
83072         function emitWhileClause(node, startPos) {
83073             var openParenPos = emitTokenWithComment(114, startPos, writeKeyword, node);
83074             writeSpace();
83075             emitTokenWithComment(20, openParenPos, writePunctuation, node);
83076             emitExpression(node.expression);
83077             emitTokenWithComment(21, node.expression.end, writePunctuation, node);
83078         }
83079         function emitDoStatement(node) {
83080             emitTokenWithComment(89, node.pos, writeKeyword, node);
83081             emitEmbeddedStatement(node, node.statement);
83082             if (ts.isBlock(node.statement) && !preserveSourceNewlines) {
83083                 writeSpace();
83084             }
83085             else {
83086                 writeLineOrSpace(node, node.statement, node.expression);
83087             }
83088             emitWhileClause(node, node.statement.end);
83089             writeTrailingSemicolon();
83090         }
83091         function emitWhileStatement(node) {
83092             emitWhileClause(node, node.pos);
83093             emitEmbeddedStatement(node, node.statement);
83094         }
83095         function emitForStatement(node) {
83096             var openParenPos = emitTokenWithComment(96, node.pos, writeKeyword, node);
83097             writeSpace();
83098             var pos = emitTokenWithComment(20, openParenPos, writePunctuation, node);
83099             emitForBinding(node.initializer);
83100             pos = emitTokenWithComment(26, node.initializer ? node.initializer.end : pos, writePunctuation, node);
83101             emitExpressionWithLeadingSpace(node.condition);
83102             pos = emitTokenWithComment(26, node.condition ? node.condition.end : pos, writePunctuation, node);
83103             emitExpressionWithLeadingSpace(node.incrementor);
83104             emitTokenWithComment(21, node.incrementor ? node.incrementor.end : pos, writePunctuation, node);
83105             emitEmbeddedStatement(node, node.statement);
83106         }
83107         function emitForInStatement(node) {
83108             var openParenPos = emitTokenWithComment(96, node.pos, writeKeyword, node);
83109             writeSpace();
83110             emitTokenWithComment(20, openParenPos, writePunctuation, node);
83111             emitForBinding(node.initializer);
83112             writeSpace();
83113             emitTokenWithComment(100, node.initializer.end, writeKeyword, node);
83114             writeSpace();
83115             emitExpression(node.expression);
83116             emitTokenWithComment(21, node.expression.end, writePunctuation, node);
83117             emitEmbeddedStatement(node, node.statement);
83118         }
83119         function emitForOfStatement(node) {
83120             var openParenPos = emitTokenWithComment(96, node.pos, writeKeyword, node);
83121             writeSpace();
83122             emitWithTrailingSpace(node.awaitModifier);
83123             emitTokenWithComment(20, openParenPos, writePunctuation, node);
83124             emitForBinding(node.initializer);
83125             writeSpace();
83126             emitTokenWithComment(156, node.initializer.end, writeKeyword, node);
83127             writeSpace();
83128             emitExpression(node.expression);
83129             emitTokenWithComment(21, node.expression.end, writePunctuation, node);
83130             emitEmbeddedStatement(node, node.statement);
83131         }
83132         function emitForBinding(node) {
83133             if (node !== undefined) {
83134                 if (node.kind === 250) {
83135                     emit(node);
83136                 }
83137                 else {
83138                     emitExpression(node);
83139                 }
83140             }
83141         }
83142         function emitContinueStatement(node) {
83143             emitTokenWithComment(85, node.pos, writeKeyword, node);
83144             emitWithLeadingSpace(node.label);
83145             writeTrailingSemicolon();
83146         }
83147         function emitBreakStatement(node) {
83148             emitTokenWithComment(80, node.pos, writeKeyword, node);
83149             emitWithLeadingSpace(node.label);
83150             writeTrailingSemicolon();
83151         }
83152         function emitTokenWithComment(token, pos, writer, contextNode, indentLeading) {
83153             var node = ts.getParseTreeNode(contextNode);
83154             var isSimilarNode = node && node.kind === contextNode.kind;
83155             var startPos = pos;
83156             if (isSimilarNode && currentSourceFile) {
83157                 pos = ts.skipTrivia(currentSourceFile.text, pos);
83158             }
83159             if (emitLeadingCommentsOfPosition && isSimilarNode && contextNode.pos !== startPos) {
83160                 var needsIndent = indentLeading && currentSourceFile && !ts.positionsAreOnSameLine(startPos, pos, currentSourceFile);
83161                 if (needsIndent) {
83162                     increaseIndent();
83163                 }
83164                 emitLeadingCommentsOfPosition(startPos);
83165                 if (needsIndent) {
83166                     decreaseIndent();
83167                 }
83168             }
83169             pos = writeTokenText(token, writer, pos);
83170             if (emitTrailingCommentsOfPosition && isSimilarNode && contextNode.end !== pos) {
83171                 emitTrailingCommentsOfPosition(pos, true);
83172             }
83173             return pos;
83174         }
83175         function emitReturnStatement(node) {
83176             emitTokenWithComment(104, node.pos, writeKeyword, node);
83177             emitExpressionWithLeadingSpace(node.expression);
83178             writeTrailingSemicolon();
83179         }
83180         function emitWithStatement(node) {
83181             var openParenPos = emitTokenWithComment(115, node.pos, writeKeyword, node);
83182             writeSpace();
83183             emitTokenWithComment(20, openParenPos, writePunctuation, node);
83184             emitExpression(node.expression);
83185             emitTokenWithComment(21, node.expression.end, writePunctuation, node);
83186             emitEmbeddedStatement(node, node.statement);
83187         }
83188         function emitSwitchStatement(node) {
83189             var openParenPos = emitTokenWithComment(106, node.pos, writeKeyword, node);
83190             writeSpace();
83191             emitTokenWithComment(20, openParenPos, writePunctuation, node);
83192             emitExpression(node.expression);
83193             emitTokenWithComment(21, node.expression.end, writePunctuation, node);
83194             writeSpace();
83195             emit(node.caseBlock);
83196         }
83197         function emitLabeledStatement(node) {
83198             emit(node.label);
83199             emitTokenWithComment(58, node.label.end, writePunctuation, node);
83200             writeSpace();
83201             emit(node.statement);
83202         }
83203         function emitThrowStatement(node) {
83204             emitTokenWithComment(108, node.pos, writeKeyword, node);
83205             emitExpressionWithLeadingSpace(node.expression);
83206             writeTrailingSemicolon();
83207         }
83208         function emitTryStatement(node) {
83209             emitTokenWithComment(110, node.pos, writeKeyword, node);
83210             writeSpace();
83211             emit(node.tryBlock);
83212             if (node.catchClause) {
83213                 writeLineOrSpace(node, node.tryBlock, node.catchClause);
83214                 emit(node.catchClause);
83215             }
83216             if (node.finallyBlock) {
83217                 writeLineOrSpace(node, node.catchClause || node.tryBlock, node.finallyBlock);
83218                 emitTokenWithComment(95, (node.catchClause || node.tryBlock).end, writeKeyword, node);
83219                 writeSpace();
83220                 emit(node.finallyBlock);
83221             }
83222         }
83223         function emitDebuggerStatement(node) {
83224             writeToken(86, node.pos, writeKeyword);
83225             writeTrailingSemicolon();
83226         }
83227         function emitVariableDeclaration(node) {
83228             emit(node.name);
83229             emit(node.exclamationToken);
83230             emitTypeAnnotation(node.type);
83231             emitInitializer(node.initializer, node.type ? node.type.end : node.name.end, node);
83232         }
83233         function emitVariableDeclarationList(node) {
83234             writeKeyword(ts.isLet(node) ? "let" : ts.isVarConst(node) ? "const" : "var");
83235             writeSpace();
83236             emitList(node, node.declarations, 528);
83237         }
83238         function emitFunctionDeclaration(node) {
83239             emitFunctionDeclarationOrExpression(node);
83240         }
83241         function emitFunctionDeclarationOrExpression(node) {
83242             emitDecorators(node, node.decorators);
83243             emitModifiers(node, node.modifiers);
83244             writeKeyword("function");
83245             emit(node.asteriskToken);
83246             writeSpace();
83247             emitIdentifierName(node.name);
83248             emitSignatureAndBody(node, emitSignatureHead);
83249         }
83250         function emitBlockCallback(_hint, body) {
83251             emitBlockFunctionBody(body);
83252         }
83253         function emitSignatureAndBody(node, emitSignatureHead) {
83254             var body = node.body;
83255             if (body) {
83256                 if (ts.isBlock(body)) {
83257                     var indentedFlag = ts.getEmitFlags(node) & 65536;
83258                     if (indentedFlag) {
83259                         increaseIndent();
83260                     }
83261                     pushNameGenerationScope(node);
83262                     ts.forEach(node.parameters, generateNames);
83263                     generateNames(node.body);
83264                     emitSignatureHead(node);
83265                     if (onEmitNode) {
83266                         onEmitNode(4, body, emitBlockCallback);
83267                     }
83268                     else {
83269                         emitBlockFunctionBody(body);
83270                     }
83271                     popNameGenerationScope(node);
83272                     if (indentedFlag) {
83273                         decreaseIndent();
83274                     }
83275                 }
83276                 else {
83277                     emitSignatureHead(node);
83278                     writeSpace();
83279                     emitExpression(body);
83280                 }
83281             }
83282             else {
83283                 emitSignatureHead(node);
83284                 writeTrailingSemicolon();
83285             }
83286         }
83287         function emitSignatureHead(node) {
83288             emitTypeParameters(node, node.typeParameters);
83289             emitParameters(node, node.parameters);
83290             emitTypeAnnotation(node.type);
83291         }
83292         function shouldEmitBlockFunctionBodyOnSingleLine(body) {
83293             if (ts.getEmitFlags(body) & 1) {
83294                 return true;
83295             }
83296             if (body.multiLine) {
83297                 return false;
83298             }
83299             if (!ts.nodeIsSynthesized(body) && !ts.rangeIsOnSingleLine(body, currentSourceFile)) {
83300                 return false;
83301             }
83302             if (getLeadingLineTerminatorCount(body, body.statements, 2)
83303                 || getClosingLineTerminatorCount(body, body.statements, 2)) {
83304                 return false;
83305             }
83306             var previousStatement;
83307             for (var _a = 0, _b = body.statements; _a < _b.length; _a++) {
83308                 var statement = _b[_a];
83309                 if (getSeparatingLineTerminatorCount(previousStatement, statement, 2) > 0) {
83310                     return false;
83311                 }
83312                 previousStatement = statement;
83313             }
83314             return true;
83315         }
83316         function emitBlockFunctionBody(body) {
83317             writeSpace();
83318             writePunctuation("{");
83319             increaseIndent();
83320             var emitBlockFunctionBody = shouldEmitBlockFunctionBodyOnSingleLine(body)
83321                 ? emitBlockFunctionBodyOnSingleLine
83322                 : emitBlockFunctionBodyWorker;
83323             if (emitBodyWithDetachedComments) {
83324                 emitBodyWithDetachedComments(body, body.statements, emitBlockFunctionBody);
83325             }
83326             else {
83327                 emitBlockFunctionBody(body);
83328             }
83329             decreaseIndent();
83330             writeToken(19, body.statements.end, writePunctuation, body);
83331         }
83332         function emitBlockFunctionBodyOnSingleLine(body) {
83333             emitBlockFunctionBodyWorker(body, true);
83334         }
83335         function emitBlockFunctionBodyWorker(body, emitBlockFunctionBodyOnSingleLine) {
83336             var statementOffset = emitPrologueDirectives(body.statements);
83337             var pos = writer.getTextPos();
83338             emitHelpers(body);
83339             if (statementOffset === 0 && pos === writer.getTextPos() && emitBlockFunctionBodyOnSingleLine) {
83340                 decreaseIndent();
83341                 emitList(body, body.statements, 768);
83342                 increaseIndent();
83343             }
83344             else {
83345                 emitList(body, body.statements, 1, statementOffset);
83346             }
83347         }
83348         function emitClassDeclaration(node) {
83349             emitClassDeclarationOrExpression(node);
83350         }
83351         function emitClassDeclarationOrExpression(node) {
83352             ts.forEach(node.members, generateMemberNames);
83353             emitDecorators(node, node.decorators);
83354             emitModifiers(node, node.modifiers);
83355             writeKeyword("class");
83356             if (node.name) {
83357                 writeSpace();
83358                 emitIdentifierName(node.name);
83359             }
83360             var indentedFlag = ts.getEmitFlags(node) & 65536;
83361             if (indentedFlag) {
83362                 increaseIndent();
83363             }
83364             emitTypeParameters(node, node.typeParameters);
83365             emitList(node, node.heritageClauses, 0);
83366             writeSpace();
83367             writePunctuation("{");
83368             emitList(node, node.members, 129);
83369             writePunctuation("}");
83370             if (indentedFlag) {
83371                 decreaseIndent();
83372             }
83373         }
83374         function emitInterfaceDeclaration(node) {
83375             emitDecorators(node, node.decorators);
83376             emitModifiers(node, node.modifiers);
83377             writeKeyword("interface");
83378             writeSpace();
83379             emit(node.name);
83380             emitTypeParameters(node, node.typeParameters);
83381             emitList(node, node.heritageClauses, 512);
83382             writeSpace();
83383             writePunctuation("{");
83384             emitList(node, node.members, 129);
83385             writePunctuation("}");
83386         }
83387         function emitTypeAliasDeclaration(node) {
83388             emitDecorators(node, node.decorators);
83389             emitModifiers(node, node.modifiers);
83390             writeKeyword("type");
83391             writeSpace();
83392             emit(node.name);
83393             emitTypeParameters(node, node.typeParameters);
83394             writeSpace();
83395             writePunctuation("=");
83396             writeSpace();
83397             emit(node.type);
83398             writeTrailingSemicolon();
83399         }
83400         function emitEnumDeclaration(node) {
83401             emitModifiers(node, node.modifiers);
83402             writeKeyword("enum");
83403             writeSpace();
83404             emit(node.name);
83405             writeSpace();
83406             writePunctuation("{");
83407             emitList(node, node.members, 145);
83408             writePunctuation("}");
83409         }
83410         function emitModuleDeclaration(node) {
83411             emitModifiers(node, node.modifiers);
83412             if (~node.flags & 1024) {
83413                 writeKeyword(node.flags & 16 ? "namespace" : "module");
83414                 writeSpace();
83415             }
83416             emit(node.name);
83417             var body = node.body;
83418             if (!body)
83419                 return writeTrailingSemicolon();
83420             while (body.kind === 256) {
83421                 writePunctuation(".");
83422                 emit(body.name);
83423                 body = body.body;
83424             }
83425             writeSpace();
83426             emit(body);
83427         }
83428         function emitModuleBlock(node) {
83429             pushNameGenerationScope(node);
83430             ts.forEach(node.statements, generateNames);
83431             emitBlockStatements(node, isEmptyBlock(node));
83432             popNameGenerationScope(node);
83433         }
83434         function emitCaseBlock(node) {
83435             emitTokenWithComment(18, node.pos, writePunctuation, node);
83436             emitList(node, node.clauses, 129);
83437             emitTokenWithComment(19, node.clauses.end, writePunctuation, node, true);
83438         }
83439         function emitImportEqualsDeclaration(node) {
83440             emitModifiers(node, node.modifiers);
83441             emitTokenWithComment(99, node.modifiers ? node.modifiers.end : node.pos, writeKeyword, node);
83442             writeSpace();
83443             emit(node.name);
83444             writeSpace();
83445             emitTokenWithComment(62, node.name.end, writePunctuation, node);
83446             writeSpace();
83447             emitModuleReference(node.moduleReference);
83448             writeTrailingSemicolon();
83449         }
83450         function emitModuleReference(node) {
83451             if (node.kind === 78) {
83452                 emitExpression(node);
83453             }
83454             else {
83455                 emit(node);
83456             }
83457         }
83458         function emitImportDeclaration(node) {
83459             emitModifiers(node, node.modifiers);
83460             emitTokenWithComment(99, node.modifiers ? node.modifiers.end : node.pos, writeKeyword, node);
83461             writeSpace();
83462             if (node.importClause) {
83463                 emit(node.importClause);
83464                 writeSpace();
83465                 emitTokenWithComment(153, node.importClause.end, writeKeyword, node);
83466                 writeSpace();
83467             }
83468             emitExpression(node.moduleSpecifier);
83469             writeTrailingSemicolon();
83470         }
83471         function emitImportClause(node) {
83472             if (node.isTypeOnly) {
83473                 emitTokenWithComment(149, node.pos, writeKeyword, node);
83474                 writeSpace();
83475             }
83476             emit(node.name);
83477             if (node.name && node.namedBindings) {
83478                 emitTokenWithComment(27, node.name.end, writePunctuation, node);
83479                 writeSpace();
83480             }
83481             emit(node.namedBindings);
83482         }
83483         function emitNamespaceImport(node) {
83484             var asPos = emitTokenWithComment(41, node.pos, writePunctuation, node);
83485             writeSpace();
83486             emitTokenWithComment(126, asPos, writeKeyword, node);
83487             writeSpace();
83488             emit(node.name);
83489         }
83490         function emitNamedImports(node) {
83491             emitNamedImportsOrExports(node);
83492         }
83493         function emitImportSpecifier(node) {
83494             emitImportOrExportSpecifier(node);
83495         }
83496         function emitExportAssignment(node) {
83497             var nextPos = emitTokenWithComment(92, node.pos, writeKeyword, node);
83498             writeSpace();
83499             if (node.isExportEquals) {
83500                 emitTokenWithComment(62, nextPos, writeOperator, node);
83501             }
83502             else {
83503                 emitTokenWithComment(87, nextPos, writeKeyword, node);
83504             }
83505             writeSpace();
83506             emitExpression(node.expression);
83507             writeTrailingSemicolon();
83508         }
83509         function emitExportDeclaration(node) {
83510             var nextPos = emitTokenWithComment(92, node.pos, writeKeyword, node);
83511             writeSpace();
83512             if (node.isTypeOnly) {
83513                 nextPos = emitTokenWithComment(149, nextPos, writeKeyword, node);
83514                 writeSpace();
83515             }
83516             if (node.exportClause) {
83517                 emit(node.exportClause);
83518             }
83519             else {
83520                 nextPos = emitTokenWithComment(41, nextPos, writePunctuation, node);
83521             }
83522             if (node.moduleSpecifier) {
83523                 writeSpace();
83524                 var fromPos = node.exportClause ? node.exportClause.end : nextPos;
83525                 emitTokenWithComment(153, fromPos, writeKeyword, node);
83526                 writeSpace();
83527                 emitExpression(node.moduleSpecifier);
83528             }
83529             writeTrailingSemicolon();
83530         }
83531         function emitNamespaceExportDeclaration(node) {
83532             var nextPos = emitTokenWithComment(92, node.pos, writeKeyword, node);
83533             writeSpace();
83534             nextPos = emitTokenWithComment(126, nextPos, writeKeyword, node);
83535             writeSpace();
83536             nextPos = emitTokenWithComment(140, nextPos, writeKeyword, node);
83537             writeSpace();
83538             emit(node.name);
83539             writeTrailingSemicolon();
83540         }
83541         function emitNamespaceExport(node) {
83542             var asPos = emitTokenWithComment(41, node.pos, writePunctuation, node);
83543             writeSpace();
83544             emitTokenWithComment(126, asPos, writeKeyword, node);
83545             writeSpace();
83546             emit(node.name);
83547         }
83548         function emitNamedExports(node) {
83549             emitNamedImportsOrExports(node);
83550         }
83551         function emitExportSpecifier(node) {
83552             emitImportOrExportSpecifier(node);
83553         }
83554         function emitNamedImportsOrExports(node) {
83555             writePunctuation("{");
83556             emitList(node, node.elements, 525136);
83557             writePunctuation("}");
83558         }
83559         function emitImportOrExportSpecifier(node) {
83560             if (node.propertyName) {
83561                 emit(node.propertyName);
83562                 writeSpace();
83563                 emitTokenWithComment(126, node.propertyName.end, writeKeyword, node);
83564                 writeSpace();
83565             }
83566             emit(node.name);
83567         }
83568         function emitExternalModuleReference(node) {
83569             writeKeyword("require");
83570             writePunctuation("(");
83571             emitExpression(node.expression);
83572             writePunctuation(")");
83573         }
83574         function emitJsxElement(node) {
83575             emit(node.openingElement);
83576             emitList(node, node.children, 262144);
83577             emit(node.closingElement);
83578         }
83579         function emitJsxSelfClosingElement(node) {
83580             writePunctuation("<");
83581             emitJsxTagName(node.tagName);
83582             emitTypeArguments(node, node.typeArguments);
83583             writeSpace();
83584             emit(node.attributes);
83585             writePunctuation("/>");
83586         }
83587         function emitJsxFragment(node) {
83588             emit(node.openingFragment);
83589             emitList(node, node.children, 262144);
83590             emit(node.closingFragment);
83591         }
83592         function emitJsxOpeningElementOrFragment(node) {
83593             writePunctuation("<");
83594             if (ts.isJsxOpeningElement(node)) {
83595                 var indented = writeLineSeparatorsAndIndentBefore(node.tagName, node);
83596                 emitJsxTagName(node.tagName);
83597                 emitTypeArguments(node, node.typeArguments);
83598                 if (node.attributes.properties && node.attributes.properties.length > 0) {
83599                     writeSpace();
83600                 }
83601                 emit(node.attributes);
83602                 writeLineSeparatorsAfter(node.attributes, node);
83603                 decreaseIndentIf(indented);
83604             }
83605             writePunctuation(">");
83606         }
83607         function emitJsxText(node) {
83608             writer.writeLiteral(node.text);
83609         }
83610         function emitJsxClosingElementOrFragment(node) {
83611             writePunctuation("</");
83612             if (ts.isJsxClosingElement(node)) {
83613                 emitJsxTagName(node.tagName);
83614             }
83615             writePunctuation(">");
83616         }
83617         function emitJsxAttributes(node) {
83618             emitList(node, node.properties, 262656);
83619         }
83620         function emitJsxAttribute(node) {
83621             emit(node.name);
83622             emitNodeWithPrefix("=", writePunctuation, node.initializer, emitJsxAttributeValue);
83623         }
83624         function emitJsxSpreadAttribute(node) {
83625             writePunctuation("{...");
83626             emitExpression(node.expression);
83627             writePunctuation("}");
83628         }
83629         function emitJsxExpression(node) {
83630             if (node.expression) {
83631                 writePunctuation("{");
83632                 emit(node.dotDotDotToken);
83633                 emitExpression(node.expression);
83634                 writePunctuation("}");
83635             }
83636         }
83637         function emitJsxTagName(node) {
83638             if (node.kind === 78) {
83639                 emitExpression(node);
83640             }
83641             else {
83642                 emit(node);
83643             }
83644         }
83645         function emitCaseClause(node) {
83646             emitTokenWithComment(81, node.pos, writeKeyword, node);
83647             writeSpace();
83648             emitExpression(node.expression);
83649             emitCaseOrDefaultClauseRest(node, node.statements, node.expression.end);
83650         }
83651         function emitDefaultClause(node) {
83652             var pos = emitTokenWithComment(87, node.pos, writeKeyword, node);
83653             emitCaseOrDefaultClauseRest(node, node.statements, pos);
83654         }
83655         function emitCaseOrDefaultClauseRest(parentNode, statements, colonPos) {
83656             var emitAsSingleStatement = statements.length === 1 &&
83657                 (ts.nodeIsSynthesized(parentNode) ||
83658                     ts.nodeIsSynthesized(statements[0]) ||
83659                     ts.rangeStartPositionsAreOnSameLine(parentNode, statements[0], currentSourceFile));
83660             var format = 163969;
83661             if (emitAsSingleStatement) {
83662                 writeToken(58, colonPos, writePunctuation, parentNode);
83663                 writeSpace();
83664                 format &= ~(1 | 128);
83665             }
83666             else {
83667                 emitTokenWithComment(58, colonPos, writePunctuation, parentNode);
83668             }
83669             emitList(parentNode, statements, format);
83670         }
83671         function emitHeritageClause(node) {
83672             writeSpace();
83673             writeTokenText(node.token, writeKeyword);
83674             writeSpace();
83675             emitList(node, node.types, 528);
83676         }
83677         function emitCatchClause(node) {
83678             var openParenPos = emitTokenWithComment(82, node.pos, writeKeyword, node);
83679             writeSpace();
83680             if (node.variableDeclaration) {
83681                 emitTokenWithComment(20, openParenPos, writePunctuation, node);
83682                 emit(node.variableDeclaration);
83683                 emitTokenWithComment(21, node.variableDeclaration.end, writePunctuation, node);
83684                 writeSpace();
83685             }
83686             emit(node.block);
83687         }
83688         function emitPropertyAssignment(node) {
83689             emit(node.name);
83690             writePunctuation(":");
83691             writeSpace();
83692             var initializer = node.initializer;
83693             if (emitTrailingCommentsOfPosition && (ts.getEmitFlags(initializer) & 512) === 0) {
83694                 var commentRange = ts.getCommentRange(initializer);
83695                 emitTrailingCommentsOfPosition(commentRange.pos);
83696             }
83697             emitExpression(initializer);
83698         }
83699         function emitShorthandPropertyAssignment(node) {
83700             emit(node.name);
83701             if (node.objectAssignmentInitializer) {
83702                 writeSpace();
83703                 writePunctuation("=");
83704                 writeSpace();
83705                 emitExpression(node.objectAssignmentInitializer);
83706             }
83707         }
83708         function emitSpreadAssignment(node) {
83709             if (node.expression) {
83710                 emitTokenWithComment(25, node.pos, writePunctuation, node);
83711                 emitExpression(node.expression);
83712             }
83713         }
83714         function emitEnumMember(node) {
83715             emit(node.name);
83716             emitInitializer(node.initializer, node.name.end, node);
83717         }
83718         function emitJSDoc(node) {
83719             write("/**");
83720             if (node.comment) {
83721                 var lines = node.comment.split(/\r\n?|\n/g);
83722                 for (var _a = 0, lines_2 = lines; _a < lines_2.length; _a++) {
83723                     var line = lines_2[_a];
83724                     writeLine();
83725                     writeSpace();
83726                     writePunctuation("*");
83727                     writeSpace();
83728                     write(line);
83729                 }
83730             }
83731             if (node.tags) {
83732                 if (node.tags.length === 1 && node.tags[0].kind === 329 && !node.comment) {
83733                     writeSpace();
83734                     emit(node.tags[0]);
83735                 }
83736                 else {
83737                     emitList(node, node.tags, 33);
83738                 }
83739             }
83740             writeSpace();
83741             write("*/");
83742         }
83743         function emitJSDocSimpleTypedTag(tag) {
83744             emitJSDocTagName(tag.tagName);
83745             emitJSDocTypeExpression(tag.typeExpression);
83746             emitJSDocComment(tag.comment);
83747         }
83748         function emitJSDocSeeTag(tag) {
83749             emitJSDocTagName(tag.tagName);
83750             emit(tag.name);
83751             emitJSDocComment(tag.comment);
83752         }
83753         function emitJSDocNameReference(node) {
83754             writeSpace();
83755             writePunctuation("{");
83756             emit(node.name);
83757             writePunctuation("}");
83758         }
83759         function emitJSDocHeritageTag(tag) {
83760             emitJSDocTagName(tag.tagName);
83761             writeSpace();
83762             writePunctuation("{");
83763             emit(tag.class);
83764             writePunctuation("}");
83765             emitJSDocComment(tag.comment);
83766         }
83767         function emitJSDocTemplateTag(tag) {
83768             emitJSDocTagName(tag.tagName);
83769             emitJSDocTypeExpression(tag.constraint);
83770             writeSpace();
83771             emitList(tag, tag.typeParameters, 528);
83772             emitJSDocComment(tag.comment);
83773         }
83774         function emitJSDocTypedefTag(tag) {
83775             emitJSDocTagName(tag.tagName);
83776             if (tag.typeExpression) {
83777                 if (tag.typeExpression.kind === 301) {
83778                     emitJSDocTypeExpression(tag.typeExpression);
83779                 }
83780                 else {
83781                     writeSpace();
83782                     writePunctuation("{");
83783                     write("Object");
83784                     if (tag.typeExpression.isArrayType) {
83785                         writePunctuation("[");
83786                         writePunctuation("]");
83787                     }
83788                     writePunctuation("}");
83789                 }
83790             }
83791             if (tag.fullName) {
83792                 writeSpace();
83793                 emit(tag.fullName);
83794             }
83795             emitJSDocComment(tag.comment);
83796             if (tag.typeExpression && tag.typeExpression.kind === 312) {
83797                 emitJSDocTypeLiteral(tag.typeExpression);
83798             }
83799         }
83800         function emitJSDocCallbackTag(tag) {
83801             emitJSDocTagName(tag.tagName);
83802             if (tag.name) {
83803                 writeSpace();
83804                 emit(tag.name);
83805             }
83806             emitJSDocComment(tag.comment);
83807             emitJSDocSignature(tag.typeExpression);
83808         }
83809         function emitJSDocSimpleTag(tag) {
83810             emitJSDocTagName(tag.tagName);
83811             emitJSDocComment(tag.comment);
83812         }
83813         function emitJSDocTypeLiteral(lit) {
83814             emitList(lit, ts.factory.createNodeArray(lit.jsDocPropertyTags), 33);
83815         }
83816         function emitJSDocSignature(sig) {
83817             if (sig.typeParameters) {
83818                 emitList(sig, ts.factory.createNodeArray(sig.typeParameters), 33);
83819             }
83820             if (sig.parameters) {
83821                 emitList(sig, ts.factory.createNodeArray(sig.parameters), 33);
83822             }
83823             if (sig.type) {
83824                 writeLine();
83825                 writeSpace();
83826                 writePunctuation("*");
83827                 writeSpace();
83828                 emit(sig.type);
83829             }
83830         }
83831         function emitJSDocPropertyLikeTag(param) {
83832             emitJSDocTagName(param.tagName);
83833             emitJSDocTypeExpression(param.typeExpression);
83834             writeSpace();
83835             if (param.isBracketed) {
83836                 writePunctuation("[");
83837             }
83838             emit(param.name);
83839             if (param.isBracketed) {
83840                 writePunctuation("]");
83841             }
83842             emitJSDocComment(param.comment);
83843         }
83844         function emitJSDocTagName(tagName) {
83845             writePunctuation("@");
83846             emit(tagName);
83847         }
83848         function emitJSDocComment(comment) {
83849             if (comment) {
83850                 writeSpace();
83851                 write(comment);
83852             }
83853         }
83854         function emitJSDocTypeExpression(typeExpression) {
83855             if (typeExpression) {
83856                 writeSpace();
83857                 writePunctuation("{");
83858                 emit(typeExpression.type);
83859                 writePunctuation("}");
83860             }
83861         }
83862         function emitSourceFile(node) {
83863             writeLine();
83864             var statements = node.statements;
83865             if (emitBodyWithDetachedComments) {
83866                 var shouldEmitDetachedComment = statements.length === 0 ||
83867                     !ts.isPrologueDirective(statements[0]) ||
83868                     ts.nodeIsSynthesized(statements[0]);
83869                 if (shouldEmitDetachedComment) {
83870                     emitBodyWithDetachedComments(node, statements, emitSourceFileWorker);
83871                     return;
83872                 }
83873             }
83874             emitSourceFileWorker(node);
83875         }
83876         function emitSyntheticTripleSlashReferencesIfNeeded(node) {
83877             emitTripleSlashDirectives(!!node.hasNoDefaultLib, node.syntheticFileReferences || [], node.syntheticTypeReferences || [], node.syntheticLibReferences || []);
83878             for (var _a = 0, _b = node.prepends; _a < _b.length; _a++) {
83879                 var prepend = _b[_a];
83880                 if (ts.isUnparsedSource(prepend) && prepend.syntheticReferences) {
83881                     for (var _c = 0, _d = prepend.syntheticReferences; _c < _d.length; _c++) {
83882                         var ref = _d[_c];
83883                         emit(ref);
83884                         writeLine();
83885                     }
83886                 }
83887             }
83888         }
83889         function emitTripleSlashDirectivesIfNeeded(node) {
83890             if (node.isDeclarationFile)
83891                 emitTripleSlashDirectives(node.hasNoDefaultLib, node.referencedFiles, node.typeReferenceDirectives, node.libReferenceDirectives);
83892         }
83893         function emitTripleSlashDirectives(hasNoDefaultLib, files, types, libs) {
83894             if (hasNoDefaultLib) {
83895                 var pos = writer.getTextPos();
83896                 writeComment("/// <reference no-default-lib=\"true\"/>");
83897                 if (bundleFileInfo)
83898                     bundleFileInfo.sections.push({ pos: pos, end: writer.getTextPos(), kind: "no-default-lib" });
83899                 writeLine();
83900             }
83901             if (currentSourceFile && currentSourceFile.moduleName) {
83902                 writeComment("/// <amd-module name=\"" + currentSourceFile.moduleName + "\" />");
83903                 writeLine();
83904             }
83905             if (currentSourceFile && currentSourceFile.amdDependencies) {
83906                 for (var _a = 0, _b = currentSourceFile.amdDependencies; _a < _b.length; _a++) {
83907                     var dep = _b[_a];
83908                     if (dep.name) {
83909                         writeComment("/// <amd-dependency name=\"" + dep.name + "\" path=\"" + dep.path + "\" />");
83910                     }
83911                     else {
83912                         writeComment("/// <amd-dependency path=\"" + dep.path + "\" />");
83913                     }
83914                     writeLine();
83915                 }
83916             }
83917             for (var _c = 0, files_1 = files; _c < files_1.length; _c++) {
83918                 var directive = files_1[_c];
83919                 var pos = writer.getTextPos();
83920                 writeComment("/// <reference path=\"" + directive.fileName + "\" />");
83921                 if (bundleFileInfo)
83922                     bundleFileInfo.sections.push({ pos: pos, end: writer.getTextPos(), kind: "reference", data: directive.fileName });
83923                 writeLine();
83924             }
83925             for (var _d = 0, types_23 = types; _d < types_23.length; _d++) {
83926                 var directive = types_23[_d];
83927                 var pos = writer.getTextPos();
83928                 writeComment("/// <reference types=\"" + directive.fileName + "\" />");
83929                 if (bundleFileInfo)
83930                     bundleFileInfo.sections.push({ pos: pos, end: writer.getTextPos(), kind: "type", data: directive.fileName });
83931                 writeLine();
83932             }
83933             for (var _e = 0, libs_1 = libs; _e < libs_1.length; _e++) {
83934                 var directive = libs_1[_e];
83935                 var pos = writer.getTextPos();
83936                 writeComment("/// <reference lib=\"" + directive.fileName + "\" />");
83937                 if (bundleFileInfo)
83938                     bundleFileInfo.sections.push({ pos: pos, end: writer.getTextPos(), kind: "lib", data: directive.fileName });
83939                 writeLine();
83940             }
83941         }
83942         function emitSourceFileWorker(node) {
83943             var statements = node.statements;
83944             pushNameGenerationScope(node);
83945             ts.forEach(node.statements, generateNames);
83946             emitHelpers(node);
83947             var index = ts.findIndex(statements, function (statement) { return !ts.isPrologueDirective(statement); });
83948             emitTripleSlashDirectivesIfNeeded(node);
83949             emitList(node, statements, 1, index === -1 ? statements.length : index);
83950             popNameGenerationScope(node);
83951         }
83952         function emitPartiallyEmittedExpression(node) {
83953             emitExpression(node.expression);
83954         }
83955         function emitCommaList(node) {
83956             emitExpressionList(node, node.elements, 528);
83957         }
83958         function emitPrologueDirectives(statements, sourceFile, seenPrologueDirectives, recordBundleFileSection) {
83959             var needsToSetSourceFile = !!sourceFile;
83960             for (var i = 0; i < statements.length; i++) {
83961                 var statement = statements[i];
83962                 if (ts.isPrologueDirective(statement)) {
83963                     var shouldEmitPrologueDirective = seenPrologueDirectives ? !seenPrologueDirectives.has(statement.expression.text) : true;
83964                     if (shouldEmitPrologueDirective) {
83965                         if (needsToSetSourceFile) {
83966                             needsToSetSourceFile = false;
83967                             setSourceFile(sourceFile);
83968                         }
83969                         writeLine();
83970                         var pos = writer.getTextPos();
83971                         emit(statement);
83972                         if (recordBundleFileSection && bundleFileInfo)
83973                             bundleFileInfo.sections.push({ pos: pos, end: writer.getTextPos(), kind: "prologue", data: statement.expression.text });
83974                         if (seenPrologueDirectives) {
83975                             seenPrologueDirectives.add(statement.expression.text);
83976                         }
83977                     }
83978                 }
83979                 else {
83980                     return i;
83981                 }
83982             }
83983             return statements.length;
83984         }
83985         function emitUnparsedPrologues(prologues, seenPrologueDirectives) {
83986             for (var _a = 0, prologues_1 = prologues; _a < prologues_1.length; _a++) {
83987                 var prologue = prologues_1[_a];
83988                 if (!seenPrologueDirectives.has(prologue.data)) {
83989                     writeLine();
83990                     var pos = writer.getTextPos();
83991                     emit(prologue);
83992                     if (bundleFileInfo)
83993                         bundleFileInfo.sections.push({ pos: pos, end: writer.getTextPos(), kind: "prologue", data: prologue.data });
83994                     if (seenPrologueDirectives) {
83995                         seenPrologueDirectives.add(prologue.data);
83996                     }
83997                 }
83998             }
83999         }
84000         function emitPrologueDirectivesIfNeeded(sourceFileOrBundle) {
84001             if (ts.isSourceFile(sourceFileOrBundle)) {
84002                 emitPrologueDirectives(sourceFileOrBundle.statements, sourceFileOrBundle);
84003             }
84004             else {
84005                 var seenPrologueDirectives = new ts.Set();
84006                 for (var _a = 0, _b = sourceFileOrBundle.prepends; _a < _b.length; _a++) {
84007                     var prepend = _b[_a];
84008                     emitUnparsedPrologues(prepend.prologues, seenPrologueDirectives);
84009                 }
84010                 for (var _c = 0, _d = sourceFileOrBundle.sourceFiles; _c < _d.length; _c++) {
84011                     var sourceFile = _d[_c];
84012                     emitPrologueDirectives(sourceFile.statements, sourceFile, seenPrologueDirectives, true);
84013                 }
84014                 setSourceFile(undefined);
84015             }
84016         }
84017         function getPrologueDirectivesFromBundledSourceFiles(bundle) {
84018             var seenPrologueDirectives = new ts.Set();
84019             var prologues;
84020             for (var index = 0; index < bundle.sourceFiles.length; index++) {
84021                 var sourceFile = bundle.sourceFiles[index];
84022                 var directives = void 0;
84023                 var end = 0;
84024                 for (var _a = 0, _b = sourceFile.statements; _a < _b.length; _a++) {
84025                     var statement = _b[_a];
84026                     if (!ts.isPrologueDirective(statement))
84027                         break;
84028                     if (seenPrologueDirectives.has(statement.expression.text))
84029                         continue;
84030                     seenPrologueDirectives.add(statement.expression.text);
84031                     (directives || (directives = [])).push({
84032                         pos: statement.pos,
84033                         end: statement.end,
84034                         expression: {
84035                             pos: statement.expression.pos,
84036                             end: statement.expression.end,
84037                             text: statement.expression.text
84038                         }
84039                     });
84040                     end = end < statement.end ? statement.end : end;
84041                 }
84042                 if (directives)
84043                     (prologues || (prologues = [])).push({ file: index, text: sourceFile.text.substring(0, end), directives: directives });
84044             }
84045             return prologues;
84046         }
84047         function emitShebangIfNeeded(sourceFileOrBundle) {
84048             if (ts.isSourceFile(sourceFileOrBundle) || ts.isUnparsedSource(sourceFileOrBundle)) {
84049                 var shebang = ts.getShebang(sourceFileOrBundle.text);
84050                 if (shebang) {
84051                     writeComment(shebang);
84052                     writeLine();
84053                     return true;
84054                 }
84055             }
84056             else {
84057                 for (var _a = 0, _b = sourceFileOrBundle.prepends; _a < _b.length; _a++) {
84058                     var prepend = _b[_a];
84059                     ts.Debug.assertNode(prepend, ts.isUnparsedSource);
84060                     if (emitShebangIfNeeded(prepend)) {
84061                         return true;
84062                     }
84063                 }
84064                 for (var _c = 0, _d = sourceFileOrBundle.sourceFiles; _c < _d.length; _c++) {
84065                     var sourceFile = _d[_c];
84066                     if (emitShebangIfNeeded(sourceFile)) {
84067                         return true;
84068                     }
84069                 }
84070             }
84071         }
84072         function emitNodeWithWriter(node, writer) {
84073             if (!node)
84074                 return;
84075             var savedWrite = write;
84076             write = writer;
84077             emit(node);
84078             write = savedWrite;
84079         }
84080         function emitModifiers(node, modifiers) {
84081             if (modifiers && modifiers.length) {
84082                 emitList(node, modifiers, 262656);
84083                 writeSpace();
84084             }
84085         }
84086         function emitTypeAnnotation(node) {
84087             if (node) {
84088                 writePunctuation(":");
84089                 writeSpace();
84090                 emit(node);
84091             }
84092         }
84093         function emitInitializer(node, equalCommentStartPos, container) {
84094             if (node) {
84095                 writeSpace();
84096                 emitTokenWithComment(62, equalCommentStartPos, writeOperator, container);
84097                 writeSpace();
84098                 emitExpression(node);
84099             }
84100         }
84101         function emitNodeWithPrefix(prefix, prefixWriter, node, emit) {
84102             if (node) {
84103                 prefixWriter(prefix);
84104                 emit(node);
84105             }
84106         }
84107         function emitWithLeadingSpace(node) {
84108             if (node) {
84109                 writeSpace();
84110                 emit(node);
84111             }
84112         }
84113         function emitExpressionWithLeadingSpace(node) {
84114             if (node) {
84115                 writeSpace();
84116                 emitExpression(node);
84117             }
84118         }
84119         function emitWithTrailingSpace(node) {
84120             if (node) {
84121                 emit(node);
84122                 writeSpace();
84123             }
84124         }
84125         function emitEmbeddedStatement(parent, node) {
84126             if (ts.isBlock(node) || ts.getEmitFlags(parent) & 1) {
84127                 writeSpace();
84128                 emit(node);
84129             }
84130             else {
84131                 writeLine();
84132                 increaseIndent();
84133                 if (ts.isEmptyStatement(node)) {
84134                     pipelineEmit(5, node);
84135                 }
84136                 else {
84137                     emit(node);
84138                 }
84139                 decreaseIndent();
84140             }
84141         }
84142         function emitDecorators(parentNode, decorators) {
84143             emitList(parentNode, decorators, 2146305);
84144         }
84145         function emitTypeArguments(parentNode, typeArguments) {
84146             emitList(parentNode, typeArguments, 53776);
84147         }
84148         function emitTypeParameters(parentNode, typeParameters) {
84149             if (ts.isFunctionLike(parentNode) && parentNode.typeArguments) {
84150                 return emitTypeArguments(parentNode, parentNode.typeArguments);
84151             }
84152             emitList(parentNode, typeParameters, 53776);
84153         }
84154         function emitParameters(parentNode, parameters) {
84155             emitList(parentNode, parameters, 2576);
84156         }
84157         function canEmitSimpleArrowHead(parentNode, parameters) {
84158             var parameter = ts.singleOrUndefined(parameters);
84159             return parameter
84160                 && parameter.pos === parentNode.pos
84161                 && ts.isArrowFunction(parentNode)
84162                 && !parentNode.type
84163                 && !ts.some(parentNode.decorators)
84164                 && !ts.some(parentNode.modifiers)
84165                 && !ts.some(parentNode.typeParameters)
84166                 && !ts.some(parameter.decorators)
84167                 && !ts.some(parameter.modifiers)
84168                 && !parameter.dotDotDotToken
84169                 && !parameter.questionToken
84170                 && !parameter.type
84171                 && !parameter.initializer
84172                 && ts.isIdentifier(parameter.name);
84173         }
84174         function emitParametersForArrow(parentNode, parameters) {
84175             if (canEmitSimpleArrowHead(parentNode, parameters)) {
84176                 emitList(parentNode, parameters, 2576 & ~2048);
84177             }
84178             else {
84179                 emitParameters(parentNode, parameters);
84180             }
84181         }
84182         function emitParametersForIndexSignature(parentNode, parameters) {
84183             emitList(parentNode, parameters, 8848);
84184         }
84185         function emitList(parentNode, children, format, start, count) {
84186             emitNodeList(emit, parentNode, children, format, start, count);
84187         }
84188         function emitExpressionList(parentNode, children, format, start, count) {
84189             emitNodeList(emitExpression, parentNode, children, format, start, count);
84190         }
84191         function writeDelimiter(format) {
84192             switch (format & 60) {
84193                 case 0:
84194                     break;
84195                 case 16:
84196                     writePunctuation(",");
84197                     break;
84198                 case 4:
84199                     writeSpace();
84200                     writePunctuation("|");
84201                     break;
84202                 case 32:
84203                     writeSpace();
84204                     writePunctuation("*");
84205                     writeSpace();
84206                     break;
84207                 case 8:
84208                     writeSpace();
84209                     writePunctuation("&");
84210                     break;
84211             }
84212         }
84213         function emitNodeList(emit, parentNode, children, format, start, count) {
84214             if (start === void 0) { start = 0; }
84215             if (count === void 0) { count = children ? children.length - start : 0; }
84216             var isUndefined = children === undefined;
84217             if (isUndefined && format & 16384) {
84218                 return;
84219             }
84220             var isEmpty = children === undefined || start >= children.length || count === 0;
84221             if (isEmpty && format & 32768) {
84222                 if (onBeforeEmitNodeArray) {
84223                     onBeforeEmitNodeArray(children);
84224                 }
84225                 if (onAfterEmitNodeArray) {
84226                     onAfterEmitNodeArray(children);
84227                 }
84228                 return;
84229             }
84230             if (format & 15360) {
84231                 writePunctuation(getOpeningBracket(format));
84232                 if (isEmpty && !isUndefined) {
84233                     emitTrailingCommentsOfPosition(children.pos, true);
84234                 }
84235             }
84236             if (onBeforeEmitNodeArray) {
84237                 onBeforeEmitNodeArray(children);
84238             }
84239             if (isEmpty) {
84240                 if (format & 1 && !(preserveSourceNewlines && ts.rangeIsOnSingleLine(parentNode, currentSourceFile))) {
84241                     writeLine();
84242                 }
84243                 else if (format & 256 && !(format & 524288)) {
84244                     writeSpace();
84245                 }
84246             }
84247             else {
84248                 var mayEmitInterveningComments = (format & 262144) === 0;
84249                 var shouldEmitInterveningComments = mayEmitInterveningComments;
84250                 var leadingLineTerminatorCount = getLeadingLineTerminatorCount(parentNode, children, format);
84251                 if (leadingLineTerminatorCount) {
84252                     writeLine(leadingLineTerminatorCount);
84253                     shouldEmitInterveningComments = false;
84254                 }
84255                 else if (format & 256) {
84256                     writeSpace();
84257                 }
84258                 if (format & 128) {
84259                     increaseIndent();
84260                 }
84261                 var previousSibling = void 0;
84262                 var previousSourceFileTextKind = void 0;
84263                 var shouldDecreaseIndentAfterEmit = false;
84264                 for (var i = 0; i < count; i++) {
84265                     var child = children[start + i];
84266                     if (format & 32) {
84267                         writeLine();
84268                         writeDelimiter(format);
84269                     }
84270                     else if (previousSibling) {
84271                         if (format & 60 && previousSibling.end !== parentNode.end) {
84272                             emitLeadingCommentsOfPosition(previousSibling.end);
84273                         }
84274                         writeDelimiter(format);
84275                         recordBundleFileInternalSectionEnd(previousSourceFileTextKind);
84276                         var separatingLineTerminatorCount = getSeparatingLineTerminatorCount(previousSibling, child, format);
84277                         if (separatingLineTerminatorCount > 0) {
84278                             if ((format & (3 | 128)) === 0) {
84279                                 increaseIndent();
84280                                 shouldDecreaseIndentAfterEmit = true;
84281                             }
84282                             writeLine(separatingLineTerminatorCount);
84283                             shouldEmitInterveningComments = false;
84284                         }
84285                         else if (previousSibling && format & 512) {
84286                             writeSpace();
84287                         }
84288                     }
84289                     previousSourceFileTextKind = recordBundleFileInternalSectionStart(child);
84290                     if (shouldEmitInterveningComments) {
84291                         if (emitTrailingCommentsOfPosition) {
84292                             var commentRange = ts.getCommentRange(child);
84293                             emitTrailingCommentsOfPosition(commentRange.pos);
84294                         }
84295                     }
84296                     else {
84297                         shouldEmitInterveningComments = mayEmitInterveningComments;
84298                     }
84299                     nextListElementPos = child.pos;
84300                     emit(child);
84301                     if (shouldDecreaseIndentAfterEmit) {
84302                         decreaseIndent();
84303                         shouldDecreaseIndentAfterEmit = false;
84304                     }
84305                     previousSibling = child;
84306                 }
84307                 var hasTrailingComma = (format & 64) && children.hasTrailingComma;
84308                 if (format & 16 && hasTrailingComma) {
84309                     writePunctuation(",");
84310                 }
84311                 if (previousSibling && format & 60 && previousSibling.end !== parentNode.end && !(ts.getEmitFlags(previousSibling) & 1024)) {
84312                     emitLeadingCommentsOfPosition(previousSibling.end);
84313                 }
84314                 if (format & 128) {
84315                     decreaseIndent();
84316                 }
84317                 recordBundleFileInternalSectionEnd(previousSourceFileTextKind);
84318                 var closingLineTerminatorCount = getClosingLineTerminatorCount(parentNode, children, format);
84319                 if (closingLineTerminatorCount) {
84320                     writeLine(closingLineTerminatorCount);
84321                 }
84322                 else if (format & (2097152 | 256)) {
84323                     writeSpace();
84324                 }
84325             }
84326             if (onAfterEmitNodeArray) {
84327                 onAfterEmitNodeArray(children);
84328             }
84329             if (format & 15360) {
84330                 if (isEmpty && !isUndefined) {
84331                     emitLeadingCommentsOfPosition(children.end);
84332                 }
84333                 writePunctuation(getClosingBracket(format));
84334             }
84335         }
84336         function writeLiteral(s) {
84337             writer.writeLiteral(s);
84338         }
84339         function writeStringLiteral(s) {
84340             writer.writeStringLiteral(s);
84341         }
84342         function writeBase(s) {
84343             writer.write(s);
84344         }
84345         function writeSymbol(s, sym) {
84346             writer.writeSymbol(s, sym);
84347         }
84348         function writePunctuation(s) {
84349             writer.writePunctuation(s);
84350         }
84351         function writeTrailingSemicolon() {
84352             writer.writeTrailingSemicolon(";");
84353         }
84354         function writeKeyword(s) {
84355             writer.writeKeyword(s);
84356         }
84357         function writeOperator(s) {
84358             writer.writeOperator(s);
84359         }
84360         function writeParameter(s) {
84361             writer.writeParameter(s);
84362         }
84363         function writeComment(s) {
84364             writer.writeComment(s);
84365         }
84366         function writeSpace() {
84367             writer.writeSpace(" ");
84368         }
84369         function writeProperty(s) {
84370             writer.writeProperty(s);
84371         }
84372         function writeLine(count) {
84373             if (count === void 0) { count = 1; }
84374             for (var i = 0; i < count; i++) {
84375                 writer.writeLine(i > 0);
84376             }
84377         }
84378         function increaseIndent() {
84379             writer.increaseIndent();
84380         }
84381         function decreaseIndent() {
84382             writer.decreaseIndent();
84383         }
84384         function writeToken(token, pos, writer, contextNode) {
84385             return !sourceMapsDisabled
84386                 ? emitTokenWithSourceMap(contextNode, token, writer, pos, writeTokenText)
84387                 : writeTokenText(token, writer, pos);
84388         }
84389         function writeTokenNode(node, writer) {
84390             if (onBeforeEmitToken) {
84391                 onBeforeEmitToken(node);
84392             }
84393             writer(ts.tokenToString(node.kind));
84394             if (onAfterEmitToken) {
84395                 onAfterEmitToken(node);
84396             }
84397         }
84398         function writeTokenText(token, writer, pos) {
84399             var tokenString = ts.tokenToString(token);
84400             writer(tokenString);
84401             return pos < 0 ? pos : pos + tokenString.length;
84402         }
84403         function writeLineOrSpace(parentNode, prevChildNode, nextChildNode) {
84404             if (ts.getEmitFlags(parentNode) & 1) {
84405                 writeSpace();
84406             }
84407             else if (preserveSourceNewlines) {
84408                 var lines = getLinesBetweenNodes(parentNode, prevChildNode, nextChildNode);
84409                 if (lines) {
84410                     writeLine(lines);
84411                 }
84412                 else {
84413                     writeSpace();
84414                 }
84415             }
84416             else {
84417                 writeLine();
84418             }
84419         }
84420         function writeLines(text) {
84421             var lines = text.split(/\r\n?|\n/g);
84422             var indentation = ts.guessIndentation(lines);
84423             for (var _a = 0, lines_3 = lines; _a < lines_3.length; _a++) {
84424                 var lineText = lines_3[_a];
84425                 var line = indentation ? lineText.slice(indentation) : lineText;
84426                 if (line.length) {
84427                     writeLine();
84428                     write(line);
84429                 }
84430             }
84431         }
84432         function writeLinesAndIndent(lineCount, writeSpaceIfNotIndenting) {
84433             if (lineCount) {
84434                 increaseIndent();
84435                 writeLine(lineCount);
84436             }
84437             else if (writeSpaceIfNotIndenting) {
84438                 writeSpace();
84439             }
84440         }
84441         function decreaseIndentIf(value1, value2) {
84442             if (value1) {
84443                 decreaseIndent();
84444             }
84445             if (value2) {
84446                 decreaseIndent();
84447             }
84448         }
84449         function getLeadingLineTerminatorCount(parentNode, children, format) {
84450             if (format & 2 || preserveSourceNewlines) {
84451                 if (format & 65536) {
84452                     return 1;
84453                 }
84454                 var firstChild_1 = children[0];
84455                 if (firstChild_1 === undefined) {
84456                     return ts.rangeIsOnSingleLine(parentNode, currentSourceFile) ? 0 : 1;
84457                 }
84458                 if (firstChild_1.pos === nextListElementPos) {
84459                     return 0;
84460                 }
84461                 if (firstChild_1.kind === 11) {
84462                     return 0;
84463                 }
84464                 if (!ts.positionIsSynthesized(parentNode.pos) &&
84465                     !ts.nodeIsSynthesized(firstChild_1) &&
84466                     (!firstChild_1.parent || ts.getOriginalNode(firstChild_1.parent) === ts.getOriginalNode(parentNode))) {
84467                     if (preserveSourceNewlines) {
84468                         return getEffectiveLines(function (includeComments) { return ts.getLinesBetweenPositionAndPrecedingNonWhitespaceCharacter(firstChild_1.pos, parentNode.pos, currentSourceFile, includeComments); });
84469                     }
84470                     return ts.rangeStartPositionsAreOnSameLine(parentNode, firstChild_1, currentSourceFile) ? 0 : 1;
84471                 }
84472                 if (synthesizedNodeStartsOnNewLine(firstChild_1, format)) {
84473                     return 1;
84474                 }
84475             }
84476             return format & 1 ? 1 : 0;
84477         }
84478         function getSeparatingLineTerminatorCount(previousNode, nextNode, format) {
84479             if (format & 2 || preserveSourceNewlines) {
84480                 if (previousNode === undefined || nextNode === undefined) {
84481                     return 0;
84482                 }
84483                 if (nextNode.kind === 11) {
84484                     return 0;
84485                 }
84486                 else if (!ts.nodeIsSynthesized(previousNode) && !ts.nodeIsSynthesized(nextNode) && previousNode.parent === nextNode.parent) {
84487                     if (preserveSourceNewlines) {
84488                         return getEffectiveLines(function (includeComments) { return ts.getLinesBetweenRangeEndAndRangeStart(previousNode, nextNode, currentSourceFile, includeComments); });
84489                     }
84490                     return ts.rangeEndIsOnSameLineAsRangeStart(previousNode, nextNode, currentSourceFile) ? 0 : 1;
84491                 }
84492                 else if (synthesizedNodeStartsOnNewLine(previousNode, format) || synthesizedNodeStartsOnNewLine(nextNode, format)) {
84493                     return 1;
84494                 }
84495             }
84496             else if (ts.getStartsOnNewLine(nextNode)) {
84497                 return 1;
84498             }
84499             return format & 1 ? 1 : 0;
84500         }
84501         function getClosingLineTerminatorCount(parentNode, children, format) {
84502             if (format & 2 || preserveSourceNewlines) {
84503                 if (format & 65536) {
84504                     return 1;
84505                 }
84506                 var lastChild = ts.lastOrUndefined(children);
84507                 if (lastChild === undefined) {
84508                     return ts.rangeIsOnSingleLine(parentNode, currentSourceFile) ? 0 : 1;
84509                 }
84510                 if (!ts.positionIsSynthesized(parentNode.pos) && !ts.nodeIsSynthesized(lastChild) && (!lastChild.parent || lastChild.parent === parentNode)) {
84511                     if (preserveSourceNewlines) {
84512                         var end_2 = ts.isNodeArray(children) && !ts.positionIsSynthesized(children.end) ? children.end : lastChild.end;
84513                         return getEffectiveLines(function (includeComments) { return ts.getLinesBetweenPositionAndNextNonWhitespaceCharacter(end_2, parentNode.end, currentSourceFile, includeComments); });
84514                     }
84515                     return ts.rangeEndPositionsAreOnSameLine(parentNode, lastChild, currentSourceFile) ? 0 : 1;
84516                 }
84517                 if (synthesizedNodeStartsOnNewLine(lastChild, format)) {
84518                     return 1;
84519                 }
84520             }
84521             if (format & 1 && !(format & 131072)) {
84522                 return 1;
84523             }
84524             return 0;
84525         }
84526         function getEffectiveLines(getLineDifference) {
84527             ts.Debug.assert(!!preserveSourceNewlines);
84528             var lines = getLineDifference(true);
84529             if (lines === 0) {
84530                 return getLineDifference(false);
84531             }
84532             return lines;
84533         }
84534         function writeLineSeparatorsAndIndentBefore(node, parent) {
84535             var leadingNewlines = preserveSourceNewlines && getLeadingLineTerminatorCount(parent, [node], 0);
84536             if (leadingNewlines) {
84537                 writeLinesAndIndent(leadingNewlines, false);
84538             }
84539             return !!leadingNewlines;
84540         }
84541         function writeLineSeparatorsAfter(node, parent) {
84542             var trailingNewlines = preserveSourceNewlines && getClosingLineTerminatorCount(parent, [node], 0);
84543             if (trailingNewlines) {
84544                 writeLine(trailingNewlines);
84545             }
84546         }
84547         function synthesizedNodeStartsOnNewLine(node, format) {
84548             if (ts.nodeIsSynthesized(node)) {
84549                 var startsOnNewLine = ts.getStartsOnNewLine(node);
84550                 if (startsOnNewLine === undefined) {
84551                     return (format & 65536) !== 0;
84552                 }
84553                 return startsOnNewLine;
84554             }
84555             return (format & 65536) !== 0;
84556         }
84557         function getLinesBetweenNodes(parent, node1, node2) {
84558             if (ts.getEmitFlags(parent) & 131072) {
84559                 return 0;
84560             }
84561             parent = skipSynthesizedParentheses(parent);
84562             node1 = skipSynthesizedParentheses(node1);
84563             node2 = skipSynthesizedParentheses(node2);
84564             if (ts.getStartsOnNewLine(node2)) {
84565                 return 1;
84566             }
84567             if (!ts.nodeIsSynthesized(parent) && !ts.nodeIsSynthesized(node1) && !ts.nodeIsSynthesized(node2)) {
84568                 if (preserveSourceNewlines) {
84569                     return getEffectiveLines(function (includeComments) { return ts.getLinesBetweenRangeEndAndRangeStart(node1, node2, currentSourceFile, includeComments); });
84570                 }
84571                 return ts.rangeEndIsOnSameLineAsRangeStart(node1, node2, currentSourceFile) ? 0 : 1;
84572             }
84573             return 0;
84574         }
84575         function isEmptyBlock(block) {
84576             return block.statements.length === 0
84577                 && ts.rangeEndIsOnSameLineAsRangeStart(block, block, currentSourceFile);
84578         }
84579         function skipSynthesizedParentheses(node) {
84580             while (node.kind === 207 && ts.nodeIsSynthesized(node)) {
84581                 node = node.expression;
84582             }
84583             return node;
84584         }
84585         function getTextOfNode(node, includeTrivia) {
84586             if (ts.isGeneratedIdentifier(node)) {
84587                 return generateName(node);
84588             }
84589             else if ((ts.isIdentifier(node) || ts.isPrivateIdentifier(node)) && (ts.nodeIsSynthesized(node) || !node.parent || !currentSourceFile || (node.parent && currentSourceFile && ts.getSourceFileOfNode(node) !== ts.getOriginalNode(currentSourceFile)))) {
84590                 return ts.idText(node);
84591             }
84592             else if (node.kind === 10 && node.textSourceNode) {
84593                 return getTextOfNode(node.textSourceNode, includeTrivia);
84594             }
84595             else if (ts.isLiteralExpression(node) && (ts.nodeIsSynthesized(node) || !node.parent)) {
84596                 return node.text;
84597             }
84598             return ts.getSourceTextOfNodeFromSourceFile(currentSourceFile, node, includeTrivia);
84599         }
84600         function getLiteralTextOfNode(node, neverAsciiEscape, jsxAttributeEscape) {
84601             if (node.kind === 10 && node.textSourceNode) {
84602                 var textSourceNode = node.textSourceNode;
84603                 if (ts.isIdentifier(textSourceNode) || ts.isNumericLiteral(textSourceNode)) {
84604                     var text = ts.isNumericLiteral(textSourceNode) ? textSourceNode.text : getTextOfNode(textSourceNode);
84605                     return jsxAttributeEscape ? "\"" + ts.escapeJsxAttributeString(text) + "\"" :
84606                         neverAsciiEscape || (ts.getEmitFlags(node) & 16777216) ? "\"" + ts.escapeString(text) + "\"" :
84607                             "\"" + ts.escapeNonAsciiString(text) + "\"";
84608                 }
84609                 else {
84610                     return getLiteralTextOfNode(textSourceNode, neverAsciiEscape, jsxAttributeEscape);
84611                 }
84612             }
84613             var flags = (neverAsciiEscape ? 1 : 0)
84614                 | (jsxAttributeEscape ? 2 : 0)
84615                 | (printerOptions.terminateUnterminatedLiterals ? 4 : 0);
84616             return ts.getLiteralText(node, currentSourceFile, flags);
84617         }
84618         function pushNameGenerationScope(node) {
84619             if (node && ts.getEmitFlags(node) & 524288) {
84620                 return;
84621             }
84622             tempFlagsStack.push(tempFlags);
84623             tempFlags = 0;
84624             reservedNamesStack.push(reservedNames);
84625         }
84626         function popNameGenerationScope(node) {
84627             if (node && ts.getEmitFlags(node) & 524288) {
84628                 return;
84629             }
84630             tempFlags = tempFlagsStack.pop();
84631             reservedNames = reservedNamesStack.pop();
84632         }
84633         function reserveNameInNestedScopes(name) {
84634             if (!reservedNames || reservedNames === ts.lastOrUndefined(reservedNamesStack)) {
84635                 reservedNames = new ts.Set();
84636             }
84637             reservedNames.add(name);
84638         }
84639         function generateNames(node) {
84640             if (!node)
84641                 return;
84642             switch (node.kind) {
84643                 case 230:
84644                     ts.forEach(node.statements, generateNames);
84645                     break;
84646                 case 245:
84647                 case 243:
84648                 case 235:
84649                 case 236:
84650                     generateNames(node.statement);
84651                     break;
84652                 case 234:
84653                     generateNames(node.thenStatement);
84654                     generateNames(node.elseStatement);
84655                     break;
84656                 case 237:
84657                 case 239:
84658                 case 238:
84659                     generateNames(node.initializer);
84660                     generateNames(node.statement);
84661                     break;
84662                 case 244:
84663                     generateNames(node.caseBlock);
84664                     break;
84665                 case 258:
84666                     ts.forEach(node.clauses, generateNames);
84667                     break;
84668                 case 284:
84669                 case 285:
84670                     ts.forEach(node.statements, generateNames);
84671                     break;
84672                 case 247:
84673                     generateNames(node.tryBlock);
84674                     generateNames(node.catchClause);
84675                     generateNames(node.finallyBlock);
84676                     break;
84677                 case 287:
84678                     generateNames(node.variableDeclaration);
84679                     generateNames(node.block);
84680                     break;
84681                 case 232:
84682                     generateNames(node.declarationList);
84683                     break;
84684                 case 250:
84685                     ts.forEach(node.declarations, generateNames);
84686                     break;
84687                 case 249:
84688                 case 160:
84689                 case 198:
84690                 case 252:
84691                     generateNameIfNeeded(node.name);
84692                     break;
84693                 case 251:
84694                     generateNameIfNeeded(node.name);
84695                     if (ts.getEmitFlags(node) & 524288) {
84696                         ts.forEach(node.parameters, generateNames);
84697                         generateNames(node.body);
84698                     }
84699                     break;
84700                 case 196:
84701                 case 197:
84702                     ts.forEach(node.elements, generateNames);
84703                     break;
84704                 case 261:
84705                     generateNames(node.importClause);
84706                     break;
84707                 case 262:
84708                     generateNameIfNeeded(node.name);
84709                     generateNames(node.namedBindings);
84710                     break;
84711                 case 263:
84712                     generateNameIfNeeded(node.name);
84713                     break;
84714                 case 269:
84715                     generateNameIfNeeded(node.name);
84716                     break;
84717                 case 264:
84718                     ts.forEach(node.elements, generateNames);
84719                     break;
84720                 case 265:
84721                     generateNameIfNeeded(node.propertyName || node.name);
84722                     break;
84723             }
84724         }
84725         function generateMemberNames(node) {
84726             if (!node)
84727                 return;
84728             switch (node.kind) {
84729                 case 288:
84730                 case 289:
84731                 case 163:
84732                 case 165:
84733                 case 167:
84734                 case 168:
84735                     generateNameIfNeeded(node.name);
84736                     break;
84737             }
84738         }
84739         function generateNameIfNeeded(name) {
84740             if (name) {
84741                 if (ts.isGeneratedIdentifier(name)) {
84742                     generateName(name);
84743                 }
84744                 else if (ts.isBindingPattern(name)) {
84745                     generateNames(name);
84746                 }
84747             }
84748         }
84749         function generateName(name) {
84750             if ((name.autoGenerateFlags & 7) === 4) {
84751                 return generateNameCached(getNodeForGeneratedName(name), name.autoGenerateFlags);
84752             }
84753             else {
84754                 var autoGenerateId = name.autoGenerateId;
84755                 return autoGeneratedIdToGeneratedName[autoGenerateId] || (autoGeneratedIdToGeneratedName[autoGenerateId] = makeName(name));
84756             }
84757         }
84758         function generateNameCached(node, flags) {
84759             var nodeId = ts.getNodeId(node);
84760             return nodeIdToGeneratedName[nodeId] || (nodeIdToGeneratedName[nodeId] = generateNameForNode(node, flags));
84761         }
84762         function isUniqueName(name) {
84763             return isFileLevelUniqueName(name)
84764                 && !generatedNames.has(name)
84765                 && !(reservedNames && reservedNames.has(name));
84766         }
84767         function isFileLevelUniqueName(name) {
84768             return currentSourceFile ? ts.isFileLevelUniqueName(currentSourceFile, name, hasGlobalName) : true;
84769         }
84770         function isUniqueLocalName(name, container) {
84771             for (var node = container; ts.isNodeDescendantOf(node, container); node = node.nextContainer) {
84772                 if (node.locals) {
84773                     var local = node.locals.get(ts.escapeLeadingUnderscores(name));
84774                     if (local && local.flags & (111551 | 1048576 | 2097152)) {
84775                         return false;
84776                     }
84777                 }
84778             }
84779             return true;
84780         }
84781         function makeTempVariableName(flags, reservedInNestedScopes) {
84782             if (flags && !(tempFlags & flags)) {
84783                 var name = flags === 268435456 ? "_i" : "_n";
84784                 if (isUniqueName(name)) {
84785                     tempFlags |= flags;
84786                     if (reservedInNestedScopes) {
84787                         reserveNameInNestedScopes(name);
84788                     }
84789                     return name;
84790                 }
84791             }
84792             while (true) {
84793                 var count = tempFlags & 268435455;
84794                 tempFlags++;
84795                 if (count !== 8 && count !== 13) {
84796                     var name = count < 26
84797                         ? "_" + String.fromCharCode(97 + count)
84798                         : "_" + (count - 26);
84799                     if (isUniqueName(name)) {
84800                         if (reservedInNestedScopes) {
84801                             reserveNameInNestedScopes(name);
84802                         }
84803                         return name;
84804                     }
84805                 }
84806             }
84807         }
84808         function makeUniqueName(baseName, checkFn, optimistic, scoped) {
84809             if (checkFn === void 0) { checkFn = isUniqueName; }
84810             if (optimistic) {
84811                 if (checkFn(baseName)) {
84812                     if (scoped) {
84813                         reserveNameInNestedScopes(baseName);
84814                     }
84815                     else {
84816                         generatedNames.add(baseName);
84817                     }
84818                     return baseName;
84819                 }
84820             }
84821             if (baseName.charCodeAt(baseName.length - 1) !== 95) {
84822                 baseName += "_";
84823             }
84824             var i = 1;
84825             while (true) {
84826                 var generatedName = baseName + i;
84827                 if (checkFn(generatedName)) {
84828                     if (scoped) {
84829                         reserveNameInNestedScopes(generatedName);
84830                     }
84831                     else {
84832                         generatedNames.add(generatedName);
84833                     }
84834                     return generatedName;
84835                 }
84836                 i++;
84837             }
84838         }
84839         function makeFileLevelOptimisticUniqueName(name) {
84840             return makeUniqueName(name, isFileLevelUniqueName, true);
84841         }
84842         function generateNameForModuleOrEnum(node) {
84843             var name = getTextOfNode(node.name);
84844             return isUniqueLocalName(name, node) ? name : makeUniqueName(name);
84845         }
84846         function generateNameForImportOrExportDeclaration(node) {
84847             var expr = ts.getExternalModuleName(node);
84848             var baseName = ts.isStringLiteral(expr) ?
84849                 ts.makeIdentifierFromModuleName(expr.text) : "module";
84850             return makeUniqueName(baseName);
84851         }
84852         function generateNameForExportDefault() {
84853             return makeUniqueName("default");
84854         }
84855         function generateNameForClassExpression() {
84856             return makeUniqueName("class");
84857         }
84858         function generateNameForMethodOrAccessor(node) {
84859             if (ts.isIdentifier(node.name)) {
84860                 return generateNameCached(node.name);
84861             }
84862             return makeTempVariableName(0);
84863         }
84864         function generateNameForNode(node, flags) {
84865             switch (node.kind) {
84866                 case 78:
84867                     return makeUniqueName(getTextOfNode(node), isUniqueName, !!(flags & 16), !!(flags & 8));
84868                 case 256:
84869                 case 255:
84870                     return generateNameForModuleOrEnum(node);
84871                 case 261:
84872                 case 267:
84873                     return generateNameForImportOrExportDeclaration(node);
84874                 case 251:
84875                 case 252:
84876                 case 266:
84877                     return generateNameForExportDefault();
84878                 case 221:
84879                     return generateNameForClassExpression();
84880                 case 165:
84881                 case 167:
84882                 case 168:
84883                     return generateNameForMethodOrAccessor(node);
84884                 case 158:
84885                     return makeTempVariableName(0, true);
84886                 default:
84887                     return makeTempVariableName(0);
84888             }
84889         }
84890         function makeName(name) {
84891             switch (name.autoGenerateFlags & 7) {
84892                 case 1:
84893                     return makeTempVariableName(0, !!(name.autoGenerateFlags & 8));
84894                 case 2:
84895                     return makeTempVariableName(268435456, !!(name.autoGenerateFlags & 8));
84896                 case 3:
84897                     return makeUniqueName(ts.idText(name), (name.autoGenerateFlags & 32) ? isFileLevelUniqueName : isUniqueName, !!(name.autoGenerateFlags & 16), !!(name.autoGenerateFlags & 8));
84898             }
84899             return ts.Debug.fail("Unsupported GeneratedIdentifierKind.");
84900         }
84901         function getNodeForGeneratedName(name) {
84902             var autoGenerateId = name.autoGenerateId;
84903             var node = name;
84904             var original = node.original;
84905             while (original) {
84906                 node = original;
84907                 if (ts.isIdentifier(node)
84908                     && !!(node.autoGenerateFlags & 4)
84909                     && node.autoGenerateId !== autoGenerateId) {
84910                     break;
84911                 }
84912                 original = node.original;
84913             }
84914             return node;
84915         }
84916         function pipelineEmitWithComments(hint, node) {
84917             ts.Debug.assert(lastNode === node || lastSubstitution === node);
84918             enterComment();
84919             hasWrittenComment = false;
84920             var emitFlags = ts.getEmitFlags(node);
84921             var _a = ts.getCommentRange(node), pos = _a.pos, end = _a.end;
84922             var isEmittedNode = node.kind !== 335;
84923             var skipLeadingComments = pos < 0 || (emitFlags & 512) !== 0 || node.kind === 11;
84924             var skipTrailingComments = end < 0 || (emitFlags & 1024) !== 0 || node.kind === 11;
84925             var savedContainerPos = containerPos;
84926             var savedContainerEnd = containerEnd;
84927             var savedDeclarationListContainerEnd = declarationListContainerEnd;
84928             if ((pos > 0 || end > 0) && pos !== end) {
84929                 if (!skipLeadingComments) {
84930                     emitLeadingComments(pos, isEmittedNode);
84931                 }
84932                 if (!skipLeadingComments || (pos >= 0 && (emitFlags & 512) !== 0)) {
84933                     containerPos = pos;
84934                 }
84935                 if (!skipTrailingComments || (end >= 0 && (emitFlags & 1024) !== 0)) {
84936                     containerEnd = end;
84937                     if (node.kind === 250) {
84938                         declarationListContainerEnd = end;
84939                     }
84940                 }
84941             }
84942             ts.forEach(ts.getSyntheticLeadingComments(node), emitLeadingSynthesizedComment);
84943             exitComment();
84944             var pipelinePhase = getNextPipelinePhase(2, hint, node);
84945             if (emitFlags & 2048) {
84946                 commentsDisabled = true;
84947                 pipelinePhase(hint, node);
84948                 commentsDisabled = false;
84949             }
84950             else {
84951                 pipelinePhase(hint, node);
84952             }
84953             enterComment();
84954             ts.forEach(ts.getSyntheticTrailingComments(node), emitTrailingSynthesizedComment);
84955             if ((pos > 0 || end > 0) && pos !== end) {
84956                 containerPos = savedContainerPos;
84957                 containerEnd = savedContainerEnd;
84958                 declarationListContainerEnd = savedDeclarationListContainerEnd;
84959                 if (!skipTrailingComments && isEmittedNode) {
84960                     emitTrailingComments(end);
84961                 }
84962             }
84963             exitComment();
84964             ts.Debug.assert(lastNode === node || lastSubstitution === node);
84965         }
84966         function emitLeadingSynthesizedComment(comment) {
84967             if (comment.hasLeadingNewline || comment.kind === 2) {
84968                 writer.writeLine();
84969             }
84970             writeSynthesizedComment(comment);
84971             if (comment.hasTrailingNewLine || comment.kind === 2) {
84972                 writer.writeLine();
84973             }
84974             else {
84975                 writer.writeSpace(" ");
84976             }
84977         }
84978         function emitTrailingSynthesizedComment(comment) {
84979             if (!writer.isAtStartOfLine()) {
84980                 writer.writeSpace(" ");
84981             }
84982             writeSynthesizedComment(comment);
84983             if (comment.hasTrailingNewLine) {
84984                 writer.writeLine();
84985             }
84986         }
84987         function writeSynthesizedComment(comment) {
84988             var text = formatSynthesizedComment(comment);
84989             var lineMap = comment.kind === 3 ? ts.computeLineStarts(text) : undefined;
84990             ts.writeCommentRange(text, lineMap, writer, 0, text.length, newLine);
84991         }
84992         function formatSynthesizedComment(comment) {
84993             return comment.kind === 3
84994                 ? "/*" + comment.text + "*/"
84995                 : "//" + comment.text;
84996         }
84997         function emitBodyWithDetachedComments(node, detachedRange, emitCallback) {
84998             enterComment();
84999             var pos = detachedRange.pos, end = detachedRange.end;
85000             var emitFlags = ts.getEmitFlags(node);
85001             var skipLeadingComments = pos < 0 || (emitFlags & 512) !== 0;
85002             var skipTrailingComments = commentsDisabled || end < 0 || (emitFlags & 1024) !== 0;
85003             if (!skipLeadingComments) {
85004                 emitDetachedCommentsAndUpdateCommentsInfo(detachedRange);
85005             }
85006             exitComment();
85007             if (emitFlags & 2048 && !commentsDisabled) {
85008                 commentsDisabled = true;
85009                 emitCallback(node);
85010                 commentsDisabled = false;
85011             }
85012             else {
85013                 emitCallback(node);
85014             }
85015             enterComment();
85016             if (!skipTrailingComments) {
85017                 emitLeadingComments(detachedRange.end, true);
85018                 if (hasWrittenComment && !writer.isAtStartOfLine()) {
85019                     writer.writeLine();
85020                 }
85021             }
85022             exitComment();
85023         }
85024         function emitLeadingComments(pos, isEmittedNode) {
85025             hasWrittenComment = false;
85026             if (isEmittedNode) {
85027                 if (pos === 0 && (currentSourceFile === null || currentSourceFile === void 0 ? void 0 : currentSourceFile.isDeclarationFile)) {
85028                     forEachLeadingCommentToEmit(pos, emitNonTripleSlashLeadingComment);
85029                 }
85030                 else {
85031                     forEachLeadingCommentToEmit(pos, emitLeadingComment);
85032                 }
85033             }
85034             else if (pos === 0) {
85035                 forEachLeadingCommentToEmit(pos, emitTripleSlashLeadingComment);
85036             }
85037         }
85038         function emitTripleSlashLeadingComment(commentPos, commentEnd, kind, hasTrailingNewLine, rangePos) {
85039             if (isTripleSlashComment(commentPos, commentEnd)) {
85040                 emitLeadingComment(commentPos, commentEnd, kind, hasTrailingNewLine, rangePos);
85041             }
85042         }
85043         function emitNonTripleSlashLeadingComment(commentPos, commentEnd, kind, hasTrailingNewLine, rangePos) {
85044             if (!isTripleSlashComment(commentPos, commentEnd)) {
85045                 emitLeadingComment(commentPos, commentEnd, kind, hasTrailingNewLine, rangePos);
85046             }
85047         }
85048         function shouldWriteComment(text, pos) {
85049             if (printerOptions.onlyPrintJsDocStyle) {
85050                 return (ts.isJSDocLikeText(text, pos) || ts.isPinnedComment(text, pos));
85051             }
85052             return true;
85053         }
85054         function emitLeadingComment(commentPos, commentEnd, kind, hasTrailingNewLine, rangePos) {
85055             if (!shouldWriteComment(currentSourceFile.text, commentPos))
85056                 return;
85057             if (!hasWrittenComment) {
85058                 ts.emitNewLineBeforeLeadingCommentOfPosition(getCurrentLineMap(), writer, rangePos, commentPos);
85059                 hasWrittenComment = true;
85060             }
85061             emitPos(commentPos);
85062             ts.writeCommentRange(currentSourceFile.text, getCurrentLineMap(), writer, commentPos, commentEnd, newLine);
85063             emitPos(commentEnd);
85064             if (hasTrailingNewLine) {
85065                 writer.writeLine();
85066             }
85067             else if (kind === 3) {
85068                 writer.writeSpace(" ");
85069             }
85070         }
85071         function emitLeadingCommentsOfPosition(pos) {
85072             if (commentsDisabled || pos === -1) {
85073                 return;
85074             }
85075             emitLeadingComments(pos, true);
85076         }
85077         function emitTrailingComments(pos) {
85078             forEachTrailingCommentToEmit(pos, emitTrailingComment);
85079         }
85080         function emitTrailingComment(commentPos, commentEnd, _kind, hasTrailingNewLine) {
85081             if (!shouldWriteComment(currentSourceFile.text, commentPos))
85082                 return;
85083             if (!writer.isAtStartOfLine()) {
85084                 writer.writeSpace(" ");
85085             }
85086             emitPos(commentPos);
85087             ts.writeCommentRange(currentSourceFile.text, getCurrentLineMap(), writer, commentPos, commentEnd, newLine);
85088             emitPos(commentEnd);
85089             if (hasTrailingNewLine) {
85090                 writer.writeLine();
85091             }
85092         }
85093         function emitTrailingCommentsOfPosition(pos, prefixSpace) {
85094             if (commentsDisabled) {
85095                 return;
85096             }
85097             enterComment();
85098             forEachTrailingCommentToEmit(pos, prefixSpace ? emitTrailingComment : emitTrailingCommentOfPosition);
85099             exitComment();
85100         }
85101         function emitTrailingCommentOfPosition(commentPos, commentEnd, _kind, hasTrailingNewLine) {
85102             emitPos(commentPos);
85103             ts.writeCommentRange(currentSourceFile.text, getCurrentLineMap(), writer, commentPos, commentEnd, newLine);
85104             emitPos(commentEnd);
85105             if (hasTrailingNewLine) {
85106                 writer.writeLine();
85107             }
85108             else {
85109                 writer.writeSpace(" ");
85110             }
85111         }
85112         function forEachLeadingCommentToEmit(pos, cb) {
85113             if (currentSourceFile && (containerPos === -1 || pos !== containerPos)) {
85114                 if (hasDetachedComments(pos)) {
85115                     forEachLeadingCommentWithoutDetachedComments(cb);
85116                 }
85117                 else {
85118                     ts.forEachLeadingCommentRange(currentSourceFile.text, pos, cb, pos);
85119                 }
85120             }
85121         }
85122         function forEachTrailingCommentToEmit(end, cb) {
85123             if (currentSourceFile && (containerEnd === -1 || (end !== containerEnd && end !== declarationListContainerEnd))) {
85124                 ts.forEachTrailingCommentRange(currentSourceFile.text, end, cb);
85125             }
85126         }
85127         function hasDetachedComments(pos) {
85128             return detachedCommentsInfo !== undefined && ts.last(detachedCommentsInfo).nodePos === pos;
85129         }
85130         function forEachLeadingCommentWithoutDetachedComments(cb) {
85131             var pos = ts.last(detachedCommentsInfo).detachedCommentEndPos;
85132             if (detachedCommentsInfo.length - 1) {
85133                 detachedCommentsInfo.pop();
85134             }
85135             else {
85136                 detachedCommentsInfo = undefined;
85137             }
85138             ts.forEachLeadingCommentRange(currentSourceFile.text, pos, cb, pos);
85139         }
85140         function emitDetachedCommentsAndUpdateCommentsInfo(range) {
85141             var currentDetachedCommentInfo = ts.emitDetachedComments(currentSourceFile.text, getCurrentLineMap(), writer, emitComment, range, newLine, commentsDisabled);
85142             if (currentDetachedCommentInfo) {
85143                 if (detachedCommentsInfo) {
85144                     detachedCommentsInfo.push(currentDetachedCommentInfo);
85145                 }
85146                 else {
85147                     detachedCommentsInfo = [currentDetachedCommentInfo];
85148                 }
85149             }
85150         }
85151         function emitComment(text, lineMap, writer, commentPos, commentEnd, newLine) {
85152             if (!shouldWriteComment(currentSourceFile.text, commentPos))
85153                 return;
85154             emitPos(commentPos);
85155             ts.writeCommentRange(text, lineMap, writer, commentPos, commentEnd, newLine);
85156             emitPos(commentEnd);
85157         }
85158         function isTripleSlashComment(commentPos, commentEnd) {
85159             return ts.isRecognizedTripleSlashComment(currentSourceFile.text, commentPos, commentEnd);
85160         }
85161         function getParsedSourceMap(node) {
85162             if (node.parsedSourceMap === undefined && node.sourceMapText !== undefined) {
85163                 node.parsedSourceMap = ts.tryParseRawSourceMap(node.sourceMapText) || false;
85164             }
85165             return node.parsedSourceMap || undefined;
85166         }
85167         function pipelineEmitWithSourceMap(hint, node) {
85168             ts.Debug.assert(lastNode === node || lastSubstitution === node);
85169             var pipelinePhase = getNextPipelinePhase(3, hint, node);
85170             if (ts.isUnparsedSource(node) || ts.isUnparsedPrepend(node)) {
85171                 pipelinePhase(hint, node);
85172             }
85173             else if (ts.isUnparsedNode(node)) {
85174                 var parsed = getParsedSourceMap(node.parent);
85175                 if (parsed && sourceMapGenerator) {
85176                     sourceMapGenerator.appendSourceMap(writer.getLine(), writer.getColumn(), parsed, node.parent.sourceMapPath, node.parent.getLineAndCharacterOfPosition(node.pos), node.parent.getLineAndCharacterOfPosition(node.end));
85177                 }
85178                 pipelinePhase(hint, node);
85179             }
85180             else {
85181                 var _a = ts.getSourceMapRange(node), pos = _a.pos, end = _a.end, _b = _a.source, source = _b === void 0 ? sourceMapSource : _b;
85182                 var emitFlags = ts.getEmitFlags(node);
85183                 if (node.kind !== 335
85184                     && (emitFlags & 16) === 0
85185                     && pos >= 0) {
85186                     emitSourcePos(source, skipSourceTrivia(source, pos));
85187                 }
85188                 if (emitFlags & 64) {
85189                     sourceMapsDisabled = true;
85190                     pipelinePhase(hint, node);
85191                     sourceMapsDisabled = false;
85192                 }
85193                 else {
85194                     pipelinePhase(hint, node);
85195                 }
85196                 if (node.kind !== 335
85197                     && (emitFlags & 32) === 0
85198                     && end >= 0) {
85199                     emitSourcePos(source, end);
85200                 }
85201             }
85202             ts.Debug.assert(lastNode === node || lastSubstitution === node);
85203         }
85204         function skipSourceTrivia(source, pos) {
85205             return source.skipTrivia ? source.skipTrivia(pos) : ts.skipTrivia(source.text, pos);
85206         }
85207         function emitPos(pos) {
85208             if (sourceMapsDisabled || ts.positionIsSynthesized(pos) || isJsonSourceMapSource(sourceMapSource)) {
85209                 return;
85210             }
85211             var _a = ts.getLineAndCharacterOfPosition(sourceMapSource, pos), sourceLine = _a.line, sourceCharacter = _a.character;
85212             sourceMapGenerator.addMapping(writer.getLine(), writer.getColumn(), sourceMapSourceIndex, sourceLine, sourceCharacter, undefined);
85213         }
85214         function emitSourcePos(source, pos) {
85215             if (source !== sourceMapSource) {
85216                 var savedSourceMapSource = sourceMapSource;
85217                 var savedSourceMapSourceIndex = sourceMapSourceIndex;
85218                 setSourceMapSource(source);
85219                 emitPos(pos);
85220                 resetSourceMapSource(savedSourceMapSource, savedSourceMapSourceIndex);
85221             }
85222             else {
85223                 emitPos(pos);
85224             }
85225         }
85226         function emitTokenWithSourceMap(node, token, writer, tokenPos, emitCallback) {
85227             if (sourceMapsDisabled || node && ts.isInJsonFile(node)) {
85228                 return emitCallback(token, writer, tokenPos);
85229             }
85230             var emitNode = node && node.emitNode;
85231             var emitFlags = emitNode && emitNode.flags || 0;
85232             var range = emitNode && emitNode.tokenSourceMapRanges && emitNode.tokenSourceMapRanges[token];
85233             var source = range && range.source || sourceMapSource;
85234             tokenPos = skipSourceTrivia(source, range ? range.pos : tokenPos);
85235             if ((emitFlags & 128) === 0 && tokenPos >= 0) {
85236                 emitSourcePos(source, tokenPos);
85237             }
85238             tokenPos = emitCallback(token, writer, tokenPos);
85239             if (range)
85240                 tokenPos = range.end;
85241             if ((emitFlags & 256) === 0 && tokenPos >= 0) {
85242                 emitSourcePos(source, tokenPos);
85243             }
85244             return tokenPos;
85245         }
85246         function setSourceMapSource(source) {
85247             if (sourceMapsDisabled) {
85248                 return;
85249             }
85250             sourceMapSource = source;
85251             if (source === mostRecentlyAddedSourceMapSource) {
85252                 sourceMapSourceIndex = mostRecentlyAddedSourceMapSourceIndex;
85253                 return;
85254             }
85255             if (isJsonSourceMapSource(source)) {
85256                 return;
85257             }
85258             sourceMapSourceIndex = sourceMapGenerator.addSource(source.fileName);
85259             if (printerOptions.inlineSources) {
85260                 sourceMapGenerator.setSourceContent(sourceMapSourceIndex, source.text);
85261             }
85262             mostRecentlyAddedSourceMapSource = source;
85263             mostRecentlyAddedSourceMapSourceIndex = sourceMapSourceIndex;
85264         }
85265         function resetSourceMapSource(source, sourceIndex) {
85266             sourceMapSource = source;
85267             sourceMapSourceIndex = sourceIndex;
85268         }
85269         function isJsonSourceMapSource(sourceFile) {
85270             return ts.fileExtensionIs(sourceFile.fileName, ".json");
85271         }
85272     }
85273     ts.createPrinter = createPrinter;
85274     function createBracketsMap() {
85275         var brackets = [];
85276         brackets[1024] = ["{", "}"];
85277         brackets[2048] = ["(", ")"];
85278         brackets[4096] = ["<", ">"];
85279         brackets[8192] = ["[", "]"];
85280         return brackets;
85281     }
85282     function getOpeningBracket(format) {
85283         return brackets[format & 15360][0];
85284     }
85285     function getClosingBracket(format) {
85286         return brackets[format & 15360][1];
85287     }
85288 })(ts || (ts = {}));
85289 var ts;
85290 (function (ts) {
85291     function createCachedDirectoryStructureHost(host, currentDirectory, useCaseSensitiveFileNames) {
85292         if (!host.getDirectories || !host.readDirectory) {
85293             return undefined;
85294         }
85295         var cachedReadDirectoryResult = new ts.Map();
85296         var getCanonicalFileName = ts.createGetCanonicalFileName(useCaseSensitiveFileNames);
85297         return {
85298             useCaseSensitiveFileNames: useCaseSensitiveFileNames,
85299             fileExists: fileExists,
85300             readFile: function (path, encoding) { return host.readFile(path, encoding); },
85301             directoryExists: host.directoryExists && directoryExists,
85302             getDirectories: getDirectories,
85303             readDirectory: readDirectory,
85304             createDirectory: host.createDirectory && createDirectory,
85305             writeFile: host.writeFile && writeFile,
85306             addOrDeleteFileOrDirectory: addOrDeleteFileOrDirectory,
85307             addOrDeleteFile: addOrDeleteFile,
85308             clearCache: clearCache,
85309             realpath: host.realpath && realpath
85310         };
85311         function toPath(fileName) {
85312             return ts.toPath(fileName, currentDirectory, getCanonicalFileName);
85313         }
85314         function getCachedFileSystemEntries(rootDirPath) {
85315             return cachedReadDirectoryResult.get(ts.ensureTrailingDirectorySeparator(rootDirPath));
85316         }
85317         function getCachedFileSystemEntriesForBaseDir(path) {
85318             return getCachedFileSystemEntries(ts.getDirectoryPath(path));
85319         }
85320         function getBaseNameOfFileName(fileName) {
85321             return ts.getBaseFileName(ts.normalizePath(fileName));
85322         }
85323         function createCachedFileSystemEntries(rootDir, rootDirPath) {
85324             var resultFromHost = {
85325                 files: ts.map(host.readDirectory(rootDir, undefined, undefined, ["*.*"]), getBaseNameOfFileName) || [],
85326                 directories: host.getDirectories(rootDir) || []
85327             };
85328             cachedReadDirectoryResult.set(ts.ensureTrailingDirectorySeparator(rootDirPath), resultFromHost);
85329             return resultFromHost;
85330         }
85331         function tryReadDirectory(rootDir, rootDirPath) {
85332             rootDirPath = ts.ensureTrailingDirectorySeparator(rootDirPath);
85333             var cachedResult = getCachedFileSystemEntries(rootDirPath);
85334             if (cachedResult) {
85335                 return cachedResult;
85336             }
85337             try {
85338                 return createCachedFileSystemEntries(rootDir, rootDirPath);
85339             }
85340             catch (_e) {
85341                 ts.Debug.assert(!cachedReadDirectoryResult.has(ts.ensureTrailingDirectorySeparator(rootDirPath)));
85342                 return undefined;
85343             }
85344         }
85345         function fileNameEqual(name1, name2) {
85346             return getCanonicalFileName(name1) === getCanonicalFileName(name2);
85347         }
85348         function hasEntry(entries, name) {
85349             return ts.some(entries, function (file) { return fileNameEqual(file, name); });
85350         }
85351         function updateFileSystemEntry(entries, baseName, isValid) {
85352             if (hasEntry(entries, baseName)) {
85353                 if (!isValid) {
85354                     return ts.filterMutate(entries, function (entry) { return !fileNameEqual(entry, baseName); });
85355                 }
85356             }
85357             else if (isValid) {
85358                 return entries.push(baseName);
85359             }
85360         }
85361         function writeFile(fileName, data, writeByteOrderMark) {
85362             var path = toPath(fileName);
85363             var result = getCachedFileSystemEntriesForBaseDir(path);
85364             if (result) {
85365                 updateFilesOfFileSystemEntry(result, getBaseNameOfFileName(fileName), true);
85366             }
85367             return host.writeFile(fileName, data, writeByteOrderMark);
85368         }
85369         function fileExists(fileName) {
85370             var path = toPath(fileName);
85371             var result = getCachedFileSystemEntriesForBaseDir(path);
85372             return result && hasEntry(result.files, getBaseNameOfFileName(fileName)) ||
85373                 host.fileExists(fileName);
85374         }
85375         function directoryExists(dirPath) {
85376             var path = toPath(dirPath);
85377             return cachedReadDirectoryResult.has(ts.ensureTrailingDirectorySeparator(path)) || host.directoryExists(dirPath);
85378         }
85379         function createDirectory(dirPath) {
85380             var path = toPath(dirPath);
85381             var result = getCachedFileSystemEntriesForBaseDir(path);
85382             var baseFileName = getBaseNameOfFileName(dirPath);
85383             if (result) {
85384                 updateFileSystemEntry(result.directories, baseFileName, true);
85385             }
85386             host.createDirectory(dirPath);
85387         }
85388         function getDirectories(rootDir) {
85389             var rootDirPath = toPath(rootDir);
85390             var result = tryReadDirectory(rootDir, rootDirPath);
85391             if (result) {
85392                 return result.directories.slice();
85393             }
85394             return host.getDirectories(rootDir);
85395         }
85396         function readDirectory(rootDir, extensions, excludes, includes, depth) {
85397             var rootDirPath = toPath(rootDir);
85398             var result = tryReadDirectory(rootDir, rootDirPath);
85399             if (result) {
85400                 return ts.matchFiles(rootDir, extensions, excludes, includes, useCaseSensitiveFileNames, currentDirectory, depth, getFileSystemEntries, realpath);
85401             }
85402             return host.readDirectory(rootDir, extensions, excludes, includes, depth);
85403             function getFileSystemEntries(dir) {
85404                 var path = toPath(dir);
85405                 if (path === rootDirPath) {
85406                     return result;
85407                 }
85408                 return tryReadDirectory(dir, path) || ts.emptyFileSystemEntries;
85409             }
85410         }
85411         function realpath(s) {
85412             return host.realpath ? host.realpath(s) : s;
85413         }
85414         function addOrDeleteFileOrDirectory(fileOrDirectory, fileOrDirectoryPath) {
85415             var existingResult = getCachedFileSystemEntries(fileOrDirectoryPath);
85416             if (existingResult) {
85417                 clearCache();
85418                 return undefined;
85419             }
85420             var parentResult = getCachedFileSystemEntriesForBaseDir(fileOrDirectoryPath);
85421             if (!parentResult) {
85422                 return undefined;
85423             }
85424             if (!host.directoryExists) {
85425                 clearCache();
85426                 return undefined;
85427             }
85428             var baseName = getBaseNameOfFileName(fileOrDirectory);
85429             var fsQueryResult = {
85430                 fileExists: host.fileExists(fileOrDirectoryPath),
85431                 directoryExists: host.directoryExists(fileOrDirectoryPath)
85432             };
85433             if (fsQueryResult.directoryExists || hasEntry(parentResult.directories, baseName)) {
85434                 clearCache();
85435             }
85436             else {
85437                 updateFilesOfFileSystemEntry(parentResult, baseName, fsQueryResult.fileExists);
85438             }
85439             return fsQueryResult;
85440         }
85441         function addOrDeleteFile(fileName, filePath, eventKind) {
85442             if (eventKind === ts.FileWatcherEventKind.Changed) {
85443                 return;
85444             }
85445             var parentResult = getCachedFileSystemEntriesForBaseDir(filePath);
85446             if (parentResult) {
85447                 updateFilesOfFileSystemEntry(parentResult, getBaseNameOfFileName(fileName), eventKind === ts.FileWatcherEventKind.Created);
85448             }
85449         }
85450         function updateFilesOfFileSystemEntry(parentResult, baseName, fileExists) {
85451             updateFileSystemEntry(parentResult.files, baseName, fileExists);
85452         }
85453         function clearCache() {
85454             cachedReadDirectoryResult.clear();
85455         }
85456     }
85457     ts.createCachedDirectoryStructureHost = createCachedDirectoryStructureHost;
85458     var ConfigFileProgramReloadLevel;
85459     (function (ConfigFileProgramReloadLevel) {
85460         ConfigFileProgramReloadLevel[ConfigFileProgramReloadLevel["None"] = 0] = "None";
85461         ConfigFileProgramReloadLevel[ConfigFileProgramReloadLevel["Partial"] = 1] = "Partial";
85462         ConfigFileProgramReloadLevel[ConfigFileProgramReloadLevel["Full"] = 2] = "Full";
85463     })(ConfigFileProgramReloadLevel = ts.ConfigFileProgramReloadLevel || (ts.ConfigFileProgramReloadLevel = {}));
85464     function updateMissingFilePathsWatch(program, missingFileWatches, createMissingFileWatch) {
85465         var missingFilePaths = program.getMissingFilePaths();
85466         var newMissingFilePathMap = ts.arrayToMap(missingFilePaths, ts.identity, ts.returnTrue);
85467         ts.mutateMap(missingFileWatches, newMissingFilePathMap, {
85468             createNewValue: createMissingFileWatch,
85469             onDeleteValue: ts.closeFileWatcher
85470         });
85471     }
85472     ts.updateMissingFilePathsWatch = updateMissingFilePathsWatch;
85473     function updateWatchingWildcardDirectories(existingWatchedForWildcards, wildcardDirectories, watchDirectory) {
85474         ts.mutateMap(existingWatchedForWildcards, wildcardDirectories, {
85475             createNewValue: createWildcardDirectoryWatcher,
85476             onDeleteValue: closeFileWatcherOf,
85477             onExistingValue: updateWildcardDirectoryWatcher
85478         });
85479         function createWildcardDirectoryWatcher(directory, flags) {
85480             return {
85481                 watcher: watchDirectory(directory, flags),
85482                 flags: flags
85483             };
85484         }
85485         function updateWildcardDirectoryWatcher(existingWatcher, flags, directory) {
85486             if (existingWatcher.flags === flags) {
85487                 return;
85488             }
85489             existingWatcher.watcher.close();
85490             existingWatchedForWildcards.set(directory, createWildcardDirectoryWatcher(directory, flags));
85491         }
85492     }
85493     ts.updateWatchingWildcardDirectories = updateWatchingWildcardDirectories;
85494     function isIgnoredFileFromWildCardWatching(_a) {
85495         var watchedDirPath = _a.watchedDirPath, fileOrDirectory = _a.fileOrDirectory, fileOrDirectoryPath = _a.fileOrDirectoryPath, configFileName = _a.configFileName, options = _a.options, configFileSpecs = _a.configFileSpecs, program = _a.program, extraFileExtensions = _a.extraFileExtensions, currentDirectory = _a.currentDirectory, useCaseSensitiveFileNames = _a.useCaseSensitiveFileNames, writeLog = _a.writeLog;
85496         var newPath = ts.removeIgnoredPath(fileOrDirectoryPath);
85497         if (!newPath) {
85498             writeLog("Project: " + configFileName + " Detected ignored path: " + fileOrDirectory);
85499             return true;
85500         }
85501         fileOrDirectoryPath = newPath;
85502         if (fileOrDirectoryPath === watchedDirPath)
85503             return false;
85504         if (ts.hasExtension(fileOrDirectoryPath) && !ts.isSupportedSourceFileName(fileOrDirectory, options, extraFileExtensions)) {
85505             writeLog("Project: " + configFileName + " Detected file add/remove of non supported extension: " + fileOrDirectory);
85506             return true;
85507         }
85508         if (ts.isExcludedFile(fileOrDirectory, configFileSpecs, ts.getNormalizedAbsolutePath(ts.getDirectoryPath(configFileName), currentDirectory), useCaseSensitiveFileNames, currentDirectory)) {
85509             writeLog("Project: " + configFileName + " Detected excluded file: " + fileOrDirectory);
85510             return true;
85511         }
85512         if (!program)
85513             return false;
85514         if (options.outFile || options.outDir)
85515             return false;
85516         if (ts.fileExtensionIs(fileOrDirectoryPath, ".d.ts")) {
85517             if (options.declarationDir)
85518                 return false;
85519         }
85520         else if (!ts.fileExtensionIsOneOf(fileOrDirectoryPath, ts.supportedJSExtensions)) {
85521             return false;
85522         }
85523         var filePathWithoutExtension = ts.removeFileExtension(fileOrDirectoryPath);
85524         var realProgram = isBuilderProgram(program) ? program.getProgramOrUndefined() : program;
85525         if (hasSourceFile((filePathWithoutExtension + ".ts")) ||
85526             hasSourceFile((filePathWithoutExtension + ".tsx"))) {
85527             writeLog("Project: " + configFileName + " Detected output file: " + fileOrDirectory);
85528             return true;
85529         }
85530         return false;
85531         function hasSourceFile(file) {
85532             return realProgram ?
85533                 !!realProgram.getSourceFileByPath(file) :
85534                 program.getState().fileInfos.has(file);
85535         }
85536     }
85537     ts.isIgnoredFileFromWildCardWatching = isIgnoredFileFromWildCardWatching;
85538     function isBuilderProgram(program) {
85539         return !!program.getState;
85540     }
85541     function isEmittedFileOfProgram(program, file) {
85542         if (!program) {
85543             return false;
85544         }
85545         return program.isEmittedFile(file);
85546     }
85547     ts.isEmittedFileOfProgram = isEmittedFileOfProgram;
85548     var WatchLogLevel;
85549     (function (WatchLogLevel) {
85550         WatchLogLevel[WatchLogLevel["None"] = 0] = "None";
85551         WatchLogLevel[WatchLogLevel["TriggerOnly"] = 1] = "TriggerOnly";
85552         WatchLogLevel[WatchLogLevel["Verbose"] = 2] = "Verbose";
85553     })(WatchLogLevel = ts.WatchLogLevel || (ts.WatchLogLevel = {}));
85554     function getWatchFactory(watchLogLevel, log, getDetailWatchInfo) {
85555         return getWatchFactoryWith(watchLogLevel, log, getDetailWatchInfo, watchFile, watchDirectory);
85556     }
85557     ts.getWatchFactory = getWatchFactory;
85558     function getWatchFactoryWith(watchLogLevel, log, getDetailWatchInfo, watchFile, watchDirectory) {
85559         var createFileWatcher = getCreateFileWatcher(watchLogLevel, watchFile);
85560         var createFilePathWatcher = watchLogLevel === WatchLogLevel.None ? watchFilePath : createFileWatcher;
85561         var createDirectoryWatcher = getCreateFileWatcher(watchLogLevel, watchDirectory);
85562         if (watchLogLevel === WatchLogLevel.Verbose && ts.sysLog === ts.noop) {
85563             ts.setSysLog(function (s) { return log(s); });
85564         }
85565         return {
85566             watchFile: function (host, file, callback, pollingInterval, options, detailInfo1, detailInfo2) {
85567                 return createFileWatcher(host, file, callback, pollingInterval, options, undefined, detailInfo1, detailInfo2, watchFile, log, "FileWatcher", getDetailWatchInfo);
85568             },
85569             watchFilePath: function (host, file, callback, pollingInterval, options, path, detailInfo1, detailInfo2) {
85570                 return createFilePathWatcher(host, file, callback, pollingInterval, options, path, detailInfo1, detailInfo2, watchFile, log, "FileWatcher", getDetailWatchInfo);
85571             },
85572             watchDirectory: function (host, directory, callback, flags, options, detailInfo1, detailInfo2) {
85573                 return createDirectoryWatcher(host, directory, callback, flags, options, undefined, detailInfo1, detailInfo2, watchDirectory, log, "DirectoryWatcher", getDetailWatchInfo);
85574             }
85575         };
85576     }
85577     function watchFile(host, file, callback, pollingInterval, options) {
85578         return host.watchFile(file, callback, pollingInterval, options);
85579     }
85580     function watchFilePath(host, file, callback, pollingInterval, options, path) {
85581         return watchFile(host, file, function (fileName, eventKind) { return callback(fileName, eventKind, path); }, pollingInterval, options);
85582     }
85583     function watchDirectory(host, directory, callback, flags, options) {
85584         return host.watchDirectory(directory, callback, (flags & 1) !== 0, options);
85585     }
85586     function getCreateFileWatcher(watchLogLevel, addWatch) {
85587         switch (watchLogLevel) {
85588             case WatchLogLevel.None:
85589                 return addWatch;
85590             case WatchLogLevel.TriggerOnly:
85591                 return createFileWatcherWithTriggerLogging;
85592             case WatchLogLevel.Verbose:
85593                 return addWatch === watchDirectory ? createDirectoryWatcherWithLogging : createFileWatcherWithLogging;
85594         }
85595     }
85596     function createFileWatcherWithLogging(host, file, cb, flags, options, passThrough, detailInfo1, detailInfo2, addWatch, log, watchCaption, getDetailWatchInfo) {
85597         log(watchCaption + ":: Added:: " + getWatchInfo(file, flags, options, detailInfo1, detailInfo2, getDetailWatchInfo));
85598         var watcher = createFileWatcherWithTriggerLogging(host, file, cb, flags, options, passThrough, detailInfo1, detailInfo2, addWatch, log, watchCaption, getDetailWatchInfo);
85599         return {
85600             close: function () {
85601                 log(watchCaption + ":: Close:: " + getWatchInfo(file, flags, options, detailInfo1, detailInfo2, getDetailWatchInfo));
85602                 watcher.close();
85603             }
85604         };
85605     }
85606     function createDirectoryWatcherWithLogging(host, file, cb, flags, options, passThrough, detailInfo1, detailInfo2, addWatch, log, watchCaption, getDetailWatchInfo) {
85607         var watchInfo = watchCaption + ":: Added:: " + getWatchInfo(file, flags, options, detailInfo1, detailInfo2, getDetailWatchInfo);
85608         log(watchInfo);
85609         var start = ts.timestamp();
85610         var watcher = createFileWatcherWithTriggerLogging(host, file, cb, flags, options, passThrough, detailInfo1, detailInfo2, addWatch, log, watchCaption, getDetailWatchInfo);
85611         var elapsed = ts.timestamp() - start;
85612         log("Elapsed:: " + elapsed + "ms " + watchInfo);
85613         return {
85614             close: function () {
85615                 var watchInfo = watchCaption + ":: Close:: " + getWatchInfo(file, flags, options, detailInfo1, detailInfo2, getDetailWatchInfo);
85616                 log(watchInfo);
85617                 var start = ts.timestamp();
85618                 watcher.close();
85619                 var elapsed = ts.timestamp() - start;
85620                 log("Elapsed:: " + elapsed + "ms " + watchInfo);
85621             }
85622         };
85623     }
85624     function createFileWatcherWithTriggerLogging(host, file, cb, flags, options, passThrough, detailInfo1, detailInfo2, addWatch, log, watchCaption, getDetailWatchInfo) {
85625         return addWatch(host, file, function (fileName, cbOptional) {
85626             var triggerredInfo = watchCaption + ":: Triggered with " + fileName + " " + (cbOptional !== undefined ? cbOptional : "") + ":: " + getWatchInfo(file, flags, options, detailInfo1, detailInfo2, getDetailWatchInfo);
85627             log(triggerredInfo);
85628             var start = ts.timestamp();
85629             cb(fileName, cbOptional, passThrough);
85630             var elapsed = ts.timestamp() - start;
85631             log("Elapsed:: " + elapsed + "ms " + triggerredInfo);
85632         }, flags, options);
85633     }
85634     function getFallbackOptions(options) {
85635         var fallbackPolling = options === null || options === void 0 ? void 0 : options.fallbackPolling;
85636         return {
85637             watchFile: fallbackPolling !== undefined ?
85638                 fallbackPolling :
85639                 ts.WatchFileKind.PriorityPollingInterval
85640         };
85641     }
85642     ts.getFallbackOptions = getFallbackOptions;
85643     function getWatchInfo(file, flags, options, detailInfo1, detailInfo2, getDetailWatchInfo) {
85644         return "WatchInfo: " + file + " " + flags + " " + JSON.stringify(options) + " " + (getDetailWatchInfo ? getDetailWatchInfo(detailInfo1, detailInfo2) : detailInfo2 === undefined ? detailInfo1 : detailInfo1 + " " + detailInfo2);
85645     }
85646     function closeFileWatcherOf(objWithWatcher) {
85647         objWithWatcher.watcher.close();
85648     }
85649     ts.closeFileWatcherOf = closeFileWatcherOf;
85650 })(ts || (ts = {}));
85651 var ts;
85652 (function (ts) {
85653     function findConfigFile(searchPath, fileExists, configName) {
85654         if (configName === void 0) { configName = "tsconfig.json"; }
85655         return ts.forEachAncestorDirectory(searchPath, function (ancestor) {
85656             var fileName = ts.combinePaths(ancestor, configName);
85657             return fileExists(fileName) ? fileName : undefined;
85658         });
85659     }
85660     ts.findConfigFile = findConfigFile;
85661     function resolveTripleslashReference(moduleName, containingFile) {
85662         var basePath = ts.getDirectoryPath(containingFile);
85663         var referencedFileName = ts.isRootedDiskPath(moduleName) ? moduleName : ts.combinePaths(basePath, moduleName);
85664         return ts.normalizePath(referencedFileName);
85665     }
85666     ts.resolveTripleslashReference = resolveTripleslashReference;
85667     function computeCommonSourceDirectoryOfFilenames(fileNames, currentDirectory, getCanonicalFileName) {
85668         var commonPathComponents;
85669         var failed = ts.forEach(fileNames, function (sourceFile) {
85670             var sourcePathComponents = ts.getNormalizedPathComponents(sourceFile, currentDirectory);
85671             sourcePathComponents.pop();
85672             if (!commonPathComponents) {
85673                 commonPathComponents = sourcePathComponents;
85674                 return;
85675             }
85676             var n = Math.min(commonPathComponents.length, sourcePathComponents.length);
85677             for (var i = 0; i < n; i++) {
85678                 if (getCanonicalFileName(commonPathComponents[i]) !== getCanonicalFileName(sourcePathComponents[i])) {
85679                     if (i === 0) {
85680                         return true;
85681                     }
85682                     commonPathComponents.length = i;
85683                     break;
85684                 }
85685             }
85686             if (sourcePathComponents.length < commonPathComponents.length) {
85687                 commonPathComponents.length = sourcePathComponents.length;
85688             }
85689         });
85690         if (failed) {
85691             return "";
85692         }
85693         if (!commonPathComponents) {
85694             return currentDirectory;
85695         }
85696         return ts.getPathFromPathComponents(commonPathComponents);
85697     }
85698     ts.computeCommonSourceDirectoryOfFilenames = computeCommonSourceDirectoryOfFilenames;
85699     function createCompilerHost(options, setParentNodes) {
85700         return createCompilerHostWorker(options, setParentNodes);
85701     }
85702     ts.createCompilerHost = createCompilerHost;
85703     function createCompilerHostWorker(options, setParentNodes, system) {
85704         if (system === void 0) { system = ts.sys; }
85705         var existingDirectories = new ts.Map();
85706         var getCanonicalFileName = ts.createGetCanonicalFileName(system.useCaseSensitiveFileNames);
85707         var computeHash = ts.maybeBind(system, system.createHash) || ts.generateDjb2Hash;
85708         function getSourceFile(fileName, languageVersion, onError) {
85709             var text;
85710             try {
85711                 ts.performance.mark("beforeIORead");
85712                 text = compilerHost.readFile(fileName);
85713                 ts.performance.mark("afterIORead");
85714                 ts.performance.measure("I/O Read", "beforeIORead", "afterIORead");
85715             }
85716             catch (e) {
85717                 if (onError) {
85718                     onError(e.message);
85719                 }
85720                 text = "";
85721             }
85722             return text !== undefined ? ts.createSourceFile(fileName, text, languageVersion, setParentNodes) : undefined;
85723         }
85724         function directoryExists(directoryPath) {
85725             if (existingDirectories.has(directoryPath)) {
85726                 return true;
85727             }
85728             if ((compilerHost.directoryExists || system.directoryExists)(directoryPath)) {
85729                 existingDirectories.set(directoryPath, true);
85730                 return true;
85731             }
85732             return false;
85733         }
85734         function writeFile(fileName, data, writeByteOrderMark, onError) {
85735             try {
85736                 ts.performance.mark("beforeIOWrite");
85737                 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); });
85738                 ts.performance.mark("afterIOWrite");
85739                 ts.performance.measure("I/O Write", "beforeIOWrite", "afterIOWrite");
85740             }
85741             catch (e) {
85742                 if (onError) {
85743                     onError(e.message);
85744                 }
85745             }
85746         }
85747         var outputFingerprints;
85748         function writeFileWorker(fileName, data, writeByteOrderMark) {
85749             if (!ts.isWatchSet(options) || !system.getModifiedTime) {
85750                 system.writeFile(fileName, data, writeByteOrderMark);
85751                 return;
85752             }
85753             if (!outputFingerprints) {
85754                 outputFingerprints = new ts.Map();
85755             }
85756             var hash = computeHash(data);
85757             var mtimeBefore = system.getModifiedTime(fileName);
85758             if (mtimeBefore) {
85759                 var fingerprint = outputFingerprints.get(fileName);
85760                 if (fingerprint &&
85761                     fingerprint.byteOrderMark === writeByteOrderMark &&
85762                     fingerprint.hash === hash &&
85763                     fingerprint.mtime.getTime() === mtimeBefore.getTime()) {
85764                     return;
85765                 }
85766             }
85767             system.writeFile(fileName, data, writeByteOrderMark);
85768             var mtimeAfter = system.getModifiedTime(fileName) || ts.missingFileModifiedTime;
85769             outputFingerprints.set(fileName, {
85770                 hash: hash,
85771                 byteOrderMark: writeByteOrderMark,
85772                 mtime: mtimeAfter
85773             });
85774         }
85775         function getDefaultLibLocation() {
85776             return ts.getDirectoryPath(ts.normalizePath(system.getExecutingFilePath()));
85777         }
85778         var newLine = ts.getNewLineCharacter(options, function () { return system.newLine; });
85779         var realpath = system.realpath && (function (path) { return system.realpath(path); });
85780         var compilerHost = {
85781             getSourceFile: getSourceFile,
85782             getDefaultLibLocation: getDefaultLibLocation,
85783             getDefaultLibFileName: function (options) { return ts.combinePaths(getDefaultLibLocation(), ts.getDefaultLibFileName(options)); },
85784             writeFile: writeFile,
85785             getCurrentDirectory: ts.memoize(function () { return system.getCurrentDirectory(); }),
85786             useCaseSensitiveFileNames: function () { return system.useCaseSensitiveFileNames; },
85787             getCanonicalFileName: getCanonicalFileName,
85788             getNewLine: function () { return newLine; },
85789             fileExists: function (fileName) { return system.fileExists(fileName); },
85790             readFile: function (fileName) { return system.readFile(fileName); },
85791             trace: function (s) { return system.write(s + newLine); },
85792             directoryExists: function (directoryName) { return system.directoryExists(directoryName); },
85793             getEnvironmentVariable: function (name) { return system.getEnvironmentVariable ? system.getEnvironmentVariable(name) : ""; },
85794             getDirectories: function (path) { return system.getDirectories(path); },
85795             realpath: realpath,
85796             readDirectory: function (path, extensions, include, exclude, depth) { return system.readDirectory(path, extensions, include, exclude, depth); },
85797             createDirectory: function (d) { return system.createDirectory(d); },
85798             createHash: ts.maybeBind(system, system.createHash)
85799         };
85800         return compilerHost;
85801     }
85802     ts.createCompilerHostWorker = createCompilerHostWorker;
85803     function changeCompilerHostLikeToUseCache(host, toPath, getSourceFile) {
85804         var originalReadFile = host.readFile;
85805         var originalFileExists = host.fileExists;
85806         var originalDirectoryExists = host.directoryExists;
85807         var originalCreateDirectory = host.createDirectory;
85808         var originalWriteFile = host.writeFile;
85809         var readFileCache = new ts.Map();
85810         var fileExistsCache = new ts.Map();
85811         var directoryExistsCache = new ts.Map();
85812         var sourceFileCache = new ts.Map();
85813         var readFileWithCache = function (fileName) {
85814             var key = toPath(fileName);
85815             var value = readFileCache.get(key);
85816             if (value !== undefined)
85817                 return value !== false ? value : undefined;
85818             return setReadFileCache(key, fileName);
85819         };
85820         var setReadFileCache = function (key, fileName) {
85821             var newValue = originalReadFile.call(host, fileName);
85822             readFileCache.set(key, newValue !== undefined ? newValue : false);
85823             return newValue;
85824         };
85825         host.readFile = function (fileName) {
85826             var key = toPath(fileName);
85827             var value = readFileCache.get(key);
85828             if (value !== undefined)
85829                 return value !== false ? value : undefined;
85830             if (!ts.fileExtensionIs(fileName, ".json") && !ts.isBuildInfoFile(fileName)) {
85831                 return originalReadFile.call(host, fileName);
85832             }
85833             return setReadFileCache(key, fileName);
85834         };
85835         var getSourceFileWithCache = getSourceFile ? function (fileName, languageVersion, onError, shouldCreateNewSourceFile) {
85836             var key = toPath(fileName);
85837             var value = sourceFileCache.get(key);
85838             if (value)
85839                 return value;
85840             var sourceFile = getSourceFile(fileName, languageVersion, onError, shouldCreateNewSourceFile);
85841             if (sourceFile && (ts.isDeclarationFileName(fileName) || ts.fileExtensionIs(fileName, ".json"))) {
85842                 sourceFileCache.set(key, sourceFile);
85843             }
85844             return sourceFile;
85845         } : undefined;
85846         host.fileExists = function (fileName) {
85847             var key = toPath(fileName);
85848             var value = fileExistsCache.get(key);
85849             if (value !== undefined)
85850                 return value;
85851             var newValue = originalFileExists.call(host, fileName);
85852             fileExistsCache.set(key, !!newValue);
85853             return newValue;
85854         };
85855         if (originalWriteFile) {
85856             host.writeFile = function (fileName, data, writeByteOrderMark, onError, sourceFiles) {
85857                 var key = toPath(fileName);
85858                 fileExistsCache.delete(key);
85859                 var value = readFileCache.get(key);
85860                 if (value !== undefined && value !== data) {
85861                     readFileCache.delete(key);
85862                     sourceFileCache.delete(key);
85863                 }
85864                 else if (getSourceFileWithCache) {
85865                     var sourceFile = sourceFileCache.get(key);
85866                     if (sourceFile && sourceFile.text !== data) {
85867                         sourceFileCache.delete(key);
85868                     }
85869                 }
85870                 originalWriteFile.call(host, fileName, data, writeByteOrderMark, onError, sourceFiles);
85871             };
85872         }
85873         if (originalDirectoryExists && originalCreateDirectory) {
85874             host.directoryExists = function (directory) {
85875                 var key = toPath(directory);
85876                 var value = directoryExistsCache.get(key);
85877                 if (value !== undefined)
85878                     return value;
85879                 var newValue = originalDirectoryExists.call(host, directory);
85880                 directoryExistsCache.set(key, !!newValue);
85881                 return newValue;
85882             };
85883             host.createDirectory = function (directory) {
85884                 var key = toPath(directory);
85885                 directoryExistsCache.delete(key);
85886                 originalCreateDirectory.call(host, directory);
85887             };
85888         }
85889         return {
85890             originalReadFile: originalReadFile,
85891             originalFileExists: originalFileExists,
85892             originalDirectoryExists: originalDirectoryExists,
85893             originalCreateDirectory: originalCreateDirectory,
85894             originalWriteFile: originalWriteFile,
85895             getSourceFileWithCache: getSourceFileWithCache,
85896             readFileWithCache: readFileWithCache
85897         };
85898     }
85899     ts.changeCompilerHostLikeToUseCache = changeCompilerHostLikeToUseCache;
85900     function getPreEmitDiagnostics(program, sourceFile, cancellationToken) {
85901         var diagnostics;
85902         diagnostics = ts.addRange(diagnostics, program.getConfigFileParsingDiagnostics());
85903         diagnostics = ts.addRange(diagnostics, program.getOptionsDiagnostics(cancellationToken));
85904         diagnostics = ts.addRange(diagnostics, program.getSyntacticDiagnostics(sourceFile, cancellationToken));
85905         diagnostics = ts.addRange(diagnostics, program.getGlobalDiagnostics(cancellationToken));
85906         diagnostics = ts.addRange(diagnostics, program.getSemanticDiagnostics(sourceFile, cancellationToken));
85907         if (ts.getEmitDeclarations(program.getCompilerOptions())) {
85908             diagnostics = ts.addRange(diagnostics, program.getDeclarationDiagnostics(sourceFile, cancellationToken));
85909         }
85910         return ts.sortAndDeduplicateDiagnostics(diagnostics || ts.emptyArray);
85911     }
85912     ts.getPreEmitDiagnostics = getPreEmitDiagnostics;
85913     function formatDiagnostics(diagnostics, host) {
85914         var output = "";
85915         for (var _i = 0, diagnostics_3 = diagnostics; _i < diagnostics_3.length; _i++) {
85916             var diagnostic = diagnostics_3[_i];
85917             output += formatDiagnostic(diagnostic, host);
85918         }
85919         return output;
85920     }
85921     ts.formatDiagnostics = formatDiagnostics;
85922     function formatDiagnostic(diagnostic, host) {
85923         var errorMessage = ts.diagnosticCategoryName(diagnostic) + " TS" + diagnostic.code + ": " + flattenDiagnosticMessageText(diagnostic.messageText, host.getNewLine()) + host.getNewLine();
85924         if (diagnostic.file) {
85925             var _a = ts.getLineAndCharacterOfPosition(diagnostic.file, diagnostic.start), line = _a.line, character = _a.character;
85926             var fileName = diagnostic.file.fileName;
85927             var relativeFileName = ts.convertToRelativePath(fileName, host.getCurrentDirectory(), function (fileName) { return host.getCanonicalFileName(fileName); });
85928             return relativeFileName + "(" + (line + 1) + "," + (character + 1) + "): " + errorMessage;
85929         }
85930         return errorMessage;
85931     }
85932     ts.formatDiagnostic = formatDiagnostic;
85933     var ForegroundColorEscapeSequences;
85934     (function (ForegroundColorEscapeSequences) {
85935         ForegroundColorEscapeSequences["Grey"] = "\u001B[90m";
85936         ForegroundColorEscapeSequences["Red"] = "\u001B[91m";
85937         ForegroundColorEscapeSequences["Yellow"] = "\u001B[93m";
85938         ForegroundColorEscapeSequences["Blue"] = "\u001B[94m";
85939         ForegroundColorEscapeSequences["Cyan"] = "\u001B[96m";
85940     })(ForegroundColorEscapeSequences = ts.ForegroundColorEscapeSequences || (ts.ForegroundColorEscapeSequences = {}));
85941     var gutterStyleSequence = "\u001b[7m";
85942     var gutterSeparator = " ";
85943     var resetEscapeSequence = "\u001b[0m";
85944     var ellipsis = "...";
85945     var halfIndent = "  ";
85946     var indent = "    ";
85947     function getCategoryFormat(category) {
85948         switch (category) {
85949             case ts.DiagnosticCategory.Error: return ForegroundColorEscapeSequences.Red;
85950             case ts.DiagnosticCategory.Warning: return ForegroundColorEscapeSequences.Yellow;
85951             case ts.DiagnosticCategory.Suggestion: return ts.Debug.fail("Should never get an Info diagnostic on the command line.");
85952             case ts.DiagnosticCategory.Message: return ForegroundColorEscapeSequences.Blue;
85953         }
85954     }
85955     function formatColorAndReset(text, formatStyle) {
85956         return formatStyle + text + resetEscapeSequence;
85957     }
85958     ts.formatColorAndReset = formatColorAndReset;
85959     function formatCodeSpan(file, start, length, indent, squiggleColor, host) {
85960         var _a = ts.getLineAndCharacterOfPosition(file, start), firstLine = _a.line, firstLineChar = _a.character;
85961         var _b = ts.getLineAndCharacterOfPosition(file, start + length), lastLine = _b.line, lastLineChar = _b.character;
85962         var lastLineInFile = ts.getLineAndCharacterOfPosition(file, file.text.length).line;
85963         var hasMoreThanFiveLines = (lastLine - firstLine) >= 4;
85964         var gutterWidth = (lastLine + 1 + "").length;
85965         if (hasMoreThanFiveLines) {
85966             gutterWidth = Math.max(ellipsis.length, gutterWidth);
85967         }
85968         var context = "";
85969         for (var i = firstLine; i <= lastLine; i++) {
85970             context += host.getNewLine();
85971             if (hasMoreThanFiveLines && firstLine + 1 < i && i < lastLine - 1) {
85972                 context += indent + formatColorAndReset(ts.padLeft(ellipsis, gutterWidth), gutterStyleSequence) + gutterSeparator + host.getNewLine();
85973                 i = lastLine - 1;
85974             }
85975             var lineStart = ts.getPositionOfLineAndCharacter(file, i, 0);
85976             var lineEnd = i < lastLineInFile ? ts.getPositionOfLineAndCharacter(file, i + 1, 0) : file.text.length;
85977             var lineContent = file.text.slice(lineStart, lineEnd);
85978             lineContent = lineContent.replace(/\s+$/g, "");
85979             lineContent = lineContent.replace("\t", " ");
85980             context += indent + formatColorAndReset(ts.padLeft(i + 1 + "", gutterWidth), gutterStyleSequence) + gutterSeparator;
85981             context += lineContent + host.getNewLine();
85982             context += indent + formatColorAndReset(ts.padLeft("", gutterWidth), gutterStyleSequence) + gutterSeparator;
85983             context += squiggleColor;
85984             if (i === firstLine) {
85985                 var lastCharForLine = i === lastLine ? lastLineChar : undefined;
85986                 context += lineContent.slice(0, firstLineChar).replace(/\S/g, " ");
85987                 context += lineContent.slice(firstLineChar, lastCharForLine).replace(/./g, "~");
85988             }
85989             else if (i === lastLine) {
85990                 context += lineContent.slice(0, lastLineChar).replace(/./g, "~");
85991             }
85992             else {
85993                 context += lineContent.replace(/./g, "~");
85994             }
85995             context += resetEscapeSequence;
85996         }
85997         return context;
85998     }
85999     function formatLocation(file, start, host, color) {
86000         if (color === void 0) { color = formatColorAndReset; }
86001         var _a = ts.getLineAndCharacterOfPosition(file, start), firstLine = _a.line, firstLineChar = _a.character;
86002         var relativeFileName = host ? ts.convertToRelativePath(file.fileName, host.getCurrentDirectory(), function (fileName) { return host.getCanonicalFileName(fileName); }) : file.fileName;
86003         var output = "";
86004         output += color(relativeFileName, ForegroundColorEscapeSequences.Cyan);
86005         output += ":";
86006         output += color("" + (firstLine + 1), ForegroundColorEscapeSequences.Yellow);
86007         output += ":";
86008         output += color("" + (firstLineChar + 1), ForegroundColorEscapeSequences.Yellow);
86009         return output;
86010     }
86011     ts.formatLocation = formatLocation;
86012     function formatDiagnosticsWithColorAndContext(diagnostics, host) {
86013         var output = "";
86014         for (var _i = 0, diagnostics_4 = diagnostics; _i < diagnostics_4.length; _i++) {
86015             var diagnostic = diagnostics_4[_i];
86016             if (diagnostic.file) {
86017                 var file = diagnostic.file, start = diagnostic.start;
86018                 output += formatLocation(file, start, host);
86019                 output += " - ";
86020             }
86021             output += formatColorAndReset(ts.diagnosticCategoryName(diagnostic), getCategoryFormat(diagnostic.category));
86022             output += formatColorAndReset(" TS" + diagnostic.code + ": ", ForegroundColorEscapeSequences.Grey);
86023             output += flattenDiagnosticMessageText(diagnostic.messageText, host.getNewLine());
86024             if (diagnostic.file) {
86025                 output += host.getNewLine();
86026                 output += formatCodeSpan(diagnostic.file, diagnostic.start, diagnostic.length, "", getCategoryFormat(diagnostic.category), host);
86027                 if (diagnostic.relatedInformation) {
86028                     output += host.getNewLine();
86029                     for (var _a = 0, _b = diagnostic.relatedInformation; _a < _b.length; _a++) {
86030                         var _c = _b[_a], file = _c.file, start = _c.start, length_8 = _c.length, messageText = _c.messageText;
86031                         if (file) {
86032                             output += host.getNewLine();
86033                             output += halfIndent + formatLocation(file, start, host);
86034                             output += formatCodeSpan(file, start, length_8, indent, ForegroundColorEscapeSequences.Cyan, host);
86035                         }
86036                         output += host.getNewLine();
86037                         output += indent + flattenDiagnosticMessageText(messageText, host.getNewLine());
86038                     }
86039                 }
86040             }
86041             output += host.getNewLine();
86042         }
86043         return output;
86044     }
86045     ts.formatDiagnosticsWithColorAndContext = formatDiagnosticsWithColorAndContext;
86046     function flattenDiagnosticMessageText(diag, newLine, indent) {
86047         if (indent === void 0) { indent = 0; }
86048         if (ts.isString(diag)) {
86049             return diag;
86050         }
86051         else if (diag === undefined) {
86052             return "";
86053         }
86054         var result = "";
86055         if (indent) {
86056             result += newLine;
86057             for (var i = 0; i < indent; i++) {
86058                 result += "  ";
86059             }
86060         }
86061         result += diag.messageText;
86062         indent++;
86063         if (diag.next) {
86064             for (var _i = 0, _a = diag.next; _i < _a.length; _i++) {
86065                 var kid = _a[_i];
86066                 result += flattenDiagnosticMessageText(kid, newLine, indent);
86067             }
86068         }
86069         return result;
86070     }
86071     ts.flattenDiagnosticMessageText = flattenDiagnosticMessageText;
86072     function loadWithLocalCache(names, containingFile, redirectedReference, loader) {
86073         if (names.length === 0) {
86074             return [];
86075         }
86076         var resolutions = [];
86077         var cache = new ts.Map();
86078         for (var _i = 0, names_2 = names; _i < names_2.length; _i++) {
86079             var name = names_2[_i];
86080             var result = void 0;
86081             if (cache.has(name)) {
86082                 result = cache.get(name);
86083             }
86084             else {
86085                 cache.set(name, result = loader(name, containingFile, redirectedReference));
86086             }
86087             resolutions.push(result);
86088         }
86089         return resolutions;
86090     }
86091     ts.loadWithLocalCache = loadWithLocalCache;
86092     function forEachResolvedProjectReference(resolvedProjectReferences, cb) {
86093         return forEachProjectReference(undefined, resolvedProjectReferences, function (resolvedRef, parent) { return resolvedRef && cb(resolvedRef, parent); });
86094     }
86095     ts.forEachResolvedProjectReference = forEachResolvedProjectReference;
86096     function forEachProjectReference(projectReferences, resolvedProjectReferences, cbResolvedRef, cbRef) {
86097         var seenResolvedRefs;
86098         return worker(projectReferences, resolvedProjectReferences, undefined);
86099         function worker(projectReferences, resolvedProjectReferences, parent) {
86100             if (cbRef) {
86101                 var result = cbRef(projectReferences, parent);
86102                 if (result) {
86103                     return result;
86104                 }
86105             }
86106             return ts.forEach(resolvedProjectReferences, function (resolvedRef, index) {
86107                 if (resolvedRef && (seenResolvedRefs === null || seenResolvedRefs === void 0 ? void 0 : seenResolvedRefs.has(resolvedRef.sourceFile.path))) {
86108                     return undefined;
86109                 }
86110                 var result = cbResolvedRef(resolvedRef, parent, index);
86111                 if (result || !resolvedRef)
86112                     return result;
86113                 (seenResolvedRefs || (seenResolvedRefs = new ts.Set())).add(resolvedRef.sourceFile.path);
86114                 return worker(resolvedRef.commandLine.projectReferences, resolvedRef.references, resolvedRef);
86115             });
86116         }
86117     }
86118     ts.inferredTypesContainingFile = "__inferred type names__.ts";
86119     function isProgramUptoDate(program, rootFileNames, newOptions, getSourceVersion, fileExists, hasInvalidatedResolution, hasChangedAutomaticTypeDirectiveNames, projectReferences) {
86120         if (!program || (hasChangedAutomaticTypeDirectiveNames === null || hasChangedAutomaticTypeDirectiveNames === void 0 ? void 0 : hasChangedAutomaticTypeDirectiveNames())) {
86121             return false;
86122         }
86123         if (!ts.arrayIsEqualTo(program.getRootFileNames(), rootFileNames)) {
86124             return false;
86125         }
86126         var seenResolvedRefs;
86127         if (!ts.arrayIsEqualTo(program.getProjectReferences(), projectReferences, projectReferenceUptoDate)) {
86128             return false;
86129         }
86130         if (program.getSourceFiles().some(sourceFileNotUptoDate)) {
86131             return false;
86132         }
86133         if (program.getMissingFilePaths().some(fileExists)) {
86134             return false;
86135         }
86136         var currentOptions = program.getCompilerOptions();
86137         if (!ts.compareDataObjects(currentOptions, newOptions)) {
86138             return false;
86139         }
86140         if (currentOptions.configFile && newOptions.configFile) {
86141             return currentOptions.configFile.text === newOptions.configFile.text;
86142         }
86143         return true;
86144         function sourceFileNotUptoDate(sourceFile) {
86145             return !sourceFileVersionUptoDate(sourceFile) ||
86146                 hasInvalidatedResolution(sourceFile.path);
86147         }
86148         function sourceFileVersionUptoDate(sourceFile) {
86149             return sourceFile.version === getSourceVersion(sourceFile.resolvedPath, sourceFile.fileName);
86150         }
86151         function projectReferenceUptoDate(oldRef, newRef, index) {
86152             if (!ts.projectReferenceIsEqualTo(oldRef, newRef)) {
86153                 return false;
86154             }
86155             return resolvedProjectReferenceUptoDate(program.getResolvedProjectReferences()[index], oldRef);
86156         }
86157         function resolvedProjectReferenceUptoDate(oldResolvedRef, oldRef) {
86158             if (oldResolvedRef) {
86159                 if (ts.contains(seenResolvedRefs, oldResolvedRef)) {
86160                     return true;
86161                 }
86162                 if (!sourceFileVersionUptoDate(oldResolvedRef.sourceFile)) {
86163                     return false;
86164                 }
86165                 (seenResolvedRefs || (seenResolvedRefs = [])).push(oldResolvedRef);
86166                 return !ts.forEach(oldResolvedRef.references, function (childResolvedRef, index) {
86167                     return !resolvedProjectReferenceUptoDate(childResolvedRef, oldResolvedRef.commandLine.projectReferences[index]);
86168                 });
86169             }
86170             return !fileExists(resolveProjectReferencePath(oldRef));
86171         }
86172     }
86173     ts.isProgramUptoDate = isProgramUptoDate;
86174     function getConfigFileParsingDiagnostics(configFileParseResult) {
86175         return configFileParseResult.options.configFile ? __spreadArrays(configFileParseResult.options.configFile.parseDiagnostics, configFileParseResult.errors) :
86176             configFileParseResult.errors;
86177     }
86178     ts.getConfigFileParsingDiagnostics = getConfigFileParsingDiagnostics;
86179     function shouldProgramCreateNewSourceFiles(program, newOptions) {
86180         if (!program)
86181             return false;
86182         var oldOptions = program.getCompilerOptions();
86183         return !!ts.sourceFileAffectingCompilerOptions.some(function (option) {
86184             return !ts.isJsonEqual(ts.getCompilerOptionValue(oldOptions, option), ts.getCompilerOptionValue(newOptions, option));
86185         });
86186     }
86187     function createCreateProgramOptions(rootNames, options, host, oldProgram, configFileParsingDiagnostics) {
86188         return {
86189             rootNames: rootNames,
86190             options: options,
86191             host: host,
86192             oldProgram: oldProgram,
86193             configFileParsingDiagnostics: configFileParsingDiagnostics
86194         };
86195     }
86196     function createProgram(rootNamesOrOptions, _options, _host, _oldProgram, _configFileParsingDiagnostics) {
86197         var _a, _b;
86198         var createProgramOptions = ts.isArray(rootNamesOrOptions) ? createCreateProgramOptions(rootNamesOrOptions, _options, _host, _oldProgram, _configFileParsingDiagnostics) : rootNamesOrOptions;
86199         var rootNames = createProgramOptions.rootNames, options = createProgramOptions.options, configFileParsingDiagnostics = createProgramOptions.configFileParsingDiagnostics, projectReferences = createProgramOptions.projectReferences;
86200         var oldProgram = createProgramOptions.oldProgram;
86201         var processingDefaultLibFiles;
86202         var processingOtherFiles;
86203         var files;
86204         var symlinks;
86205         var commonSourceDirectory;
86206         var diagnosticsProducingTypeChecker;
86207         var noDiagnosticsTypeChecker;
86208         var classifiableNames;
86209         var ambientModuleNameToUnmodifiedFileName = new ts.Map();
86210         var refFileMap;
86211         var cachedBindAndCheckDiagnosticsForFile = {};
86212         var cachedDeclarationDiagnosticsForFile = {};
86213         var resolvedTypeReferenceDirectives = new ts.Map();
86214         var fileProcessingDiagnostics = ts.createDiagnosticCollection();
86215         var maxNodeModuleJsDepth = typeof options.maxNodeModuleJsDepth === "number" ? options.maxNodeModuleJsDepth : 0;
86216         var currentNodeModulesDepth = 0;
86217         var modulesWithElidedImports = new ts.Map();
86218         var sourceFilesFoundSearchingNodeModules = new ts.Map();
86219         var tracingData = ["program", "createProgram"];
86220         ts.tracing.begin.apply(ts.tracing, tracingData);
86221         ts.performance.mark("beforeProgram");
86222         var host = createProgramOptions.host || createCompilerHost(options);
86223         var configParsingHost = parseConfigHostFromCompilerHostLike(host);
86224         var skipDefaultLib = options.noLib;
86225         var getDefaultLibraryFileName = ts.memoize(function () { return host.getDefaultLibFileName(options); });
86226         var defaultLibraryPath = host.getDefaultLibLocation ? host.getDefaultLibLocation() : ts.getDirectoryPath(getDefaultLibraryFileName());
86227         var programDiagnostics = ts.createDiagnosticCollection();
86228         var currentDirectory = host.getCurrentDirectory();
86229         var supportedExtensions = ts.getSupportedExtensions(options);
86230         var supportedExtensionsWithJsonIfResolveJsonModule = ts.getSuppoertedExtensionsWithJsonIfResolveJsonModule(options, supportedExtensions);
86231         var hasEmitBlockingDiagnostics = new ts.Map();
86232         var _compilerOptionsObjectLiteralSyntax;
86233         var moduleResolutionCache;
86234         var actualResolveModuleNamesWorker;
86235         var hasInvalidatedResolution = host.hasInvalidatedResolution || ts.returnFalse;
86236         if (host.resolveModuleNames) {
86237             actualResolveModuleNamesWorker = function (moduleNames, containingFile, reusedNames, redirectedReference) { return host.resolveModuleNames(ts.Debug.checkEachDefined(moduleNames), containingFile, reusedNames, redirectedReference, options).map(function (resolved) {
86238                 if (!resolved || resolved.extension !== undefined) {
86239                     return resolved;
86240                 }
86241                 var withExtension = ts.clone(resolved);
86242                 withExtension.extension = ts.extensionFromPath(resolved.resolvedFileName);
86243                 return withExtension;
86244             }); };
86245         }
86246         else {
86247             moduleResolutionCache = ts.createModuleResolutionCache(currentDirectory, function (x) { return host.getCanonicalFileName(x); }, options);
86248             var loader_1 = function (moduleName, containingFile, redirectedReference) { return ts.resolveModuleName(moduleName, containingFile, options, host, moduleResolutionCache, redirectedReference).resolvedModule; };
86249             actualResolveModuleNamesWorker = function (moduleNames, containingFile, _reusedNames, redirectedReference) { return loadWithLocalCache(ts.Debug.checkEachDefined(moduleNames), containingFile, redirectedReference, loader_1); };
86250         }
86251         var actualResolveTypeReferenceDirectiveNamesWorker;
86252         if (host.resolveTypeReferenceDirectives) {
86253             actualResolveTypeReferenceDirectiveNamesWorker = function (typeDirectiveNames, containingFile, redirectedReference) { return host.resolveTypeReferenceDirectives(ts.Debug.checkEachDefined(typeDirectiveNames), containingFile, redirectedReference, options); };
86254         }
86255         else {
86256             var loader_2 = function (typesRef, containingFile, redirectedReference) { return ts.resolveTypeReferenceDirective(typesRef, containingFile, options, host, redirectedReference).resolvedTypeReferenceDirective; };
86257             actualResolveTypeReferenceDirectiveNamesWorker = function (typeReferenceDirectiveNames, containingFile, redirectedReference) { return loadWithLocalCache(ts.Debug.checkEachDefined(typeReferenceDirectiveNames), containingFile, redirectedReference, loader_2); };
86258         }
86259         var packageIdToSourceFile = new ts.Map();
86260         var sourceFileToPackageName = new ts.Map();
86261         var redirectTargetsMap = ts.createMultiMap();
86262         var filesByName = new ts.Map();
86263         var missingFilePaths;
86264         var filesByNameIgnoreCase = host.useCaseSensitiveFileNames() ? new ts.Map() : undefined;
86265         var resolvedProjectReferences;
86266         var projectReferenceRedirects;
86267         var mapFromFileToProjectReferenceRedirects;
86268         var mapFromToProjectReferenceRedirectSource;
86269         var useSourceOfProjectReferenceRedirect = !!((_a = host.useSourceOfProjectReferenceRedirect) === null || _a === void 0 ? void 0 : _a.call(host)) &&
86270             !options.disableSourceOfProjectReferenceRedirect;
86271         var _c = updateHostForUseSourceOfProjectReferenceRedirect({
86272             compilerHost: host,
86273             getSymlinkCache: getSymlinkCache,
86274             useSourceOfProjectReferenceRedirect: useSourceOfProjectReferenceRedirect,
86275             toPath: toPath,
86276             getResolvedProjectReferences: getResolvedProjectReferences,
86277             getSourceOfProjectReferenceRedirect: getSourceOfProjectReferenceRedirect,
86278             forEachResolvedProjectReference: forEachResolvedProjectReference
86279         }), onProgramCreateComplete = _c.onProgramCreateComplete, fileExists = _c.fileExists, directoryExists = _c.directoryExists;
86280         ts.tracing.push("program", "shouldProgramCreateNewSourceFiles", { hasOldProgram: !!oldProgram });
86281         var shouldCreateNewSourceFile = shouldProgramCreateNewSourceFiles(oldProgram, options);
86282         ts.tracing.pop();
86283         var structureIsReused;
86284         ts.tracing.push("program", "tryReuseStructureFromOldProgram", {});
86285         structureIsReused = tryReuseStructureFromOldProgram();
86286         ts.tracing.pop();
86287         if (structureIsReused !== 2) {
86288             processingDefaultLibFiles = [];
86289             processingOtherFiles = [];
86290             if (projectReferences) {
86291                 if (!resolvedProjectReferences) {
86292                     resolvedProjectReferences = projectReferences.map(parseProjectReferenceConfigFile);
86293                 }
86294                 if (rootNames.length) {
86295                     for (var _i = 0, resolvedProjectReferences_1 = resolvedProjectReferences; _i < resolvedProjectReferences_1.length; _i++) {
86296                         var parsedRef = resolvedProjectReferences_1[_i];
86297                         if (!parsedRef)
86298                             continue;
86299                         var out = ts.outFile(parsedRef.commandLine.options);
86300                         if (useSourceOfProjectReferenceRedirect) {
86301                             if (out || ts.getEmitModuleKind(parsedRef.commandLine.options) === ts.ModuleKind.None) {
86302                                 for (var _d = 0, _e = parsedRef.commandLine.fileNames; _d < _e.length; _d++) {
86303                                     var fileName = _e[_d];
86304                                     processSourceFile(fileName, false, false, undefined);
86305                                 }
86306                             }
86307                         }
86308                         else {
86309                             if (out) {
86310                                 processSourceFile(ts.changeExtension(out, ".d.ts"), false, false, undefined);
86311                             }
86312                             else if (ts.getEmitModuleKind(parsedRef.commandLine.options) === ts.ModuleKind.None) {
86313                                 for (var _f = 0, _g = parsedRef.commandLine.fileNames; _f < _g.length; _f++) {
86314                                     var fileName = _g[_f];
86315                                     if (!ts.fileExtensionIs(fileName, ".d.ts") && !ts.fileExtensionIs(fileName, ".json")) {
86316                                         processSourceFile(ts.getOutputDeclarationFileName(fileName, parsedRef.commandLine, !host.useCaseSensitiveFileNames()), false, false, undefined);
86317                                     }
86318                                 }
86319                             }
86320                         }
86321                     }
86322                 }
86323             }
86324             ts.tracing.push("program", "processRootFiles", { count: rootNames.length });
86325             ts.forEach(rootNames, function (name) { return processRootFile(name, false, false); });
86326             ts.tracing.pop();
86327             var typeReferences = rootNames.length ? ts.getAutomaticTypeDirectiveNames(options, host) : ts.emptyArray;
86328             if (typeReferences.length) {
86329                 ts.tracing.push("program", "processTypeReferences", { count: typeReferences.length });
86330                 var containingDirectory = options.configFilePath ? ts.getDirectoryPath(options.configFilePath) : host.getCurrentDirectory();
86331                 var containingFilename = ts.combinePaths(containingDirectory, ts.inferredTypesContainingFile);
86332                 var resolutions = resolveTypeReferenceDirectiveNamesWorker(typeReferences, containingFilename);
86333                 for (var i = 0; i < typeReferences.length; i++) {
86334                     processTypeReferenceDirective(typeReferences[i], resolutions[i]);
86335                 }
86336                 ts.tracing.pop();
86337             }
86338             if (rootNames.length && !skipDefaultLib) {
86339                 var defaultLibraryFileName = getDefaultLibraryFileName();
86340                 if (!options.lib && defaultLibraryFileName) {
86341                     processRootFile(defaultLibraryFileName, true, false);
86342                 }
86343                 else {
86344                     ts.forEach(options.lib, function (libFileName) {
86345                         processRootFile(ts.combinePaths(defaultLibraryPath, libFileName), true, false);
86346                     });
86347                 }
86348             }
86349             missingFilePaths = ts.arrayFrom(ts.mapDefinedIterator(filesByName.entries(), function (_a) {
86350                 var path = _a[0], file = _a[1];
86351                 return file === undefined ? path : undefined;
86352             }));
86353             files = ts.stableSort(processingDefaultLibFiles, compareDefaultLibFiles).concat(processingOtherFiles);
86354             processingDefaultLibFiles = undefined;
86355             processingOtherFiles = undefined;
86356         }
86357         ts.Debug.assert(!!missingFilePaths);
86358         if (oldProgram && host.onReleaseOldSourceFile) {
86359             var oldSourceFiles = oldProgram.getSourceFiles();
86360             for (var _h = 0, oldSourceFiles_1 = oldSourceFiles; _h < oldSourceFiles_1.length; _h++) {
86361                 var oldSourceFile = oldSourceFiles_1[_h];
86362                 var newFile = getSourceFileByPath(oldSourceFile.resolvedPath);
86363                 if (shouldCreateNewSourceFile || !newFile ||
86364                     (oldSourceFile.resolvedPath === oldSourceFile.path && newFile.resolvedPath !== oldSourceFile.path)) {
86365                     host.onReleaseOldSourceFile(oldSourceFile, oldProgram.getCompilerOptions(), !!getSourceFileByPath(oldSourceFile.path));
86366                 }
86367             }
86368             oldProgram.forEachResolvedProjectReference(function (resolvedProjectReference) {
86369                 if (!getResolvedProjectReferenceByPath(resolvedProjectReference.sourceFile.path)) {
86370                     host.onReleaseOldSourceFile(resolvedProjectReference.sourceFile, oldProgram.getCompilerOptions(), false);
86371                 }
86372             });
86373         }
86374         oldProgram = undefined;
86375         var program = {
86376             getRootFileNames: function () { return rootNames; },
86377             getSourceFile: getSourceFile,
86378             getSourceFileByPath: getSourceFileByPath,
86379             getSourceFiles: function () { return files; },
86380             getMissingFilePaths: function () { return missingFilePaths; },
86381             getRefFileMap: function () { return refFileMap; },
86382             getFilesByNameMap: function () { return filesByName; },
86383             getCompilerOptions: function () { return options; },
86384             getSyntacticDiagnostics: getSyntacticDiagnostics,
86385             getOptionsDiagnostics: getOptionsDiagnostics,
86386             getGlobalDiagnostics: getGlobalDiagnostics,
86387             getSemanticDiagnostics: getSemanticDiagnostics,
86388             getCachedSemanticDiagnostics: getCachedSemanticDiagnostics,
86389             getSuggestionDiagnostics: getSuggestionDiagnostics,
86390             getDeclarationDiagnostics: getDeclarationDiagnostics,
86391             getBindAndCheckDiagnostics: getBindAndCheckDiagnostics,
86392             getProgramDiagnostics: getProgramDiagnostics,
86393             getTypeChecker: getTypeChecker,
86394             getClassifiableNames: getClassifiableNames,
86395             getDiagnosticsProducingTypeChecker: getDiagnosticsProducingTypeChecker,
86396             getCommonSourceDirectory: getCommonSourceDirectory,
86397             emit: emit,
86398             getCurrentDirectory: function () { return currentDirectory; },
86399             getNodeCount: function () { return getDiagnosticsProducingTypeChecker().getNodeCount(); },
86400             getIdentifierCount: function () { return getDiagnosticsProducingTypeChecker().getIdentifierCount(); },
86401             getSymbolCount: function () { return getDiagnosticsProducingTypeChecker().getSymbolCount(); },
86402             getTypeCatalog: function () { return getDiagnosticsProducingTypeChecker().getTypeCatalog(); },
86403             getTypeCount: function () { return getDiagnosticsProducingTypeChecker().getTypeCount(); },
86404             getInstantiationCount: function () { return getDiagnosticsProducingTypeChecker().getInstantiationCount(); },
86405             getRelationCacheSizes: function () { return getDiagnosticsProducingTypeChecker().getRelationCacheSizes(); },
86406             getFileProcessingDiagnostics: function () { return fileProcessingDiagnostics; },
86407             getResolvedTypeReferenceDirectives: function () { return resolvedTypeReferenceDirectives; },
86408             isSourceFileFromExternalLibrary: isSourceFileFromExternalLibrary,
86409             isSourceFileDefaultLibrary: isSourceFileDefaultLibrary,
86410             dropDiagnosticsProducingTypeChecker: dropDiagnosticsProducingTypeChecker,
86411             getSourceFileFromReference: getSourceFileFromReference,
86412             getLibFileFromReference: getLibFileFromReference,
86413             sourceFileToPackageName: sourceFileToPackageName,
86414             redirectTargetsMap: redirectTargetsMap,
86415             isEmittedFile: isEmittedFile,
86416             getConfigFileParsingDiagnostics: getConfigFileParsingDiagnostics,
86417             getResolvedModuleWithFailedLookupLocationsFromCache: getResolvedModuleWithFailedLookupLocationsFromCache,
86418             getProjectReferences: getProjectReferences,
86419             getResolvedProjectReferences: getResolvedProjectReferences,
86420             getProjectReferenceRedirect: getProjectReferenceRedirect,
86421             getResolvedProjectReferenceToRedirect: getResolvedProjectReferenceToRedirect,
86422             getResolvedProjectReferenceByPath: getResolvedProjectReferenceByPath,
86423             forEachResolvedProjectReference: forEachResolvedProjectReference,
86424             isSourceOfProjectReferenceRedirect: isSourceOfProjectReferenceRedirect,
86425             emitBuildInfo: emitBuildInfo,
86426             fileExists: fileExists,
86427             directoryExists: directoryExists,
86428             getSymlinkCache: getSymlinkCache,
86429             realpath: (_b = host.realpath) === null || _b === void 0 ? void 0 : _b.bind(host),
86430             useCaseSensitiveFileNames: function () { return host.useCaseSensitiveFileNames(); },
86431             structureIsReused: structureIsReused,
86432         };
86433         onProgramCreateComplete();
86434         verifyCompilerOptions();
86435         ts.performance.mark("afterProgram");
86436         ts.performance.measure("Program", "beforeProgram", "afterProgram");
86437         ts.tracing.end.apply(ts.tracing, tracingData);
86438         return program;
86439         function resolveModuleNamesWorker(moduleNames, containingFile, reusedNames) {
86440             if (!moduleNames.length)
86441                 return ts.emptyArray;
86442             var containingFileName = ts.getNormalizedAbsolutePath(containingFile.originalFileName, currentDirectory);
86443             var redirectedReference = getRedirectReferenceForResolution(containingFile);
86444             ts.tracing.push("program", "resolveModuleNamesWorker", { containingFileName: containingFileName });
86445             ts.performance.mark("beforeResolveModule");
86446             var result = actualResolveModuleNamesWorker(moduleNames, containingFileName, reusedNames, redirectedReference);
86447             ts.performance.mark("afterResolveModule");
86448             ts.performance.measure("ResolveModule", "beforeResolveModule", "afterResolveModule");
86449             ts.tracing.pop();
86450             return result;
86451         }
86452         function resolveTypeReferenceDirectiveNamesWorker(typeDirectiveNames, containingFile) {
86453             if (!typeDirectiveNames.length)
86454                 return [];
86455             var containingFileName = !ts.isString(containingFile) ? ts.getNormalizedAbsolutePath(containingFile.originalFileName, currentDirectory) : containingFile;
86456             var redirectedReference = !ts.isString(containingFile) ? getRedirectReferenceForResolution(containingFile) : undefined;
86457             ts.tracing.push("program", "resolveTypeReferenceDirectiveNamesWorker", { containingFileName: containingFileName });
86458             ts.performance.mark("beforeResolveTypeReference");
86459             var result = actualResolveTypeReferenceDirectiveNamesWorker(typeDirectiveNames, containingFileName, redirectedReference);
86460             ts.performance.mark("afterResolveTypeReference");
86461             ts.performance.measure("ResolveTypeReference", "beforeResolveTypeReference", "afterResolveTypeReference");
86462             ts.tracing.pop();
86463             return result;
86464         }
86465         function getRedirectReferenceForResolution(file) {
86466             var redirect = getResolvedProjectReferenceToRedirect(file.originalFileName);
86467             if (redirect || !ts.fileExtensionIs(file.originalFileName, ".d.ts"))
86468                 return redirect;
86469             var resultFromDts = getRedirectReferenceForResolutionFromSourceOfProject(file.originalFileName, file.path);
86470             if (resultFromDts)
86471                 return resultFromDts;
86472             if (!host.realpath || !options.preserveSymlinks || !ts.stringContains(file.originalFileName, ts.nodeModulesPathPart))
86473                 return undefined;
86474             var realDeclarationFileName = host.realpath(file.originalFileName);
86475             var realDeclarationPath = toPath(realDeclarationFileName);
86476             return realDeclarationPath === file.path ? undefined : getRedirectReferenceForResolutionFromSourceOfProject(realDeclarationFileName, realDeclarationPath);
86477         }
86478         function getRedirectReferenceForResolutionFromSourceOfProject(fileName, filePath) {
86479             var source = getSourceOfProjectReferenceRedirect(fileName);
86480             if (ts.isString(source))
86481                 return getResolvedProjectReferenceToRedirect(source);
86482             if (!source)
86483                 return undefined;
86484             return forEachResolvedProjectReference(function (resolvedRef) {
86485                 var out = ts.outFile(resolvedRef.commandLine.options);
86486                 if (!out)
86487                     return undefined;
86488                 return toPath(out) === filePath ? resolvedRef : undefined;
86489             });
86490         }
86491         function compareDefaultLibFiles(a, b) {
86492             return ts.compareValues(getDefaultLibFilePriority(a), getDefaultLibFilePriority(b));
86493         }
86494         function getDefaultLibFilePriority(a) {
86495             if (ts.containsPath(defaultLibraryPath, a.fileName, false)) {
86496                 var basename = ts.getBaseFileName(a.fileName);
86497                 if (basename === "lib.d.ts" || basename === "lib.es6.d.ts")
86498                     return 0;
86499                 var name = ts.removeSuffix(ts.removePrefix(basename, "lib."), ".d.ts");
86500                 var index = ts.libs.indexOf(name);
86501                 if (index !== -1)
86502                     return index + 1;
86503             }
86504             return ts.libs.length + 2;
86505         }
86506         function getResolvedModuleWithFailedLookupLocationsFromCache(moduleName, containingFile) {
86507             return moduleResolutionCache && ts.resolveModuleNameFromCache(moduleName, containingFile, moduleResolutionCache);
86508         }
86509         function toPath(fileName) {
86510             return ts.toPath(fileName, currentDirectory, getCanonicalFileName);
86511         }
86512         function getCommonSourceDirectory() {
86513             if (commonSourceDirectory === undefined) {
86514                 var emittedFiles = ts.filter(files, function (file) { return ts.sourceFileMayBeEmitted(file, program); });
86515                 if (options.rootDir && checkSourceFilesBelongToPath(emittedFiles, options.rootDir)) {
86516                     commonSourceDirectory = ts.getNormalizedAbsolutePath(options.rootDir, currentDirectory);
86517                 }
86518                 else if (options.composite && options.configFilePath) {
86519                     commonSourceDirectory = ts.getDirectoryPath(ts.normalizeSlashes(options.configFilePath));
86520                     checkSourceFilesBelongToPath(emittedFiles, commonSourceDirectory);
86521                 }
86522                 else {
86523                     commonSourceDirectory = computeCommonSourceDirectory(emittedFiles);
86524                 }
86525                 if (commonSourceDirectory && commonSourceDirectory[commonSourceDirectory.length - 1] !== ts.directorySeparator) {
86526                     commonSourceDirectory += ts.directorySeparator;
86527                 }
86528             }
86529             return commonSourceDirectory;
86530         }
86531         function getClassifiableNames() {
86532             var _a;
86533             if (!classifiableNames) {
86534                 getTypeChecker();
86535                 classifiableNames = new ts.Set();
86536                 for (var _i = 0, files_2 = files; _i < files_2.length; _i++) {
86537                     var sourceFile = files_2[_i];
86538                     (_a = sourceFile.classifiableNames) === null || _a === void 0 ? void 0 : _a.forEach(function (value) { return classifiableNames.add(value); });
86539                 }
86540             }
86541             return classifiableNames;
86542         }
86543         function resolveModuleNamesReusingOldState(moduleNames, file) {
86544             if (structureIsReused === 0 && !file.ambientModuleNames.length) {
86545                 return resolveModuleNamesWorker(moduleNames, file, undefined);
86546             }
86547             var oldSourceFile = oldProgram && oldProgram.getSourceFile(file.fileName);
86548             if (oldSourceFile !== file && file.resolvedModules) {
86549                 var result_14 = [];
86550                 for (var _i = 0, moduleNames_1 = moduleNames; _i < moduleNames_1.length; _i++) {
86551                     var moduleName = moduleNames_1[_i];
86552                     var resolvedModule = file.resolvedModules.get(moduleName);
86553                     result_14.push(resolvedModule);
86554                 }
86555                 return result_14;
86556             }
86557             var unknownModuleNames;
86558             var result;
86559             var reusedNames;
86560             var predictedToResolveToAmbientModuleMarker = {};
86561             for (var i = 0; i < moduleNames.length; i++) {
86562                 var moduleName = moduleNames[i];
86563                 if (file === oldSourceFile && !hasInvalidatedResolution(oldSourceFile.path)) {
86564                     var oldResolvedModule = ts.getResolvedModule(oldSourceFile, moduleName);
86565                     if (oldResolvedModule) {
86566                         if (ts.isTraceEnabled(options, host)) {
86567                             ts.trace(host, ts.Diagnostics.Reusing_resolution_of_module_0_to_file_1_from_old_program, moduleName, ts.getNormalizedAbsolutePath(file.originalFileName, currentDirectory));
86568                         }
86569                         (result || (result = new Array(moduleNames.length)))[i] = oldResolvedModule;
86570                         (reusedNames || (reusedNames = [])).push(moduleName);
86571                         continue;
86572                     }
86573                 }
86574                 var resolvesToAmbientModuleInNonModifiedFile = false;
86575                 if (ts.contains(file.ambientModuleNames, moduleName)) {
86576                     resolvesToAmbientModuleInNonModifiedFile = true;
86577                     if (ts.isTraceEnabled(options, host)) {
86578                         ts.trace(host, ts.Diagnostics.Module_0_was_resolved_as_locally_declared_ambient_module_in_file_1, moduleName, ts.getNormalizedAbsolutePath(file.originalFileName, currentDirectory));
86579                     }
86580                 }
86581                 else {
86582                     resolvesToAmbientModuleInNonModifiedFile = moduleNameResolvesToAmbientModuleInNonModifiedFile(moduleName);
86583                 }
86584                 if (resolvesToAmbientModuleInNonModifiedFile) {
86585                     (result || (result = new Array(moduleNames.length)))[i] = predictedToResolveToAmbientModuleMarker;
86586                 }
86587                 else {
86588                     (unknownModuleNames || (unknownModuleNames = [])).push(moduleName);
86589                 }
86590             }
86591             var resolutions = unknownModuleNames && unknownModuleNames.length
86592                 ? resolveModuleNamesWorker(unknownModuleNames, file, reusedNames)
86593                 : ts.emptyArray;
86594             if (!result) {
86595                 ts.Debug.assert(resolutions.length === moduleNames.length);
86596                 return resolutions;
86597             }
86598             var j = 0;
86599             for (var i = 0; i < result.length; i++) {
86600                 if (result[i]) {
86601                     if (result[i] === predictedToResolveToAmbientModuleMarker) {
86602                         result[i] = undefined;
86603                     }
86604                 }
86605                 else {
86606                     result[i] = resolutions[j];
86607                     j++;
86608                 }
86609             }
86610             ts.Debug.assert(j === resolutions.length);
86611             return result;
86612             function moduleNameResolvesToAmbientModuleInNonModifiedFile(moduleName) {
86613                 var resolutionToFile = ts.getResolvedModule(oldSourceFile, moduleName);
86614                 var resolvedFile = resolutionToFile && oldProgram.getSourceFile(resolutionToFile.resolvedFileName);
86615                 if (resolutionToFile && resolvedFile) {
86616                     return false;
86617                 }
86618                 var unmodifiedFile = ambientModuleNameToUnmodifiedFileName.get(moduleName);
86619                 if (!unmodifiedFile) {
86620                     return false;
86621                 }
86622                 if (ts.isTraceEnabled(options, host)) {
86623                     ts.trace(host, ts.Diagnostics.Module_0_was_resolved_as_ambient_module_declared_in_1_since_this_file_was_not_modified, moduleName, unmodifiedFile);
86624                 }
86625                 return true;
86626             }
86627         }
86628         function canReuseProjectReferences() {
86629             return !forEachProjectReference(oldProgram.getProjectReferences(), oldProgram.getResolvedProjectReferences(), function (oldResolvedRef, parent, index) {
86630                 var newRef = (parent ? parent.commandLine.projectReferences : projectReferences)[index];
86631                 var newResolvedRef = parseProjectReferenceConfigFile(newRef);
86632                 if (oldResolvedRef) {
86633                     return !newResolvedRef || newResolvedRef.sourceFile !== oldResolvedRef.sourceFile;
86634                 }
86635                 else {
86636                     return newResolvedRef !== undefined;
86637                 }
86638             }, function (oldProjectReferences, parent) {
86639                 var newReferences = parent ? getResolvedProjectReferenceByPath(parent.sourceFile.path).commandLine.projectReferences : projectReferences;
86640                 return !ts.arrayIsEqualTo(oldProjectReferences, newReferences, ts.projectReferenceIsEqualTo);
86641             });
86642         }
86643         function tryReuseStructureFromOldProgram() {
86644             var _a;
86645             if (!oldProgram) {
86646                 return 0;
86647             }
86648             var oldOptions = oldProgram.getCompilerOptions();
86649             if (ts.changesAffectModuleResolution(oldOptions, options)) {
86650                 return 0;
86651             }
86652             var oldRootNames = oldProgram.getRootFileNames();
86653             if (!ts.arrayIsEqualTo(oldRootNames, rootNames)) {
86654                 return 0;
86655             }
86656             if (!ts.arrayIsEqualTo(options.types, oldOptions.types)) {
86657                 return 0;
86658             }
86659             if (!canReuseProjectReferences()) {
86660                 return 0;
86661             }
86662             if (projectReferences) {
86663                 resolvedProjectReferences = projectReferences.map(parseProjectReferenceConfigFile);
86664             }
86665             var newSourceFiles = [];
86666             var modifiedSourceFiles = [];
86667             structureIsReused = 2;
86668             if (oldProgram.getMissingFilePaths().some(function (missingFilePath) { return host.fileExists(missingFilePath); })) {
86669                 return 0;
86670             }
86671             var oldSourceFiles = oldProgram.getSourceFiles();
86672             var seenPackageNames = new ts.Map();
86673             for (var _i = 0, oldSourceFiles_2 = oldSourceFiles; _i < oldSourceFiles_2.length; _i++) {
86674                 var oldSourceFile = oldSourceFiles_2[_i];
86675                 var newSourceFile = host.getSourceFileByPath
86676                     ? host.getSourceFileByPath(oldSourceFile.fileName, oldSourceFile.resolvedPath, options.target, undefined, shouldCreateNewSourceFile)
86677                     : host.getSourceFile(oldSourceFile.fileName, options.target, undefined, shouldCreateNewSourceFile);
86678                 if (!newSourceFile) {
86679                     return 0;
86680                 }
86681                 ts.Debug.assert(!newSourceFile.redirectInfo, "Host should not return a redirect source file from `getSourceFile`");
86682                 var fileChanged = void 0;
86683                 if (oldSourceFile.redirectInfo) {
86684                     if (newSourceFile !== oldSourceFile.redirectInfo.unredirected) {
86685                         return 0;
86686                     }
86687                     fileChanged = false;
86688                     newSourceFile = oldSourceFile;
86689                 }
86690                 else if (oldProgram.redirectTargetsMap.has(oldSourceFile.path)) {
86691                     if (newSourceFile !== oldSourceFile) {
86692                         return 0;
86693                     }
86694                     fileChanged = false;
86695                 }
86696                 else {
86697                     fileChanged = newSourceFile !== oldSourceFile;
86698                 }
86699                 newSourceFile.path = oldSourceFile.path;
86700                 newSourceFile.originalFileName = oldSourceFile.originalFileName;
86701                 newSourceFile.resolvedPath = oldSourceFile.resolvedPath;
86702                 newSourceFile.fileName = oldSourceFile.fileName;
86703                 var packageName = oldProgram.sourceFileToPackageName.get(oldSourceFile.path);
86704                 if (packageName !== undefined) {
86705                     var prevKind = seenPackageNames.get(packageName);
86706                     var newKind = fileChanged ? 1 : 0;
86707                     if ((prevKind !== undefined && newKind === 1) || prevKind === 1) {
86708                         return 0;
86709                     }
86710                     seenPackageNames.set(packageName, newKind);
86711                 }
86712                 if (fileChanged) {
86713                     if (!ts.arrayIsEqualTo(oldSourceFile.libReferenceDirectives, newSourceFile.libReferenceDirectives, fileReferenceIsEqualTo)) {
86714                         return 0;
86715                     }
86716                     if (oldSourceFile.hasNoDefaultLib !== newSourceFile.hasNoDefaultLib) {
86717                         structureIsReused = 1;
86718                     }
86719                     if (!ts.arrayIsEqualTo(oldSourceFile.referencedFiles, newSourceFile.referencedFiles, fileReferenceIsEqualTo)) {
86720                         structureIsReused = 1;
86721                     }
86722                     collectExternalModuleReferences(newSourceFile);
86723                     if (!ts.arrayIsEqualTo(oldSourceFile.imports, newSourceFile.imports, moduleNameIsEqualTo)) {
86724                         structureIsReused = 1;
86725                     }
86726                     if (!ts.arrayIsEqualTo(oldSourceFile.moduleAugmentations, newSourceFile.moduleAugmentations, moduleNameIsEqualTo)) {
86727                         structureIsReused = 1;
86728                     }
86729                     if ((oldSourceFile.flags & 3145728) !== (newSourceFile.flags & 3145728)) {
86730                         structureIsReused = 1;
86731                     }
86732                     if (!ts.arrayIsEqualTo(oldSourceFile.typeReferenceDirectives, newSourceFile.typeReferenceDirectives, fileReferenceIsEqualTo)) {
86733                         structureIsReused = 1;
86734                     }
86735                     modifiedSourceFiles.push({ oldFile: oldSourceFile, newFile: newSourceFile });
86736                 }
86737                 else if (hasInvalidatedResolution(oldSourceFile.path)) {
86738                     structureIsReused = 1;
86739                     modifiedSourceFiles.push({ oldFile: oldSourceFile, newFile: newSourceFile });
86740                 }
86741                 newSourceFiles.push(newSourceFile);
86742             }
86743             if (structureIsReused !== 2) {
86744                 return structureIsReused;
86745             }
86746             var modifiedFiles = modifiedSourceFiles.map(function (f) { return f.oldFile; });
86747             for (var _b = 0, oldSourceFiles_3 = oldSourceFiles; _b < oldSourceFiles_3.length; _b++) {
86748                 var oldFile = oldSourceFiles_3[_b];
86749                 if (!ts.contains(modifiedFiles, oldFile)) {
86750                     for (var _c = 0, _d = oldFile.ambientModuleNames; _c < _d.length; _c++) {
86751                         var moduleName = _d[_c];
86752                         ambientModuleNameToUnmodifiedFileName.set(moduleName, oldFile.fileName);
86753                     }
86754                 }
86755             }
86756             for (var _e = 0, modifiedSourceFiles_1 = modifiedSourceFiles; _e < modifiedSourceFiles_1.length; _e++) {
86757                 var _f = modifiedSourceFiles_1[_e], oldSourceFile = _f.oldFile, newSourceFile = _f.newFile;
86758                 var moduleNames = getModuleNames(newSourceFile);
86759                 var resolutions = resolveModuleNamesReusingOldState(moduleNames, newSourceFile);
86760                 var resolutionsChanged = ts.hasChangesInResolutions(moduleNames, resolutions, oldSourceFile.resolvedModules, ts.moduleResolutionIsEqualTo);
86761                 if (resolutionsChanged) {
86762                     structureIsReused = 1;
86763                     newSourceFile.resolvedModules = ts.zipToMap(moduleNames, resolutions);
86764                 }
86765                 else {
86766                     newSourceFile.resolvedModules = oldSourceFile.resolvedModules;
86767                 }
86768                 var typesReferenceDirectives = ts.map(newSourceFile.typeReferenceDirectives, function (ref) { return ts.toFileNameLowerCase(ref.fileName); });
86769                 var typeReferenceResolutions = resolveTypeReferenceDirectiveNamesWorker(typesReferenceDirectives, newSourceFile);
86770                 var typeReferenceEesolutionsChanged = ts.hasChangesInResolutions(typesReferenceDirectives, typeReferenceResolutions, oldSourceFile.resolvedTypeReferenceDirectiveNames, ts.typeDirectiveIsEqualTo);
86771                 if (typeReferenceEesolutionsChanged) {
86772                     structureIsReused = 1;
86773                     newSourceFile.resolvedTypeReferenceDirectiveNames = ts.zipToMap(typesReferenceDirectives, typeReferenceResolutions);
86774                 }
86775                 else {
86776                     newSourceFile.resolvedTypeReferenceDirectiveNames = oldSourceFile.resolvedTypeReferenceDirectiveNames;
86777                 }
86778             }
86779             if (structureIsReused !== 2) {
86780                 return structureIsReused;
86781             }
86782             if ((_a = host.hasChangedAutomaticTypeDirectiveNames) === null || _a === void 0 ? void 0 : _a.call(host)) {
86783                 return 1;
86784             }
86785             missingFilePaths = oldProgram.getMissingFilePaths();
86786             refFileMap = oldProgram.getRefFileMap();
86787             ts.Debug.assert(newSourceFiles.length === oldProgram.getSourceFiles().length);
86788             for (var _g = 0, newSourceFiles_1 = newSourceFiles; _g < newSourceFiles_1.length; _g++) {
86789                 var newSourceFile = newSourceFiles_1[_g];
86790                 filesByName.set(newSourceFile.path, newSourceFile);
86791             }
86792             var oldFilesByNameMap = oldProgram.getFilesByNameMap();
86793             oldFilesByNameMap.forEach(function (oldFile, path) {
86794                 if (!oldFile) {
86795                     filesByName.set(path, oldFile);
86796                     return;
86797                 }
86798                 if (oldFile.path === path) {
86799                     if (oldProgram.isSourceFileFromExternalLibrary(oldFile)) {
86800                         sourceFilesFoundSearchingNodeModules.set(oldFile.path, true);
86801                     }
86802                     return;
86803                 }
86804                 filesByName.set(path, filesByName.get(oldFile.path));
86805             });
86806             files = newSourceFiles;
86807             fileProcessingDiagnostics = oldProgram.getFileProcessingDiagnostics();
86808             for (var _h = 0, modifiedSourceFiles_2 = modifiedSourceFiles; _h < modifiedSourceFiles_2.length; _h++) {
86809                 var modifiedFile = modifiedSourceFiles_2[_h];
86810                 fileProcessingDiagnostics.reattachFileDiagnostics(modifiedFile.newFile);
86811             }
86812             resolvedTypeReferenceDirectives = oldProgram.getResolvedTypeReferenceDirectives();
86813             sourceFileToPackageName = oldProgram.sourceFileToPackageName;
86814             redirectTargetsMap = oldProgram.redirectTargetsMap;
86815             return 2;
86816         }
86817         function getEmitHost(writeFileCallback) {
86818             return {
86819                 getPrependNodes: getPrependNodes,
86820                 getCanonicalFileName: getCanonicalFileName,
86821                 getCommonSourceDirectory: program.getCommonSourceDirectory,
86822                 getCompilerOptions: program.getCompilerOptions,
86823                 getCurrentDirectory: function () { return currentDirectory; },
86824                 getNewLine: function () { return host.getNewLine(); },
86825                 getSourceFile: program.getSourceFile,
86826                 getSourceFileByPath: program.getSourceFileByPath,
86827                 getSourceFiles: program.getSourceFiles,
86828                 getLibFileFromReference: program.getLibFileFromReference,
86829                 isSourceFileFromExternalLibrary: isSourceFileFromExternalLibrary,
86830                 getResolvedProjectReferenceToRedirect: getResolvedProjectReferenceToRedirect,
86831                 getProjectReferenceRedirect: getProjectReferenceRedirect,
86832                 isSourceOfProjectReferenceRedirect: isSourceOfProjectReferenceRedirect,
86833                 getSymlinkCache: getSymlinkCache,
86834                 writeFile: writeFileCallback || (function (fileName, data, writeByteOrderMark, onError, sourceFiles) { return host.writeFile(fileName, data, writeByteOrderMark, onError, sourceFiles); }),
86835                 isEmitBlocked: isEmitBlocked,
86836                 readFile: function (f) { return host.readFile(f); },
86837                 fileExists: function (f) {
86838                     var path = toPath(f);
86839                     if (getSourceFileByPath(path))
86840                         return true;
86841                     if (ts.contains(missingFilePaths, path))
86842                         return false;
86843                     return host.fileExists(f);
86844                 },
86845                 useCaseSensitiveFileNames: function () { return host.useCaseSensitiveFileNames(); },
86846                 getProgramBuildInfo: function () { return program.getProgramBuildInfo && program.getProgramBuildInfo(); },
86847                 getSourceFileFromReference: function (file, ref) { return program.getSourceFileFromReference(file, ref); },
86848                 redirectTargetsMap: redirectTargetsMap,
86849             };
86850         }
86851         function emitBuildInfo(writeFileCallback) {
86852             ts.Debug.assert(!ts.outFile(options));
86853             var tracingData = ["emit", "emitBuildInfo"];
86854             ts.tracing.begin.apply(ts.tracing, tracingData);
86855             ts.performance.mark("beforeEmit");
86856             var emitResult = ts.emitFiles(ts.notImplementedResolver, getEmitHost(writeFileCallback), undefined, ts.noTransformers, false, true);
86857             ts.performance.mark("afterEmit");
86858             ts.performance.measure("Emit", "beforeEmit", "afterEmit");
86859             ts.tracing.end.apply(ts.tracing, tracingData);
86860             return emitResult;
86861         }
86862         function getResolvedProjectReferences() {
86863             return resolvedProjectReferences;
86864         }
86865         function getProjectReferences() {
86866             return projectReferences;
86867         }
86868         function getPrependNodes() {
86869             return createPrependNodes(projectReferences, function (_ref, index) { var _a; return (_a = resolvedProjectReferences[index]) === null || _a === void 0 ? void 0 : _a.commandLine; }, function (fileName) {
86870                 var path = toPath(fileName);
86871                 var sourceFile = getSourceFileByPath(path);
86872                 return sourceFile ? sourceFile.text : filesByName.has(path) ? undefined : host.readFile(path);
86873             });
86874         }
86875         function isSourceFileFromExternalLibrary(file) {
86876             return !!sourceFilesFoundSearchingNodeModules.get(file.path);
86877         }
86878         function isSourceFileDefaultLibrary(file) {
86879             if (file.hasNoDefaultLib) {
86880                 return true;
86881             }
86882             if (!options.noLib) {
86883                 return false;
86884             }
86885             var equalityComparer = host.useCaseSensitiveFileNames() ? ts.equateStringsCaseSensitive : ts.equateStringsCaseInsensitive;
86886             if (!options.lib) {
86887                 return equalityComparer(file.fileName, getDefaultLibraryFileName());
86888             }
86889             else {
86890                 return ts.some(options.lib, function (libFileName) { return equalityComparer(file.fileName, ts.combinePaths(defaultLibraryPath, libFileName)); });
86891             }
86892         }
86893         function getDiagnosticsProducingTypeChecker() {
86894             return diagnosticsProducingTypeChecker || (diagnosticsProducingTypeChecker = ts.createTypeChecker(program, true));
86895         }
86896         function dropDiagnosticsProducingTypeChecker() {
86897             diagnosticsProducingTypeChecker = undefined;
86898         }
86899         function getTypeChecker() {
86900             return noDiagnosticsTypeChecker || (noDiagnosticsTypeChecker = ts.createTypeChecker(program, false));
86901         }
86902         function emit(sourceFile, writeFileCallback, cancellationToken, emitOnlyDtsFiles, transformers, forceDtsEmit) {
86903             var tracingData = ["emit", "emit", { path: sourceFile === null || sourceFile === void 0 ? void 0 : sourceFile.path }];
86904             ts.tracing.begin.apply(ts.tracing, tracingData);
86905             var result = runWithCancellationToken(function () { return emitWorker(program, sourceFile, writeFileCallback, cancellationToken, emitOnlyDtsFiles, transformers, forceDtsEmit); });
86906             ts.tracing.end.apply(ts.tracing, tracingData);
86907             return result;
86908         }
86909         function isEmitBlocked(emitFileName) {
86910             return hasEmitBlockingDiagnostics.has(toPath(emitFileName));
86911         }
86912         function emitWorker(program, sourceFile, writeFileCallback, cancellationToken, emitOnlyDtsFiles, customTransformers, forceDtsEmit) {
86913             if (!forceDtsEmit) {
86914                 var result = handleNoEmitOptions(program, sourceFile, writeFileCallback, cancellationToken);
86915                 if (result)
86916                     return result;
86917             }
86918             var emitResolver = getDiagnosticsProducingTypeChecker().getEmitResolver(ts.outFile(options) ? undefined : sourceFile, cancellationToken);
86919             ts.performance.mark("beforeEmit");
86920             var emitResult = ts.emitFiles(emitResolver, getEmitHost(writeFileCallback), sourceFile, ts.getTransformers(options, customTransformers, emitOnlyDtsFiles), emitOnlyDtsFiles, false, forceDtsEmit);
86921             ts.performance.mark("afterEmit");
86922             ts.performance.measure("Emit", "beforeEmit", "afterEmit");
86923             return emitResult;
86924         }
86925         function getSourceFile(fileName) {
86926             return getSourceFileByPath(toPath(fileName));
86927         }
86928         function getSourceFileByPath(path) {
86929             return filesByName.get(path) || undefined;
86930         }
86931         function getDiagnosticsHelper(sourceFile, getDiagnostics, cancellationToken) {
86932             if (sourceFile) {
86933                 return getDiagnostics(sourceFile, cancellationToken);
86934             }
86935             return ts.sortAndDeduplicateDiagnostics(ts.flatMap(program.getSourceFiles(), function (sourceFile) {
86936                 if (cancellationToken) {
86937                     cancellationToken.throwIfCancellationRequested();
86938                 }
86939                 return getDiagnostics(sourceFile, cancellationToken);
86940             }));
86941         }
86942         function getSyntacticDiagnostics(sourceFile, cancellationToken) {
86943             return getDiagnosticsHelper(sourceFile, getSyntacticDiagnosticsForFile, cancellationToken);
86944         }
86945         function getSemanticDiagnostics(sourceFile, cancellationToken) {
86946             return getDiagnosticsHelper(sourceFile, getSemanticDiagnosticsForFile, cancellationToken);
86947         }
86948         function getCachedSemanticDiagnostics(sourceFile) {
86949             var _a;
86950             return sourceFile
86951                 ? (_a = cachedBindAndCheckDiagnosticsForFile.perFile) === null || _a === void 0 ? void 0 : _a.get(sourceFile.path) : cachedBindAndCheckDiagnosticsForFile.allDiagnostics;
86952         }
86953         function getBindAndCheckDiagnostics(sourceFile, cancellationToken) {
86954             return getBindAndCheckDiagnosticsForFile(sourceFile, cancellationToken);
86955         }
86956         function getProgramDiagnostics(sourceFile) {
86957             if (ts.skipTypeChecking(sourceFile, options, program)) {
86958                 return ts.emptyArray;
86959             }
86960             var fileProcessingDiagnosticsInFile = fileProcessingDiagnostics.getDiagnostics(sourceFile.fileName);
86961             var programDiagnosticsInFile = programDiagnostics.getDiagnostics(sourceFile.fileName);
86962             return getMergedProgramDiagnostics(sourceFile, fileProcessingDiagnosticsInFile, programDiagnosticsInFile);
86963         }
86964         function getMergedProgramDiagnostics(sourceFile) {
86965             var _a;
86966             var allDiagnostics = [];
86967             for (var _i = 1; _i < arguments.length; _i++) {
86968                 allDiagnostics[_i - 1] = arguments[_i];
86969             }
86970             var flatDiagnostics = ts.flatten(allDiagnostics);
86971             if (!((_a = sourceFile.commentDirectives) === null || _a === void 0 ? void 0 : _a.length)) {
86972                 return flatDiagnostics;
86973             }
86974             return getDiagnosticsWithPrecedingDirectives(sourceFile, sourceFile.commentDirectives, flatDiagnostics).diagnostics;
86975         }
86976         function getDeclarationDiagnostics(sourceFile, cancellationToken) {
86977             var options = program.getCompilerOptions();
86978             if (!sourceFile || ts.outFile(options)) {
86979                 return getDeclarationDiagnosticsWorker(sourceFile, cancellationToken);
86980             }
86981             else {
86982                 return getDiagnosticsHelper(sourceFile, getDeclarationDiagnosticsForFile, cancellationToken);
86983             }
86984         }
86985         function getSyntacticDiagnosticsForFile(sourceFile) {
86986             if (ts.isSourceFileJS(sourceFile)) {
86987                 if (!sourceFile.additionalSyntacticDiagnostics) {
86988                     sourceFile.additionalSyntacticDiagnostics = getJSSyntacticDiagnosticsForFile(sourceFile);
86989                 }
86990                 return ts.concatenate(sourceFile.additionalSyntacticDiagnostics, sourceFile.parseDiagnostics);
86991             }
86992             return sourceFile.parseDiagnostics;
86993         }
86994         function runWithCancellationToken(func) {
86995             try {
86996                 return func();
86997             }
86998             catch (e) {
86999                 if (e instanceof ts.OperationCanceledException) {
87000                     noDiagnosticsTypeChecker = undefined;
87001                     diagnosticsProducingTypeChecker = undefined;
87002                 }
87003                 throw e;
87004             }
87005         }
87006         function getSemanticDiagnosticsForFile(sourceFile, cancellationToken) {
87007             return ts.concatenate(filterSemanticDiagnotics(getBindAndCheckDiagnosticsForFile(sourceFile, cancellationToken), options), getProgramDiagnostics(sourceFile));
87008         }
87009         function getBindAndCheckDiagnosticsForFile(sourceFile, cancellationToken) {
87010             return getAndCacheDiagnostics(sourceFile, cancellationToken, cachedBindAndCheckDiagnosticsForFile, getBindAndCheckDiagnosticsForFileNoCache);
87011         }
87012         function getBindAndCheckDiagnosticsForFileNoCache(sourceFile, cancellationToken) {
87013             return runWithCancellationToken(function () {
87014                 if (ts.skipTypeChecking(sourceFile, options, program)) {
87015                     return ts.emptyArray;
87016                 }
87017                 var typeChecker = getDiagnosticsProducingTypeChecker();
87018                 ts.Debug.assert(!!sourceFile.bindDiagnostics);
87019                 var isCheckJs = ts.isCheckJsEnabledForFile(sourceFile, options);
87020                 var isTsNoCheck = !!sourceFile.checkJsDirective && sourceFile.checkJsDirective.enabled === false;
87021                 var includeBindAndCheckDiagnostics = !isTsNoCheck && (sourceFile.scriptKind === 3 || sourceFile.scriptKind === 4 ||
87022                     sourceFile.scriptKind === 5 || isCheckJs || sourceFile.scriptKind === 7);
87023                 var bindDiagnostics = includeBindAndCheckDiagnostics ? sourceFile.bindDiagnostics : ts.emptyArray;
87024                 var checkDiagnostics = includeBindAndCheckDiagnostics ? typeChecker.getDiagnostics(sourceFile, cancellationToken) : ts.emptyArray;
87025                 return getMergedBindAndCheckDiagnostics(sourceFile, includeBindAndCheckDiagnostics, bindDiagnostics, checkDiagnostics, isCheckJs ? sourceFile.jsDocDiagnostics : undefined);
87026             });
87027         }
87028         function getMergedBindAndCheckDiagnostics(sourceFile, includeBindAndCheckDiagnostics) {
87029             var _a;
87030             var allDiagnostics = [];
87031             for (var _i = 2; _i < arguments.length; _i++) {
87032                 allDiagnostics[_i - 2] = arguments[_i];
87033             }
87034             var flatDiagnostics = ts.flatten(allDiagnostics);
87035             if (!includeBindAndCheckDiagnostics || !((_a = sourceFile.commentDirectives) === null || _a === void 0 ? void 0 : _a.length)) {
87036                 return flatDiagnostics;
87037             }
87038             var _b = getDiagnosticsWithPrecedingDirectives(sourceFile, sourceFile.commentDirectives, flatDiagnostics), diagnostics = _b.diagnostics, directives = _b.directives;
87039             for (var _c = 0, _d = directives.getUnusedExpectations(); _c < _d.length; _c++) {
87040                 var errorExpectation = _d[_c];
87041                 diagnostics.push(ts.createDiagnosticForRange(sourceFile, errorExpectation.range, ts.Diagnostics.Unused_ts_expect_error_directive));
87042             }
87043             return diagnostics;
87044         }
87045         function getDiagnosticsWithPrecedingDirectives(sourceFile, commentDirectives, flatDiagnostics) {
87046             var directives = ts.createCommentDirectivesMap(sourceFile, commentDirectives);
87047             var diagnostics = flatDiagnostics.filter(function (diagnostic) { return markPrecedingCommentDirectiveLine(diagnostic, directives) === -1; });
87048             return { diagnostics: diagnostics, directives: directives };
87049         }
87050         function getSuggestionDiagnostics(sourceFile, cancellationToken) {
87051             return runWithCancellationToken(function () {
87052                 return getDiagnosticsProducingTypeChecker().getSuggestionDiagnostics(sourceFile, cancellationToken);
87053             });
87054         }
87055         function markPrecedingCommentDirectiveLine(diagnostic, directives) {
87056             var file = diagnostic.file, start = diagnostic.start;
87057             if (!file) {
87058                 return -1;
87059             }
87060             var lineStarts = ts.getLineStarts(file);
87061             var line = ts.computeLineAndCharacterOfPosition(lineStarts, start).line - 1;
87062             while (line >= 0) {
87063                 if (directives.markUsed(line)) {
87064                     return line;
87065                 }
87066                 var lineText = file.text.slice(lineStarts[line], lineStarts[line + 1]).trim();
87067                 if (lineText !== "" && !/^(\s*)\/\/(.*)$/.test(lineText)) {
87068                     return -1;
87069                 }
87070                 line--;
87071             }
87072             return -1;
87073         }
87074         function getJSSyntacticDiagnosticsForFile(sourceFile) {
87075             return runWithCancellationToken(function () {
87076                 var diagnostics = [];
87077                 walk(sourceFile, sourceFile);
87078                 ts.forEachChildRecursively(sourceFile, walk, walkArray);
87079                 return diagnostics;
87080                 function walk(node, parent) {
87081                     switch (parent.kind) {
87082                         case 160:
87083                         case 163:
87084                         case 165:
87085                             if (parent.questionToken === node) {
87086                                 diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.The_0_modifier_can_only_be_used_in_TypeScript_files, "?"));
87087                                 return "skip";
87088                             }
87089                         case 164:
87090                         case 166:
87091                         case 167:
87092                         case 168:
87093                         case 208:
87094                         case 251:
87095                         case 209:
87096                         case 249:
87097                             if (parent.type === node) {
87098                                 diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.Type_annotations_can_only_be_used_in_TypeScript_files));
87099                                 return "skip";
87100                             }
87101                     }
87102                     switch (node.kind) {
87103                         case 262:
87104                             if (node.isTypeOnly) {
87105                                 diagnostics.push(createDiagnosticForNode(parent, ts.Diagnostics._0_declarations_can_only_be_used_in_TypeScript_files, "import type"));
87106                                 return "skip";
87107                             }
87108                             break;
87109                         case 267:
87110                             if (node.isTypeOnly) {
87111                                 diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics._0_declarations_can_only_be_used_in_TypeScript_files, "export type"));
87112                                 return "skip";
87113                             }
87114                             break;
87115                         case 260:
87116                             diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.import_can_only_be_used_in_TypeScript_files));
87117                             return "skip";
87118                         case 266:
87119                             if (node.isExportEquals) {
87120                                 diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.export_can_only_be_used_in_TypeScript_files));
87121                                 return "skip";
87122                             }
87123                             break;
87124                         case 286:
87125                             var heritageClause = node;
87126                             if (heritageClause.token === 116) {
87127                                 diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.implements_clauses_can_only_be_used_in_TypeScript_files));
87128                                 return "skip";
87129                             }
87130                             break;
87131                         case 253:
87132                             var interfaceKeyword = ts.tokenToString(117);
87133                             ts.Debug.assertIsDefined(interfaceKeyword);
87134                             diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics._0_declarations_can_only_be_used_in_TypeScript_files, interfaceKeyword));
87135                             return "skip";
87136                         case 256:
87137                             var moduleKeyword = node.flags & 16 ? ts.tokenToString(140) : ts.tokenToString(139);
87138                             ts.Debug.assertIsDefined(moduleKeyword);
87139                             diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics._0_declarations_can_only_be_used_in_TypeScript_files, moduleKeyword));
87140                             return "skip";
87141                         case 254:
87142                             diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.Type_aliases_can_only_be_used_in_TypeScript_files));
87143                             return "skip";
87144                         case 255:
87145                             var enumKeyword = ts.Debug.checkDefined(ts.tokenToString(91));
87146                             diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics._0_declarations_can_only_be_used_in_TypeScript_files, enumKeyword));
87147                             return "skip";
87148                         case 225:
87149                             diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.Non_null_assertions_can_only_be_used_in_TypeScript_files));
87150                             return "skip";
87151                         case 224:
87152                             diagnostics.push(createDiagnosticForNode(node.type, ts.Diagnostics.Type_assertion_expressions_can_only_be_used_in_TypeScript_files));
87153                             return "skip";
87154                         case 206:
87155                             ts.Debug.fail();
87156                     }
87157                 }
87158                 function walkArray(nodes, parent) {
87159                     if (parent.decorators === nodes && !options.experimentalDecorators) {
87160                         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));
87161                     }
87162                     switch (parent.kind) {
87163                         case 252:
87164                         case 221:
87165                         case 165:
87166                         case 166:
87167                         case 167:
87168                         case 168:
87169                         case 208:
87170                         case 251:
87171                         case 209:
87172                             if (nodes === parent.typeParameters) {
87173                                 diagnostics.push(createDiagnosticForNodeArray(nodes, ts.Diagnostics.Type_parameter_declarations_can_only_be_used_in_TypeScript_files));
87174                                 return "skip";
87175                             }
87176                         case 232:
87177                             if (nodes === parent.modifiers) {
87178                                 checkModifiers(parent.modifiers, parent.kind === 232);
87179                                 return "skip";
87180                             }
87181                             break;
87182                         case 163:
87183                             if (nodes === parent.modifiers) {
87184                                 for (var _i = 0, _a = nodes; _i < _a.length; _i++) {
87185                                     var modifier = _a[_i];
87186                                     if (modifier.kind !== 123) {
87187                                         diagnostics.push(createDiagnosticForNode(modifier, ts.Diagnostics.The_0_modifier_can_only_be_used_in_TypeScript_files, ts.tokenToString(modifier.kind)));
87188                                     }
87189                                 }
87190                                 return "skip";
87191                             }
87192                             break;
87193                         case 160:
87194                             if (nodes === parent.modifiers) {
87195                                 diagnostics.push(createDiagnosticForNodeArray(nodes, ts.Diagnostics.Parameter_modifiers_can_only_be_used_in_TypeScript_files));
87196                                 return "skip";
87197                             }
87198                             break;
87199                         case 203:
87200                         case 204:
87201                         case 223:
87202                         case 274:
87203                         case 275:
87204                         case 205:
87205                             if (nodes === parent.typeArguments) {
87206                                 diagnostics.push(createDiagnosticForNodeArray(nodes, ts.Diagnostics.Type_arguments_can_only_be_used_in_TypeScript_files));
87207                                 return "skip";
87208                             }
87209                             break;
87210                     }
87211                 }
87212                 function checkModifiers(modifiers, isConstValid) {
87213                     for (var _i = 0, modifiers_2 = modifiers; _i < modifiers_2.length; _i++) {
87214                         var modifier = modifiers_2[_i];
87215                         switch (modifier.kind) {
87216                             case 84:
87217                                 if (isConstValid) {
87218                                     continue;
87219                                 }
87220                             case 122:
87221                             case 120:
87222                             case 121:
87223                             case 142:
87224                             case 133:
87225                             case 125:
87226                                 diagnostics.push(createDiagnosticForNode(modifier, ts.Diagnostics.The_0_modifier_can_only_be_used_in_TypeScript_files, ts.tokenToString(modifier.kind)));
87227                                 break;
87228                             case 123:
87229                             case 92:
87230                             case 87:
87231                         }
87232                     }
87233                 }
87234                 function createDiagnosticForNodeArray(nodes, message, arg0, arg1, arg2) {
87235                     var start = nodes.pos;
87236                     return ts.createFileDiagnostic(sourceFile, start, nodes.end - start, message, arg0, arg1, arg2);
87237                 }
87238                 function createDiagnosticForNode(node, message, arg0, arg1, arg2) {
87239                     return ts.createDiagnosticForNodeInSourceFile(sourceFile, node, message, arg0, arg1, arg2);
87240                 }
87241             });
87242         }
87243         function getDeclarationDiagnosticsWorker(sourceFile, cancellationToken) {
87244             return getAndCacheDiagnostics(sourceFile, cancellationToken, cachedDeclarationDiagnosticsForFile, getDeclarationDiagnosticsForFileNoCache);
87245         }
87246         function getDeclarationDiagnosticsForFileNoCache(sourceFile, cancellationToken) {
87247             return runWithCancellationToken(function () {
87248                 var resolver = getDiagnosticsProducingTypeChecker().getEmitResolver(sourceFile, cancellationToken);
87249                 return ts.getDeclarationDiagnostics(getEmitHost(ts.noop), resolver, sourceFile) || ts.emptyArray;
87250             });
87251         }
87252         function getAndCacheDiagnostics(sourceFile, cancellationToken, cache, getDiagnostics) {
87253             var _a;
87254             var cachedResult = sourceFile
87255                 ? (_a = cache.perFile) === null || _a === void 0 ? void 0 : _a.get(sourceFile.path) : cache.allDiagnostics;
87256             if (cachedResult) {
87257                 return cachedResult;
87258             }
87259             var result = getDiagnostics(sourceFile, cancellationToken);
87260             if (sourceFile) {
87261                 (cache.perFile || (cache.perFile = new ts.Map())).set(sourceFile.path, result);
87262             }
87263             else {
87264                 cache.allDiagnostics = result;
87265             }
87266             return result;
87267         }
87268         function getDeclarationDiagnosticsForFile(sourceFile, cancellationToken) {
87269             return sourceFile.isDeclarationFile ? [] : getDeclarationDiagnosticsWorker(sourceFile, cancellationToken);
87270         }
87271         function getOptionsDiagnostics() {
87272             return ts.sortAndDeduplicateDiagnostics(ts.concatenate(fileProcessingDiagnostics.getGlobalDiagnostics(), ts.concatenate(programDiagnostics.getGlobalDiagnostics(), getOptionsDiagnosticsOfConfigFile())));
87273         }
87274         function getOptionsDiagnosticsOfConfigFile() {
87275             if (!options.configFile) {
87276                 return ts.emptyArray;
87277             }
87278             var diagnostics = programDiagnostics.getDiagnostics(options.configFile.fileName);
87279             forEachResolvedProjectReference(function (resolvedRef) {
87280                 diagnostics = ts.concatenate(diagnostics, programDiagnostics.getDiagnostics(resolvedRef.sourceFile.fileName));
87281             });
87282             return diagnostics;
87283         }
87284         function getGlobalDiagnostics() {
87285             return rootNames.length ? ts.sortAndDeduplicateDiagnostics(getDiagnosticsProducingTypeChecker().getGlobalDiagnostics().slice()) : ts.emptyArray;
87286         }
87287         function getConfigFileParsingDiagnostics() {
87288             return configFileParsingDiagnostics || ts.emptyArray;
87289         }
87290         function processRootFile(fileName, isDefaultLib, ignoreNoDefaultLib) {
87291             processSourceFile(ts.normalizePath(fileName), isDefaultLib, ignoreNoDefaultLib, undefined);
87292         }
87293         function fileReferenceIsEqualTo(a, b) {
87294             return a.fileName === b.fileName;
87295         }
87296         function moduleNameIsEqualTo(a, b) {
87297             return a.kind === 78
87298                 ? b.kind === 78 && a.escapedText === b.escapedText
87299                 : b.kind === 10 && a.text === b.text;
87300         }
87301         function createSyntheticImport(text, file) {
87302             var externalHelpersModuleReference = ts.factory.createStringLiteral(text);
87303             var importDecl = ts.factory.createImportDeclaration(undefined, undefined, undefined, externalHelpersModuleReference);
87304             ts.addEmitFlags(importDecl, 67108864);
87305             ts.setParent(externalHelpersModuleReference, importDecl);
87306             ts.setParent(importDecl, file);
87307             externalHelpersModuleReference.flags &= ~8;
87308             importDecl.flags &= ~8;
87309             return externalHelpersModuleReference;
87310         }
87311         function collectExternalModuleReferences(file) {
87312             if (file.imports) {
87313                 return;
87314             }
87315             var isJavaScriptFile = ts.isSourceFileJS(file);
87316             var isExternalModuleFile = ts.isExternalModule(file);
87317             var imports;
87318             var moduleAugmentations;
87319             var ambientModules;
87320             if ((options.isolatedModules || isExternalModuleFile)
87321                 && !file.isDeclarationFile) {
87322                 if (options.importHelpers) {
87323                     imports = [createSyntheticImport(ts.externalHelpersModuleNameText, file)];
87324                 }
87325                 var jsxImport = ts.getJSXRuntimeImport(ts.getJSXImplicitImportBase(options, file), options);
87326                 if (jsxImport) {
87327                     (imports || (imports = [])).push(createSyntheticImport(jsxImport, file));
87328                 }
87329             }
87330             for (var _i = 0, _a = file.statements; _i < _a.length; _i++) {
87331                 var node = _a[_i];
87332                 collectModuleReferences(node, false);
87333             }
87334             if ((file.flags & 1048576) || isJavaScriptFile) {
87335                 collectDynamicImportOrRequireCalls(file);
87336             }
87337             file.imports = imports || ts.emptyArray;
87338             file.moduleAugmentations = moduleAugmentations || ts.emptyArray;
87339             file.ambientModuleNames = ambientModules || ts.emptyArray;
87340             return;
87341             function collectModuleReferences(node, inAmbientModule) {
87342                 if (ts.isAnyImportOrReExport(node)) {
87343                     var moduleNameExpr = ts.getExternalModuleName(node);
87344                     if (moduleNameExpr && ts.isStringLiteral(moduleNameExpr) && moduleNameExpr.text && (!inAmbientModule || !ts.isExternalModuleNameRelative(moduleNameExpr.text))) {
87345                         imports = ts.append(imports, moduleNameExpr);
87346                     }
87347                 }
87348                 else if (ts.isModuleDeclaration(node)) {
87349                     if (ts.isAmbientModule(node) && (inAmbientModule || ts.hasSyntacticModifier(node, 2) || file.isDeclarationFile)) {
87350                         var nameText = ts.getTextOfIdentifierOrLiteral(node.name);
87351                         if (isExternalModuleFile || (inAmbientModule && !ts.isExternalModuleNameRelative(nameText))) {
87352                             (moduleAugmentations || (moduleAugmentations = [])).push(node.name);
87353                         }
87354                         else if (!inAmbientModule) {
87355                             if (file.isDeclarationFile) {
87356                                 (ambientModules || (ambientModules = [])).push(nameText);
87357                             }
87358                             var body = node.body;
87359                             if (body) {
87360                                 for (var _i = 0, _a = body.statements; _i < _a.length; _i++) {
87361                                     var statement = _a[_i];
87362                                     collectModuleReferences(statement, true);
87363                                 }
87364                             }
87365                         }
87366                     }
87367                 }
87368             }
87369             function collectDynamicImportOrRequireCalls(file) {
87370                 var r = /import|require/g;
87371                 while (r.exec(file.text) !== null) {
87372                     var node = getNodeAtPosition(file, r.lastIndex);
87373                     if (isJavaScriptFile && ts.isRequireCall(node, true)) {
87374                         imports = ts.append(imports, node.arguments[0]);
87375                     }
87376                     else if (ts.isImportCall(node) && node.arguments.length === 1 && ts.isStringLiteralLike(node.arguments[0])) {
87377                         imports = ts.append(imports, node.arguments[0]);
87378                     }
87379                     else if (ts.isLiteralImportTypeNode(node)) {
87380                         imports = ts.append(imports, node.argument.literal);
87381                     }
87382                 }
87383             }
87384             function getNodeAtPosition(sourceFile, position) {
87385                 var current = sourceFile;
87386                 var getContainingChild = function (child) {
87387                     if (child.pos <= position && (position < child.end || (position === child.end && (child.kind === 1)))) {
87388                         return child;
87389                     }
87390                 };
87391                 while (true) {
87392                     var child = isJavaScriptFile && ts.hasJSDocNodes(current) && ts.forEach(current.jsDoc, getContainingChild) || ts.forEachChild(current, getContainingChild);
87393                     if (!child) {
87394                         return current;
87395                     }
87396                     current = child;
87397                 }
87398             }
87399         }
87400         function getLibFileFromReference(ref) {
87401             var libName = ts.toFileNameLowerCase(ref.fileName);
87402             var libFileName = ts.libMap.get(libName);
87403             if (libFileName) {
87404                 return getSourceFile(ts.combinePaths(defaultLibraryPath, libFileName));
87405             }
87406         }
87407         function getSourceFileFromReference(referencingFile, ref) {
87408             return getSourceFileFromReferenceWorker(resolveTripleslashReference(ref.fileName, referencingFile.fileName), function (fileName) { return filesByName.get(toPath(fileName)) || undefined; });
87409         }
87410         function getSourceFileFromReferenceWorker(fileName, getSourceFile, fail, refFile) {
87411             if (ts.hasExtension(fileName)) {
87412                 var canonicalFileName_1 = host.getCanonicalFileName(fileName);
87413                 if (!options.allowNonTsExtensions && !ts.forEach(supportedExtensionsWithJsonIfResolveJsonModule, function (extension) { return ts.fileExtensionIs(canonicalFileName_1, extension); })) {
87414                     if (fail) {
87415                         if (ts.hasJSFileExtension(canonicalFileName_1)) {
87416                             fail(ts.Diagnostics.File_0_is_a_JavaScript_file_Did_you_mean_to_enable_the_allowJs_option, fileName);
87417                         }
87418                         else {
87419                             fail(ts.Diagnostics.File_0_has_an_unsupported_extension_The_only_supported_extensions_are_1, fileName, "'" + supportedExtensions.join("', '") + "'");
87420                         }
87421                     }
87422                     return undefined;
87423                 }
87424                 var sourceFile = getSourceFile(fileName);
87425                 if (fail) {
87426                     if (!sourceFile) {
87427                         var redirect = getProjectReferenceRedirect(fileName);
87428                         if (redirect) {
87429                             fail(ts.Diagnostics.Output_file_0_has_not_been_built_from_source_file_1, redirect, fileName);
87430                         }
87431                         else {
87432                             fail(ts.Diagnostics.File_0_not_found, fileName);
87433                         }
87434                     }
87435                     else if (refFile && canonicalFileName_1 === host.getCanonicalFileName(refFile.fileName)) {
87436                         fail(ts.Diagnostics.A_file_cannot_have_a_reference_to_itself);
87437                     }
87438                 }
87439                 return sourceFile;
87440             }
87441             else {
87442                 var sourceFileNoExtension = options.allowNonTsExtensions && getSourceFile(fileName);
87443                 if (sourceFileNoExtension)
87444                     return sourceFileNoExtension;
87445                 if (fail && options.allowNonTsExtensions) {
87446                     fail(ts.Diagnostics.File_0_not_found, fileName);
87447                     return undefined;
87448                 }
87449                 var sourceFileWithAddedExtension = ts.forEach(supportedExtensions, function (extension) { return getSourceFile(fileName + extension); });
87450                 if (fail && !sourceFileWithAddedExtension)
87451                     fail(ts.Diagnostics.Could_not_resolve_the_path_0_with_the_extensions_Colon_1, fileName, "'" + supportedExtensions.join("', '") + "'");
87452                 return sourceFileWithAddedExtension;
87453             }
87454         }
87455         function processSourceFile(fileName, isDefaultLib, ignoreNoDefaultLib, packageId, refFile) {
87456             getSourceFileFromReferenceWorker(fileName, function (fileName) { return findSourceFile(fileName, toPath(fileName), isDefaultLib, ignoreNoDefaultLib, refFile, packageId); }, function (diagnostic) {
87457                 var args = [];
87458                 for (var _i = 1; _i < arguments.length; _i++) {
87459                     args[_i - 1] = arguments[_i];
87460                 }
87461                 return fileProcessingDiagnostics.add(createRefFileDiagnostic.apply(void 0, __spreadArrays([refFile, diagnostic], args)));
87462             }, refFile && refFile.file);
87463         }
87464         function reportFileNamesDifferOnlyInCasingError(fileName, existingFile, refFile) {
87465             var refs = !refFile ? refFileMap && refFileMap.get(existingFile.path) : undefined;
87466             var refToReportErrorOn = refs && ts.find(refs, function (ref) { return ref.referencedFileName === existingFile.fileName; });
87467             fileProcessingDiagnostics.add(refToReportErrorOn ?
87468                 createFileDiagnosticAtReference(refToReportErrorOn, ts.Diagnostics.Already_included_file_name_0_differs_from_file_name_1_only_in_casing, existingFile.fileName, fileName) :
87469                 createRefFileDiagnostic(refFile, ts.Diagnostics.File_name_0_differs_from_already_included_file_name_1_only_in_casing, fileName, existingFile.fileName));
87470         }
87471         function createRedirectSourceFile(redirectTarget, unredirected, fileName, path, resolvedPath, originalFileName) {
87472             var redirect = Object.create(redirectTarget);
87473             redirect.fileName = fileName;
87474             redirect.path = path;
87475             redirect.resolvedPath = resolvedPath;
87476             redirect.originalFileName = originalFileName;
87477             redirect.redirectInfo = { redirectTarget: redirectTarget, unredirected: unredirected };
87478             sourceFilesFoundSearchingNodeModules.set(path, currentNodeModulesDepth > 0);
87479             Object.defineProperties(redirect, {
87480                 id: {
87481                     get: function () { return this.redirectInfo.redirectTarget.id; },
87482                     set: function (value) { this.redirectInfo.redirectTarget.id = value; },
87483                 },
87484                 symbol: {
87485                     get: function () { return this.redirectInfo.redirectTarget.symbol; },
87486                     set: function (value) { this.redirectInfo.redirectTarget.symbol = value; },
87487                 },
87488             });
87489             return redirect;
87490         }
87491         function findSourceFile(fileName, path, isDefaultLib, ignoreNoDefaultLib, refFile, packageId) {
87492             ts.tracing.push("program", "findSourceFile", {
87493                 fileName: fileName,
87494                 isDefaultLib: isDefaultLib || undefined,
87495                 refKind: refFile ? ts.RefFileKind[refFile.kind] : undefined,
87496             });
87497             var result = findSourceFileWorker(fileName, path, isDefaultLib, ignoreNoDefaultLib, refFile, packageId);
87498             ts.tracing.pop();
87499             return result;
87500         }
87501         function findSourceFileWorker(fileName, path, isDefaultLib, ignoreNoDefaultLib, refFile, packageId) {
87502             if (useSourceOfProjectReferenceRedirect) {
87503                 var source = getSourceOfProjectReferenceRedirect(fileName);
87504                 if (!source &&
87505                     host.realpath &&
87506                     options.preserveSymlinks &&
87507                     ts.isDeclarationFileName(fileName) &&
87508                     ts.stringContains(fileName, ts.nodeModulesPathPart)) {
87509                     var realPath = host.realpath(fileName);
87510                     if (realPath !== fileName)
87511                         source = getSourceOfProjectReferenceRedirect(realPath);
87512                 }
87513                 if (source) {
87514                     var file_1 = ts.isString(source) ?
87515                         findSourceFile(source, toPath(source), isDefaultLib, ignoreNoDefaultLib, refFile, packageId) :
87516                         undefined;
87517                     if (file_1)
87518                         addFileToFilesByName(file_1, path, undefined);
87519                     return file_1;
87520                 }
87521             }
87522             var originalFileName = fileName;
87523             if (filesByName.has(path)) {
87524                 var file_2 = filesByName.get(path);
87525                 addFileToRefFileMap(fileName, file_2 || undefined, refFile);
87526                 if (file_2 && options.forceConsistentCasingInFileNames) {
87527                     var checkedName = file_2.fileName;
87528                     var isRedirect = toPath(checkedName) !== toPath(fileName);
87529                     if (isRedirect) {
87530                         fileName = getProjectReferenceRedirect(fileName) || fileName;
87531                     }
87532                     var checkedAbsolutePath = ts.getNormalizedAbsolutePathWithoutRoot(checkedName, currentDirectory);
87533                     var inputAbsolutePath = ts.getNormalizedAbsolutePathWithoutRoot(fileName, currentDirectory);
87534                     if (checkedAbsolutePath !== inputAbsolutePath) {
87535                         reportFileNamesDifferOnlyInCasingError(fileName, file_2, refFile);
87536                     }
87537                 }
87538                 if (file_2 && sourceFilesFoundSearchingNodeModules.get(file_2.path) && currentNodeModulesDepth === 0) {
87539                     sourceFilesFoundSearchingNodeModules.set(file_2.path, false);
87540                     if (!options.noResolve) {
87541                         processReferencedFiles(file_2, isDefaultLib);
87542                         processTypeReferenceDirectives(file_2);
87543                     }
87544                     if (!options.noLib) {
87545                         processLibReferenceDirectives(file_2);
87546                     }
87547                     modulesWithElidedImports.set(file_2.path, false);
87548                     processImportedModules(file_2);
87549                 }
87550                 else if (file_2 && modulesWithElidedImports.get(file_2.path)) {
87551                     if (currentNodeModulesDepth < maxNodeModuleJsDepth) {
87552                         modulesWithElidedImports.set(file_2.path, false);
87553                         processImportedModules(file_2);
87554                     }
87555                 }
87556                 return file_2 || undefined;
87557             }
87558             var redirectedPath;
87559             if (refFile && !useSourceOfProjectReferenceRedirect) {
87560                 var redirectProject = getProjectReferenceRedirectProject(fileName);
87561                 if (redirectProject) {
87562                     if (ts.outFile(redirectProject.commandLine.options)) {
87563                         return undefined;
87564                     }
87565                     var redirect = getProjectReferenceOutputName(redirectProject, fileName);
87566                     fileName = redirect;
87567                     redirectedPath = toPath(redirect);
87568                 }
87569             }
87570             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);
87571             if (packageId) {
87572                 var packageIdKey = ts.packageIdToString(packageId);
87573                 var fileFromPackageId = packageIdToSourceFile.get(packageIdKey);
87574                 if (fileFromPackageId) {
87575                     var dupFile = createRedirectSourceFile(fileFromPackageId, file, fileName, path, toPath(fileName), originalFileName);
87576                     redirectTargetsMap.add(fileFromPackageId.path, fileName);
87577                     addFileToFilesByName(dupFile, path, redirectedPath);
87578                     sourceFileToPackageName.set(path, packageId.name);
87579                     processingOtherFiles.push(dupFile);
87580                     return dupFile;
87581                 }
87582                 else if (file) {
87583                     packageIdToSourceFile.set(packageIdKey, file);
87584                     sourceFileToPackageName.set(path, packageId.name);
87585                 }
87586             }
87587             addFileToFilesByName(file, path, redirectedPath);
87588             if (file) {
87589                 sourceFilesFoundSearchingNodeModules.set(path, currentNodeModulesDepth > 0);
87590                 file.fileName = fileName;
87591                 file.path = path;
87592                 file.resolvedPath = toPath(fileName);
87593                 file.originalFileName = originalFileName;
87594                 addFileToRefFileMap(fileName, file, refFile);
87595                 if (host.useCaseSensitiveFileNames()) {
87596                     var pathLowerCase = ts.toFileNameLowerCase(path);
87597                     var existingFile = filesByNameIgnoreCase.get(pathLowerCase);
87598                     if (existingFile) {
87599                         reportFileNamesDifferOnlyInCasingError(fileName, existingFile, refFile);
87600                     }
87601                     else {
87602                         filesByNameIgnoreCase.set(pathLowerCase, file);
87603                     }
87604                 }
87605                 skipDefaultLib = skipDefaultLib || (file.hasNoDefaultLib && !ignoreNoDefaultLib);
87606                 if (!options.noResolve) {
87607                     processReferencedFiles(file, isDefaultLib);
87608                     processTypeReferenceDirectives(file);
87609                 }
87610                 if (!options.noLib) {
87611                     processLibReferenceDirectives(file);
87612                 }
87613                 processImportedModules(file);
87614                 if (isDefaultLib) {
87615                     processingDefaultLibFiles.push(file);
87616                 }
87617                 else {
87618                     processingOtherFiles.push(file);
87619                 }
87620             }
87621             return file;
87622         }
87623         function addFileToRefFileMap(referencedFileName, file, refFile) {
87624             if (refFile && file) {
87625                 (refFileMap || (refFileMap = ts.createMultiMap())).add(file.path, {
87626                     referencedFileName: referencedFileName,
87627                     kind: refFile.kind,
87628                     index: refFile.index,
87629                     file: refFile.file.path
87630                 });
87631             }
87632         }
87633         function addFileToFilesByName(file, path, redirectedPath) {
87634             if (redirectedPath) {
87635                 filesByName.set(redirectedPath, file);
87636                 filesByName.set(path, file || false);
87637             }
87638             else {
87639                 filesByName.set(path, file);
87640             }
87641         }
87642         function getProjectReferenceRedirect(fileName) {
87643             var referencedProject = getProjectReferenceRedirectProject(fileName);
87644             return referencedProject && getProjectReferenceOutputName(referencedProject, fileName);
87645         }
87646         function getProjectReferenceRedirectProject(fileName) {
87647             if (!resolvedProjectReferences || !resolvedProjectReferences.length || ts.fileExtensionIs(fileName, ".d.ts") || ts.fileExtensionIs(fileName, ".json")) {
87648                 return undefined;
87649             }
87650             return getResolvedProjectReferenceToRedirect(fileName);
87651         }
87652         function getProjectReferenceOutputName(referencedProject, fileName) {
87653             var out = ts.outFile(referencedProject.commandLine.options);
87654             return out ?
87655                 ts.changeExtension(out, ".d.ts") :
87656                 ts.getOutputDeclarationFileName(fileName, referencedProject.commandLine, !host.useCaseSensitiveFileNames());
87657         }
87658         function getResolvedProjectReferenceToRedirect(fileName) {
87659             if (mapFromFileToProjectReferenceRedirects === undefined) {
87660                 mapFromFileToProjectReferenceRedirects = new ts.Map();
87661                 forEachResolvedProjectReference(function (referencedProject) {
87662                     if (toPath(options.configFilePath) !== referencedProject.sourceFile.path) {
87663                         referencedProject.commandLine.fileNames.forEach(function (f) {
87664                             return mapFromFileToProjectReferenceRedirects.set(toPath(f), referencedProject.sourceFile.path);
87665                         });
87666                     }
87667                 });
87668             }
87669             var referencedProjectPath = mapFromFileToProjectReferenceRedirects.get(toPath(fileName));
87670             return referencedProjectPath && getResolvedProjectReferenceByPath(referencedProjectPath);
87671         }
87672         function forEachResolvedProjectReference(cb) {
87673             return ts.forEachResolvedProjectReference(resolvedProjectReferences, cb);
87674         }
87675         function getSourceOfProjectReferenceRedirect(file) {
87676             if (!ts.isDeclarationFileName(file))
87677                 return undefined;
87678             if (mapFromToProjectReferenceRedirectSource === undefined) {
87679                 mapFromToProjectReferenceRedirectSource = new ts.Map();
87680                 forEachResolvedProjectReference(function (resolvedRef) {
87681                     var out = ts.outFile(resolvedRef.commandLine.options);
87682                     if (out) {
87683                         var outputDts = ts.changeExtension(out, ".d.ts");
87684                         mapFromToProjectReferenceRedirectSource.set(toPath(outputDts), true);
87685                     }
87686                     else {
87687                         ts.forEach(resolvedRef.commandLine.fileNames, function (fileName) {
87688                             if (!ts.fileExtensionIs(fileName, ".d.ts") && !ts.fileExtensionIs(fileName, ".json")) {
87689                                 var outputDts = ts.getOutputDeclarationFileName(fileName, resolvedRef.commandLine, host.useCaseSensitiveFileNames());
87690                                 mapFromToProjectReferenceRedirectSource.set(toPath(outputDts), fileName);
87691                             }
87692                         });
87693                     }
87694                 });
87695             }
87696             return mapFromToProjectReferenceRedirectSource.get(toPath(file));
87697         }
87698         function isSourceOfProjectReferenceRedirect(fileName) {
87699             return useSourceOfProjectReferenceRedirect && !!getResolvedProjectReferenceToRedirect(fileName);
87700         }
87701         function getResolvedProjectReferenceByPath(projectReferencePath) {
87702             if (!projectReferenceRedirects) {
87703                 return undefined;
87704             }
87705             return projectReferenceRedirects.get(projectReferencePath) || undefined;
87706         }
87707         function processReferencedFiles(file, isDefaultLib) {
87708             ts.forEach(file.referencedFiles, function (ref, index) {
87709                 var referencedFileName = resolveTripleslashReference(ref.fileName, file.fileName);
87710                 processSourceFile(referencedFileName, isDefaultLib, false, undefined, {
87711                     kind: ts.RefFileKind.ReferenceFile,
87712                     index: index,
87713                     file: file,
87714                     pos: ref.pos,
87715                     end: ref.end
87716                 });
87717             });
87718         }
87719         function processTypeReferenceDirectives(file) {
87720             var typeDirectives = ts.map(file.typeReferenceDirectives, function (ref) { return ts.toFileNameLowerCase(ref.fileName); });
87721             if (!typeDirectives) {
87722                 return;
87723             }
87724             var resolutions = resolveTypeReferenceDirectiveNamesWorker(typeDirectives, file);
87725             for (var i = 0; i < typeDirectives.length; i++) {
87726                 var ref = file.typeReferenceDirectives[i];
87727                 var resolvedTypeReferenceDirective = resolutions[i];
87728                 var fileName = ts.toFileNameLowerCase(ref.fileName);
87729                 ts.setResolvedTypeReferenceDirective(file, fileName, resolvedTypeReferenceDirective);
87730                 processTypeReferenceDirective(fileName, resolvedTypeReferenceDirective, {
87731                     kind: ts.RefFileKind.TypeReferenceDirective,
87732                     index: i,
87733                     file: file,
87734                     pos: ref.pos,
87735                     end: ref.end
87736                 });
87737             }
87738         }
87739         function processTypeReferenceDirective(typeReferenceDirective, resolvedTypeReferenceDirective, refFile) {
87740             ts.tracing.push("program", "processTypeReferenceDirective", { directive: typeReferenceDirective, hasResolved: !!resolveModuleNamesReusingOldState, refKind: refFile === null || refFile === void 0 ? void 0 : refFile.kind, refPath: refFile === null || refFile === void 0 ? void 0 : refFile.file.path });
87741             processTypeReferenceDirectiveWorker(typeReferenceDirective, resolvedTypeReferenceDirective, refFile);
87742             ts.tracing.pop();
87743         }
87744         function processTypeReferenceDirectiveWorker(typeReferenceDirective, resolvedTypeReferenceDirective, refFile) {
87745             var previousResolution = resolvedTypeReferenceDirectives.get(typeReferenceDirective);
87746             if (previousResolution && previousResolution.primary) {
87747                 return;
87748             }
87749             var saveResolution = true;
87750             if (resolvedTypeReferenceDirective) {
87751                 if (resolvedTypeReferenceDirective.isExternalLibraryImport)
87752                     currentNodeModulesDepth++;
87753                 if (resolvedTypeReferenceDirective.primary) {
87754                     processSourceFile(resolvedTypeReferenceDirective.resolvedFileName, false, false, resolvedTypeReferenceDirective.packageId, refFile);
87755                 }
87756                 else {
87757                     if (previousResolution) {
87758                         if (resolvedTypeReferenceDirective.resolvedFileName !== previousResolution.resolvedFileName) {
87759                             var otherFileText = host.readFile(resolvedTypeReferenceDirective.resolvedFileName);
87760                             var existingFile_1 = getSourceFile(previousResolution.resolvedFileName);
87761                             if (otherFileText !== existingFile_1.text) {
87762                                 var refs = !refFile ? refFileMap && refFileMap.get(existingFile_1.path) : undefined;
87763                                 var refToReportErrorOn = refs && ts.find(refs, function (ref) { return ref.referencedFileName === existingFile_1.fileName; });
87764                                 fileProcessingDiagnostics.add(refToReportErrorOn ?
87765                                     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) :
87766                                     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));
87767                             }
87768                         }
87769                         saveResolution = false;
87770                     }
87771                     else {
87772                         processSourceFile(resolvedTypeReferenceDirective.resolvedFileName, false, false, resolvedTypeReferenceDirective.packageId, refFile);
87773                     }
87774                 }
87775                 if (resolvedTypeReferenceDirective.isExternalLibraryImport)
87776                     currentNodeModulesDepth--;
87777             }
87778             else {
87779                 fileProcessingDiagnostics.add(createRefFileDiagnostic(refFile, ts.Diagnostics.Cannot_find_type_definition_file_for_0, typeReferenceDirective));
87780             }
87781             if (saveResolution) {
87782                 resolvedTypeReferenceDirectives.set(typeReferenceDirective, resolvedTypeReferenceDirective);
87783             }
87784         }
87785         function processLibReferenceDirectives(file) {
87786             ts.forEach(file.libReferenceDirectives, function (libReference) {
87787                 var libName = ts.toFileNameLowerCase(libReference.fileName);
87788                 var libFileName = ts.libMap.get(libName);
87789                 if (libFileName) {
87790                     processRootFile(ts.combinePaths(defaultLibraryPath, libFileName), true, true);
87791                 }
87792                 else {
87793                     var unqualifiedLibName = ts.removeSuffix(ts.removePrefix(libName, "lib."), ".d.ts");
87794                     var suggestion = ts.getSpellingSuggestion(unqualifiedLibName, ts.libs, ts.identity);
87795                     var message = suggestion ? ts.Diagnostics.Cannot_find_lib_definition_for_0_Did_you_mean_1 : ts.Diagnostics.Cannot_find_lib_definition_for_0;
87796                     fileProcessingDiagnostics.add(ts.createFileDiagnostic(file, libReference.pos, libReference.end - libReference.pos, message, libName, suggestion));
87797                 }
87798             });
87799         }
87800         function createRefFileDiagnostic(refFile, message) {
87801             var args = [];
87802             for (var _i = 2; _i < arguments.length; _i++) {
87803                 args[_i - 2] = arguments[_i];
87804             }
87805             if (!refFile) {
87806                 return ts.createCompilerDiagnostic.apply(void 0, __spreadArrays([message], args));
87807             }
87808             else {
87809                 return ts.createFileDiagnostic.apply(void 0, __spreadArrays([refFile.file, refFile.pos, refFile.end - refFile.pos, message], args));
87810             }
87811         }
87812         function getCanonicalFileName(fileName) {
87813             return host.getCanonicalFileName(fileName);
87814         }
87815         function processImportedModules(file) {
87816             collectExternalModuleReferences(file);
87817             if (file.imports.length || file.moduleAugmentations.length) {
87818                 var moduleNames = getModuleNames(file);
87819                 var resolutions = resolveModuleNamesReusingOldState(moduleNames, file);
87820                 ts.Debug.assert(resolutions.length === moduleNames.length);
87821                 for (var i = 0; i < moduleNames.length; i++) {
87822                     var resolution = resolutions[i];
87823                     ts.setResolvedModule(file, moduleNames[i], resolution);
87824                     if (!resolution) {
87825                         continue;
87826                     }
87827                     var isFromNodeModulesSearch = resolution.isExternalLibraryImport;
87828                     var isJsFile = !ts.resolutionExtensionIsTSOrJson(resolution.extension);
87829                     var isJsFileFromNodeModules = isFromNodeModulesSearch && isJsFile;
87830                     var resolvedFileName = resolution.resolvedFileName;
87831                     if (isFromNodeModulesSearch) {
87832                         currentNodeModulesDepth++;
87833                     }
87834                     var elideImport = isJsFileFromNodeModules && currentNodeModulesDepth > maxNodeModuleJsDepth;
87835                     var shouldAddFile = resolvedFileName
87836                         && !getResolutionDiagnostic(options, resolution)
87837                         && !options.noResolve
87838                         && i < file.imports.length
87839                         && !elideImport
87840                         && !(isJsFile && !ts.getAllowJSCompilerOption(options))
87841                         && (ts.isInJSFile(file.imports[i]) || !(file.imports[i].flags & 4194304));
87842                     if (elideImport) {
87843                         modulesWithElidedImports.set(file.path, true);
87844                     }
87845                     else if (shouldAddFile) {
87846                         var path = toPath(resolvedFileName);
87847                         var pos = ts.skipTrivia(file.text, file.imports[i].pos);
87848                         findSourceFile(resolvedFileName, path, false, false, {
87849                             kind: ts.RefFileKind.Import,
87850                             index: i,
87851                             file: file,
87852                             pos: pos,
87853                             end: file.imports[i].end
87854                         }, resolution.packageId);
87855                     }
87856                     if (isFromNodeModulesSearch) {
87857                         currentNodeModulesDepth--;
87858                     }
87859                 }
87860             }
87861             else {
87862                 file.resolvedModules = undefined;
87863             }
87864         }
87865         function computeCommonSourceDirectory(sourceFiles) {
87866             var fileNames = ts.mapDefined(sourceFiles, function (file) { return file.isDeclarationFile ? undefined : file.fileName; });
87867             return computeCommonSourceDirectoryOfFilenames(fileNames, currentDirectory, getCanonicalFileName);
87868         }
87869         function checkSourceFilesBelongToPath(sourceFiles, rootDirectory) {
87870             var allFilesBelongToPath = true;
87871             var absoluteRootDirectoryPath = host.getCanonicalFileName(ts.getNormalizedAbsolutePath(rootDirectory, currentDirectory));
87872             var rootPaths;
87873             for (var _i = 0, sourceFiles_2 = sourceFiles; _i < sourceFiles_2.length; _i++) {
87874                 var sourceFile = sourceFiles_2[_i];
87875                 if (!sourceFile.isDeclarationFile) {
87876                     var absoluteSourceFilePath = host.getCanonicalFileName(ts.getNormalizedAbsolutePath(sourceFile.fileName, currentDirectory));
87877                     if (absoluteSourceFilePath.indexOf(absoluteRootDirectoryPath) !== 0) {
87878                         if (!rootPaths)
87879                             rootPaths = new ts.Set(rootNames.map(toPath));
87880                         addProgramDiagnosticAtRefPath(sourceFile, rootPaths, ts.Diagnostics.File_0_is_not_under_rootDir_1_rootDir_is_expected_to_contain_all_source_files, sourceFile.fileName, rootDirectory);
87881                         allFilesBelongToPath = false;
87882                     }
87883                 }
87884             }
87885             return allFilesBelongToPath;
87886         }
87887         function parseProjectReferenceConfigFile(ref) {
87888             if (!projectReferenceRedirects) {
87889                 projectReferenceRedirects = new ts.Map();
87890             }
87891             var refPath = resolveProjectReferencePath(ref);
87892             var sourceFilePath = toPath(refPath);
87893             var fromCache = projectReferenceRedirects.get(sourceFilePath);
87894             if (fromCache !== undefined) {
87895                 return fromCache || undefined;
87896             }
87897             var commandLine;
87898             var sourceFile;
87899             if (host.getParsedCommandLine) {
87900                 commandLine = host.getParsedCommandLine(refPath);
87901                 if (!commandLine) {
87902                     addFileToFilesByName(undefined, sourceFilePath, undefined);
87903                     projectReferenceRedirects.set(sourceFilePath, false);
87904                     return undefined;
87905                 }
87906                 sourceFile = ts.Debug.checkDefined(commandLine.options.configFile);
87907                 ts.Debug.assert(!sourceFile.path || sourceFile.path === sourceFilePath);
87908                 addFileToFilesByName(sourceFile, sourceFilePath, undefined);
87909             }
87910             else {
87911                 var basePath = ts.getNormalizedAbsolutePath(ts.getDirectoryPath(refPath), host.getCurrentDirectory());
87912                 sourceFile = host.getSourceFile(refPath, 100);
87913                 addFileToFilesByName(sourceFile, sourceFilePath, undefined);
87914                 if (sourceFile === undefined) {
87915                     projectReferenceRedirects.set(sourceFilePath, false);
87916                     return undefined;
87917                 }
87918                 commandLine = ts.parseJsonSourceFileConfigFileContent(sourceFile, configParsingHost, basePath, undefined, refPath);
87919             }
87920             sourceFile.fileName = refPath;
87921             sourceFile.path = sourceFilePath;
87922             sourceFile.resolvedPath = sourceFilePath;
87923             sourceFile.originalFileName = refPath;
87924             var resolvedRef = { commandLine: commandLine, sourceFile: sourceFile };
87925             projectReferenceRedirects.set(sourceFilePath, resolvedRef);
87926             if (commandLine.projectReferences) {
87927                 resolvedRef.references = commandLine.projectReferences.map(parseProjectReferenceConfigFile);
87928             }
87929             return resolvedRef;
87930         }
87931         function verifyCompilerOptions() {
87932             if (options.strictPropertyInitialization && !ts.getStrictOptionValue(options, "strictNullChecks")) {
87933                 createDiagnosticForOptionName(ts.Diagnostics.Option_0_cannot_be_specified_without_specifying_option_1, "strictPropertyInitialization", "strictNullChecks");
87934             }
87935             if (options.isolatedModules) {
87936                 if (options.out) {
87937                     createDiagnosticForOptionName(ts.Diagnostics.Option_0_cannot_be_specified_with_option_1, "out", "isolatedModules");
87938                 }
87939                 if (options.outFile) {
87940                     createDiagnosticForOptionName(ts.Diagnostics.Option_0_cannot_be_specified_with_option_1, "outFile", "isolatedModules");
87941                 }
87942             }
87943             if (options.inlineSourceMap) {
87944                 if (options.sourceMap) {
87945                     createDiagnosticForOptionName(ts.Diagnostics.Option_0_cannot_be_specified_with_option_1, "sourceMap", "inlineSourceMap");
87946                 }
87947                 if (options.mapRoot) {
87948                     createDiagnosticForOptionName(ts.Diagnostics.Option_0_cannot_be_specified_with_option_1, "mapRoot", "inlineSourceMap");
87949                 }
87950             }
87951             if (options.composite) {
87952                 if (options.declaration === false) {
87953                     createDiagnosticForOptionName(ts.Diagnostics.Composite_projects_may_not_disable_declaration_emit, "declaration");
87954                 }
87955                 if (options.incremental === false) {
87956                     createDiagnosticForOptionName(ts.Diagnostics.Composite_projects_may_not_disable_incremental_compilation, "declaration");
87957                 }
87958             }
87959             var outputFile = ts.outFile(options);
87960             if (options.tsBuildInfoFile) {
87961                 if (!ts.isIncrementalCompilation(options)) {
87962                     createDiagnosticForOptionName(ts.Diagnostics.Option_0_cannot_be_specified_without_specifying_option_1_or_option_2, "tsBuildInfoFile", "incremental", "composite");
87963                 }
87964             }
87965             else if (options.incremental && !outputFile && !options.configFilePath) {
87966                 programDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_incremental_can_only_be_specified_using_tsconfig_emitting_to_single_file_or_when_option_tsBuildInfoFile_is_specified));
87967             }
87968             verifyProjectReferences();
87969             if (options.composite) {
87970                 var rootPaths = new ts.Set(rootNames.map(toPath));
87971                 for (var _i = 0, files_3 = files; _i < files_3.length; _i++) {
87972                     var file = files_3[_i];
87973                     if (ts.sourceFileMayBeEmitted(file, program) && !rootPaths.has(file.path)) {
87974                         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 || "");
87975                     }
87976                 }
87977             }
87978             if (options.paths) {
87979                 for (var key in options.paths) {
87980                     if (!ts.hasProperty(options.paths, key)) {
87981                         continue;
87982                     }
87983                     if (!ts.hasZeroOrOneAsteriskCharacter(key)) {
87984                         createDiagnosticForOptionPaths(true, key, ts.Diagnostics.Pattern_0_can_have_at_most_one_Asterisk_character, key);
87985                     }
87986                     if (ts.isArray(options.paths[key])) {
87987                         var len = options.paths[key].length;
87988                         if (len === 0) {
87989                             createDiagnosticForOptionPaths(false, key, ts.Diagnostics.Substitutions_for_pattern_0_shouldn_t_be_an_empty_array, key);
87990                         }
87991                         for (var i = 0; i < len; i++) {
87992                             var subst = options.paths[key][i];
87993                             var typeOfSubst = typeof subst;
87994                             if (typeOfSubst === "string") {
87995                                 if (!ts.hasZeroOrOneAsteriskCharacter(subst)) {
87996                                     createDiagnosticForOptionPathKeyValue(key, i, ts.Diagnostics.Substitution_0_in_pattern_1_can_have_at_most_one_Asterisk_character, subst, key);
87997                                 }
87998                                 if (!options.baseUrl && !ts.pathIsRelative(subst) && !ts.pathIsAbsolute(subst)) {
87999                                     createDiagnosticForOptionPathKeyValue(key, i, ts.Diagnostics.Non_relative_paths_are_not_allowed_when_baseUrl_is_not_set_Did_you_forget_a_leading_Slash);
88000                                 }
88001                             }
88002                             else {
88003                                 createDiagnosticForOptionPathKeyValue(key, i, ts.Diagnostics.Substitution_0_for_pattern_1_has_incorrect_type_expected_string_got_2, subst, key, typeOfSubst);
88004                             }
88005                         }
88006                     }
88007                     else {
88008                         createDiagnosticForOptionPaths(false, key, ts.Diagnostics.Substitutions_for_pattern_0_should_be_an_array, key);
88009                     }
88010                 }
88011             }
88012             if (!options.sourceMap && !options.inlineSourceMap) {
88013                 if (options.inlineSources) {
88014                     createDiagnosticForOptionName(ts.Diagnostics.Option_0_can_only_be_used_when_either_option_inlineSourceMap_or_option_sourceMap_is_provided, "inlineSources");
88015                 }
88016                 if (options.sourceRoot) {
88017                     createDiagnosticForOptionName(ts.Diagnostics.Option_0_can_only_be_used_when_either_option_inlineSourceMap_or_option_sourceMap_is_provided, "sourceRoot");
88018                 }
88019             }
88020             if (options.out && options.outFile) {
88021                 createDiagnosticForOptionName(ts.Diagnostics.Option_0_cannot_be_specified_with_option_1, "out", "outFile");
88022             }
88023             if (options.mapRoot && !(options.sourceMap || options.declarationMap)) {
88024                 createDiagnosticForOptionName(ts.Diagnostics.Option_0_cannot_be_specified_without_specifying_option_1_or_option_2, "mapRoot", "sourceMap", "declarationMap");
88025             }
88026             if (options.declarationDir) {
88027                 if (!ts.getEmitDeclarations(options)) {
88028                     createDiagnosticForOptionName(ts.Diagnostics.Option_0_cannot_be_specified_without_specifying_option_1_or_option_2, "declarationDir", "declaration", "composite");
88029                 }
88030                 if (outputFile) {
88031                     createDiagnosticForOptionName(ts.Diagnostics.Option_0_cannot_be_specified_with_option_1, "declarationDir", options.out ? "out" : "outFile");
88032                 }
88033             }
88034             if (options.declarationMap && !ts.getEmitDeclarations(options)) {
88035                 createDiagnosticForOptionName(ts.Diagnostics.Option_0_cannot_be_specified_without_specifying_option_1_or_option_2, "declarationMap", "declaration", "composite");
88036             }
88037             if (options.lib && options.noLib) {
88038                 createDiagnosticForOptionName(ts.Diagnostics.Option_0_cannot_be_specified_with_option_1, "lib", "noLib");
88039             }
88040             if (options.noImplicitUseStrict && ts.getStrictOptionValue(options, "alwaysStrict")) {
88041                 createDiagnosticForOptionName(ts.Diagnostics.Option_0_cannot_be_specified_with_option_1, "noImplicitUseStrict", "alwaysStrict");
88042             }
88043             var languageVersion = options.target || 0;
88044             var firstNonAmbientExternalModuleSourceFile = ts.find(files, function (f) { return ts.isExternalModule(f) && !f.isDeclarationFile; });
88045             if (options.isolatedModules) {
88046                 if (options.module === ts.ModuleKind.None && languageVersion < 2) {
88047                     createDiagnosticForOptionName(ts.Diagnostics.Option_isolatedModules_can_only_be_used_when_either_option_module_is_provided_or_option_target_is_ES2015_or_higher, "isolatedModules", "target");
88048                 }
88049                 var firstNonExternalModuleSourceFile = ts.find(files, function (f) { return !ts.isExternalModule(f) && !ts.isSourceFileJS(f) && !f.isDeclarationFile && f.scriptKind !== 6; });
88050                 if (firstNonExternalModuleSourceFile) {
88051                     var span = ts.getErrorSpanForNode(firstNonExternalModuleSourceFile, firstNonExternalModuleSourceFile);
88052                     programDiagnostics.add(ts.createFileDiagnostic(firstNonExternalModuleSourceFile, span.start, span.length, ts.Diagnostics._0_cannot_be_compiled_under_isolatedModules_because_it_is_considered_a_global_script_file_Add_an_import_export_or_an_empty_export_statement_to_make_it_a_module, ts.getBaseFileName(firstNonExternalModuleSourceFile.fileName)));
88053                 }
88054             }
88055             else if (firstNonAmbientExternalModuleSourceFile && languageVersion < 2 && options.module === ts.ModuleKind.None) {
88056                 var span = ts.getErrorSpanForNode(firstNonAmbientExternalModuleSourceFile, firstNonAmbientExternalModuleSourceFile.externalModuleIndicator);
88057                 programDiagnostics.add(ts.createFileDiagnostic(firstNonAmbientExternalModuleSourceFile, span.start, span.length, ts.Diagnostics.Cannot_use_imports_exports_or_module_augmentations_when_module_is_none));
88058             }
88059             if (outputFile && !options.emitDeclarationOnly) {
88060                 if (options.module && !(options.module === ts.ModuleKind.AMD || options.module === ts.ModuleKind.System)) {
88061                     createDiagnosticForOptionName(ts.Diagnostics.Only_amd_and_system_modules_are_supported_alongside_0, options.out ? "out" : "outFile", "module");
88062                 }
88063                 else if (options.module === undefined && firstNonAmbientExternalModuleSourceFile) {
88064                     var span = ts.getErrorSpanForNode(firstNonAmbientExternalModuleSourceFile, firstNonAmbientExternalModuleSourceFile.externalModuleIndicator);
88065                     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"));
88066                 }
88067             }
88068             if (options.resolveJsonModule) {
88069                 if (ts.getEmitModuleResolutionKind(options) !== ts.ModuleResolutionKind.NodeJs) {
88070                     createDiagnosticForOptionName(ts.Diagnostics.Option_resolveJsonModule_cannot_be_specified_without_node_module_resolution_strategy, "resolveJsonModule");
88071                 }
88072                 else if (!ts.hasJsonModuleEmitEnabled(options)) {
88073                     createDiagnosticForOptionName(ts.Diagnostics.Option_resolveJsonModule_can_only_be_specified_when_module_code_generation_is_commonjs_amd_es2015_or_esNext, "resolveJsonModule", "module");
88074                 }
88075             }
88076             if (options.outDir ||
88077                 options.sourceRoot ||
88078                 options.mapRoot) {
88079                 var dir = getCommonSourceDirectory();
88080                 if (options.outDir && dir === "" && files.some(function (file) { return ts.getRootLength(file.fileName) > 1; })) {
88081                     createDiagnosticForOptionName(ts.Diagnostics.Cannot_find_the_common_subdirectory_path_for_the_input_files, "outDir");
88082                 }
88083             }
88084             if (options.useDefineForClassFields && languageVersion === 0) {
88085                 createDiagnosticForOptionName(ts.Diagnostics.Option_0_cannot_be_specified_when_option_target_is_ES3, "useDefineForClassFields");
88086             }
88087             if (options.checkJs && !ts.getAllowJSCompilerOption(options)) {
88088                 programDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_0_cannot_be_specified_without_specifying_option_1, "checkJs", "allowJs"));
88089             }
88090             if (options.emitDeclarationOnly) {
88091                 if (!ts.getEmitDeclarations(options)) {
88092                     createDiagnosticForOptionName(ts.Diagnostics.Option_0_cannot_be_specified_without_specifying_option_1_or_option_2, "emitDeclarationOnly", "declaration", "composite");
88093                 }
88094                 if (options.noEmit) {
88095                     createDiagnosticForOptionName(ts.Diagnostics.Option_0_cannot_be_specified_with_option_1, "emitDeclarationOnly", "noEmit");
88096                 }
88097             }
88098             if (options.emitDecoratorMetadata &&
88099                 !options.experimentalDecorators) {
88100                 createDiagnosticForOptionName(ts.Diagnostics.Option_0_cannot_be_specified_without_specifying_option_1, "emitDecoratorMetadata", "experimentalDecorators");
88101             }
88102             if (options.jsxFactory) {
88103                 if (options.reactNamespace) {
88104                     createDiagnosticForOptionName(ts.Diagnostics.Option_0_cannot_be_specified_with_option_1, "reactNamespace", "jsxFactory");
88105                 }
88106                 if (options.jsx === 4 || options.jsx === 5) {
88107                     createDiagnosticForOptionName(ts.Diagnostics.Option_0_cannot_be_specified_when_option_jsx_is_1, "jsxFactory", ts.inverseJsxOptionMap.get("" + options.jsx));
88108                 }
88109                 if (!ts.parseIsolatedEntityName(options.jsxFactory, languageVersion)) {
88110                     createOptionValueDiagnostic("jsxFactory", ts.Diagnostics.Invalid_value_for_jsxFactory_0_is_not_a_valid_identifier_or_qualified_name, options.jsxFactory);
88111                 }
88112             }
88113             else if (options.reactNamespace && !ts.isIdentifierText(options.reactNamespace, languageVersion)) {
88114                 createOptionValueDiagnostic("reactNamespace", ts.Diagnostics.Invalid_value_for_reactNamespace_0_is_not_a_valid_identifier, options.reactNamespace);
88115             }
88116             if (options.jsxFragmentFactory) {
88117                 if (!options.jsxFactory) {
88118                     createDiagnosticForOptionName(ts.Diagnostics.Option_0_cannot_be_specified_without_specifying_option_1, "jsxFragmentFactory", "jsxFactory");
88119                 }
88120                 if (options.jsx === 4 || options.jsx === 5) {
88121                     createDiagnosticForOptionName(ts.Diagnostics.Option_0_cannot_be_specified_when_option_jsx_is_1, "jsxFragmentFactory", ts.inverseJsxOptionMap.get("" + options.jsx));
88122                 }
88123                 if (!ts.parseIsolatedEntityName(options.jsxFragmentFactory, languageVersion)) {
88124                     createOptionValueDiagnostic("jsxFragmentFactory", ts.Diagnostics.Invalid_value_for_jsxFragmentFactory_0_is_not_a_valid_identifier_or_qualified_name, options.jsxFragmentFactory);
88125                 }
88126             }
88127             if (options.reactNamespace) {
88128                 if (options.jsx === 4 || options.jsx === 5) {
88129                     createDiagnosticForOptionName(ts.Diagnostics.Option_0_cannot_be_specified_when_option_jsx_is_1, "reactNamespace", ts.inverseJsxOptionMap.get("" + options.jsx));
88130                 }
88131             }
88132             if (options.jsxImportSource) {
88133                 if (options.jsx === 2) {
88134                     createDiagnosticForOptionName(ts.Diagnostics.Option_0_cannot_be_specified_when_option_jsx_is_1, "jsxImportSource", ts.inverseJsxOptionMap.get("" + options.jsx));
88135                 }
88136             }
88137             if (!options.noEmit && !options.suppressOutputPathCheck) {
88138                 var emitHost = getEmitHost();
88139                 var emitFilesSeen_1 = new ts.Set();
88140                 ts.forEachEmittedFile(emitHost, function (emitFileNames) {
88141                     if (!options.emitDeclarationOnly) {
88142                         verifyEmitFilePath(emitFileNames.jsFilePath, emitFilesSeen_1);
88143                     }
88144                     verifyEmitFilePath(emitFileNames.declarationFilePath, emitFilesSeen_1);
88145                 });
88146             }
88147             function verifyEmitFilePath(emitFileName, emitFilesSeen) {
88148                 if (emitFileName) {
88149                     var emitFilePath = toPath(emitFileName);
88150                     if (filesByName.has(emitFilePath)) {
88151                         var chain = void 0;
88152                         if (!options.configFilePath) {
88153                             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);
88154                         }
88155                         chain = ts.chainDiagnosticMessages(chain, ts.Diagnostics.Cannot_write_file_0_because_it_would_overwrite_input_file, emitFileName);
88156                         blockEmittingOfFile(emitFileName, ts.createCompilerDiagnosticFromMessageChain(chain));
88157                     }
88158                     var emitFileKey = !host.useCaseSensitiveFileNames() ? ts.toFileNameLowerCase(emitFilePath) : emitFilePath;
88159                     if (emitFilesSeen.has(emitFileKey)) {
88160                         blockEmittingOfFile(emitFileName, ts.createCompilerDiagnostic(ts.Diagnostics.Cannot_write_file_0_because_it_would_be_overwritten_by_multiple_input_files, emitFileName));
88161                     }
88162                     else {
88163                         emitFilesSeen.add(emitFileKey);
88164                     }
88165                 }
88166             }
88167         }
88168         function createFileDiagnosticAtReference(refPathToReportErrorOn, message) {
88169             var _a, _b;
88170             var args = [];
88171             for (var _i = 2; _i < arguments.length; _i++) {
88172                 args[_i - 2] = arguments[_i];
88173             }
88174             var refFile = ts.Debug.checkDefined(getSourceFileByPath(refPathToReportErrorOn.file));
88175             var kind = refPathToReportErrorOn.kind, index = refPathToReportErrorOn.index;
88176             var pos, end;
88177             switch (kind) {
88178                 case ts.RefFileKind.Import:
88179                     pos = ts.skipTrivia(refFile.text, refFile.imports[index].pos);
88180                     end = refFile.imports[index].end;
88181                     break;
88182                 case ts.RefFileKind.ReferenceFile:
88183                     (_a = refFile.referencedFiles[index], pos = _a.pos, end = _a.end);
88184                     break;
88185                 case ts.RefFileKind.TypeReferenceDirective:
88186                     (_b = refFile.typeReferenceDirectives[index], pos = _b.pos, end = _b.end);
88187                     break;
88188                 default:
88189                     return ts.Debug.assertNever(kind);
88190             }
88191             return ts.createFileDiagnostic.apply(void 0, __spreadArrays([refFile, pos, end - pos, message], args));
88192         }
88193         function addProgramDiagnosticAtRefPath(file, rootPaths, message) {
88194             var args = [];
88195             for (var _i = 3; _i < arguments.length; _i++) {
88196                 args[_i - 3] = arguments[_i];
88197             }
88198             var refPaths = refFileMap === null || refFileMap === void 0 ? void 0 : refFileMap.get(file.path);
88199             var refPathToReportErrorOn = ts.forEach(refPaths, function (refPath) { return rootPaths.has(refPath.file) ? refPath : undefined; }) ||
88200                 ts.elementAt(refPaths, 0);
88201             programDiagnostics.add(refPathToReportErrorOn ? createFileDiagnosticAtReference.apply(void 0, __spreadArrays([refPathToReportErrorOn, message], args)) : ts.createCompilerDiagnostic.apply(void 0, __spreadArrays([message], args)));
88202         }
88203         function verifyProjectReferences() {
88204             var buildInfoPath = !options.suppressOutputPathCheck ? ts.getTsBuildInfoEmitOutputFilePath(options) : undefined;
88205             forEachProjectReference(projectReferences, resolvedProjectReferences, function (resolvedRef, parent, index) {
88206                 var ref = (parent ? parent.commandLine.projectReferences : projectReferences)[index];
88207                 var parentFile = parent && parent.sourceFile;
88208                 if (!resolvedRef) {
88209                     createDiagnosticForReference(parentFile, index, ts.Diagnostics.File_0_not_found, ref.path);
88210                     return;
88211                 }
88212                 var options = resolvedRef.commandLine.options;
88213                 if (!options.composite || options.noEmit) {
88214                     var inputs = parent ? parent.commandLine.fileNames : rootNames;
88215                     if (inputs.length) {
88216                         if (!options.composite)
88217                             createDiagnosticForReference(parentFile, index, ts.Diagnostics.Referenced_project_0_must_have_setting_composite_Colon_true, ref.path);
88218                         if (options.noEmit)
88219                             createDiagnosticForReference(parentFile, index, ts.Diagnostics.Referenced_project_0_may_not_disable_emit, ref.path);
88220                     }
88221                 }
88222                 if (ref.prepend) {
88223                     var out = ts.outFile(options);
88224                     if (out) {
88225                         if (!host.fileExists(out)) {
88226                             createDiagnosticForReference(parentFile, index, ts.Diagnostics.Output_file_0_from_project_1_does_not_exist, out, ref.path);
88227                         }
88228                     }
88229                     else {
88230                         createDiagnosticForReference(parentFile, index, ts.Diagnostics.Cannot_prepend_project_0_because_it_does_not_have_outFile_set, ref.path);
88231                     }
88232                 }
88233                 if (!parent && buildInfoPath && buildInfoPath === ts.getTsBuildInfoEmitOutputFilePath(options)) {
88234                     createDiagnosticForReference(parentFile, index, ts.Diagnostics.Cannot_write_file_0_because_it_will_overwrite_tsbuildinfo_file_generated_by_referenced_project_1, buildInfoPath, ref.path);
88235                     hasEmitBlockingDiagnostics.set(toPath(buildInfoPath), true);
88236                 }
88237             });
88238         }
88239         function createDiagnosticForOptionPathKeyValue(key, valueIndex, message, arg0, arg1, arg2) {
88240             var needCompilerDiagnostic = true;
88241             var pathsSyntax = getOptionPathsSyntax();
88242             for (var _i = 0, pathsSyntax_1 = pathsSyntax; _i < pathsSyntax_1.length; _i++) {
88243                 var pathProp = pathsSyntax_1[_i];
88244                 if (ts.isObjectLiteralExpression(pathProp.initializer)) {
88245                     for (var _a = 0, _b = ts.getPropertyAssignment(pathProp.initializer, key); _a < _b.length; _a++) {
88246                         var keyProps = _b[_a];
88247                         var initializer = keyProps.initializer;
88248                         if (ts.isArrayLiteralExpression(initializer) && initializer.elements.length > valueIndex) {
88249                             programDiagnostics.add(ts.createDiagnosticForNodeInSourceFile(options.configFile, initializer.elements[valueIndex], message, arg0, arg1, arg2));
88250                             needCompilerDiagnostic = false;
88251                         }
88252                     }
88253                 }
88254             }
88255             if (needCompilerDiagnostic) {
88256                 programDiagnostics.add(ts.createCompilerDiagnostic(message, arg0, arg1, arg2));
88257             }
88258         }
88259         function createDiagnosticForOptionPaths(onKey, key, message, arg0) {
88260             var needCompilerDiagnostic = true;
88261             var pathsSyntax = getOptionPathsSyntax();
88262             for (var _i = 0, pathsSyntax_2 = pathsSyntax; _i < pathsSyntax_2.length; _i++) {
88263                 var pathProp = pathsSyntax_2[_i];
88264                 if (ts.isObjectLiteralExpression(pathProp.initializer) &&
88265                     createOptionDiagnosticInObjectLiteralSyntax(pathProp.initializer, onKey, key, undefined, message, arg0)) {
88266                     needCompilerDiagnostic = false;
88267                 }
88268             }
88269             if (needCompilerDiagnostic) {
88270                 programDiagnostics.add(ts.createCompilerDiagnostic(message, arg0));
88271             }
88272         }
88273         function getOptionsSyntaxByName(name) {
88274             var compilerOptionsObjectLiteralSyntax = getCompilerOptionsObjectLiteralSyntax();
88275             if (compilerOptionsObjectLiteralSyntax) {
88276                 return ts.getPropertyAssignment(compilerOptionsObjectLiteralSyntax, name);
88277             }
88278             return undefined;
88279         }
88280         function getOptionPathsSyntax() {
88281             return getOptionsSyntaxByName("paths") || ts.emptyArray;
88282         }
88283         function createDiagnosticForOptionName(message, option1, option2, option3) {
88284             createDiagnosticForOption(true, option1, option2, message, option1, option2, option3);
88285         }
88286         function createOptionValueDiagnostic(option1, message, arg0) {
88287             createDiagnosticForOption(false, option1, undefined, message, arg0);
88288         }
88289         function createDiagnosticForReference(sourceFile, index, message, arg0, arg1) {
88290             var referencesSyntax = ts.firstDefined(ts.getTsConfigPropArray(sourceFile || options.configFile, "references"), function (property) { return ts.isArrayLiteralExpression(property.initializer) ? property.initializer : undefined; });
88291             if (referencesSyntax && referencesSyntax.elements.length > index) {
88292                 programDiagnostics.add(ts.createDiagnosticForNodeInSourceFile(sourceFile || options.configFile, referencesSyntax.elements[index], message, arg0, arg1));
88293             }
88294             else {
88295                 programDiagnostics.add(ts.createCompilerDiagnostic(message, arg0, arg1));
88296             }
88297         }
88298         function createDiagnosticForOption(onKey, option1, option2, message, arg0, arg1, arg2) {
88299             var compilerOptionsObjectLiteralSyntax = getCompilerOptionsObjectLiteralSyntax();
88300             var needCompilerDiagnostic = !compilerOptionsObjectLiteralSyntax ||
88301                 !createOptionDiagnosticInObjectLiteralSyntax(compilerOptionsObjectLiteralSyntax, onKey, option1, option2, message, arg0, arg1, arg2);
88302             if (needCompilerDiagnostic) {
88303                 programDiagnostics.add(ts.createCompilerDiagnostic(message, arg0, arg1, arg2));
88304             }
88305         }
88306         function getCompilerOptionsObjectLiteralSyntax() {
88307             if (_compilerOptionsObjectLiteralSyntax === undefined) {
88308                 _compilerOptionsObjectLiteralSyntax = null;
88309                 var jsonObjectLiteral = ts.getTsConfigObjectLiteralExpression(options.configFile);
88310                 if (jsonObjectLiteral) {
88311                     for (var _i = 0, _a = ts.getPropertyAssignment(jsonObjectLiteral, "compilerOptions"); _i < _a.length; _i++) {
88312                         var prop = _a[_i];
88313                         if (ts.isObjectLiteralExpression(prop.initializer)) {
88314                             _compilerOptionsObjectLiteralSyntax = prop.initializer;
88315                             break;
88316                         }
88317                     }
88318                 }
88319             }
88320             return _compilerOptionsObjectLiteralSyntax;
88321         }
88322         function createOptionDiagnosticInObjectLiteralSyntax(objectLiteral, onKey, key1, key2, message, arg0, arg1, arg2) {
88323             var props = ts.getPropertyAssignment(objectLiteral, key1, key2);
88324             for (var _i = 0, props_3 = props; _i < props_3.length; _i++) {
88325                 var prop = props_3[_i];
88326                 programDiagnostics.add(ts.createDiagnosticForNodeInSourceFile(options.configFile, onKey ? prop.name : prop.initializer, message, arg0, arg1, arg2));
88327             }
88328             return !!props.length;
88329         }
88330         function blockEmittingOfFile(emitFileName, diag) {
88331             hasEmitBlockingDiagnostics.set(toPath(emitFileName), true);
88332             programDiagnostics.add(diag);
88333         }
88334         function isEmittedFile(file) {
88335             if (options.noEmit) {
88336                 return false;
88337             }
88338             var filePath = toPath(file);
88339             if (getSourceFileByPath(filePath)) {
88340                 return false;
88341             }
88342             var out = ts.outFile(options);
88343             if (out) {
88344                 return isSameFile(filePath, out) || isSameFile(filePath, ts.removeFileExtension(out) + ".d.ts");
88345             }
88346             if (options.declarationDir && ts.containsPath(options.declarationDir, filePath, currentDirectory, !host.useCaseSensitiveFileNames())) {
88347                 return true;
88348             }
88349             if (options.outDir) {
88350                 return ts.containsPath(options.outDir, filePath, currentDirectory, !host.useCaseSensitiveFileNames());
88351             }
88352             if (ts.fileExtensionIsOneOf(filePath, ts.supportedJSExtensions) || ts.fileExtensionIs(filePath, ".d.ts")) {
88353                 var filePathWithoutExtension = ts.removeFileExtension(filePath);
88354                 return !!getSourceFileByPath((filePathWithoutExtension + ".ts")) ||
88355                     !!getSourceFileByPath((filePathWithoutExtension + ".tsx"));
88356             }
88357             return false;
88358         }
88359         function isSameFile(file1, file2) {
88360             return ts.comparePaths(file1, file2, currentDirectory, !host.useCaseSensitiveFileNames()) === 0;
88361         }
88362         function getSymlinkCache() {
88363             if (host.getSymlinkCache) {
88364                 return host.getSymlinkCache();
88365             }
88366             return symlinks || (symlinks = ts.discoverProbableSymlinks(files, getCanonicalFileName, host.getCurrentDirectory()));
88367         }
88368     }
88369     ts.createProgram = createProgram;
88370     function updateHostForUseSourceOfProjectReferenceRedirect(host) {
88371         var setOfDeclarationDirectories;
88372         var originalFileExists = host.compilerHost.fileExists;
88373         var originalDirectoryExists = host.compilerHost.directoryExists;
88374         var originalGetDirectories = host.compilerHost.getDirectories;
88375         var originalRealpath = host.compilerHost.realpath;
88376         if (!host.useSourceOfProjectReferenceRedirect)
88377             return { onProgramCreateComplete: ts.noop, fileExists: fileExists };
88378         host.compilerHost.fileExists = fileExists;
88379         var directoryExists;
88380         if (originalDirectoryExists) {
88381             directoryExists = host.compilerHost.directoryExists = function (path) {
88382                 if (originalDirectoryExists.call(host.compilerHost, path)) {
88383                     handleDirectoryCouldBeSymlink(path);
88384                     return true;
88385                 }
88386                 if (!host.getResolvedProjectReferences())
88387                     return false;
88388                 if (!setOfDeclarationDirectories) {
88389                     setOfDeclarationDirectories = new ts.Set();
88390                     host.forEachResolvedProjectReference(function (ref) {
88391                         var out = ts.outFile(ref.commandLine.options);
88392                         if (out) {
88393                             setOfDeclarationDirectories.add(ts.getDirectoryPath(host.toPath(out)));
88394                         }
88395                         else {
88396                             var declarationDir = ref.commandLine.options.declarationDir || ref.commandLine.options.outDir;
88397                             if (declarationDir) {
88398                                 setOfDeclarationDirectories.add(host.toPath(declarationDir));
88399                             }
88400                         }
88401                     });
88402                 }
88403                 return fileOrDirectoryExistsUsingSource(path, false);
88404             };
88405         }
88406         if (originalGetDirectories) {
88407             host.compilerHost.getDirectories = function (path) {
88408                 return !host.getResolvedProjectReferences() || (originalDirectoryExists && originalDirectoryExists.call(host.compilerHost, path)) ?
88409                     originalGetDirectories.call(host.compilerHost, path) :
88410                     [];
88411             };
88412         }
88413         if (originalRealpath) {
88414             host.compilerHost.realpath = function (s) {
88415                 var _a;
88416                 return ((_a = host.getSymlinkCache().getSymlinkedFiles()) === null || _a === void 0 ? void 0 : _a.get(host.toPath(s))) ||
88417                     originalRealpath.call(host.compilerHost, s);
88418             };
88419         }
88420         return { onProgramCreateComplete: onProgramCreateComplete, fileExists: fileExists, directoryExists: directoryExists };
88421         function onProgramCreateComplete() {
88422             host.compilerHost.fileExists = originalFileExists;
88423             host.compilerHost.directoryExists = originalDirectoryExists;
88424             host.compilerHost.getDirectories = originalGetDirectories;
88425         }
88426         function fileExists(file) {
88427             if (originalFileExists.call(host.compilerHost, file))
88428                 return true;
88429             if (!host.getResolvedProjectReferences())
88430                 return false;
88431             if (!ts.isDeclarationFileName(file))
88432                 return false;
88433             return fileOrDirectoryExistsUsingSource(file, true);
88434         }
88435         function fileExistsIfProjectReferenceDts(file) {
88436             var source = host.getSourceOfProjectReferenceRedirect(file);
88437             return source !== undefined ?
88438                 ts.isString(source) ? originalFileExists.call(host.compilerHost, source) : true :
88439                 undefined;
88440         }
88441         function directoryExistsIfProjectReferenceDeclDir(dir) {
88442             var dirPath = host.toPath(dir);
88443             var dirPathWithTrailingDirectorySeparator = "" + dirPath + ts.directorySeparator;
88444             return ts.forEachKey(setOfDeclarationDirectories, function (declDirPath) { return dirPath === declDirPath ||
88445                 ts.startsWith(declDirPath, dirPathWithTrailingDirectorySeparator) ||
88446                 ts.startsWith(dirPath, declDirPath + "/"); });
88447         }
88448         function handleDirectoryCouldBeSymlink(directory) {
88449             var _a;
88450             if (!host.getResolvedProjectReferences())
88451                 return;
88452             if (!originalRealpath || !ts.stringContains(directory, ts.nodeModulesPathPart))
88453                 return;
88454             var symlinkCache = host.getSymlinkCache();
88455             var directoryPath = ts.ensureTrailingDirectorySeparator(host.toPath(directory));
88456             if ((_a = symlinkCache.getSymlinkedDirectories()) === null || _a === void 0 ? void 0 : _a.has(directoryPath))
88457                 return;
88458             var real = ts.normalizePath(originalRealpath.call(host.compilerHost, directory));
88459             var realPath;
88460             if (real === directory ||
88461                 (realPath = ts.ensureTrailingDirectorySeparator(host.toPath(real))) === directoryPath) {
88462                 symlinkCache.setSymlinkedDirectory(directoryPath, false);
88463                 return;
88464             }
88465             symlinkCache.setSymlinkedDirectory(directoryPath, {
88466                 real: ts.ensureTrailingDirectorySeparator(real),
88467                 realPath: realPath
88468             });
88469         }
88470         function fileOrDirectoryExistsUsingSource(fileOrDirectory, isFile) {
88471             var _a;
88472             var fileOrDirectoryExistsUsingSource = isFile ?
88473                 function (file) { return fileExistsIfProjectReferenceDts(file); } :
88474                 function (dir) { return directoryExistsIfProjectReferenceDeclDir(dir); };
88475             var result = fileOrDirectoryExistsUsingSource(fileOrDirectory);
88476             if (result !== undefined)
88477                 return result;
88478             var symlinkCache = host.getSymlinkCache();
88479             var symlinkedDirectories = symlinkCache.getSymlinkedDirectories();
88480             if (!symlinkedDirectories)
88481                 return false;
88482             var fileOrDirectoryPath = host.toPath(fileOrDirectory);
88483             if (!ts.stringContains(fileOrDirectoryPath, ts.nodeModulesPathPart))
88484                 return false;
88485             if (isFile && ((_a = symlinkCache.getSymlinkedFiles()) === null || _a === void 0 ? void 0 : _a.has(fileOrDirectoryPath)))
88486                 return true;
88487             return ts.firstDefinedIterator(symlinkedDirectories.entries(), function (_a) {
88488                 var directoryPath = _a[0], symlinkedDirectory = _a[1];
88489                 if (!symlinkedDirectory || !ts.startsWith(fileOrDirectoryPath, directoryPath))
88490                     return undefined;
88491                 var result = fileOrDirectoryExistsUsingSource(fileOrDirectoryPath.replace(directoryPath, symlinkedDirectory.realPath));
88492                 if (isFile && result) {
88493                     var absolutePath = ts.getNormalizedAbsolutePath(fileOrDirectory, host.compilerHost.getCurrentDirectory());
88494                     symlinkCache.setSymlinkedFile(fileOrDirectoryPath, "" + symlinkedDirectory.real + absolutePath.replace(new RegExp(directoryPath, "i"), ""));
88495                 }
88496                 return result;
88497             }) || false;
88498         }
88499     }
88500     ts.emitSkippedWithNoDiagnostics = { diagnostics: ts.emptyArray, sourceMaps: undefined, emittedFiles: undefined, emitSkipped: true };
88501     function handleNoEmitOptions(program, sourceFile, writeFile, cancellationToken) {
88502         var options = program.getCompilerOptions();
88503         if (options.noEmit) {
88504             program.getSemanticDiagnostics(sourceFile, cancellationToken);
88505             return sourceFile || ts.outFile(options) ?
88506                 ts.emitSkippedWithNoDiagnostics :
88507                 program.emitBuildInfo(writeFile, cancellationToken);
88508         }
88509         if (!options.noEmitOnError)
88510             return undefined;
88511         var diagnostics = __spreadArrays(program.getOptionsDiagnostics(cancellationToken), program.getSyntacticDiagnostics(sourceFile, cancellationToken), program.getGlobalDiagnostics(cancellationToken), program.getSemanticDiagnostics(sourceFile, cancellationToken));
88512         if (diagnostics.length === 0 && ts.getEmitDeclarations(program.getCompilerOptions())) {
88513             diagnostics = program.getDeclarationDiagnostics(undefined, cancellationToken);
88514         }
88515         if (!diagnostics.length)
88516             return undefined;
88517         var emittedFiles;
88518         if (!sourceFile && !ts.outFile(options)) {
88519             var emitResult = program.emitBuildInfo(writeFile, cancellationToken);
88520             if (emitResult.diagnostics)
88521                 diagnostics = __spreadArrays(diagnostics, emitResult.diagnostics);
88522             emittedFiles = emitResult.emittedFiles;
88523         }
88524         return { diagnostics: diagnostics, sourceMaps: undefined, emittedFiles: emittedFiles, emitSkipped: true };
88525     }
88526     ts.handleNoEmitOptions = handleNoEmitOptions;
88527     function filterSemanticDiagnotics(diagnostic, option) {
88528         return ts.filter(diagnostic, function (d) { return !d.skippedOn || !option[d.skippedOn]; });
88529     }
88530     ts.filterSemanticDiagnotics = filterSemanticDiagnotics;
88531     function parseConfigHostFromCompilerHostLike(host, directoryStructureHost) {
88532         if (directoryStructureHost === void 0) { directoryStructureHost = host; }
88533         return {
88534             fileExists: function (f) { return directoryStructureHost.fileExists(f); },
88535             readDirectory: function (root, extensions, excludes, includes, depth) {
88536                 ts.Debug.assertIsDefined(directoryStructureHost.readDirectory, "'CompilerHost.readDirectory' must be implemented to correctly process 'projectReferences'");
88537                 return directoryStructureHost.readDirectory(root, extensions, excludes, includes, depth);
88538             },
88539             readFile: function (f) { return directoryStructureHost.readFile(f); },
88540             useCaseSensitiveFileNames: host.useCaseSensitiveFileNames(),
88541             getCurrentDirectory: function () { return host.getCurrentDirectory(); },
88542             onUnRecoverableConfigFileDiagnostic: host.onUnRecoverableConfigFileDiagnostic || ts.returnUndefined,
88543             trace: host.trace ? function (s) { return host.trace(s); } : undefined
88544         };
88545     }
88546     ts.parseConfigHostFromCompilerHostLike = parseConfigHostFromCompilerHostLike;
88547     function createPrependNodes(projectReferences, getCommandLine, readFile) {
88548         if (!projectReferences)
88549             return ts.emptyArray;
88550         var nodes;
88551         for (var i = 0; i < projectReferences.length; i++) {
88552             var ref = projectReferences[i];
88553             var resolvedRefOpts = getCommandLine(ref, i);
88554             if (ref.prepend && resolvedRefOpts && resolvedRefOpts.options) {
88555                 var out = ts.outFile(resolvedRefOpts.options);
88556                 if (!out)
88557                     continue;
88558                 var _a = ts.getOutputPathsForBundle(resolvedRefOpts.options, true), jsFilePath = _a.jsFilePath, sourceMapFilePath = _a.sourceMapFilePath, declarationFilePath = _a.declarationFilePath, declarationMapPath = _a.declarationMapPath, buildInfoPath = _a.buildInfoPath;
88559                 var node = ts.createInputFiles(readFile, jsFilePath, sourceMapFilePath, declarationFilePath, declarationMapPath, buildInfoPath);
88560                 (nodes || (nodes = [])).push(node);
88561             }
88562         }
88563         return nodes || ts.emptyArray;
88564     }
88565     ts.createPrependNodes = createPrependNodes;
88566     function resolveProjectReferencePath(hostOrRef, ref) {
88567         var passedInRef = ref ? ref : hostOrRef;
88568         return ts.resolveConfigFileProjectName(passedInRef.path);
88569     }
88570     ts.resolveProjectReferencePath = resolveProjectReferencePath;
88571     function getResolutionDiagnostic(options, _a) {
88572         var extension = _a.extension;
88573         switch (extension) {
88574             case ".ts":
88575             case ".d.ts":
88576                 return undefined;
88577             case ".tsx":
88578                 return needJsx();
88579             case ".jsx":
88580                 return needJsx() || needAllowJs();
88581             case ".js":
88582                 return needAllowJs();
88583             case ".json":
88584                 return needResolveJsonModule();
88585         }
88586         function needJsx() {
88587             return options.jsx ? undefined : ts.Diagnostics.Module_0_was_resolved_to_1_but_jsx_is_not_set;
88588         }
88589         function needAllowJs() {
88590             return ts.getAllowJSCompilerOption(options) || !ts.getStrictOptionValue(options, "noImplicitAny") ? undefined : ts.Diagnostics.Could_not_find_a_declaration_file_for_module_0_1_implicitly_has_an_any_type;
88591         }
88592         function needResolveJsonModule() {
88593             return options.resolveJsonModule ? undefined : ts.Diagnostics.Module_0_was_resolved_to_1_but_resolveJsonModule_is_not_used;
88594         }
88595     }
88596     ts.getResolutionDiagnostic = getResolutionDiagnostic;
88597     function getModuleNames(_a) {
88598         var imports = _a.imports, moduleAugmentations = _a.moduleAugmentations;
88599         var res = imports.map(function (i) { return i.text; });
88600         for (var _i = 0, moduleAugmentations_1 = moduleAugmentations; _i < moduleAugmentations_1.length; _i++) {
88601             var aug = moduleAugmentations_1[_i];
88602             if (aug.kind === 10) {
88603                 res.push(aug.text);
88604             }
88605         }
88606         return res;
88607     }
88608 })(ts || (ts = {}));
88609 var ts;
88610 (function (ts) {
88611     function getFileEmitOutput(program, sourceFile, emitOnlyDtsFiles, cancellationToken, customTransformers, forceDtsEmit) {
88612         var outputFiles = [];
88613         var _a = program.emit(sourceFile, writeFile, cancellationToken, emitOnlyDtsFiles, customTransformers, forceDtsEmit), emitSkipped = _a.emitSkipped, diagnostics = _a.diagnostics, exportedModulesFromDeclarationEmit = _a.exportedModulesFromDeclarationEmit;
88614         return { outputFiles: outputFiles, emitSkipped: emitSkipped, diagnostics: diagnostics, exportedModulesFromDeclarationEmit: exportedModulesFromDeclarationEmit };
88615         function writeFile(fileName, text, writeByteOrderMark) {
88616             outputFiles.push({ name: fileName, writeByteOrderMark: writeByteOrderMark, text: text });
88617         }
88618     }
88619     ts.getFileEmitOutput = getFileEmitOutput;
88620     var BuilderState;
88621     (function (BuilderState) {
88622         function getReferencedFileFromImportedModuleSymbol(symbol) {
88623             if (symbol.declarations && symbol.declarations[0]) {
88624                 var declarationSourceFile = ts.getSourceFileOfNode(symbol.declarations[0]);
88625                 return declarationSourceFile && declarationSourceFile.resolvedPath;
88626             }
88627         }
88628         function getReferencedFileFromImportLiteral(checker, importName) {
88629             var symbol = checker.getSymbolAtLocation(importName);
88630             return symbol && getReferencedFileFromImportedModuleSymbol(symbol);
88631         }
88632         function getReferencedFileFromFileName(program, fileName, sourceFileDirectory, getCanonicalFileName) {
88633             return ts.toPath(program.getProjectReferenceRedirect(fileName) || fileName, sourceFileDirectory, getCanonicalFileName);
88634         }
88635         function getReferencedFiles(program, sourceFile, getCanonicalFileName) {
88636             var referencedFiles;
88637             if (sourceFile.imports && sourceFile.imports.length > 0) {
88638                 var checker = program.getTypeChecker();
88639                 for (var _i = 0, _a = sourceFile.imports; _i < _a.length; _i++) {
88640                     var importName = _a[_i];
88641                     var declarationSourceFilePath = getReferencedFileFromImportLiteral(checker, importName);
88642                     if (declarationSourceFilePath) {
88643                         addReferencedFile(declarationSourceFilePath);
88644                     }
88645                 }
88646             }
88647             var sourceFileDirectory = ts.getDirectoryPath(sourceFile.resolvedPath);
88648             if (sourceFile.referencedFiles && sourceFile.referencedFiles.length > 0) {
88649                 for (var _b = 0, _c = sourceFile.referencedFiles; _b < _c.length; _b++) {
88650                     var referencedFile = _c[_b];
88651                     var referencedPath = getReferencedFileFromFileName(program, referencedFile.fileName, sourceFileDirectory, getCanonicalFileName);
88652                     addReferencedFile(referencedPath);
88653                 }
88654             }
88655             if (sourceFile.resolvedTypeReferenceDirectiveNames) {
88656                 sourceFile.resolvedTypeReferenceDirectiveNames.forEach(function (resolvedTypeReferenceDirective) {
88657                     if (!resolvedTypeReferenceDirective) {
88658                         return;
88659                     }
88660                     var fileName = resolvedTypeReferenceDirective.resolvedFileName;
88661                     var typeFilePath = getReferencedFileFromFileName(program, fileName, sourceFileDirectory, getCanonicalFileName);
88662                     addReferencedFile(typeFilePath);
88663                 });
88664             }
88665             if (sourceFile.moduleAugmentations.length) {
88666                 var checker = program.getTypeChecker();
88667                 for (var _d = 0, _e = sourceFile.moduleAugmentations; _d < _e.length; _d++) {
88668                     var moduleName = _e[_d];
88669                     if (!ts.isStringLiteral(moduleName)) {
88670                         continue;
88671                     }
88672                     var symbol = checker.getSymbolAtLocation(moduleName);
88673                     if (!symbol) {
88674                         continue;
88675                     }
88676                     addReferenceFromAmbientModule(symbol);
88677                 }
88678             }
88679             for (var _f = 0, _g = program.getTypeChecker().getAmbientModules(); _f < _g.length; _f++) {
88680                 var ambientModule = _g[_f];
88681                 if (ambientModule.declarations.length > 1) {
88682                     addReferenceFromAmbientModule(ambientModule);
88683                 }
88684             }
88685             return referencedFiles;
88686             function addReferenceFromAmbientModule(symbol) {
88687                 for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) {
88688                     var declaration = _a[_i];
88689                     var declarationSourceFile = ts.getSourceFileOfNode(declaration);
88690                     if (declarationSourceFile &&
88691                         declarationSourceFile !== sourceFile) {
88692                         addReferencedFile(declarationSourceFile.resolvedPath);
88693                     }
88694                 }
88695             }
88696             function addReferencedFile(referencedPath) {
88697                 (referencedFiles || (referencedFiles = new ts.Set())).add(referencedPath);
88698             }
88699         }
88700         function canReuseOldState(newReferencedMap, oldState) {
88701             return oldState && !oldState.referencedMap === !newReferencedMap;
88702         }
88703         BuilderState.canReuseOldState = canReuseOldState;
88704         function create(newProgram, getCanonicalFileName, oldState) {
88705             var fileInfos = new ts.Map();
88706             var referencedMap = newProgram.getCompilerOptions().module !== ts.ModuleKind.None ? new ts.Map() : undefined;
88707             var exportedModulesMap = referencedMap ? new ts.Map() : undefined;
88708             var hasCalledUpdateShapeSignature = new ts.Set();
88709             var useOldState = canReuseOldState(referencedMap, oldState);
88710             newProgram.getTypeChecker();
88711             for (var _i = 0, _a = newProgram.getSourceFiles(); _i < _a.length; _i++) {
88712                 var sourceFile = _a[_i];
88713                 var version_2 = ts.Debug.checkDefined(sourceFile.version, "Program intended to be used with Builder should have source files with versions set");
88714                 var oldInfo = useOldState ? oldState.fileInfos.get(sourceFile.resolvedPath) : undefined;
88715                 if (referencedMap) {
88716                     var newReferences = getReferencedFiles(newProgram, sourceFile, getCanonicalFileName);
88717                     if (newReferences) {
88718                         referencedMap.set(sourceFile.resolvedPath, newReferences);
88719                     }
88720                     if (useOldState) {
88721                         var exportedModules = oldState.exportedModulesMap.get(sourceFile.resolvedPath);
88722                         if (exportedModules) {
88723                             exportedModulesMap.set(sourceFile.resolvedPath, exportedModules);
88724                         }
88725                     }
88726                 }
88727                 fileInfos.set(sourceFile.resolvedPath, { version: version_2, signature: oldInfo && oldInfo.signature, affectsGlobalScope: isFileAffectingGlobalScope(sourceFile) });
88728             }
88729             return {
88730                 fileInfos: fileInfos,
88731                 referencedMap: referencedMap,
88732                 exportedModulesMap: exportedModulesMap,
88733                 hasCalledUpdateShapeSignature: hasCalledUpdateShapeSignature
88734             };
88735         }
88736         BuilderState.create = create;
88737         function releaseCache(state) {
88738             state.allFilesExcludingDefaultLibraryFile = undefined;
88739             state.allFileNames = undefined;
88740         }
88741         BuilderState.releaseCache = releaseCache;
88742         function clone(state) {
88743             return {
88744                 fileInfos: new ts.Map(state.fileInfos),
88745                 referencedMap: state.referencedMap && new ts.Map(state.referencedMap),
88746                 exportedModulesMap: state.exportedModulesMap && new ts.Map(state.exportedModulesMap),
88747                 hasCalledUpdateShapeSignature: new ts.Set(state.hasCalledUpdateShapeSignature),
88748             };
88749         }
88750         BuilderState.clone = clone;
88751         function getFilesAffectedBy(state, programOfThisState, path, cancellationToken, computeHash, cacheToUpdateSignature, exportedModulesMapCache) {
88752             var signatureCache = cacheToUpdateSignature || new ts.Map();
88753             var sourceFile = programOfThisState.getSourceFileByPath(path);
88754             if (!sourceFile) {
88755                 return ts.emptyArray;
88756             }
88757             if (!updateShapeSignature(state, programOfThisState, sourceFile, signatureCache, cancellationToken, computeHash, exportedModulesMapCache)) {
88758                 return [sourceFile];
88759             }
88760             var result = (state.referencedMap ? getFilesAffectedByUpdatedShapeWhenModuleEmit : getFilesAffectedByUpdatedShapeWhenNonModuleEmit)(state, programOfThisState, sourceFile, signatureCache, cancellationToken, computeHash, exportedModulesMapCache);
88761             if (!cacheToUpdateSignature) {
88762                 updateSignaturesFromCache(state, signatureCache);
88763             }
88764             return result;
88765         }
88766         BuilderState.getFilesAffectedBy = getFilesAffectedBy;
88767         function updateSignaturesFromCache(state, signatureCache) {
88768             signatureCache.forEach(function (signature, path) { return updateSignatureOfFile(state, signature, path); });
88769         }
88770         BuilderState.updateSignaturesFromCache = updateSignaturesFromCache;
88771         function updateSignatureOfFile(state, signature, path) {
88772             state.fileInfos.get(path).signature = signature;
88773             state.hasCalledUpdateShapeSignature.add(path);
88774         }
88775         BuilderState.updateSignatureOfFile = updateSignatureOfFile;
88776         function updateShapeSignature(state, programOfThisState, sourceFile, cacheToUpdateSignature, cancellationToken, computeHash, exportedModulesMapCache) {
88777             ts.Debug.assert(!!sourceFile);
88778             ts.Debug.assert(!exportedModulesMapCache || !!state.exportedModulesMap, "Compute visible to outside map only if visibleToOutsideReferencedMap present in the state");
88779             if (state.hasCalledUpdateShapeSignature.has(sourceFile.resolvedPath) || cacheToUpdateSignature.has(sourceFile.resolvedPath)) {
88780                 return false;
88781             }
88782             var info = state.fileInfos.get(sourceFile.resolvedPath);
88783             if (!info)
88784                 return ts.Debug.fail();
88785             var prevSignature = info.signature;
88786             var latestSignature;
88787             if (sourceFile.isDeclarationFile) {
88788                 latestSignature = sourceFile.version;
88789                 if (exportedModulesMapCache && latestSignature !== prevSignature) {
88790                     var references = state.referencedMap ? state.referencedMap.get(sourceFile.resolvedPath) : undefined;
88791                     exportedModulesMapCache.set(sourceFile.resolvedPath, references || false);
88792                 }
88793             }
88794             else {
88795                 var emitOutput_1 = getFileEmitOutput(programOfThisState, sourceFile, true, cancellationToken, undefined, true);
88796                 var firstDts_1 = emitOutput_1.outputFiles &&
88797                     programOfThisState.getCompilerOptions().declarationMap ?
88798                     emitOutput_1.outputFiles.length > 1 ? emitOutput_1.outputFiles[1] : undefined :
88799                     emitOutput_1.outputFiles.length > 0 ? emitOutput_1.outputFiles[0] : undefined;
88800                 if (firstDts_1) {
88801                     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; })); });
88802                     latestSignature = (computeHash || ts.generateDjb2Hash)(firstDts_1.text);
88803                     if (exportedModulesMapCache && latestSignature !== prevSignature) {
88804                         updateExportedModules(sourceFile, emitOutput_1.exportedModulesFromDeclarationEmit, exportedModulesMapCache);
88805                     }
88806                 }
88807                 else {
88808                     latestSignature = prevSignature;
88809                 }
88810             }
88811             cacheToUpdateSignature.set(sourceFile.resolvedPath, latestSignature);
88812             return !prevSignature || latestSignature !== prevSignature;
88813         }
88814         BuilderState.updateShapeSignature = updateShapeSignature;
88815         function updateExportedModules(sourceFile, exportedModulesFromDeclarationEmit, exportedModulesMapCache) {
88816             if (!exportedModulesFromDeclarationEmit) {
88817                 exportedModulesMapCache.set(sourceFile.resolvedPath, false);
88818                 return;
88819             }
88820             var exportedModules;
88821             exportedModulesFromDeclarationEmit.forEach(function (symbol) { return addExportedModule(getReferencedFileFromImportedModuleSymbol(symbol)); });
88822             exportedModulesMapCache.set(sourceFile.resolvedPath, exportedModules || false);
88823             function addExportedModule(exportedModulePath) {
88824                 if (exportedModulePath) {
88825                     if (!exportedModules) {
88826                         exportedModules = new ts.Set();
88827                     }
88828                     exportedModules.add(exportedModulePath);
88829                 }
88830             }
88831         }
88832         function updateExportedFilesMapFromCache(state, exportedModulesMapCache) {
88833             if (exportedModulesMapCache) {
88834                 ts.Debug.assert(!!state.exportedModulesMap);
88835                 exportedModulesMapCache.forEach(function (exportedModules, path) {
88836                     if (exportedModules) {
88837                         state.exportedModulesMap.set(path, exportedModules);
88838                     }
88839                     else {
88840                         state.exportedModulesMap.delete(path);
88841                     }
88842                 });
88843             }
88844         }
88845         BuilderState.updateExportedFilesMapFromCache = updateExportedFilesMapFromCache;
88846         function getAllDependencies(state, programOfThisState, sourceFile) {
88847             var compilerOptions = programOfThisState.getCompilerOptions();
88848             if (ts.outFile(compilerOptions)) {
88849                 return getAllFileNames(state, programOfThisState);
88850             }
88851             if (!state.referencedMap || isFileAffectingGlobalScope(sourceFile)) {
88852                 return getAllFileNames(state, programOfThisState);
88853             }
88854             var seenMap = new ts.Set();
88855             var queue = [sourceFile.resolvedPath];
88856             while (queue.length) {
88857                 var path = queue.pop();
88858                 if (!seenMap.has(path)) {
88859                     seenMap.add(path);
88860                     var references = state.referencedMap.get(path);
88861                     if (references) {
88862                         var iterator = references.keys();
88863                         for (var iterResult = iterator.next(); !iterResult.done; iterResult = iterator.next()) {
88864                             queue.push(iterResult.value);
88865                         }
88866                     }
88867                 }
88868             }
88869             return ts.arrayFrom(ts.mapDefinedIterator(seenMap.keys(), function (path) { var _a, _b; return (_b = (_a = programOfThisState.getSourceFileByPath(path)) === null || _a === void 0 ? void 0 : _a.fileName) !== null && _b !== void 0 ? _b : path; }));
88870         }
88871         BuilderState.getAllDependencies = getAllDependencies;
88872         function getAllFileNames(state, programOfThisState) {
88873             if (!state.allFileNames) {
88874                 var sourceFiles = programOfThisState.getSourceFiles();
88875                 state.allFileNames = sourceFiles === ts.emptyArray ? ts.emptyArray : sourceFiles.map(function (file) { return file.fileName; });
88876             }
88877             return state.allFileNames;
88878         }
88879         function getReferencedByPaths(state, referencedFilePath) {
88880             return ts.arrayFrom(ts.mapDefinedIterator(state.referencedMap.entries(), function (_a) {
88881                 var filePath = _a[0], referencesInFile = _a[1];
88882                 return referencesInFile.has(referencedFilePath) ? filePath : undefined;
88883             }));
88884         }
88885         BuilderState.getReferencedByPaths = getReferencedByPaths;
88886         function containsOnlyAmbientModules(sourceFile) {
88887             for (var _i = 0, _a = sourceFile.statements; _i < _a.length; _i++) {
88888                 var statement = _a[_i];
88889                 if (!ts.isModuleWithStringLiteralName(statement)) {
88890                     return false;
88891                 }
88892             }
88893             return true;
88894         }
88895         function containsGlobalScopeAugmentation(sourceFile) {
88896             return ts.some(sourceFile.moduleAugmentations, function (augmentation) { return ts.isGlobalScopeAugmentation(augmentation.parent); });
88897         }
88898         function isFileAffectingGlobalScope(sourceFile) {
88899             return containsGlobalScopeAugmentation(sourceFile) ||
88900                 !ts.isExternalModule(sourceFile) && !containsOnlyAmbientModules(sourceFile);
88901         }
88902         function getAllFilesExcludingDefaultLibraryFile(state, programOfThisState, firstSourceFile) {
88903             if (state.allFilesExcludingDefaultLibraryFile) {
88904                 return state.allFilesExcludingDefaultLibraryFile;
88905             }
88906             var result;
88907             if (firstSourceFile)
88908                 addSourceFile(firstSourceFile);
88909             for (var _i = 0, _a = programOfThisState.getSourceFiles(); _i < _a.length; _i++) {
88910                 var sourceFile = _a[_i];
88911                 if (sourceFile !== firstSourceFile) {
88912                     addSourceFile(sourceFile);
88913                 }
88914             }
88915             state.allFilesExcludingDefaultLibraryFile = result || ts.emptyArray;
88916             return state.allFilesExcludingDefaultLibraryFile;
88917             function addSourceFile(sourceFile) {
88918                 if (!programOfThisState.isSourceFileDefaultLibrary(sourceFile)) {
88919                     (result || (result = [])).push(sourceFile);
88920                 }
88921             }
88922         }
88923         BuilderState.getAllFilesExcludingDefaultLibraryFile = getAllFilesExcludingDefaultLibraryFile;
88924         function getFilesAffectedByUpdatedShapeWhenNonModuleEmit(state, programOfThisState, sourceFileWithUpdatedShape) {
88925             var compilerOptions = programOfThisState.getCompilerOptions();
88926             if (compilerOptions && ts.outFile(compilerOptions)) {
88927                 return [sourceFileWithUpdatedShape];
88928             }
88929             return getAllFilesExcludingDefaultLibraryFile(state, programOfThisState, sourceFileWithUpdatedShape);
88930         }
88931         function getFilesAffectedByUpdatedShapeWhenModuleEmit(state, programOfThisState, sourceFileWithUpdatedShape, cacheToUpdateSignature, cancellationToken, computeHash, exportedModulesMapCache) {
88932             if (isFileAffectingGlobalScope(sourceFileWithUpdatedShape)) {
88933                 return getAllFilesExcludingDefaultLibraryFile(state, programOfThisState, sourceFileWithUpdatedShape);
88934             }
88935             var compilerOptions = programOfThisState.getCompilerOptions();
88936             if (compilerOptions && (compilerOptions.isolatedModules || ts.outFile(compilerOptions))) {
88937                 return [sourceFileWithUpdatedShape];
88938             }
88939             var seenFileNamesMap = new ts.Map();
88940             seenFileNamesMap.set(sourceFileWithUpdatedShape.resolvedPath, sourceFileWithUpdatedShape);
88941             var queue = getReferencedByPaths(state, sourceFileWithUpdatedShape.resolvedPath);
88942             while (queue.length > 0) {
88943                 var currentPath = queue.pop();
88944                 if (!seenFileNamesMap.has(currentPath)) {
88945                     var currentSourceFile = programOfThisState.getSourceFileByPath(currentPath);
88946                     seenFileNamesMap.set(currentPath, currentSourceFile);
88947                     if (currentSourceFile && updateShapeSignature(state, programOfThisState, currentSourceFile, cacheToUpdateSignature, cancellationToken, computeHash, exportedModulesMapCache)) {
88948                         queue.push.apply(queue, getReferencedByPaths(state, currentSourceFile.resolvedPath));
88949                     }
88950                 }
88951             }
88952             return ts.arrayFrom(ts.mapDefinedIterator(seenFileNamesMap.values(), function (value) { return value; }));
88953         }
88954     })(BuilderState = ts.BuilderState || (ts.BuilderState = {}));
88955 })(ts || (ts = {}));
88956 var ts;
88957 (function (ts) {
88958     function hasSameKeys(map1, map2) {
88959         return map1 === map2 || map1 !== undefined && map2 !== undefined && map1.size === map2.size && !ts.forEachKey(map1, function (key) { return !map2.has(key); });
88960     }
88961     function createBuilderProgramState(newProgram, getCanonicalFileName, oldState) {
88962         var state = ts.BuilderState.create(newProgram, getCanonicalFileName, oldState);
88963         state.program = newProgram;
88964         var compilerOptions = newProgram.getCompilerOptions();
88965         state.compilerOptions = compilerOptions;
88966         if (!ts.outFile(compilerOptions)) {
88967             state.semanticDiagnosticsPerFile = new ts.Map();
88968         }
88969         state.changedFilesSet = new ts.Set();
88970         var useOldState = ts.BuilderState.canReuseOldState(state.referencedMap, oldState);
88971         var oldCompilerOptions = useOldState ? oldState.compilerOptions : undefined;
88972         var canCopySemanticDiagnostics = useOldState && oldState.semanticDiagnosticsPerFile && !!state.semanticDiagnosticsPerFile &&
88973             !ts.compilerOptionsAffectSemanticDiagnostics(compilerOptions, oldCompilerOptions);
88974         if (useOldState) {
88975             if (!oldState.currentChangedFilePath) {
88976                 var affectedSignatures = oldState.currentAffectedFilesSignatures;
88977                 ts.Debug.assert(!oldState.affectedFiles && (!affectedSignatures || !affectedSignatures.size), "Cannot reuse if only few affected files of currentChangedFile were iterated");
88978             }
88979             var changedFilesSet = oldState.changedFilesSet;
88980             if (canCopySemanticDiagnostics) {
88981                 ts.Debug.assert(!changedFilesSet || !ts.forEachKey(changedFilesSet, function (path) { return oldState.semanticDiagnosticsPerFile.has(path); }), "Semantic diagnostics shouldnt be available for changed files");
88982             }
88983             changedFilesSet === null || changedFilesSet === void 0 ? void 0 : changedFilesSet.forEach(function (value) { return state.changedFilesSet.add(value); });
88984             if (!ts.outFile(compilerOptions) && oldState.affectedFilesPendingEmit) {
88985                 state.affectedFilesPendingEmit = oldState.affectedFilesPendingEmit.slice();
88986                 state.affectedFilesPendingEmitKind = oldState.affectedFilesPendingEmitKind && new ts.Map(oldState.affectedFilesPendingEmitKind);
88987                 state.affectedFilesPendingEmitIndex = oldState.affectedFilesPendingEmitIndex;
88988                 state.seenAffectedFiles = new ts.Set();
88989             }
88990         }
88991         var referencedMap = state.referencedMap;
88992         var oldReferencedMap = useOldState ? oldState.referencedMap : undefined;
88993         var copyDeclarationFileDiagnostics = canCopySemanticDiagnostics && !compilerOptions.skipLibCheck === !oldCompilerOptions.skipLibCheck;
88994         var copyLibFileDiagnostics = copyDeclarationFileDiagnostics && !compilerOptions.skipDefaultLibCheck === !oldCompilerOptions.skipDefaultLibCheck;
88995         state.fileInfos.forEach(function (info, sourceFilePath) {
88996             var oldInfo;
88997             var newReferences;
88998             if (!useOldState ||
88999                 !(oldInfo = oldState.fileInfos.get(sourceFilePath)) ||
89000                 oldInfo.version !== info.version ||
89001                 !hasSameKeys(newReferences = referencedMap && referencedMap.get(sourceFilePath), oldReferencedMap && oldReferencedMap.get(sourceFilePath)) ||
89002                 newReferences && ts.forEachKey(newReferences, function (path) { return !state.fileInfos.has(path) && oldState.fileInfos.has(path); })) {
89003                 state.changedFilesSet.add(sourceFilePath);
89004             }
89005             else if (canCopySemanticDiagnostics) {
89006                 var sourceFile = newProgram.getSourceFileByPath(sourceFilePath);
89007                 if (sourceFile.isDeclarationFile && !copyDeclarationFileDiagnostics) {
89008                     return;
89009                 }
89010                 if (sourceFile.hasNoDefaultLib && !copyLibFileDiagnostics) {
89011                     return;
89012                 }
89013                 var diagnostics = oldState.semanticDiagnosticsPerFile.get(sourceFilePath);
89014                 if (diagnostics) {
89015                     state.semanticDiagnosticsPerFile.set(sourceFilePath, oldState.hasReusableDiagnostic ? convertToDiagnostics(diagnostics, newProgram, getCanonicalFileName) : diagnostics);
89016                     if (!state.semanticDiagnosticsFromOldState) {
89017                         state.semanticDiagnosticsFromOldState = new ts.Set();
89018                     }
89019                     state.semanticDiagnosticsFromOldState.add(sourceFilePath);
89020                 }
89021             }
89022         });
89023         if (useOldState && ts.forEachEntry(oldState.fileInfos, function (info, sourceFilePath) { return info.affectsGlobalScope && !state.fileInfos.has(sourceFilePath); })) {
89024             ts.BuilderState.getAllFilesExcludingDefaultLibraryFile(state, newProgram, undefined)
89025                 .forEach(function (file) { return state.changedFilesSet.add(file.resolvedPath); });
89026         }
89027         else if (oldCompilerOptions && !ts.outFile(compilerOptions) && ts.compilerOptionsAffectEmit(compilerOptions, oldCompilerOptions)) {
89028             newProgram.getSourceFiles().forEach(function (f) { return addToAffectedFilesPendingEmit(state, f.resolvedPath, 1); });
89029             ts.Debug.assert(!state.seenAffectedFiles || !state.seenAffectedFiles.size);
89030             state.seenAffectedFiles = state.seenAffectedFiles || new ts.Set();
89031         }
89032         state.buildInfoEmitPending = !!state.changedFilesSet.size;
89033         return state;
89034     }
89035     function convertToDiagnostics(diagnostics, newProgram, getCanonicalFileName) {
89036         if (!diagnostics.length)
89037             return ts.emptyArray;
89038         var buildInfoDirectory = ts.getDirectoryPath(ts.getNormalizedAbsolutePath(ts.getTsBuildInfoEmitOutputFilePath(newProgram.getCompilerOptions()), newProgram.getCurrentDirectory()));
89039         return diagnostics.map(function (diagnostic) {
89040             var result = convertToDiagnosticRelatedInformation(diagnostic, newProgram, toPath);
89041             result.reportsUnnecessary = diagnostic.reportsUnnecessary;
89042             result.reportsDeprecated = diagnostic.reportDeprecated;
89043             result.source = diagnostic.source;
89044             result.skippedOn = diagnostic.skippedOn;
89045             var relatedInformation = diagnostic.relatedInformation;
89046             result.relatedInformation = relatedInformation ?
89047                 relatedInformation.length ?
89048                     relatedInformation.map(function (r) { return convertToDiagnosticRelatedInformation(r, newProgram, toPath); }) :
89049                     [] :
89050                 undefined;
89051             return result;
89052         });
89053         function toPath(path) {
89054             return ts.toPath(path, buildInfoDirectory, getCanonicalFileName);
89055         }
89056     }
89057     function convertToDiagnosticRelatedInformation(diagnostic, newProgram, toPath) {
89058         var file = diagnostic.file;
89059         return __assign(__assign({}, diagnostic), { file: file ? newProgram.getSourceFileByPath(toPath(file)) : undefined });
89060     }
89061     function releaseCache(state) {
89062         ts.BuilderState.releaseCache(state);
89063         state.program = undefined;
89064     }
89065     function cloneBuilderProgramState(state) {
89066         var newState = ts.BuilderState.clone(state);
89067         newState.semanticDiagnosticsPerFile = state.semanticDiagnosticsPerFile && new ts.Map(state.semanticDiagnosticsPerFile);
89068         newState.changedFilesSet = new ts.Set(state.changedFilesSet);
89069         newState.affectedFiles = state.affectedFiles;
89070         newState.affectedFilesIndex = state.affectedFilesIndex;
89071         newState.currentChangedFilePath = state.currentChangedFilePath;
89072         newState.currentAffectedFilesSignatures = state.currentAffectedFilesSignatures && new ts.Map(state.currentAffectedFilesSignatures);
89073         newState.currentAffectedFilesExportedModulesMap = state.currentAffectedFilesExportedModulesMap && new ts.Map(state.currentAffectedFilesExportedModulesMap);
89074         newState.seenAffectedFiles = state.seenAffectedFiles && new ts.Set(state.seenAffectedFiles);
89075         newState.cleanedDiagnosticsOfLibFiles = state.cleanedDiagnosticsOfLibFiles;
89076         newState.semanticDiagnosticsFromOldState = state.semanticDiagnosticsFromOldState && new ts.Set(state.semanticDiagnosticsFromOldState);
89077         newState.program = state.program;
89078         newState.compilerOptions = state.compilerOptions;
89079         newState.affectedFilesPendingEmit = state.affectedFilesPendingEmit && state.affectedFilesPendingEmit.slice();
89080         newState.affectedFilesPendingEmitKind = state.affectedFilesPendingEmitKind && new ts.Map(state.affectedFilesPendingEmitKind);
89081         newState.affectedFilesPendingEmitIndex = state.affectedFilesPendingEmitIndex;
89082         newState.seenEmittedFiles = state.seenEmittedFiles && new ts.Map(state.seenEmittedFiles);
89083         newState.programEmitComplete = state.programEmitComplete;
89084         return newState;
89085     }
89086     function assertSourceFileOkWithoutNextAffectedCall(state, sourceFile) {
89087         ts.Debug.assert(!sourceFile || !state.affectedFiles || state.affectedFiles[state.affectedFilesIndex - 1] !== sourceFile || !state.semanticDiagnosticsPerFile.has(sourceFile.resolvedPath));
89088     }
89089     function getNextAffectedFile(state, cancellationToken, computeHash) {
89090         while (true) {
89091             var affectedFiles = state.affectedFiles;
89092             if (affectedFiles) {
89093                 var seenAffectedFiles = state.seenAffectedFiles;
89094                 var affectedFilesIndex = state.affectedFilesIndex;
89095                 while (affectedFilesIndex < affectedFiles.length) {
89096                     var affectedFile = affectedFiles[affectedFilesIndex];
89097                     if (!seenAffectedFiles.has(affectedFile.resolvedPath)) {
89098                         state.affectedFilesIndex = affectedFilesIndex;
89099                         handleDtsMayChangeOfAffectedFile(state, affectedFile, cancellationToken, computeHash);
89100                         return affectedFile;
89101                     }
89102                     affectedFilesIndex++;
89103                 }
89104                 state.changedFilesSet.delete(state.currentChangedFilePath);
89105                 state.currentChangedFilePath = undefined;
89106                 ts.BuilderState.updateSignaturesFromCache(state, state.currentAffectedFilesSignatures);
89107                 state.currentAffectedFilesSignatures.clear();
89108                 ts.BuilderState.updateExportedFilesMapFromCache(state, state.currentAffectedFilesExportedModulesMap);
89109                 state.affectedFiles = undefined;
89110             }
89111             var nextKey = state.changedFilesSet.keys().next();
89112             if (nextKey.done) {
89113                 return undefined;
89114             }
89115             var program = ts.Debug.checkDefined(state.program);
89116             var compilerOptions = program.getCompilerOptions();
89117             if (ts.outFile(compilerOptions)) {
89118                 ts.Debug.assert(!state.semanticDiagnosticsPerFile);
89119                 return program;
89120             }
89121             if (!state.currentAffectedFilesSignatures)
89122                 state.currentAffectedFilesSignatures = new ts.Map();
89123             if (state.exportedModulesMap) {
89124                 if (!state.currentAffectedFilesExportedModulesMap)
89125                     state.currentAffectedFilesExportedModulesMap = new ts.Map();
89126             }
89127             state.affectedFiles = ts.BuilderState.getFilesAffectedBy(state, program, nextKey.value, cancellationToken, computeHash, state.currentAffectedFilesSignatures, state.currentAffectedFilesExportedModulesMap);
89128             state.currentChangedFilePath = nextKey.value;
89129             state.affectedFilesIndex = 0;
89130             if (!state.seenAffectedFiles)
89131                 state.seenAffectedFiles = new ts.Set();
89132         }
89133     }
89134     function getNextAffectedFilePendingEmit(state) {
89135         var affectedFilesPendingEmit = state.affectedFilesPendingEmit;
89136         if (affectedFilesPendingEmit) {
89137             var seenEmittedFiles = (state.seenEmittedFiles || (state.seenEmittedFiles = new ts.Map()));
89138             for (var i = state.affectedFilesPendingEmitIndex; i < affectedFilesPendingEmit.length; i++) {
89139                 var affectedFile = ts.Debug.checkDefined(state.program).getSourceFileByPath(affectedFilesPendingEmit[i]);
89140                 if (affectedFile) {
89141                     var seenKind = seenEmittedFiles.get(affectedFile.resolvedPath);
89142                     var emitKind = ts.Debug.checkDefined(ts.Debug.checkDefined(state.affectedFilesPendingEmitKind).get(affectedFile.resolvedPath));
89143                     if (seenKind === undefined || seenKind < emitKind) {
89144                         state.affectedFilesPendingEmitIndex = i;
89145                         return { affectedFile: affectedFile, emitKind: emitKind };
89146                     }
89147                 }
89148             }
89149             state.affectedFilesPendingEmit = undefined;
89150             state.affectedFilesPendingEmitKind = undefined;
89151             state.affectedFilesPendingEmitIndex = undefined;
89152         }
89153         return undefined;
89154     }
89155     function handleDtsMayChangeOfAffectedFile(state, affectedFile, cancellationToken, computeHash) {
89156         removeSemanticDiagnosticsOf(state, affectedFile.resolvedPath);
89157         if (state.allFilesExcludingDefaultLibraryFile === state.affectedFiles) {
89158             if (!state.cleanedDiagnosticsOfLibFiles) {
89159                 state.cleanedDiagnosticsOfLibFiles = true;
89160                 var program_1 = ts.Debug.checkDefined(state.program);
89161                 var options_2 = program_1.getCompilerOptions();
89162                 ts.forEach(program_1.getSourceFiles(), function (f) {
89163                     return program_1.isSourceFileDefaultLibrary(f) &&
89164                         !ts.skipTypeChecking(f, options_2, program_1) &&
89165                         removeSemanticDiagnosticsOf(state, f.resolvedPath);
89166                 });
89167             }
89168             return;
89169         }
89170         if (!state.compilerOptions.assumeChangesOnlyAffectDirectDependencies) {
89171             forEachReferencingModulesOfExportOfAffectedFile(state, affectedFile, function (state, path) { return handleDtsMayChangeOf(state, path, cancellationToken, computeHash); });
89172         }
89173     }
89174     function handleDtsMayChangeOf(state, path, cancellationToken, computeHash) {
89175         removeSemanticDiagnosticsOf(state, path);
89176         if (!state.changedFilesSet.has(path)) {
89177             var program = ts.Debug.checkDefined(state.program);
89178             var sourceFile = program.getSourceFileByPath(path);
89179             if (sourceFile) {
89180                 ts.BuilderState.updateShapeSignature(state, program, sourceFile, ts.Debug.checkDefined(state.currentAffectedFilesSignatures), cancellationToken, computeHash, state.currentAffectedFilesExportedModulesMap);
89181                 if (ts.getEmitDeclarations(state.compilerOptions)) {
89182                     addToAffectedFilesPendingEmit(state, path, 0);
89183                 }
89184             }
89185         }
89186         return false;
89187     }
89188     function removeSemanticDiagnosticsOf(state, path) {
89189         if (!state.semanticDiagnosticsFromOldState) {
89190             return true;
89191         }
89192         state.semanticDiagnosticsFromOldState.delete(path);
89193         state.semanticDiagnosticsPerFile.delete(path);
89194         return !state.semanticDiagnosticsFromOldState.size;
89195     }
89196     function isChangedSignature(state, path) {
89197         var newSignature = ts.Debug.checkDefined(state.currentAffectedFilesSignatures).get(path);
89198         var oldSignature = ts.Debug.checkDefined(state.fileInfos.get(path)).signature;
89199         return newSignature !== oldSignature;
89200     }
89201     function forEachReferencingModulesOfExportOfAffectedFile(state, affectedFile, fn) {
89202         if (!state.exportedModulesMap || !state.changedFilesSet.has(affectedFile.resolvedPath)) {
89203             return;
89204         }
89205         if (!isChangedSignature(state, affectedFile.resolvedPath))
89206             return;
89207         if (state.compilerOptions.isolatedModules) {
89208             var seenFileNamesMap = new ts.Map();
89209             seenFileNamesMap.set(affectedFile.resolvedPath, true);
89210             var queue = ts.BuilderState.getReferencedByPaths(state, affectedFile.resolvedPath);
89211             while (queue.length > 0) {
89212                 var currentPath = queue.pop();
89213                 if (!seenFileNamesMap.has(currentPath)) {
89214                     seenFileNamesMap.set(currentPath, true);
89215                     var result = fn(state, currentPath);
89216                     if (result && isChangedSignature(state, currentPath)) {
89217                         var currentSourceFile = ts.Debug.checkDefined(state.program).getSourceFileByPath(currentPath);
89218                         queue.push.apply(queue, ts.BuilderState.getReferencedByPaths(state, currentSourceFile.resolvedPath));
89219                     }
89220                 }
89221             }
89222         }
89223         ts.Debug.assert(!!state.currentAffectedFilesExportedModulesMap);
89224         var seenFileAndExportsOfFile = new ts.Set();
89225         if (ts.forEachEntry(state.currentAffectedFilesExportedModulesMap, function (exportedModules, exportedFromPath) {
89226             return exportedModules &&
89227                 exportedModules.has(affectedFile.resolvedPath) &&
89228                 forEachFilesReferencingPath(state, exportedFromPath, seenFileAndExportsOfFile, fn);
89229         })) {
89230             return;
89231         }
89232         ts.forEachEntry(state.exportedModulesMap, function (exportedModules, exportedFromPath) {
89233             return !state.currentAffectedFilesExportedModulesMap.has(exportedFromPath) &&
89234                 exportedModules.has(affectedFile.resolvedPath) &&
89235                 forEachFilesReferencingPath(state, exportedFromPath, seenFileAndExportsOfFile, fn);
89236         });
89237     }
89238     function forEachFilesReferencingPath(state, referencedPath, seenFileAndExportsOfFile, fn) {
89239         return ts.forEachEntry(state.referencedMap, function (referencesInFile, filePath) {
89240             return referencesInFile.has(referencedPath) && forEachFileAndExportsOfFile(state, filePath, seenFileAndExportsOfFile, fn);
89241         });
89242     }
89243     function forEachFileAndExportsOfFile(state, filePath, seenFileAndExportsOfFile, fn) {
89244         if (!ts.tryAddToSet(seenFileAndExportsOfFile, filePath)) {
89245             return false;
89246         }
89247         if (fn(state, filePath)) {
89248             return true;
89249         }
89250         ts.Debug.assert(!!state.currentAffectedFilesExportedModulesMap);
89251         if (ts.forEachEntry(state.currentAffectedFilesExportedModulesMap, function (exportedModules, exportedFromPath) {
89252             return exportedModules &&
89253                 exportedModules.has(filePath) &&
89254                 forEachFileAndExportsOfFile(state, exportedFromPath, seenFileAndExportsOfFile, fn);
89255         })) {
89256             return true;
89257         }
89258         if (ts.forEachEntry(state.exportedModulesMap, function (exportedModules, exportedFromPath) {
89259             return !state.currentAffectedFilesExportedModulesMap.has(exportedFromPath) &&
89260                 exportedModules.has(filePath) &&
89261                 forEachFileAndExportsOfFile(state, exportedFromPath, seenFileAndExportsOfFile, fn);
89262         })) {
89263             return true;
89264         }
89265         return !!ts.forEachEntry(state.referencedMap, function (referencesInFile, referencingFilePath) {
89266             return referencesInFile.has(filePath) &&
89267                 !seenFileAndExportsOfFile.has(referencingFilePath) &&
89268                 fn(state, referencingFilePath);
89269         });
89270     }
89271     function doneWithAffectedFile(state, affected, emitKind, isPendingEmit, isBuildInfoEmit) {
89272         if (isBuildInfoEmit) {
89273             state.buildInfoEmitPending = false;
89274         }
89275         else if (affected === state.program) {
89276             state.changedFilesSet.clear();
89277             state.programEmitComplete = true;
89278         }
89279         else {
89280             state.seenAffectedFiles.add(affected.resolvedPath);
89281             if (emitKind !== undefined) {
89282                 (state.seenEmittedFiles || (state.seenEmittedFiles = new ts.Map())).set(affected.resolvedPath, emitKind);
89283             }
89284             if (isPendingEmit) {
89285                 state.affectedFilesPendingEmitIndex++;
89286                 state.buildInfoEmitPending = true;
89287             }
89288             else {
89289                 state.affectedFilesIndex++;
89290             }
89291         }
89292     }
89293     function toAffectedFileResult(state, result, affected) {
89294         doneWithAffectedFile(state, affected);
89295         return { result: result, affected: affected };
89296     }
89297     function toAffectedFileEmitResult(state, result, affected, emitKind, isPendingEmit, isBuildInfoEmit) {
89298         doneWithAffectedFile(state, affected, emitKind, isPendingEmit, isBuildInfoEmit);
89299         return { result: result, affected: affected };
89300     }
89301     function getSemanticDiagnosticsOfFile(state, sourceFile, cancellationToken) {
89302         return ts.concatenate(getBinderAndCheckerDiagnosticsOfFile(state, sourceFile, cancellationToken), ts.Debug.checkDefined(state.program).getProgramDiagnostics(sourceFile));
89303     }
89304     function getBinderAndCheckerDiagnosticsOfFile(state, sourceFile, cancellationToken) {
89305         var path = sourceFile.resolvedPath;
89306         if (state.semanticDiagnosticsPerFile) {
89307             var cachedDiagnostics = state.semanticDiagnosticsPerFile.get(path);
89308             if (cachedDiagnostics) {
89309                 return ts.filterSemanticDiagnotics(cachedDiagnostics, state.compilerOptions);
89310             }
89311         }
89312         var diagnostics = ts.Debug.checkDefined(state.program).getBindAndCheckDiagnostics(sourceFile, cancellationToken);
89313         if (state.semanticDiagnosticsPerFile) {
89314             state.semanticDiagnosticsPerFile.set(path, diagnostics);
89315         }
89316         return ts.filterSemanticDiagnotics(diagnostics, state.compilerOptions);
89317     }
89318     function getProgramBuildInfo(state, getCanonicalFileName) {
89319         if (ts.outFile(state.compilerOptions))
89320             return undefined;
89321         var currentDirectory = ts.Debug.checkDefined(state.program).getCurrentDirectory();
89322         var buildInfoDirectory = ts.getDirectoryPath(ts.getNormalizedAbsolutePath(ts.getTsBuildInfoEmitOutputFilePath(state.compilerOptions), currentDirectory));
89323         var fileInfos = {};
89324         state.fileInfos.forEach(function (value, key) {
89325             var signature = state.currentAffectedFilesSignatures && state.currentAffectedFilesSignatures.get(key);
89326             fileInfos[relativeToBuildInfo(key)] = signature === undefined ? value : { version: value.version, signature: signature, affectsGlobalScope: value.affectsGlobalScope };
89327         });
89328         var result = {
89329             fileInfos: fileInfos,
89330             options: convertToReusableCompilerOptions(state.compilerOptions, relativeToBuildInfoEnsuringAbsolutePath)
89331         };
89332         if (state.referencedMap) {
89333             var referencedMap = {};
89334             for (var _i = 0, _a = ts.arrayFrom(state.referencedMap.keys()).sort(ts.compareStringsCaseSensitive); _i < _a.length; _i++) {
89335                 var key = _a[_i];
89336                 referencedMap[relativeToBuildInfo(key)] = ts.arrayFrom(state.referencedMap.get(key).keys(), relativeToBuildInfo).sort(ts.compareStringsCaseSensitive);
89337             }
89338             result.referencedMap = referencedMap;
89339         }
89340         if (state.exportedModulesMap) {
89341             var exportedModulesMap = {};
89342             for (var _b = 0, _c = ts.arrayFrom(state.exportedModulesMap.keys()).sort(ts.compareStringsCaseSensitive); _b < _c.length; _b++) {
89343                 var key = _c[_b];
89344                 var newValue = state.currentAffectedFilesExportedModulesMap && state.currentAffectedFilesExportedModulesMap.get(key);
89345                 if (newValue === undefined)
89346                     exportedModulesMap[relativeToBuildInfo(key)] = ts.arrayFrom(state.exportedModulesMap.get(key).keys(), relativeToBuildInfo).sort(ts.compareStringsCaseSensitive);
89347                 else if (newValue)
89348                     exportedModulesMap[relativeToBuildInfo(key)] = ts.arrayFrom(newValue.keys(), relativeToBuildInfo).sort(ts.compareStringsCaseSensitive);
89349             }
89350             result.exportedModulesMap = exportedModulesMap;
89351         }
89352         if (state.semanticDiagnosticsPerFile) {
89353             var semanticDiagnosticsPerFile = [];
89354             for (var _d = 0, _e = ts.arrayFrom(state.semanticDiagnosticsPerFile.keys()).sort(ts.compareStringsCaseSensitive); _d < _e.length; _d++) {
89355                 var key = _e[_d];
89356                 var value = state.semanticDiagnosticsPerFile.get(key);
89357                 semanticDiagnosticsPerFile.push(value.length ?
89358                     [
89359                         relativeToBuildInfo(key),
89360                         state.hasReusableDiagnostic ?
89361                             value :
89362                             convertToReusableDiagnostics(value, relativeToBuildInfo)
89363                     ] :
89364                     relativeToBuildInfo(key));
89365             }
89366             result.semanticDiagnosticsPerFile = semanticDiagnosticsPerFile;
89367         }
89368         if (state.affectedFilesPendingEmit) {
89369             var affectedFilesPendingEmit = [];
89370             var seenFiles = new ts.Set();
89371             for (var _f = 0, _g = state.affectedFilesPendingEmit.slice(state.affectedFilesPendingEmitIndex).sort(ts.compareStringsCaseSensitive); _f < _g.length; _f++) {
89372                 var path = _g[_f];
89373                 if (ts.tryAddToSet(seenFiles, path)) {
89374                     affectedFilesPendingEmit.push([relativeToBuildInfo(path), state.affectedFilesPendingEmitKind.get(path)]);
89375                 }
89376             }
89377             result.affectedFilesPendingEmit = affectedFilesPendingEmit;
89378         }
89379         return result;
89380         function relativeToBuildInfoEnsuringAbsolutePath(path) {
89381             return relativeToBuildInfo(ts.getNormalizedAbsolutePath(path, currentDirectory));
89382         }
89383         function relativeToBuildInfo(path) {
89384             return ts.ensurePathIsNonModuleName(ts.getRelativePathFromDirectory(buildInfoDirectory, path, getCanonicalFileName));
89385         }
89386     }
89387     function convertToReusableCompilerOptions(options, relativeToBuildInfo) {
89388         var result = {};
89389         var optionsNameMap = ts.getOptionsNameMap().optionsNameMap;
89390         for (var name in options) {
89391             if (ts.hasProperty(options, name)) {
89392                 result[name] = convertToReusableCompilerOptionValue(optionsNameMap.get(name.toLowerCase()), options[name], relativeToBuildInfo);
89393             }
89394         }
89395         if (result.configFilePath) {
89396             result.configFilePath = relativeToBuildInfo(result.configFilePath);
89397         }
89398         return result;
89399     }
89400     function convertToReusableCompilerOptionValue(option, value, relativeToBuildInfo) {
89401         if (option) {
89402             if (option.type === "list") {
89403                 var values = value;
89404                 if (option.element.isFilePath && values.length) {
89405                     return values.map(relativeToBuildInfo);
89406                 }
89407             }
89408             else if (option.isFilePath) {
89409                 return relativeToBuildInfo(value);
89410             }
89411         }
89412         return value;
89413     }
89414     function convertToReusableDiagnostics(diagnostics, relativeToBuildInfo) {
89415         ts.Debug.assert(!!diagnostics.length);
89416         return diagnostics.map(function (diagnostic) {
89417             var result = convertToReusableDiagnosticRelatedInformation(diagnostic, relativeToBuildInfo);
89418             result.reportsUnnecessary = diagnostic.reportsUnnecessary;
89419             result.reportDeprecated = diagnostic.reportsDeprecated;
89420             result.source = diagnostic.source;
89421             result.skippedOn = diagnostic.skippedOn;
89422             var relatedInformation = diagnostic.relatedInformation;
89423             result.relatedInformation = relatedInformation ?
89424                 relatedInformation.length ?
89425                     relatedInformation.map(function (r) { return convertToReusableDiagnosticRelatedInformation(r, relativeToBuildInfo); }) :
89426                     [] :
89427                 undefined;
89428             return result;
89429         });
89430     }
89431     function convertToReusableDiagnosticRelatedInformation(diagnostic, relativeToBuildInfo) {
89432         var file = diagnostic.file;
89433         return __assign(__assign({}, diagnostic), { file: file ? relativeToBuildInfo(file.resolvedPath) : undefined });
89434     }
89435     var BuilderProgramKind;
89436     (function (BuilderProgramKind) {
89437         BuilderProgramKind[BuilderProgramKind["SemanticDiagnosticsBuilderProgram"] = 0] = "SemanticDiagnosticsBuilderProgram";
89438         BuilderProgramKind[BuilderProgramKind["EmitAndSemanticDiagnosticsBuilderProgram"] = 1] = "EmitAndSemanticDiagnosticsBuilderProgram";
89439     })(BuilderProgramKind = ts.BuilderProgramKind || (ts.BuilderProgramKind = {}));
89440     function getBuilderCreationParameters(newProgramOrRootNames, hostOrOptions, oldProgramOrHost, configFileParsingDiagnosticsOrOldProgram, configFileParsingDiagnostics, projectReferences) {
89441         var host;
89442         var newProgram;
89443         var oldProgram;
89444         if (newProgramOrRootNames === undefined) {
89445             ts.Debug.assert(hostOrOptions === undefined);
89446             host = oldProgramOrHost;
89447             oldProgram = configFileParsingDiagnosticsOrOldProgram;
89448             ts.Debug.assert(!!oldProgram);
89449             newProgram = oldProgram.getProgram();
89450         }
89451         else if (ts.isArray(newProgramOrRootNames)) {
89452             oldProgram = configFileParsingDiagnosticsOrOldProgram;
89453             newProgram = ts.createProgram({
89454                 rootNames: newProgramOrRootNames,
89455                 options: hostOrOptions,
89456                 host: oldProgramOrHost,
89457                 oldProgram: oldProgram && oldProgram.getProgramOrUndefined(),
89458                 configFileParsingDiagnostics: configFileParsingDiagnostics,
89459                 projectReferences: projectReferences
89460             });
89461             host = oldProgramOrHost;
89462         }
89463         else {
89464             newProgram = newProgramOrRootNames;
89465             host = hostOrOptions;
89466             oldProgram = oldProgramOrHost;
89467             configFileParsingDiagnostics = configFileParsingDiagnosticsOrOldProgram;
89468         }
89469         return { host: host, newProgram: newProgram, oldProgram: oldProgram, configFileParsingDiagnostics: configFileParsingDiagnostics || ts.emptyArray };
89470     }
89471     ts.getBuilderCreationParameters = getBuilderCreationParameters;
89472     function createBuilderProgram(kind, _a) {
89473         var newProgram = _a.newProgram, host = _a.host, oldProgram = _a.oldProgram, configFileParsingDiagnostics = _a.configFileParsingDiagnostics;
89474         var oldState = oldProgram && oldProgram.getState();
89475         if (oldState && newProgram === oldState.program && configFileParsingDiagnostics === newProgram.getConfigFileParsingDiagnostics()) {
89476             newProgram = undefined;
89477             oldState = undefined;
89478             return oldProgram;
89479         }
89480         var getCanonicalFileName = ts.createGetCanonicalFileName(host.useCaseSensitiveFileNames());
89481         var computeHash = ts.maybeBind(host, host.createHash);
89482         var state = createBuilderProgramState(newProgram, getCanonicalFileName, oldState);
89483         var backupState;
89484         newProgram.getProgramBuildInfo = function () { return getProgramBuildInfo(state, getCanonicalFileName); };
89485         newProgram = undefined;
89486         oldProgram = undefined;
89487         oldState = undefined;
89488         var builderProgram = createRedirectedBuilderProgram(state, configFileParsingDiagnostics);
89489         builderProgram.getState = function () { return state; };
89490         builderProgram.backupState = function () {
89491             ts.Debug.assert(backupState === undefined);
89492             backupState = cloneBuilderProgramState(state);
89493         };
89494         builderProgram.restoreState = function () {
89495             state = ts.Debug.checkDefined(backupState);
89496             backupState = undefined;
89497         };
89498         builderProgram.getAllDependencies = function (sourceFile) { return ts.BuilderState.getAllDependencies(state, ts.Debug.checkDefined(state.program), sourceFile); };
89499         builderProgram.getSemanticDiagnostics = getSemanticDiagnostics;
89500         builderProgram.emit = emit;
89501         builderProgram.releaseProgram = function () {
89502             releaseCache(state);
89503             backupState = undefined;
89504         };
89505         if (kind === BuilderProgramKind.SemanticDiagnosticsBuilderProgram) {
89506             builderProgram.getSemanticDiagnosticsOfNextAffectedFile = getSemanticDiagnosticsOfNextAffectedFile;
89507         }
89508         else if (kind === BuilderProgramKind.EmitAndSemanticDiagnosticsBuilderProgram) {
89509             builderProgram.getSemanticDiagnosticsOfNextAffectedFile = getSemanticDiagnosticsOfNextAffectedFile;
89510             builderProgram.emitNextAffectedFile = emitNextAffectedFile;
89511             builderProgram.emitBuildInfo = emitBuildInfo;
89512         }
89513         else {
89514             ts.notImplemented();
89515         }
89516         return builderProgram;
89517         function emitBuildInfo(writeFile, cancellationToken) {
89518             if (state.buildInfoEmitPending) {
89519                 var result = ts.Debug.checkDefined(state.program).emitBuildInfo(writeFile || ts.maybeBind(host, host.writeFile), cancellationToken);
89520                 state.buildInfoEmitPending = false;
89521                 return result;
89522             }
89523             return ts.emitSkippedWithNoDiagnostics;
89524         }
89525         function emitNextAffectedFile(writeFile, cancellationToken, emitOnlyDtsFiles, customTransformers) {
89526             var affected = getNextAffectedFile(state, cancellationToken, computeHash);
89527             var emitKind = 1;
89528             var isPendingEmitFile = false;
89529             if (!affected) {
89530                 if (!ts.outFile(state.compilerOptions)) {
89531                     var pendingAffectedFile = getNextAffectedFilePendingEmit(state);
89532                     if (!pendingAffectedFile) {
89533                         if (!state.buildInfoEmitPending) {
89534                             return undefined;
89535                         }
89536                         var affected_1 = ts.Debug.checkDefined(state.program);
89537                         return toAffectedFileEmitResult(state, affected_1.emitBuildInfo(writeFile || ts.maybeBind(host, host.writeFile), cancellationToken), affected_1, 1, false, true);
89538                     }
89539                     (affected = pendingAffectedFile.affectedFile, emitKind = pendingAffectedFile.emitKind);
89540                     isPendingEmitFile = true;
89541                 }
89542                 else {
89543                     var program = ts.Debug.checkDefined(state.program);
89544                     if (state.programEmitComplete)
89545                         return undefined;
89546                     affected = program;
89547                 }
89548             }
89549             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);
89550         }
89551         function emit(targetSourceFile, writeFile, cancellationToken, emitOnlyDtsFiles, customTransformers) {
89552             var restorePendingEmitOnHandlingNoEmitSuccess = false;
89553             var savedAffectedFilesPendingEmit;
89554             var savedAffectedFilesPendingEmitKind;
89555             var savedAffectedFilesPendingEmitIndex;
89556             if (kind !== BuilderProgramKind.EmitAndSemanticDiagnosticsBuilderProgram &&
89557                 !targetSourceFile &&
89558                 !ts.outFile(state.compilerOptions) &&
89559                 !state.compilerOptions.noEmit &&
89560                 state.compilerOptions.noEmitOnError) {
89561                 restorePendingEmitOnHandlingNoEmitSuccess = true;
89562                 savedAffectedFilesPendingEmit = state.affectedFilesPendingEmit && state.affectedFilesPendingEmit.slice();
89563                 savedAffectedFilesPendingEmitKind = state.affectedFilesPendingEmitKind && new ts.Map(state.affectedFilesPendingEmitKind);
89564                 savedAffectedFilesPendingEmitIndex = state.affectedFilesPendingEmitIndex;
89565             }
89566             if (kind === BuilderProgramKind.EmitAndSemanticDiagnosticsBuilderProgram) {
89567                 assertSourceFileOkWithoutNextAffectedCall(state, targetSourceFile);
89568             }
89569             var result = ts.handleNoEmitOptions(builderProgram, targetSourceFile, writeFile, cancellationToken);
89570             if (result)
89571                 return result;
89572             if (restorePendingEmitOnHandlingNoEmitSuccess) {
89573                 state.affectedFilesPendingEmit = savedAffectedFilesPendingEmit;
89574                 state.affectedFilesPendingEmitKind = savedAffectedFilesPendingEmitKind;
89575                 state.affectedFilesPendingEmitIndex = savedAffectedFilesPendingEmitIndex;
89576             }
89577             if (!targetSourceFile && kind === BuilderProgramKind.EmitAndSemanticDiagnosticsBuilderProgram) {
89578                 var sourceMaps = [];
89579                 var emitSkipped = false;
89580                 var diagnostics = void 0;
89581                 var emittedFiles = [];
89582                 var affectedEmitResult = void 0;
89583                 while (affectedEmitResult = emitNextAffectedFile(writeFile, cancellationToken, emitOnlyDtsFiles, customTransformers)) {
89584                     emitSkipped = emitSkipped || affectedEmitResult.result.emitSkipped;
89585                     diagnostics = ts.addRange(diagnostics, affectedEmitResult.result.diagnostics);
89586                     emittedFiles = ts.addRange(emittedFiles, affectedEmitResult.result.emittedFiles);
89587                     sourceMaps = ts.addRange(sourceMaps, affectedEmitResult.result.sourceMaps);
89588                 }
89589                 return {
89590                     emitSkipped: emitSkipped,
89591                     diagnostics: diagnostics || ts.emptyArray,
89592                     emittedFiles: emittedFiles,
89593                     sourceMaps: sourceMaps
89594                 };
89595             }
89596             return ts.Debug.checkDefined(state.program).emit(targetSourceFile, writeFile || ts.maybeBind(host, host.writeFile), cancellationToken, emitOnlyDtsFiles, customTransformers);
89597         }
89598         function getSemanticDiagnosticsOfNextAffectedFile(cancellationToken, ignoreSourceFile) {
89599             while (true) {
89600                 var affected = getNextAffectedFile(state, cancellationToken, computeHash);
89601                 if (!affected) {
89602                     return undefined;
89603                 }
89604                 else if (affected === state.program) {
89605                     return toAffectedFileResult(state, state.program.getSemanticDiagnostics(undefined, cancellationToken), affected);
89606                 }
89607                 if (kind === BuilderProgramKind.EmitAndSemanticDiagnosticsBuilderProgram || state.compilerOptions.noEmit || state.compilerOptions.noEmitOnError) {
89608                     addToAffectedFilesPendingEmit(state, affected.resolvedPath, 1);
89609                 }
89610                 if (ignoreSourceFile && ignoreSourceFile(affected)) {
89611                     doneWithAffectedFile(state, affected);
89612                     continue;
89613                 }
89614                 return toAffectedFileResult(state, getSemanticDiagnosticsOfFile(state, affected, cancellationToken), affected);
89615             }
89616         }
89617         function getSemanticDiagnostics(sourceFile, cancellationToken) {
89618             assertSourceFileOkWithoutNextAffectedCall(state, sourceFile);
89619             var compilerOptions = ts.Debug.checkDefined(state.program).getCompilerOptions();
89620             if (ts.outFile(compilerOptions)) {
89621                 ts.Debug.assert(!state.semanticDiagnosticsPerFile);
89622                 return ts.Debug.checkDefined(state.program).getSemanticDiagnostics(sourceFile, cancellationToken);
89623             }
89624             if (sourceFile) {
89625                 return getSemanticDiagnosticsOfFile(state, sourceFile, cancellationToken);
89626             }
89627             while (getSemanticDiagnosticsOfNextAffectedFile(cancellationToken)) {
89628             }
89629             var diagnostics;
89630             for (var _i = 0, _a = ts.Debug.checkDefined(state.program).getSourceFiles(); _i < _a.length; _i++) {
89631                 var sourceFile_1 = _a[_i];
89632                 diagnostics = ts.addRange(diagnostics, getSemanticDiagnosticsOfFile(state, sourceFile_1, cancellationToken));
89633             }
89634             return diagnostics || ts.emptyArray;
89635         }
89636     }
89637     ts.createBuilderProgram = createBuilderProgram;
89638     function addToAffectedFilesPendingEmit(state, affectedFilePendingEmit, kind) {
89639         if (!state.affectedFilesPendingEmit)
89640             state.affectedFilesPendingEmit = [];
89641         if (!state.affectedFilesPendingEmitKind)
89642             state.affectedFilesPendingEmitKind = new ts.Map();
89643         var existingKind = state.affectedFilesPendingEmitKind.get(affectedFilePendingEmit);
89644         state.affectedFilesPendingEmit.push(affectedFilePendingEmit);
89645         state.affectedFilesPendingEmitKind.set(affectedFilePendingEmit, existingKind || kind);
89646         if (state.affectedFilesPendingEmitIndex === undefined) {
89647             state.affectedFilesPendingEmitIndex = 0;
89648         }
89649     }
89650     function getMapOfReferencedSet(mapLike, toPath) {
89651         if (!mapLike)
89652             return undefined;
89653         var map = new ts.Map();
89654         for (var key in mapLike) {
89655             if (ts.hasProperty(mapLike, key)) {
89656                 map.set(toPath(key), new ts.Set(mapLike[key].map(toPath)));
89657             }
89658         }
89659         return map;
89660     }
89661     function createBuildProgramUsingProgramBuildInfo(program, buildInfoPath, host) {
89662         var buildInfoDirectory = ts.getDirectoryPath(ts.getNormalizedAbsolutePath(buildInfoPath, host.getCurrentDirectory()));
89663         var getCanonicalFileName = ts.createGetCanonicalFileName(host.useCaseSensitiveFileNames());
89664         var fileInfos = new ts.Map();
89665         for (var key in program.fileInfos) {
89666             if (ts.hasProperty(program.fileInfos, key)) {
89667                 fileInfos.set(toPath(key), program.fileInfos[key]);
89668             }
89669         }
89670         var state = {
89671             fileInfos: fileInfos,
89672             compilerOptions: ts.convertToOptionsWithAbsolutePaths(program.options, toAbsolutePath),
89673             referencedMap: getMapOfReferencedSet(program.referencedMap, toPath),
89674             exportedModulesMap: getMapOfReferencedSet(program.exportedModulesMap, toPath),
89675             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]; }),
89676             hasReusableDiagnostic: true,
89677             affectedFilesPendingEmit: ts.map(program.affectedFilesPendingEmit, function (value) { return toPath(value[0]); }),
89678             affectedFilesPendingEmitKind: program.affectedFilesPendingEmit && ts.arrayToMap(program.affectedFilesPendingEmit, function (value) { return toPath(value[0]); }, function (value) { return value[1]; }),
89679             affectedFilesPendingEmitIndex: program.affectedFilesPendingEmit && 0,
89680         };
89681         return {
89682             getState: function () { return state; },
89683             backupState: ts.noop,
89684             restoreState: ts.noop,
89685             getProgram: ts.notImplemented,
89686             getProgramOrUndefined: ts.returnUndefined,
89687             releaseProgram: ts.noop,
89688             getCompilerOptions: function () { return state.compilerOptions; },
89689             getSourceFile: ts.notImplemented,
89690             getSourceFiles: ts.notImplemented,
89691             getOptionsDiagnostics: ts.notImplemented,
89692             getGlobalDiagnostics: ts.notImplemented,
89693             getConfigFileParsingDiagnostics: ts.notImplemented,
89694             getSyntacticDiagnostics: ts.notImplemented,
89695             getDeclarationDiagnostics: ts.notImplemented,
89696             getSemanticDiagnostics: ts.notImplemented,
89697             emit: ts.notImplemented,
89698             getAllDependencies: ts.notImplemented,
89699             getCurrentDirectory: ts.notImplemented,
89700             emitNextAffectedFile: ts.notImplemented,
89701             getSemanticDiagnosticsOfNextAffectedFile: ts.notImplemented,
89702             emitBuildInfo: ts.notImplemented,
89703             close: ts.noop,
89704         };
89705         function toPath(path) {
89706             return ts.toPath(path, buildInfoDirectory, getCanonicalFileName);
89707         }
89708         function toAbsolutePath(path) {
89709             return ts.getNormalizedAbsolutePath(path, buildInfoDirectory);
89710         }
89711     }
89712     ts.createBuildProgramUsingProgramBuildInfo = createBuildProgramUsingProgramBuildInfo;
89713     function createRedirectedBuilderProgram(state, configFileParsingDiagnostics) {
89714         return {
89715             getState: ts.notImplemented,
89716             backupState: ts.noop,
89717             restoreState: ts.noop,
89718             getProgram: getProgram,
89719             getProgramOrUndefined: function () { return state.program; },
89720             releaseProgram: function () { return state.program = undefined; },
89721             getCompilerOptions: function () { return state.compilerOptions; },
89722             getSourceFile: function (fileName) { return getProgram().getSourceFile(fileName); },
89723             getSourceFiles: function () { return getProgram().getSourceFiles(); },
89724             getOptionsDiagnostics: function (cancellationToken) { return getProgram().getOptionsDiagnostics(cancellationToken); },
89725             getGlobalDiagnostics: function (cancellationToken) { return getProgram().getGlobalDiagnostics(cancellationToken); },
89726             getConfigFileParsingDiagnostics: function () { return configFileParsingDiagnostics; },
89727             getSyntacticDiagnostics: function (sourceFile, cancellationToken) { return getProgram().getSyntacticDiagnostics(sourceFile, cancellationToken); },
89728             getDeclarationDiagnostics: function (sourceFile, cancellationToken) { return getProgram().getDeclarationDiagnostics(sourceFile, cancellationToken); },
89729             getSemanticDiagnostics: function (sourceFile, cancellationToken) { return getProgram().getSemanticDiagnostics(sourceFile, cancellationToken); },
89730             emit: function (sourceFile, writeFile, cancellationToken, emitOnlyDts, customTransformers) { return getProgram().emit(sourceFile, writeFile, cancellationToken, emitOnlyDts, customTransformers); },
89731             emitBuildInfo: function (writeFile, cancellationToken) { return getProgram().emitBuildInfo(writeFile, cancellationToken); },
89732             getAllDependencies: ts.notImplemented,
89733             getCurrentDirectory: function () { return getProgram().getCurrentDirectory(); },
89734             close: ts.noop,
89735         };
89736         function getProgram() {
89737             return ts.Debug.checkDefined(state.program);
89738         }
89739     }
89740     ts.createRedirectedBuilderProgram = createRedirectedBuilderProgram;
89741 })(ts || (ts = {}));
89742 var ts;
89743 (function (ts) {
89744     function createSemanticDiagnosticsBuilderProgram(newProgramOrRootNames, hostOrOptions, oldProgramOrHost, configFileParsingDiagnosticsOrOldProgram, configFileParsingDiagnostics, projectReferences) {
89745         return ts.createBuilderProgram(ts.BuilderProgramKind.SemanticDiagnosticsBuilderProgram, ts.getBuilderCreationParameters(newProgramOrRootNames, hostOrOptions, oldProgramOrHost, configFileParsingDiagnosticsOrOldProgram, configFileParsingDiagnostics, projectReferences));
89746     }
89747     ts.createSemanticDiagnosticsBuilderProgram = createSemanticDiagnosticsBuilderProgram;
89748     function createEmitAndSemanticDiagnosticsBuilderProgram(newProgramOrRootNames, hostOrOptions, oldProgramOrHost, configFileParsingDiagnosticsOrOldProgram, configFileParsingDiagnostics, projectReferences) {
89749         return ts.createBuilderProgram(ts.BuilderProgramKind.EmitAndSemanticDiagnosticsBuilderProgram, ts.getBuilderCreationParameters(newProgramOrRootNames, hostOrOptions, oldProgramOrHost, configFileParsingDiagnosticsOrOldProgram, configFileParsingDiagnostics, projectReferences));
89750     }
89751     ts.createEmitAndSemanticDiagnosticsBuilderProgram = createEmitAndSemanticDiagnosticsBuilderProgram;
89752     function createAbstractBuilder(newProgramOrRootNames, hostOrOptions, oldProgramOrHost, configFileParsingDiagnosticsOrOldProgram, configFileParsingDiagnostics, projectReferences) {
89753         var _a = ts.getBuilderCreationParameters(newProgramOrRootNames, hostOrOptions, oldProgramOrHost, configFileParsingDiagnosticsOrOldProgram, configFileParsingDiagnostics, projectReferences), newProgram = _a.newProgram, newConfigFileParsingDiagnostics = _a.configFileParsingDiagnostics;
89754         return ts.createRedirectedBuilderProgram({ program: newProgram, compilerOptions: newProgram.getCompilerOptions() }, newConfigFileParsingDiagnostics);
89755     }
89756     ts.createAbstractBuilder = createAbstractBuilder;
89757 })(ts || (ts = {}));
89758 var ts;
89759 (function (ts) {
89760     function removeIgnoredPath(path) {
89761         if (ts.endsWith(path, "/node_modules/.staging")) {
89762             return ts.removeSuffix(path, "/.staging");
89763         }
89764         return ts.some(ts.ignoredPaths, function (searchPath) { return ts.stringContains(path, searchPath); }) ?
89765             undefined :
89766             path;
89767     }
89768     ts.removeIgnoredPath = removeIgnoredPath;
89769     function canWatchDirectory(dirPath) {
89770         var rootLength = ts.getRootLength(dirPath);
89771         if (dirPath.length === rootLength) {
89772             return false;
89773         }
89774         var nextDirectorySeparator = dirPath.indexOf(ts.directorySeparator, rootLength);
89775         if (nextDirectorySeparator === -1) {
89776             return false;
89777         }
89778         var pathPartForUserCheck = dirPath.substring(rootLength, nextDirectorySeparator + 1);
89779         var isNonDirectorySeparatorRoot = rootLength > 1 || dirPath.charCodeAt(0) !== 47;
89780         if (isNonDirectorySeparatorRoot &&
89781             dirPath.search(/[a-zA-Z]:/) !== 0 &&
89782             pathPartForUserCheck.search(/[a-zA-z]\$\//) === 0) {
89783             nextDirectorySeparator = dirPath.indexOf(ts.directorySeparator, nextDirectorySeparator + 1);
89784             if (nextDirectorySeparator === -1) {
89785                 return false;
89786             }
89787             pathPartForUserCheck = dirPath.substring(rootLength + pathPartForUserCheck.length, nextDirectorySeparator + 1);
89788         }
89789         if (isNonDirectorySeparatorRoot &&
89790             pathPartForUserCheck.search(/users\//i) !== 0) {
89791             return true;
89792         }
89793         for (var searchIndex = nextDirectorySeparator + 1, searchLevels = 2; searchLevels > 0; searchLevels--) {
89794             searchIndex = dirPath.indexOf(ts.directorySeparator, searchIndex) + 1;
89795             if (searchIndex === 0) {
89796                 return false;
89797             }
89798         }
89799         return true;
89800     }
89801     ts.canWatchDirectory = canWatchDirectory;
89802     function createResolutionCache(resolutionHost, rootDirForResolution, logChangesWhenResolvingModule) {
89803         var filesWithChangedSetOfUnresolvedImports;
89804         var filesWithInvalidatedResolutions;
89805         var filesWithInvalidatedNonRelativeUnresolvedImports;
89806         var nonRelativeExternalModuleResolutions = ts.createMultiMap();
89807         var resolutionsWithFailedLookups = [];
89808         var resolvedFileToResolution = ts.createMultiMap();
89809         var hasChangedAutomaticTypeDirectiveNames = false;
89810         var failedLookupChecks = [];
89811         var startsWithPathChecks = [];
89812         var isInDirectoryChecks = [];
89813         var getCurrentDirectory = ts.memoize(function () { return resolutionHost.getCurrentDirectory(); });
89814         var cachedDirectoryStructureHost = resolutionHost.getCachedDirectoryStructureHost();
89815         var resolvedModuleNames = new ts.Map();
89816         var perDirectoryResolvedModuleNames = ts.createCacheWithRedirects();
89817         var nonRelativeModuleNameCache = ts.createCacheWithRedirects();
89818         var moduleResolutionCache = ts.createModuleResolutionCacheWithMaps(perDirectoryResolvedModuleNames, nonRelativeModuleNameCache, getCurrentDirectory(), resolutionHost.getCanonicalFileName);
89819         var resolvedTypeReferenceDirectives = new ts.Map();
89820         var perDirectoryResolvedTypeReferenceDirectives = ts.createCacheWithRedirects();
89821         var failedLookupDefaultExtensions = [".ts", ".tsx", ".js", ".jsx", ".json"];
89822         var customFailedLookupPaths = new ts.Map();
89823         var directoryWatchesOfFailedLookups = new ts.Map();
89824         var rootDir = rootDirForResolution && ts.removeTrailingDirectorySeparator(ts.getNormalizedAbsolutePath(rootDirForResolution, getCurrentDirectory()));
89825         var rootPath = (rootDir && resolutionHost.toPath(rootDir));
89826         var rootSplitLength = rootPath !== undefined ? rootPath.split(ts.directorySeparator).length : 0;
89827         var typeRootsWatches = new ts.Map();
89828         return {
89829             startRecordingFilesWithChangedResolutions: startRecordingFilesWithChangedResolutions,
89830             finishRecordingFilesWithChangedResolutions: finishRecordingFilesWithChangedResolutions,
89831             startCachingPerDirectoryResolution: clearPerDirectoryResolutions,
89832             finishCachingPerDirectoryResolution: finishCachingPerDirectoryResolution,
89833             resolveModuleNames: resolveModuleNames,
89834             getResolvedModuleWithFailedLookupLocationsFromCache: getResolvedModuleWithFailedLookupLocationsFromCache,
89835             resolveTypeReferenceDirectives: resolveTypeReferenceDirectives,
89836             removeResolutionsFromProjectReferenceRedirects: removeResolutionsFromProjectReferenceRedirects,
89837             removeResolutionsOfFile: removeResolutionsOfFile,
89838             hasChangedAutomaticTypeDirectiveNames: function () { return hasChangedAutomaticTypeDirectiveNames; },
89839             invalidateResolutionOfFile: invalidateResolutionOfFile,
89840             invalidateResolutionsOfFailedLookupLocations: invalidateResolutionsOfFailedLookupLocations,
89841             setFilesWithInvalidatedNonRelativeUnresolvedImports: setFilesWithInvalidatedNonRelativeUnresolvedImports,
89842             createHasInvalidatedResolution: createHasInvalidatedResolution,
89843             updateTypeRootsWatch: updateTypeRootsWatch,
89844             closeTypeRootsWatch: closeTypeRootsWatch,
89845             clear: clear
89846         };
89847         function getResolvedModule(resolution) {
89848             return resolution.resolvedModule;
89849         }
89850         function getResolvedTypeReferenceDirective(resolution) {
89851             return resolution.resolvedTypeReferenceDirective;
89852         }
89853         function isInDirectoryPath(dir, file) {
89854             if (dir === undefined || file.length <= dir.length) {
89855                 return false;
89856             }
89857             return ts.startsWith(file, dir) && file[dir.length] === ts.directorySeparator;
89858         }
89859         function clear() {
89860             ts.clearMap(directoryWatchesOfFailedLookups, ts.closeFileWatcherOf);
89861             customFailedLookupPaths.clear();
89862             nonRelativeExternalModuleResolutions.clear();
89863             closeTypeRootsWatch();
89864             resolvedModuleNames.clear();
89865             resolvedTypeReferenceDirectives.clear();
89866             resolvedFileToResolution.clear();
89867             resolutionsWithFailedLookups.length = 0;
89868             failedLookupChecks.length = 0;
89869             startsWithPathChecks.length = 0;
89870             isInDirectoryChecks.length = 0;
89871             clearPerDirectoryResolutions();
89872             hasChangedAutomaticTypeDirectiveNames = false;
89873         }
89874         function startRecordingFilesWithChangedResolutions() {
89875             filesWithChangedSetOfUnresolvedImports = [];
89876         }
89877         function finishRecordingFilesWithChangedResolutions() {
89878             var collected = filesWithChangedSetOfUnresolvedImports;
89879             filesWithChangedSetOfUnresolvedImports = undefined;
89880             return collected;
89881         }
89882         function isFileWithInvalidatedNonRelativeUnresolvedImports(path) {
89883             if (!filesWithInvalidatedNonRelativeUnresolvedImports) {
89884                 return false;
89885             }
89886             var value = filesWithInvalidatedNonRelativeUnresolvedImports.get(path);
89887             return !!value && !!value.length;
89888         }
89889         function createHasInvalidatedResolution(forceAllFilesAsInvalidated) {
89890             invalidateResolutionsOfFailedLookupLocations();
89891             if (forceAllFilesAsInvalidated) {
89892                 filesWithInvalidatedResolutions = undefined;
89893                 return ts.returnTrue;
89894             }
89895             var collected = filesWithInvalidatedResolutions;
89896             filesWithInvalidatedResolutions = undefined;
89897             return function (path) { return (!!collected && collected.has(path)) ||
89898                 isFileWithInvalidatedNonRelativeUnresolvedImports(path); };
89899         }
89900         function clearPerDirectoryResolutions() {
89901             perDirectoryResolvedModuleNames.clear();
89902             nonRelativeModuleNameCache.clear();
89903             perDirectoryResolvedTypeReferenceDirectives.clear();
89904             nonRelativeExternalModuleResolutions.forEach(watchFailedLookupLocationOfNonRelativeModuleResolutions);
89905             nonRelativeExternalModuleResolutions.clear();
89906         }
89907         function finishCachingPerDirectoryResolution() {
89908             filesWithInvalidatedNonRelativeUnresolvedImports = undefined;
89909             clearPerDirectoryResolutions();
89910             directoryWatchesOfFailedLookups.forEach(function (watcher, path) {
89911                 if (watcher.refCount === 0) {
89912                     directoryWatchesOfFailedLookups.delete(path);
89913                     watcher.watcher.close();
89914                 }
89915             });
89916             hasChangedAutomaticTypeDirectiveNames = false;
89917         }
89918         function resolveModuleName(moduleName, containingFile, compilerOptions, host, redirectedReference) {
89919             var _a;
89920             var primaryResult = ts.resolveModuleName(moduleName, containingFile, compilerOptions, host, moduleResolutionCache, redirectedReference);
89921             if (!resolutionHost.getGlobalCache) {
89922                 return primaryResult;
89923             }
89924             var globalCache = resolutionHost.getGlobalCache();
89925             if (globalCache !== undefined && !ts.isExternalModuleNameRelative(moduleName) && !(primaryResult.resolvedModule && ts.extensionIsTS(primaryResult.resolvedModule.extension))) {
89926                 var _b = ts.loadModuleFromGlobalCache(ts.Debug.checkDefined(resolutionHost.globalCacheResolutionModuleName)(moduleName), resolutionHost.projectName, compilerOptions, host, globalCache), resolvedModule = _b.resolvedModule, failedLookupLocations = _b.failedLookupLocations;
89927                 if (resolvedModule) {
89928                     primaryResult.resolvedModule = resolvedModule;
89929                     (_a = primaryResult.failedLookupLocations).push.apply(_a, failedLookupLocations);
89930                     return primaryResult;
89931                 }
89932             }
89933             return primaryResult;
89934         }
89935         function resolveNamesWithLocalCache(_a) {
89936             var _b;
89937             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;
89938             var path = resolutionHost.toPath(containingFile);
89939             var resolutionsInFile = cache.get(path) || cache.set(path, new ts.Map()).get(path);
89940             var dirPath = ts.getDirectoryPath(path);
89941             var perDirectoryCache = perDirectoryCacheWithRedirects.getOrCreateMapOfCacheRedirects(redirectedReference);
89942             var perDirectoryResolution = perDirectoryCache.get(dirPath);
89943             if (!perDirectoryResolution) {
89944                 perDirectoryResolution = new ts.Map();
89945                 perDirectoryCache.set(dirPath, perDirectoryResolution);
89946             }
89947             var resolvedModules = [];
89948             var compilerOptions = resolutionHost.getCompilationSettings();
89949             var hasInvalidatedNonRelativeUnresolvedImport = logChanges && isFileWithInvalidatedNonRelativeUnresolvedImports(path);
89950             var program = resolutionHost.getCurrentProgram();
89951             var oldRedirect = program && program.getResolvedProjectReferenceToRedirect(containingFile);
89952             var unmatchedRedirects = oldRedirect ?
89953                 !redirectedReference || redirectedReference.sourceFile.path !== oldRedirect.sourceFile.path :
89954                 !!redirectedReference;
89955             var seenNamesInFile = new ts.Map();
89956             for (var _i = 0, names_3 = names; _i < names_3.length; _i++) {
89957                 var name = names_3[_i];
89958                 var resolution = resolutionsInFile.get(name);
89959                 if (!seenNamesInFile.has(name) &&
89960                     unmatchedRedirects || !resolution || resolution.isInvalidated ||
89961                     (hasInvalidatedNonRelativeUnresolvedImport && !ts.isExternalModuleNameRelative(name) && shouldRetryResolution(resolution))) {
89962                     var existingResolution = resolution;
89963                     var resolutionInDirectory = perDirectoryResolution.get(name);
89964                     if (resolutionInDirectory) {
89965                         resolution = resolutionInDirectory;
89966                     }
89967                     else {
89968                         resolution = loader(name, containingFile, compilerOptions, ((_b = resolutionHost.getCompilerHost) === null || _b === void 0 ? void 0 : _b.call(resolutionHost)) || resolutionHost, redirectedReference);
89969                         perDirectoryResolution.set(name, resolution);
89970                     }
89971                     resolutionsInFile.set(name, resolution);
89972                     watchFailedLookupLocationsOfExternalModuleResolutions(name, resolution, path, getResolutionWithResolvedFileName);
89973                     if (existingResolution) {
89974                         stopWatchFailedLookupLocationOfResolution(existingResolution, path, getResolutionWithResolvedFileName);
89975                     }
89976                     if (logChanges && filesWithChangedSetOfUnresolvedImports && !resolutionIsEqualTo(existingResolution, resolution)) {
89977                         filesWithChangedSetOfUnresolvedImports.push(path);
89978                         logChanges = false;
89979                     }
89980                 }
89981                 ts.Debug.assert(resolution !== undefined && !resolution.isInvalidated);
89982                 seenNamesInFile.set(name, true);
89983                 resolvedModules.push(getResolutionWithResolvedFileName(resolution));
89984             }
89985             resolutionsInFile.forEach(function (resolution, name) {
89986                 if (!seenNamesInFile.has(name) && !ts.contains(reusedNames, name)) {
89987                     stopWatchFailedLookupLocationOfResolution(resolution, path, getResolutionWithResolvedFileName);
89988                     resolutionsInFile.delete(name);
89989                 }
89990             });
89991             return resolvedModules;
89992             function resolutionIsEqualTo(oldResolution, newResolution) {
89993                 if (oldResolution === newResolution) {
89994                     return true;
89995                 }
89996                 if (!oldResolution || !newResolution) {
89997                     return false;
89998                 }
89999                 var oldResult = getResolutionWithResolvedFileName(oldResolution);
90000                 var newResult = getResolutionWithResolvedFileName(newResolution);
90001                 if (oldResult === newResult) {
90002                     return true;
90003                 }
90004                 if (!oldResult || !newResult) {
90005                     return false;
90006                 }
90007                 return oldResult.resolvedFileName === newResult.resolvedFileName;
90008             }
90009         }
90010         function resolveTypeReferenceDirectives(typeDirectiveNames, containingFile, redirectedReference) {
90011             return resolveNamesWithLocalCache({
90012                 names: typeDirectiveNames,
90013                 containingFile: containingFile,
90014                 redirectedReference: redirectedReference,
90015                 cache: resolvedTypeReferenceDirectives,
90016                 perDirectoryCacheWithRedirects: perDirectoryResolvedTypeReferenceDirectives,
90017                 loader: ts.resolveTypeReferenceDirective,
90018                 getResolutionWithResolvedFileName: getResolvedTypeReferenceDirective,
90019                 shouldRetryResolution: function (resolution) { return resolution.resolvedTypeReferenceDirective === undefined; },
90020             });
90021         }
90022         function resolveModuleNames(moduleNames, containingFile, reusedNames, redirectedReference) {
90023             return resolveNamesWithLocalCache({
90024                 names: moduleNames,
90025                 containingFile: containingFile,
90026                 redirectedReference: redirectedReference,
90027                 cache: resolvedModuleNames,
90028                 perDirectoryCacheWithRedirects: perDirectoryResolvedModuleNames,
90029                 loader: resolveModuleName,
90030                 getResolutionWithResolvedFileName: getResolvedModule,
90031                 shouldRetryResolution: function (resolution) { return !resolution.resolvedModule || !ts.resolutionExtensionIsTSOrJson(resolution.resolvedModule.extension); },
90032                 reusedNames: reusedNames,
90033                 logChanges: logChangesWhenResolvingModule,
90034             });
90035         }
90036         function getResolvedModuleWithFailedLookupLocationsFromCache(moduleName, containingFile) {
90037             var cache = resolvedModuleNames.get(resolutionHost.toPath(containingFile));
90038             return cache && cache.get(moduleName);
90039         }
90040         function isNodeModulesAtTypesDirectory(dirPath) {
90041             return ts.endsWith(dirPath, "/node_modules/@types");
90042         }
90043         function getDirectoryToWatchFailedLookupLocation(failedLookupLocation, failedLookupLocationPath) {
90044             if (isInDirectoryPath(rootPath, failedLookupLocationPath)) {
90045                 failedLookupLocation = ts.isRootedDiskPath(failedLookupLocation) ? ts.normalizePath(failedLookupLocation) : ts.getNormalizedAbsolutePath(failedLookupLocation, getCurrentDirectory());
90046                 var failedLookupPathSplit = failedLookupLocationPath.split(ts.directorySeparator);
90047                 var failedLookupSplit = failedLookupLocation.split(ts.directorySeparator);
90048                 ts.Debug.assert(failedLookupSplit.length === failedLookupPathSplit.length, "FailedLookup: " + failedLookupLocation + " failedLookupLocationPath: " + failedLookupLocationPath);
90049                 if (failedLookupPathSplit.length > rootSplitLength + 1) {
90050                     return {
90051                         dir: failedLookupSplit.slice(0, rootSplitLength + 1).join(ts.directorySeparator),
90052                         dirPath: failedLookupPathSplit.slice(0, rootSplitLength + 1).join(ts.directorySeparator)
90053                     };
90054                 }
90055                 else {
90056                     return {
90057                         dir: rootDir,
90058                         dirPath: rootPath,
90059                         nonRecursive: false
90060                     };
90061                 }
90062             }
90063             return getDirectoryToWatchFromFailedLookupLocationDirectory(ts.getDirectoryPath(ts.getNormalizedAbsolutePath(failedLookupLocation, getCurrentDirectory())), ts.getDirectoryPath(failedLookupLocationPath));
90064         }
90065         function getDirectoryToWatchFromFailedLookupLocationDirectory(dir, dirPath) {
90066             while (ts.pathContainsNodeModules(dirPath)) {
90067                 dir = ts.getDirectoryPath(dir);
90068                 dirPath = ts.getDirectoryPath(dirPath);
90069             }
90070             if (ts.isNodeModulesDirectory(dirPath)) {
90071                 return canWatchDirectory(ts.getDirectoryPath(dirPath)) ? { dir: dir, dirPath: dirPath } : undefined;
90072             }
90073             var nonRecursive = true;
90074             var subDirectoryPath, subDirectory;
90075             if (rootPath !== undefined) {
90076                 while (!isInDirectoryPath(dirPath, rootPath)) {
90077                     var parentPath = ts.getDirectoryPath(dirPath);
90078                     if (parentPath === dirPath) {
90079                         break;
90080                     }
90081                     nonRecursive = false;
90082                     subDirectoryPath = dirPath;
90083                     subDirectory = dir;
90084                     dirPath = parentPath;
90085                     dir = ts.getDirectoryPath(dir);
90086                 }
90087             }
90088             return canWatchDirectory(dirPath) ? { dir: subDirectory || dir, dirPath: subDirectoryPath || dirPath, nonRecursive: nonRecursive } : undefined;
90089         }
90090         function isPathWithDefaultFailedLookupExtension(path) {
90091             return ts.fileExtensionIsOneOf(path, failedLookupDefaultExtensions);
90092         }
90093         function watchFailedLookupLocationsOfExternalModuleResolutions(name, resolution, filePath, getResolutionWithResolvedFileName) {
90094             if (resolution.refCount) {
90095                 resolution.refCount++;
90096                 ts.Debug.assertDefined(resolution.files);
90097             }
90098             else {
90099                 resolution.refCount = 1;
90100                 ts.Debug.assert(ts.length(resolution.files) === 0);
90101                 if (ts.isExternalModuleNameRelative(name)) {
90102                     watchFailedLookupLocationOfResolution(resolution);
90103                 }
90104                 else {
90105                     nonRelativeExternalModuleResolutions.add(name, resolution);
90106                 }
90107                 var resolved = getResolutionWithResolvedFileName(resolution);
90108                 if (resolved && resolved.resolvedFileName) {
90109                     resolvedFileToResolution.add(resolutionHost.toPath(resolved.resolvedFileName), resolution);
90110                 }
90111             }
90112             (resolution.files || (resolution.files = [])).push(filePath);
90113         }
90114         function watchFailedLookupLocationOfResolution(resolution) {
90115             ts.Debug.assert(!!resolution.refCount);
90116             var failedLookupLocations = resolution.failedLookupLocations;
90117             if (!failedLookupLocations.length)
90118                 return;
90119             resolutionsWithFailedLookups.push(resolution);
90120             var setAtRoot = false;
90121             for (var _i = 0, failedLookupLocations_1 = failedLookupLocations; _i < failedLookupLocations_1.length; _i++) {
90122                 var failedLookupLocation = failedLookupLocations_1[_i];
90123                 var failedLookupLocationPath = resolutionHost.toPath(failedLookupLocation);
90124                 var toWatch = getDirectoryToWatchFailedLookupLocation(failedLookupLocation, failedLookupLocationPath);
90125                 if (toWatch) {
90126                     var dir = toWatch.dir, dirPath = toWatch.dirPath, nonRecursive = toWatch.nonRecursive;
90127                     if (!isPathWithDefaultFailedLookupExtension(failedLookupLocationPath)) {
90128                         var refCount = customFailedLookupPaths.get(failedLookupLocationPath) || 0;
90129                         customFailedLookupPaths.set(failedLookupLocationPath, refCount + 1);
90130                     }
90131                     if (dirPath === rootPath) {
90132                         ts.Debug.assert(!nonRecursive);
90133                         setAtRoot = true;
90134                     }
90135                     else {
90136                         setDirectoryWatcher(dir, dirPath, nonRecursive);
90137                     }
90138                 }
90139             }
90140             if (setAtRoot) {
90141                 setDirectoryWatcher(rootDir, rootPath, true);
90142             }
90143         }
90144         function watchFailedLookupLocationOfNonRelativeModuleResolutions(resolutions, name) {
90145             var program = resolutionHost.getCurrentProgram();
90146             if (!program || !program.getTypeChecker().tryFindAmbientModuleWithoutAugmentations(name)) {
90147                 resolutions.forEach(watchFailedLookupLocationOfResolution);
90148             }
90149         }
90150         function setDirectoryWatcher(dir, dirPath, nonRecursive) {
90151             var dirWatcher = directoryWatchesOfFailedLookups.get(dirPath);
90152             if (dirWatcher) {
90153                 ts.Debug.assert(!!nonRecursive === !!dirWatcher.nonRecursive);
90154                 dirWatcher.refCount++;
90155             }
90156             else {
90157                 directoryWatchesOfFailedLookups.set(dirPath, { watcher: createDirectoryWatcher(dir, dirPath, nonRecursive), refCount: 1, nonRecursive: nonRecursive });
90158             }
90159         }
90160         function stopWatchFailedLookupLocationOfResolution(resolution, filePath, getResolutionWithResolvedFileName) {
90161             ts.unorderedRemoveItem(ts.Debug.assertDefined(resolution.files), filePath);
90162             resolution.refCount--;
90163             if (resolution.refCount) {
90164                 return;
90165             }
90166             var resolved = getResolutionWithResolvedFileName(resolution);
90167             if (resolved && resolved.resolvedFileName) {
90168                 resolvedFileToResolution.remove(resolutionHost.toPath(resolved.resolvedFileName), resolution);
90169             }
90170             if (!ts.unorderedRemoveItem(resolutionsWithFailedLookups, resolution)) {
90171                 return;
90172             }
90173             var failedLookupLocations = resolution.failedLookupLocations;
90174             var removeAtRoot = false;
90175             for (var _i = 0, failedLookupLocations_2 = failedLookupLocations; _i < failedLookupLocations_2.length; _i++) {
90176                 var failedLookupLocation = failedLookupLocations_2[_i];
90177                 var failedLookupLocationPath = resolutionHost.toPath(failedLookupLocation);
90178                 var toWatch = getDirectoryToWatchFailedLookupLocation(failedLookupLocation, failedLookupLocationPath);
90179                 if (toWatch) {
90180                     var dirPath = toWatch.dirPath;
90181                     var refCount = customFailedLookupPaths.get(failedLookupLocationPath);
90182                     if (refCount) {
90183                         if (refCount === 1) {
90184                             customFailedLookupPaths.delete(failedLookupLocationPath);
90185                         }
90186                         else {
90187                             ts.Debug.assert(refCount > 1);
90188                             customFailedLookupPaths.set(failedLookupLocationPath, refCount - 1);
90189                         }
90190                     }
90191                     if (dirPath === rootPath) {
90192                         removeAtRoot = true;
90193                     }
90194                     else {
90195                         removeDirectoryWatcher(dirPath);
90196                     }
90197                 }
90198             }
90199             if (removeAtRoot) {
90200                 removeDirectoryWatcher(rootPath);
90201             }
90202         }
90203         function removeDirectoryWatcher(dirPath) {
90204             var dirWatcher = directoryWatchesOfFailedLookups.get(dirPath);
90205             dirWatcher.refCount--;
90206         }
90207         function createDirectoryWatcher(directory, dirPath, nonRecursive) {
90208             return resolutionHost.watchDirectoryOfFailedLookupLocation(directory, function (fileOrDirectory) {
90209                 var fileOrDirectoryPath = resolutionHost.toPath(fileOrDirectory);
90210                 if (cachedDirectoryStructureHost) {
90211                     cachedDirectoryStructureHost.addOrDeleteFileOrDirectory(fileOrDirectory, fileOrDirectoryPath);
90212                 }
90213                 scheduleInvalidateResolutionOfFailedLookupLocation(fileOrDirectoryPath, dirPath === fileOrDirectoryPath);
90214             }, nonRecursive ? 0 : 1);
90215         }
90216         function removeResolutionsOfFileFromCache(cache, filePath, getResolutionWithResolvedFileName) {
90217             var resolutions = cache.get(filePath);
90218             if (resolutions) {
90219                 resolutions.forEach(function (resolution) { return stopWatchFailedLookupLocationOfResolution(resolution, filePath, getResolutionWithResolvedFileName); });
90220                 cache.delete(filePath);
90221             }
90222         }
90223         function removeResolutionsFromProjectReferenceRedirects(filePath) {
90224             if (!ts.fileExtensionIs(filePath, ".json")) {
90225                 return;
90226             }
90227             var program = resolutionHost.getCurrentProgram();
90228             if (!program) {
90229                 return;
90230             }
90231             var resolvedProjectReference = program.getResolvedProjectReferenceByPath(filePath);
90232             if (!resolvedProjectReference) {
90233                 return;
90234             }
90235             resolvedProjectReference.commandLine.fileNames.forEach(function (f) { return removeResolutionsOfFile(resolutionHost.toPath(f)); });
90236         }
90237         function removeResolutionsOfFile(filePath) {
90238             removeResolutionsOfFileFromCache(resolvedModuleNames, filePath, getResolvedModule);
90239             removeResolutionsOfFileFromCache(resolvedTypeReferenceDirectives, filePath, getResolvedTypeReferenceDirective);
90240         }
90241         function invalidateResolutions(resolutions, canInvalidate) {
90242             if (!resolutions)
90243                 return false;
90244             var invalidated = false;
90245             for (var _i = 0, resolutions_1 = resolutions; _i < resolutions_1.length; _i++) {
90246                 var resolution = resolutions_1[_i];
90247                 if (resolution.isInvalidated || !canInvalidate(resolution))
90248                     continue;
90249                 resolution.isInvalidated = invalidated = true;
90250                 for (var _a = 0, _b = ts.Debug.assertDefined(resolution.files); _a < _b.length; _a++) {
90251                     var containingFilePath = _b[_a];
90252                     (filesWithInvalidatedResolutions || (filesWithInvalidatedResolutions = new ts.Set())).add(containingFilePath);
90253                     hasChangedAutomaticTypeDirectiveNames = hasChangedAutomaticTypeDirectiveNames || ts.endsWith(containingFilePath, ts.inferredTypesContainingFile);
90254                 }
90255             }
90256             return invalidated;
90257         }
90258         function invalidateResolutionOfFile(filePath) {
90259             removeResolutionsOfFile(filePath);
90260             var prevHasChangedAutomaticTypeDirectiveNames = hasChangedAutomaticTypeDirectiveNames;
90261             if (invalidateResolutions(resolvedFileToResolution.get(filePath), ts.returnTrue) &&
90262                 hasChangedAutomaticTypeDirectiveNames &&
90263                 !prevHasChangedAutomaticTypeDirectiveNames) {
90264                 resolutionHost.onChangedAutomaticTypeDirectiveNames();
90265             }
90266         }
90267         function setFilesWithInvalidatedNonRelativeUnresolvedImports(filesMap) {
90268             ts.Debug.assert(filesWithInvalidatedNonRelativeUnresolvedImports === filesMap || filesWithInvalidatedNonRelativeUnresolvedImports === undefined);
90269             filesWithInvalidatedNonRelativeUnresolvedImports = filesMap;
90270         }
90271         function scheduleInvalidateResolutionOfFailedLookupLocation(fileOrDirectoryPath, isCreatingWatchedDirectory) {
90272             if (isCreatingWatchedDirectory) {
90273                 isInDirectoryChecks.push(fileOrDirectoryPath);
90274             }
90275             else {
90276                 var updatedPath = removeIgnoredPath(fileOrDirectoryPath);
90277                 if (!updatedPath)
90278                     return false;
90279                 fileOrDirectoryPath = updatedPath;
90280                 if (resolutionHost.fileIsOpen(fileOrDirectoryPath)) {
90281                     return false;
90282                 }
90283                 var dirOfFileOrDirectory = ts.getDirectoryPath(fileOrDirectoryPath);
90284                 if (isNodeModulesAtTypesDirectory(fileOrDirectoryPath) || ts.isNodeModulesDirectory(fileOrDirectoryPath) ||
90285                     isNodeModulesAtTypesDirectory(dirOfFileOrDirectory) || ts.isNodeModulesDirectory(dirOfFileOrDirectory)) {
90286                     failedLookupChecks.push(fileOrDirectoryPath);
90287                     startsWithPathChecks.push(fileOrDirectoryPath);
90288                 }
90289                 else {
90290                     if (!isPathWithDefaultFailedLookupExtension(fileOrDirectoryPath) && !customFailedLookupPaths.has(fileOrDirectoryPath)) {
90291                         return false;
90292                     }
90293                     if (ts.isEmittedFileOfProgram(resolutionHost.getCurrentProgram(), fileOrDirectoryPath)) {
90294                         return false;
90295                     }
90296                     failedLookupChecks.push(fileOrDirectoryPath);
90297                 }
90298             }
90299             resolutionHost.scheduleInvalidateResolutionsOfFailedLookupLocations();
90300         }
90301         function invalidateResolutionsOfFailedLookupLocations() {
90302             if (!failedLookupChecks.length && !startsWithPathChecks.length && !isInDirectoryChecks.length) {
90303                 return false;
90304             }
90305             var invalidated = invalidateResolutions(resolutionsWithFailedLookups, canInvalidateFailedLookupResolution);
90306             failedLookupChecks.length = 0;
90307             startsWithPathChecks.length = 0;
90308             isInDirectoryChecks.length = 0;
90309             return invalidated;
90310         }
90311         function canInvalidateFailedLookupResolution(resolution) {
90312             return resolution.failedLookupLocations.some(function (location) {
90313                 var locationPath = resolutionHost.toPath(location);
90314                 return ts.contains(failedLookupChecks, locationPath) ||
90315                     startsWithPathChecks.some(function (fileOrDirectoryPath) { return ts.startsWith(locationPath, fileOrDirectoryPath); }) ||
90316                     isInDirectoryChecks.some(function (fileOrDirectoryPath) { return isInDirectoryPath(fileOrDirectoryPath, locationPath); });
90317             });
90318         }
90319         function closeTypeRootsWatch() {
90320             ts.clearMap(typeRootsWatches, ts.closeFileWatcher);
90321         }
90322         function getDirectoryToWatchFailedLookupLocationFromTypeRoot(typeRoot, typeRootPath) {
90323             if (isInDirectoryPath(rootPath, typeRootPath)) {
90324                 return rootPath;
90325             }
90326             var toWatch = getDirectoryToWatchFromFailedLookupLocationDirectory(typeRoot, typeRootPath);
90327             return toWatch && directoryWatchesOfFailedLookups.has(toWatch.dirPath) ? toWatch.dirPath : undefined;
90328         }
90329         function createTypeRootsWatch(typeRootPath, typeRoot) {
90330             return resolutionHost.watchTypeRootsDirectory(typeRoot, function (fileOrDirectory) {
90331                 var fileOrDirectoryPath = resolutionHost.toPath(fileOrDirectory);
90332                 if (cachedDirectoryStructureHost) {
90333                     cachedDirectoryStructureHost.addOrDeleteFileOrDirectory(fileOrDirectory, fileOrDirectoryPath);
90334                 }
90335                 hasChangedAutomaticTypeDirectiveNames = true;
90336                 resolutionHost.onChangedAutomaticTypeDirectiveNames();
90337                 var dirPath = getDirectoryToWatchFailedLookupLocationFromTypeRoot(typeRoot, typeRootPath);
90338                 if (dirPath) {
90339                     scheduleInvalidateResolutionOfFailedLookupLocation(fileOrDirectoryPath, dirPath === fileOrDirectoryPath);
90340                 }
90341             }, 1);
90342         }
90343         function updateTypeRootsWatch() {
90344             var options = resolutionHost.getCompilationSettings();
90345             if (options.types) {
90346                 closeTypeRootsWatch();
90347                 return;
90348             }
90349             var typeRoots = ts.getEffectiveTypeRoots(options, { directoryExists: directoryExistsForTypeRootWatch, getCurrentDirectory: getCurrentDirectory });
90350             if (typeRoots) {
90351                 ts.mutateMap(typeRootsWatches, ts.arrayToMap(typeRoots, function (tr) { return resolutionHost.toPath(tr); }), {
90352                     createNewValue: createTypeRootsWatch,
90353                     onDeleteValue: ts.closeFileWatcher
90354                 });
90355             }
90356             else {
90357                 closeTypeRootsWatch();
90358             }
90359         }
90360         function directoryExistsForTypeRootWatch(nodeTypesDirectory) {
90361             var dir = ts.getDirectoryPath(ts.getDirectoryPath(nodeTypesDirectory));
90362             var dirPath = resolutionHost.toPath(dir);
90363             return dirPath === rootPath || canWatchDirectory(dirPath);
90364         }
90365     }
90366     ts.createResolutionCache = createResolutionCache;
90367 })(ts || (ts = {}));
90368 var ts;
90369 (function (ts) {
90370     var moduleSpecifiers;
90371     (function (moduleSpecifiers) {
90372         function getPreferences(_a, compilerOptions, importingSourceFile) {
90373             var importModuleSpecifierPreference = _a.importModuleSpecifierPreference, importModuleSpecifierEnding = _a.importModuleSpecifierEnding;
90374             return {
90375                 relativePreference: importModuleSpecifierPreference === "relative" ? 0 : importModuleSpecifierPreference === "non-relative" ? 1 : 2,
90376                 ending: getEnding(),
90377             };
90378             function getEnding() {
90379                 switch (importModuleSpecifierEnding) {
90380                     case "minimal": return 0;
90381                     case "index": return 1;
90382                     case "js": return 2;
90383                     default: return usesJsExtensionOnImports(importingSourceFile) ? 2
90384                         : ts.getEmitModuleResolutionKind(compilerOptions) !== ts.ModuleResolutionKind.NodeJs ? 1 : 0;
90385                 }
90386             }
90387         }
90388         function getPreferencesForUpdate(compilerOptions, oldImportSpecifier) {
90389             return {
90390                 relativePreference: ts.isExternalModuleNameRelative(oldImportSpecifier) ? 0 : 1,
90391                 ending: ts.hasJSFileExtension(oldImportSpecifier) ?
90392                     2 :
90393                     ts.getEmitModuleResolutionKind(compilerOptions) !== ts.ModuleResolutionKind.NodeJs || ts.endsWith(oldImportSpecifier, "index") ? 1 : 0,
90394             };
90395         }
90396         function updateModuleSpecifier(compilerOptions, importingSourceFileName, toFileName, host, oldImportSpecifier) {
90397             var res = getModuleSpecifierWorker(compilerOptions, importingSourceFileName, toFileName, host, getPreferencesForUpdate(compilerOptions, oldImportSpecifier));
90398             if (res === oldImportSpecifier)
90399                 return undefined;
90400             return res;
90401         }
90402         moduleSpecifiers.updateModuleSpecifier = updateModuleSpecifier;
90403         function getModuleSpecifier(compilerOptions, importingSourceFile, importingSourceFileName, toFileName, host, preferences) {
90404             if (preferences === void 0) { preferences = {}; }
90405             return getModuleSpecifierWorker(compilerOptions, importingSourceFileName, toFileName, host, getPreferences(preferences, compilerOptions, importingSourceFile));
90406         }
90407         moduleSpecifiers.getModuleSpecifier = getModuleSpecifier;
90408         function getNodeModulesPackageName(compilerOptions, importingSourceFileName, nodeModulesFileName, host) {
90409             var info = getInfo(importingSourceFileName, host);
90410             var modulePaths = getAllModulePaths(importingSourceFileName, nodeModulesFileName, host);
90411             return ts.firstDefined(modulePaths, function (modulePath) { return tryGetModuleNameAsNodeModule(modulePath, info, host, compilerOptions, true); });
90412         }
90413         moduleSpecifiers.getNodeModulesPackageName = getNodeModulesPackageName;
90414         function getModuleSpecifierWorker(compilerOptions, importingSourceFileName, toFileName, host, preferences) {
90415             var info = getInfo(importingSourceFileName, host);
90416             var modulePaths = getAllModulePaths(importingSourceFileName, toFileName, host);
90417             return ts.firstDefined(modulePaths, function (modulePath) { return tryGetModuleNameAsNodeModule(modulePath, info, host, compilerOptions); }) ||
90418                 getLocalModuleSpecifier(toFileName, info, compilerOptions, host, preferences);
90419         }
90420         function getModuleSpecifiers(moduleSymbol, compilerOptions, importingSourceFile, host, userPreferences) {
90421             var ambient = tryGetModuleNameFromAmbientModule(moduleSymbol);
90422             if (ambient)
90423                 return [ambient];
90424             var info = getInfo(importingSourceFile.path, host);
90425             var moduleSourceFile = ts.getSourceFileOfNode(moduleSymbol.valueDeclaration || ts.getNonAugmentationDeclaration(moduleSymbol));
90426             var modulePaths = getAllModulePaths(importingSourceFile.path, moduleSourceFile.originalFileName, host);
90427             var preferences = getPreferences(userPreferences, compilerOptions, importingSourceFile);
90428             var importedFileIsInNodeModules = ts.some(modulePaths, function (p) { return p.isInNodeModules; });
90429             var nodeModulesSpecifiers;
90430             var pathsSpecifiers;
90431             var relativeSpecifiers;
90432             for (var _i = 0, modulePaths_1 = modulePaths; _i < modulePaths_1.length; _i++) {
90433                 var modulePath = modulePaths_1[_i];
90434                 var specifier = tryGetModuleNameAsNodeModule(modulePath, info, host, compilerOptions);
90435                 nodeModulesSpecifiers = ts.append(nodeModulesSpecifiers, specifier);
90436                 if (specifier && modulePath.isRedirect) {
90437                     return nodeModulesSpecifiers;
90438                 }
90439                 if (!specifier && !modulePath.isRedirect) {
90440                     var local = getLocalModuleSpecifier(modulePath.path, info, compilerOptions, host, preferences);
90441                     if (ts.pathIsBareSpecifier(local)) {
90442                         pathsSpecifiers = ts.append(pathsSpecifiers, local);
90443                     }
90444                     else if (!importedFileIsInNodeModules || modulePath.isInNodeModules) {
90445                         relativeSpecifiers = ts.append(relativeSpecifiers, local);
90446                     }
90447                 }
90448             }
90449             return (pathsSpecifiers === null || pathsSpecifiers === void 0 ? void 0 : pathsSpecifiers.length) ? pathsSpecifiers :
90450                 (nodeModulesSpecifiers === null || nodeModulesSpecifiers === void 0 ? void 0 : nodeModulesSpecifiers.length) ? nodeModulesSpecifiers :
90451                     ts.Debug.checkDefined(relativeSpecifiers);
90452         }
90453         moduleSpecifiers.getModuleSpecifiers = getModuleSpecifiers;
90454         function getInfo(importingSourceFileName, host) {
90455             var getCanonicalFileName = ts.createGetCanonicalFileName(host.useCaseSensitiveFileNames ? host.useCaseSensitiveFileNames() : true);
90456             var sourceDirectory = ts.getDirectoryPath(importingSourceFileName);
90457             return { getCanonicalFileName: getCanonicalFileName, sourceDirectory: sourceDirectory };
90458         }
90459         function getLocalModuleSpecifier(moduleFileName, _a, compilerOptions, host, _b) {
90460             var getCanonicalFileName = _a.getCanonicalFileName, sourceDirectory = _a.sourceDirectory;
90461             var ending = _b.ending, relativePreference = _b.relativePreference;
90462             var baseUrl = compilerOptions.baseUrl, paths = compilerOptions.paths, rootDirs = compilerOptions.rootDirs;
90463             var relativePath = rootDirs && tryGetModuleNameFromRootDirs(rootDirs, moduleFileName, sourceDirectory, getCanonicalFileName, ending, compilerOptions) ||
90464                 removeExtensionAndIndexPostFix(ts.ensurePathIsNonModuleName(ts.getRelativePathFromDirectory(sourceDirectory, moduleFileName, getCanonicalFileName)), ending, compilerOptions);
90465             if (!baseUrl && !paths || relativePreference === 0) {
90466                 return relativePath;
90467             }
90468             var baseDirectory = ts.getPathsBasePath(compilerOptions, host) || baseUrl;
90469             var relativeToBaseUrl = getRelativePathIfInDirectory(moduleFileName, baseDirectory, getCanonicalFileName);
90470             if (!relativeToBaseUrl) {
90471                 return relativePath;
90472             }
90473             var importRelativeToBaseUrl = removeExtensionAndIndexPostFix(relativeToBaseUrl, ending, compilerOptions);
90474             var fromPaths = paths && tryGetModuleNameFromPaths(ts.removeFileExtension(relativeToBaseUrl), importRelativeToBaseUrl, paths);
90475             var nonRelative = fromPaths === undefined && baseUrl !== undefined ? importRelativeToBaseUrl : fromPaths;
90476             if (!nonRelative) {
90477                 return relativePath;
90478             }
90479             if (relativePreference === 1) {
90480                 return nonRelative;
90481             }
90482             if (relativePreference !== 2)
90483                 ts.Debug.assertNever(relativePreference);
90484             return isPathRelativeToParent(nonRelative) || countPathComponents(relativePath) < countPathComponents(nonRelative) ? relativePath : nonRelative;
90485         }
90486         function countPathComponents(path) {
90487             var count = 0;
90488             for (var i = ts.startsWith(path, "./") ? 2 : 0; i < path.length; i++) {
90489                 if (path.charCodeAt(i) === 47)
90490                     count++;
90491             }
90492             return count;
90493         }
90494         moduleSpecifiers.countPathComponents = countPathComponents;
90495         function usesJsExtensionOnImports(_a) {
90496             var imports = _a.imports;
90497             return ts.firstDefined(imports, function (_a) {
90498                 var text = _a.text;
90499                 return ts.pathIsRelative(text) ? ts.hasJSFileExtension(text) : undefined;
90500             }) || false;
90501         }
90502         function numberOfDirectorySeparators(str) {
90503             var match = str.match(/\//g);
90504             return match ? match.length : 0;
90505         }
90506         function comparePathsByRedirectAndNumberOfDirectorySeparators(a, b) {
90507             return ts.compareBooleans(b.isRedirect, a.isRedirect) || ts.compareValues(numberOfDirectorySeparators(a.path), numberOfDirectorySeparators(b.path));
90508         }
90509         function forEachFileNameOfModule(importingFileName, importedFileName, host, preferSymlinks, cb) {
90510             var getCanonicalFileName = ts.hostGetCanonicalFileName(host);
90511             var cwd = host.getCurrentDirectory();
90512             var referenceRedirect = host.isSourceOfProjectReferenceRedirect(importedFileName) ? host.getProjectReferenceRedirect(importedFileName) : undefined;
90513             var redirects = host.redirectTargetsMap.get(ts.toPath(importedFileName, cwd, getCanonicalFileName)) || ts.emptyArray;
90514             var importedFileNames = __spreadArrays((referenceRedirect ? [referenceRedirect] : ts.emptyArray), [importedFileName], redirects);
90515             var targets = importedFileNames.map(function (f) { return ts.getNormalizedAbsolutePath(f, cwd); });
90516             if (!preferSymlinks) {
90517                 var result_15 = ts.forEach(targets, function (p) { return cb(p, referenceRedirect === p); });
90518                 if (result_15)
90519                     return result_15;
90520             }
90521             var links = host.getSymlinkCache
90522                 ? host.getSymlinkCache()
90523                 : ts.discoverProbableSymlinks(host.getSourceFiles(), getCanonicalFileName, cwd);
90524             var symlinkedDirectories = links.getSymlinkedDirectories();
90525             var useCaseSensitiveFileNames = !host.useCaseSensitiveFileNames || host.useCaseSensitiveFileNames();
90526             var result = symlinkedDirectories && ts.forEachEntry(symlinkedDirectories, function (resolved, path) {
90527                 if (resolved === false)
90528                     return undefined;
90529                 if (ts.startsWithDirectory(importingFileName, resolved.realPath, getCanonicalFileName)) {
90530                     return undefined;
90531                 }
90532                 return ts.forEach(targets, function (target) {
90533                     if (!ts.containsPath(resolved.real, target, !useCaseSensitiveFileNames)) {
90534                         return;
90535                     }
90536                     var relative = ts.getRelativePathFromDirectory(resolved.real, target, getCanonicalFileName);
90537                     var option = ts.resolvePath(path, relative);
90538                     if (!host.fileExists || host.fileExists(option)) {
90539                         var result_16 = cb(option, target === referenceRedirect);
90540                         if (result_16)
90541                             return result_16;
90542                     }
90543                 });
90544             });
90545             return result ||
90546                 (preferSymlinks ? ts.forEach(targets, function (p) { return cb(p, p === referenceRedirect); }) : undefined);
90547         }
90548         moduleSpecifiers.forEachFileNameOfModule = forEachFileNameOfModule;
90549         function getAllModulePaths(importingFileName, importedFileName, host) {
90550             var cwd = host.getCurrentDirectory();
90551             var getCanonicalFileName = ts.hostGetCanonicalFileName(host);
90552             var allFileNames = new ts.Map();
90553             var importedFileFromNodeModules = false;
90554             forEachFileNameOfModule(importingFileName, importedFileName, host, true, function (path, isRedirect) {
90555                 var isInNodeModules = ts.pathContainsNodeModules(path);
90556                 allFileNames.set(path, { path: getCanonicalFileName(path), isRedirect: isRedirect, isInNodeModules: isInNodeModules });
90557                 importedFileFromNodeModules = importedFileFromNodeModules || isInNodeModules;
90558             });
90559             var sortedPaths = [];
90560             var _loop_24 = function (directory) {
90561                 var directoryStart = ts.ensureTrailingDirectorySeparator(directory);
90562                 var pathsInDirectory;
90563                 allFileNames.forEach(function (_a, fileName) {
90564                     var path = _a.path, isRedirect = _a.isRedirect, isInNodeModules = _a.isInNodeModules;
90565                     if (ts.startsWith(path, directoryStart)) {
90566                         (pathsInDirectory || (pathsInDirectory = [])).push({ path: fileName, isRedirect: isRedirect, isInNodeModules: isInNodeModules });
90567                         allFileNames.delete(fileName);
90568                     }
90569                 });
90570                 if (pathsInDirectory) {
90571                     if (pathsInDirectory.length > 1) {
90572                         pathsInDirectory.sort(comparePathsByRedirectAndNumberOfDirectorySeparators);
90573                     }
90574                     sortedPaths.push.apply(sortedPaths, pathsInDirectory);
90575                 }
90576                 var newDirectory = ts.getDirectoryPath(directory);
90577                 if (newDirectory === directory)
90578                     return out_directory_1 = directory, "break";
90579                 directory = newDirectory;
90580                 out_directory_1 = directory;
90581             };
90582             var out_directory_1;
90583             for (var directory = ts.getDirectoryPath(ts.toPath(importingFileName, cwd, getCanonicalFileName)); allFileNames.size !== 0;) {
90584                 var state_8 = _loop_24(directory);
90585                 directory = out_directory_1;
90586                 if (state_8 === "break")
90587                     break;
90588             }
90589             if (allFileNames.size) {
90590                 var remainingPaths = ts.arrayFrom(allFileNames.values());
90591                 if (remainingPaths.length > 1)
90592                     remainingPaths.sort(comparePathsByRedirectAndNumberOfDirectorySeparators);
90593                 sortedPaths.push.apply(sortedPaths, remainingPaths);
90594             }
90595             return sortedPaths;
90596         }
90597         function tryGetModuleNameFromAmbientModule(moduleSymbol) {
90598             var decl = ts.find(moduleSymbol.declarations, function (d) { return ts.isNonGlobalAmbientModule(d) && (!ts.isExternalModuleAugmentation(d) || !ts.isExternalModuleNameRelative(ts.getTextOfIdentifierOrLiteral(d.name))); });
90599             if (decl) {
90600                 return decl.name.text;
90601             }
90602         }
90603         function tryGetModuleNameFromPaths(relativeToBaseUrlWithIndex, relativeToBaseUrl, paths) {
90604             for (var key in paths) {
90605                 for (var _i = 0, _a = paths[key]; _i < _a.length; _i++) {
90606                     var patternText_1 = _a[_i];
90607                     var pattern = ts.removeFileExtension(ts.normalizePath(patternText_1));
90608                     var indexOfStar = pattern.indexOf("*");
90609                     if (indexOfStar !== -1) {
90610                         var prefix = pattern.substr(0, indexOfStar);
90611                         var suffix = pattern.substr(indexOfStar + 1);
90612                         if (relativeToBaseUrl.length >= prefix.length + suffix.length &&
90613                             ts.startsWith(relativeToBaseUrl, prefix) &&
90614                             ts.endsWith(relativeToBaseUrl, suffix) ||
90615                             !suffix && relativeToBaseUrl === ts.removeTrailingDirectorySeparator(prefix)) {
90616                             var matchedStar = relativeToBaseUrl.substr(prefix.length, relativeToBaseUrl.length - suffix.length);
90617                             return key.replace("*", matchedStar);
90618                         }
90619                     }
90620                     else if (pattern === relativeToBaseUrl || pattern === relativeToBaseUrlWithIndex) {
90621                         return key;
90622                     }
90623                 }
90624             }
90625         }
90626         function tryGetModuleNameFromRootDirs(rootDirs, moduleFileName, sourceDirectory, getCanonicalFileName, ending, compilerOptions) {
90627             var normalizedTargetPath = getPathRelativeToRootDirs(moduleFileName, rootDirs, getCanonicalFileName);
90628             if (normalizedTargetPath === undefined) {
90629                 return undefined;
90630             }
90631             var normalizedSourcePath = getPathRelativeToRootDirs(sourceDirectory, rootDirs, getCanonicalFileName);
90632             var relativePath = normalizedSourcePath !== undefined ? ts.ensurePathIsNonModuleName(ts.getRelativePathFromDirectory(normalizedSourcePath, normalizedTargetPath, getCanonicalFileName)) : normalizedTargetPath;
90633             return ts.getEmitModuleResolutionKind(compilerOptions) === ts.ModuleResolutionKind.NodeJs
90634                 ? removeExtensionAndIndexPostFix(relativePath, ending, compilerOptions)
90635                 : ts.removeFileExtension(relativePath);
90636         }
90637         function tryGetModuleNameAsNodeModule(_a, _b, host, options, packageNameOnly) {
90638             var path = _a.path, isRedirect = _a.isRedirect;
90639             var getCanonicalFileName = _b.getCanonicalFileName, sourceDirectory = _b.sourceDirectory;
90640             if (!host.fileExists || !host.readFile) {
90641                 return undefined;
90642             }
90643             var parts = getNodeModulePathParts(path);
90644             if (!parts) {
90645                 return undefined;
90646             }
90647             var moduleSpecifier = path;
90648             var isPackageRootPath = false;
90649             if (!packageNameOnly) {
90650                 var packageRootIndex = parts.packageRootIndex;
90651                 var moduleFileNameForExtensionless = void 0;
90652                 while (true) {
90653                     var _c = tryDirectoryWithPackageJson(packageRootIndex), moduleFileToTry = _c.moduleFileToTry, packageRootPath = _c.packageRootPath;
90654                     if (packageRootPath) {
90655                         moduleSpecifier = packageRootPath;
90656                         isPackageRootPath = true;
90657                         break;
90658                     }
90659                     if (!moduleFileNameForExtensionless)
90660                         moduleFileNameForExtensionless = moduleFileToTry;
90661                     packageRootIndex = path.indexOf(ts.directorySeparator, packageRootIndex + 1);
90662                     if (packageRootIndex === -1) {
90663                         moduleSpecifier = getExtensionlessFileName(moduleFileNameForExtensionless);
90664                         break;
90665                     }
90666                 }
90667             }
90668             if (isRedirect && !isPackageRootPath) {
90669                 return undefined;
90670             }
90671             var globalTypingsCacheLocation = host.getGlobalTypingsCacheLocation && host.getGlobalTypingsCacheLocation();
90672             var pathToTopLevelNodeModules = getCanonicalFileName(moduleSpecifier.substring(0, parts.topLevelNodeModulesIndex));
90673             if (!(ts.startsWith(sourceDirectory, pathToTopLevelNodeModules) || globalTypingsCacheLocation && ts.startsWith(getCanonicalFileName(globalTypingsCacheLocation), pathToTopLevelNodeModules))) {
90674                 return undefined;
90675             }
90676             var nodeModulesDirectoryName = moduleSpecifier.substring(parts.topLevelPackageNameIndex + 1);
90677             var packageName = ts.getPackageNameFromTypesPackageName(nodeModulesDirectoryName);
90678             return ts.getEmitModuleResolutionKind(options) !== ts.ModuleResolutionKind.NodeJs && packageName === nodeModulesDirectoryName ? undefined : packageName;
90679             function tryDirectoryWithPackageJson(packageRootIndex) {
90680                 var packageRootPath = path.substring(0, packageRootIndex);
90681                 var packageJsonPath = ts.combinePaths(packageRootPath, "package.json");
90682                 var moduleFileToTry = path;
90683                 if (host.fileExists(packageJsonPath)) {
90684                     var packageJsonContent = JSON.parse(host.readFile(packageJsonPath));
90685                     var versionPaths = packageJsonContent.typesVersions
90686                         ? ts.getPackageJsonTypesVersionsPaths(packageJsonContent.typesVersions)
90687                         : undefined;
90688                     if (versionPaths) {
90689                         var subModuleName = path.slice(packageRootPath.length + 1);
90690                         var fromPaths = tryGetModuleNameFromPaths(ts.removeFileExtension(subModuleName), removeExtensionAndIndexPostFix(subModuleName, 0, options), versionPaths.paths);
90691                         if (fromPaths !== undefined) {
90692                             moduleFileToTry = ts.combinePaths(packageRootPath, fromPaths);
90693                         }
90694                     }
90695                     var mainFileRelative = packageJsonContent.typings || packageJsonContent.types || packageJsonContent.main;
90696                     if (ts.isString(mainFileRelative)) {
90697                         var mainExportFile = ts.toPath(mainFileRelative, packageRootPath, getCanonicalFileName);
90698                         if (ts.removeFileExtension(mainExportFile) === ts.removeFileExtension(getCanonicalFileName(moduleFileToTry))) {
90699                             return { packageRootPath: packageRootPath, moduleFileToTry: moduleFileToTry };
90700                         }
90701                     }
90702                 }
90703                 return { moduleFileToTry: moduleFileToTry };
90704             }
90705             function getExtensionlessFileName(path) {
90706                 var fullModulePathWithoutExtension = ts.removeFileExtension(path);
90707                 if (getCanonicalFileName(fullModulePathWithoutExtension.substring(parts.fileNameIndex)) === "/index" && !tryGetAnyFileFromPath(host, fullModulePathWithoutExtension.substring(0, parts.fileNameIndex))) {
90708                     return fullModulePathWithoutExtension.substring(0, parts.fileNameIndex);
90709                 }
90710                 return fullModulePathWithoutExtension;
90711             }
90712         }
90713         function tryGetAnyFileFromPath(host, path) {
90714             if (!host.fileExists)
90715                 return;
90716             var extensions = ts.getSupportedExtensions({ allowJs: true }, [{ extension: "node", isMixedContent: false }, { extension: "json", isMixedContent: false, scriptKind: 6 }]);
90717             for (var _i = 0, extensions_3 = extensions; _i < extensions_3.length; _i++) {
90718                 var e = extensions_3[_i];
90719                 var fullPath = path + e;
90720                 if (host.fileExists(fullPath)) {
90721                     return fullPath;
90722                 }
90723             }
90724         }
90725         function getNodeModulePathParts(fullPath) {
90726             var topLevelNodeModulesIndex = 0;
90727             var topLevelPackageNameIndex = 0;
90728             var packageRootIndex = 0;
90729             var fileNameIndex = 0;
90730             var partStart = 0;
90731             var partEnd = 0;
90732             var state = 0;
90733             while (partEnd >= 0) {
90734                 partStart = partEnd;
90735                 partEnd = fullPath.indexOf("/", partStart + 1);
90736                 switch (state) {
90737                     case 0:
90738                         if (fullPath.indexOf(ts.nodeModulesPathPart, partStart) === partStart) {
90739                             topLevelNodeModulesIndex = partStart;
90740                             topLevelPackageNameIndex = partEnd;
90741                             state = 1;
90742                         }
90743                         break;
90744                     case 1:
90745                     case 2:
90746                         if (state === 1 && fullPath.charAt(partStart + 1) === "@") {
90747                             state = 2;
90748                         }
90749                         else {
90750                             packageRootIndex = partEnd;
90751                             state = 3;
90752                         }
90753                         break;
90754                     case 3:
90755                         if (fullPath.indexOf(ts.nodeModulesPathPart, partStart) === partStart) {
90756                             state = 1;
90757                         }
90758                         else {
90759                             state = 3;
90760                         }
90761                         break;
90762                 }
90763             }
90764             fileNameIndex = partStart;
90765             return state > 1 ? { topLevelNodeModulesIndex: topLevelNodeModulesIndex, topLevelPackageNameIndex: topLevelPackageNameIndex, packageRootIndex: packageRootIndex, fileNameIndex: fileNameIndex } : undefined;
90766         }
90767         function getPathRelativeToRootDirs(path, rootDirs, getCanonicalFileName) {
90768             return ts.firstDefined(rootDirs, function (rootDir) {
90769                 var relativePath = getRelativePathIfInDirectory(path, rootDir, getCanonicalFileName);
90770                 return isPathRelativeToParent(relativePath) ? undefined : relativePath;
90771             });
90772         }
90773         function removeExtensionAndIndexPostFix(fileName, ending, options) {
90774             if (ts.fileExtensionIs(fileName, ".json"))
90775                 return fileName;
90776             var noExtension = ts.removeFileExtension(fileName);
90777             switch (ending) {
90778                 case 0:
90779                     return ts.removeSuffix(noExtension, "/index");
90780                 case 1:
90781                     return noExtension;
90782                 case 2:
90783                     return noExtension + getJSExtensionForFile(fileName, options);
90784                 default:
90785                     return ts.Debug.assertNever(ending);
90786             }
90787         }
90788         function getJSExtensionForFile(fileName, options) {
90789             var ext = ts.extensionFromPath(fileName);
90790             switch (ext) {
90791                 case ".ts":
90792                 case ".d.ts":
90793                     return ".js";
90794                 case ".tsx":
90795                     return options.jsx === 1 ? ".jsx" : ".js";
90796                 case ".js":
90797                 case ".jsx":
90798                 case ".json":
90799                     return ext;
90800                 case ".tsbuildinfo":
90801                     return ts.Debug.fail("Extension " + ".tsbuildinfo" + " is unsupported:: FileName:: " + fileName);
90802                 default:
90803                     return ts.Debug.assertNever(ext);
90804             }
90805         }
90806         function getRelativePathIfInDirectory(path, directoryPath, getCanonicalFileName) {
90807             var relativePath = ts.getRelativePathToDirectoryOrUrl(directoryPath, path, directoryPath, getCanonicalFileName, false);
90808             return ts.isRootedDiskPath(relativePath) ? undefined : relativePath;
90809         }
90810         function isPathRelativeToParent(path) {
90811             return ts.startsWith(path, "..");
90812         }
90813     })(moduleSpecifiers = ts.moduleSpecifiers || (ts.moduleSpecifiers = {}));
90814 })(ts || (ts = {}));
90815 var ts;
90816 (function (ts) {
90817     var sysFormatDiagnosticsHost = ts.sys ? {
90818         getCurrentDirectory: function () { return ts.sys.getCurrentDirectory(); },
90819         getNewLine: function () { return ts.sys.newLine; },
90820         getCanonicalFileName: ts.createGetCanonicalFileName(ts.sys.useCaseSensitiveFileNames)
90821     } : undefined;
90822     function createDiagnosticReporter(system, pretty) {
90823         var host = system === ts.sys ? sysFormatDiagnosticsHost : {
90824             getCurrentDirectory: function () { return system.getCurrentDirectory(); },
90825             getNewLine: function () { return system.newLine; },
90826             getCanonicalFileName: ts.createGetCanonicalFileName(system.useCaseSensitiveFileNames),
90827         };
90828         if (!pretty) {
90829             return function (diagnostic) { return system.write(ts.formatDiagnostic(diagnostic, host)); };
90830         }
90831         var diagnostics = new Array(1);
90832         return function (diagnostic) {
90833             diagnostics[0] = diagnostic;
90834             system.write(ts.formatDiagnosticsWithColorAndContext(diagnostics, host) + host.getNewLine());
90835             diagnostics[0] = undefined;
90836         };
90837     }
90838     ts.createDiagnosticReporter = createDiagnosticReporter;
90839     function clearScreenIfNotWatchingForFileChanges(system, diagnostic, options) {
90840         if (system.clearScreen &&
90841             !options.preserveWatchOutput &&
90842             !options.extendedDiagnostics &&
90843             !options.diagnostics &&
90844             ts.contains(ts.screenStartingMessageCodes, diagnostic.code)) {
90845             system.clearScreen();
90846             return true;
90847         }
90848         return false;
90849     }
90850     ts.screenStartingMessageCodes = [
90851         ts.Diagnostics.Starting_compilation_in_watch_mode.code,
90852         ts.Diagnostics.File_change_detected_Starting_incremental_compilation.code,
90853     ];
90854     function getPlainDiagnosticFollowingNewLines(diagnostic, newLine) {
90855         return ts.contains(ts.screenStartingMessageCodes, diagnostic.code)
90856             ? newLine + newLine
90857             : newLine;
90858     }
90859     function getLocaleTimeString(system) {
90860         return !system.now ?
90861             new Date().toLocaleTimeString() :
90862             system.now().toLocaleTimeString("en-US", { timeZone: "UTC" });
90863     }
90864     ts.getLocaleTimeString = getLocaleTimeString;
90865     function createWatchStatusReporter(system, pretty) {
90866         return pretty ?
90867             function (diagnostic, newLine, options) {
90868                 clearScreenIfNotWatchingForFileChanges(system, diagnostic, options);
90869                 var output = "[" + ts.formatColorAndReset(getLocaleTimeString(system), ts.ForegroundColorEscapeSequences.Grey) + "] ";
90870                 output += "" + ts.flattenDiagnosticMessageText(diagnostic.messageText, system.newLine) + (newLine + newLine);
90871                 system.write(output);
90872             } :
90873             function (diagnostic, newLine, options) {
90874                 var output = "";
90875                 if (!clearScreenIfNotWatchingForFileChanges(system, diagnostic, options)) {
90876                     output += newLine;
90877                 }
90878                 output += getLocaleTimeString(system) + " - ";
90879                 output += "" + ts.flattenDiagnosticMessageText(diagnostic.messageText, system.newLine) + getPlainDiagnosticFollowingNewLines(diagnostic, newLine);
90880                 system.write(output);
90881             };
90882     }
90883     ts.createWatchStatusReporter = createWatchStatusReporter;
90884     function parseConfigFileWithSystem(configFileName, optionsToExtend, watchOptionsToExtend, system, reportDiagnostic) {
90885         var host = system;
90886         host.onUnRecoverableConfigFileDiagnostic = function (diagnostic) { return reportUnrecoverableDiagnostic(system, reportDiagnostic, diagnostic); };
90887         var result = ts.getParsedCommandLineOfConfigFile(configFileName, optionsToExtend, host, undefined, watchOptionsToExtend);
90888         host.onUnRecoverableConfigFileDiagnostic = undefined;
90889         return result;
90890     }
90891     ts.parseConfigFileWithSystem = parseConfigFileWithSystem;
90892     function getErrorCountForSummary(diagnostics) {
90893         return ts.countWhere(diagnostics, function (diagnostic) { return diagnostic.category === ts.DiagnosticCategory.Error; });
90894     }
90895     ts.getErrorCountForSummary = getErrorCountForSummary;
90896     function getWatchErrorSummaryDiagnosticMessage(errorCount) {
90897         return errorCount === 1 ?
90898             ts.Diagnostics.Found_1_error_Watching_for_file_changes :
90899             ts.Diagnostics.Found_0_errors_Watching_for_file_changes;
90900     }
90901     ts.getWatchErrorSummaryDiagnosticMessage = getWatchErrorSummaryDiagnosticMessage;
90902     function getErrorSummaryText(errorCount, newLine) {
90903         if (errorCount === 0)
90904             return "";
90905         var d = ts.createCompilerDiagnostic(errorCount === 1 ? ts.Diagnostics.Found_1_error : ts.Diagnostics.Found_0_errors, errorCount);
90906         return "" + newLine + ts.flattenDiagnosticMessageText(d.messageText, newLine) + newLine + newLine;
90907     }
90908     ts.getErrorSummaryText = getErrorSummaryText;
90909     function listFiles(program, writeFileName) {
90910         if (program.getCompilerOptions().listFiles || program.getCompilerOptions().listFilesOnly) {
90911             ts.forEach(program.getSourceFiles(), function (file) {
90912                 writeFileName(file.fileName);
90913             });
90914         }
90915     }
90916     ts.listFiles = listFiles;
90917     function emitFilesAndReportErrors(program, reportDiagnostic, writeFileName, reportSummary, writeFile, cancellationToken, emitOnlyDtsFiles, customTransformers) {
90918         var isListFilesOnly = !!program.getCompilerOptions().listFilesOnly;
90919         var allDiagnostics = program.getConfigFileParsingDiagnostics().slice();
90920         var configFileParsingDiagnosticsLength = allDiagnostics.length;
90921         ts.addRange(allDiagnostics, program.getSyntacticDiagnostics(undefined, cancellationToken));
90922         if (allDiagnostics.length === configFileParsingDiagnosticsLength) {
90923             ts.addRange(allDiagnostics, program.getOptionsDiagnostics(cancellationToken));
90924             if (!isListFilesOnly) {
90925                 ts.addRange(allDiagnostics, program.getGlobalDiagnostics(cancellationToken));
90926                 if (allDiagnostics.length === configFileParsingDiagnosticsLength) {
90927                     ts.addRange(allDiagnostics, program.getSemanticDiagnostics(undefined, cancellationToken));
90928                 }
90929             }
90930         }
90931         var emitResult = isListFilesOnly
90932             ? { emitSkipped: true, diagnostics: ts.emptyArray }
90933             : program.emit(undefined, writeFile, cancellationToken, emitOnlyDtsFiles, customTransformers);
90934         var emittedFiles = emitResult.emittedFiles, emitDiagnostics = emitResult.diagnostics;
90935         ts.addRange(allDiagnostics, emitDiagnostics);
90936         var diagnostics = ts.sortAndDeduplicateDiagnostics(allDiagnostics);
90937         diagnostics.forEach(reportDiagnostic);
90938         if (writeFileName) {
90939             var currentDir_1 = program.getCurrentDirectory();
90940             ts.forEach(emittedFiles, function (file) {
90941                 var filepath = ts.getNormalizedAbsolutePath(file, currentDir_1);
90942                 writeFileName("TSFILE: " + filepath);
90943             });
90944             listFiles(program, writeFileName);
90945         }
90946         if (reportSummary) {
90947             reportSummary(getErrorCountForSummary(diagnostics));
90948         }
90949         return {
90950             emitResult: emitResult,
90951             diagnostics: diagnostics,
90952         };
90953     }
90954     ts.emitFilesAndReportErrors = emitFilesAndReportErrors;
90955     function emitFilesAndReportErrorsAndGetExitStatus(program, reportDiagnostic, writeFileName, reportSummary, writeFile, cancellationToken, emitOnlyDtsFiles, customTransformers) {
90956         var _a = emitFilesAndReportErrors(program, reportDiagnostic, writeFileName, reportSummary, writeFile, cancellationToken, emitOnlyDtsFiles, customTransformers), emitResult = _a.emitResult, diagnostics = _a.diagnostics;
90957         if (emitResult.emitSkipped && diagnostics.length > 0) {
90958             return ts.ExitStatus.DiagnosticsPresent_OutputsSkipped;
90959         }
90960         else if (diagnostics.length > 0) {
90961             return ts.ExitStatus.DiagnosticsPresent_OutputsGenerated;
90962         }
90963         return ts.ExitStatus.Success;
90964     }
90965     ts.emitFilesAndReportErrorsAndGetExitStatus = emitFilesAndReportErrorsAndGetExitStatus;
90966     ts.noopFileWatcher = { close: ts.noop };
90967     ts.returnNoopFileWatcher = function () { return ts.noopFileWatcher; };
90968     function createWatchHost(system, reportWatchStatus) {
90969         if (system === void 0) { system = ts.sys; }
90970         var onWatchStatusChange = reportWatchStatus || createWatchStatusReporter(system);
90971         return {
90972             onWatchStatusChange: onWatchStatusChange,
90973             watchFile: ts.maybeBind(system, system.watchFile) || ts.returnNoopFileWatcher,
90974             watchDirectory: ts.maybeBind(system, system.watchDirectory) || ts.returnNoopFileWatcher,
90975             setTimeout: ts.maybeBind(system, system.setTimeout) || ts.noop,
90976             clearTimeout: ts.maybeBind(system, system.clearTimeout) || ts.noop
90977         };
90978     }
90979     ts.createWatchHost = createWatchHost;
90980     ts.WatchType = {
90981         ConfigFile: "Config file",
90982         SourceFile: "Source file",
90983         MissingFile: "Missing file",
90984         WildcardDirectory: "Wild card directory",
90985         FailedLookupLocations: "Failed Lookup Locations",
90986         TypeRoots: "Type roots"
90987     };
90988     function createWatchFactory(host, options) {
90989         var watchLogLevel = host.trace ? options.extendedDiagnostics ? ts.WatchLogLevel.Verbose : options.diagnostics ? ts.WatchLogLevel.TriggerOnly : ts.WatchLogLevel.None : ts.WatchLogLevel.None;
90990         var writeLog = watchLogLevel !== ts.WatchLogLevel.None ? (function (s) { return host.trace(s); }) : ts.noop;
90991         var result = ts.getWatchFactory(watchLogLevel, writeLog);
90992         result.writeLog = writeLog;
90993         return result;
90994     }
90995     ts.createWatchFactory = createWatchFactory;
90996     function createCompilerHostFromProgramHost(host, getCompilerOptions, directoryStructureHost) {
90997         if (directoryStructureHost === void 0) { directoryStructureHost = host; }
90998         var useCaseSensitiveFileNames = host.useCaseSensitiveFileNames();
90999         var hostGetNewLine = ts.memoize(function () { return host.getNewLine(); });
91000         return {
91001             getSourceFile: function (fileName, languageVersion, onError) {
91002                 var text;
91003                 try {
91004                     ts.performance.mark("beforeIORead");
91005                     text = host.readFile(fileName, getCompilerOptions().charset);
91006                     ts.performance.mark("afterIORead");
91007                     ts.performance.measure("I/O Read", "beforeIORead", "afterIORead");
91008                 }
91009                 catch (e) {
91010                     if (onError) {
91011                         onError(e.message);
91012                     }
91013                     text = "";
91014                 }
91015                 return text !== undefined ? ts.createSourceFile(fileName, text, languageVersion) : undefined;
91016             },
91017             getDefaultLibLocation: ts.maybeBind(host, host.getDefaultLibLocation),
91018             getDefaultLibFileName: function (options) { return host.getDefaultLibFileName(options); },
91019             writeFile: writeFile,
91020             getCurrentDirectory: ts.memoize(function () { return host.getCurrentDirectory(); }),
91021             useCaseSensitiveFileNames: function () { return useCaseSensitiveFileNames; },
91022             getCanonicalFileName: ts.createGetCanonicalFileName(useCaseSensitiveFileNames),
91023             getNewLine: function () { return ts.getNewLineCharacter(getCompilerOptions(), hostGetNewLine); },
91024             fileExists: function (f) { return host.fileExists(f); },
91025             readFile: function (f) { return host.readFile(f); },
91026             trace: ts.maybeBind(host, host.trace),
91027             directoryExists: ts.maybeBind(directoryStructureHost, directoryStructureHost.directoryExists),
91028             getDirectories: ts.maybeBind(directoryStructureHost, directoryStructureHost.getDirectories),
91029             realpath: ts.maybeBind(host, host.realpath),
91030             getEnvironmentVariable: ts.maybeBind(host, host.getEnvironmentVariable) || (function () { return ""; }),
91031             createHash: ts.maybeBind(host, host.createHash),
91032             readDirectory: ts.maybeBind(host, host.readDirectory),
91033         };
91034         function writeFile(fileName, text, writeByteOrderMark, onError) {
91035             try {
91036                 ts.performance.mark("beforeIOWrite");
91037                 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); });
91038                 ts.performance.mark("afterIOWrite");
91039                 ts.performance.measure("I/O Write", "beforeIOWrite", "afterIOWrite");
91040             }
91041             catch (e) {
91042                 if (onError) {
91043                     onError(e.message);
91044                 }
91045             }
91046         }
91047     }
91048     ts.createCompilerHostFromProgramHost = createCompilerHostFromProgramHost;
91049     function setGetSourceFileAsHashVersioned(compilerHost, host) {
91050         var originalGetSourceFile = compilerHost.getSourceFile;
91051         var computeHash = ts.maybeBind(host, host.createHash) || ts.generateDjb2Hash;
91052         compilerHost.getSourceFile = function () {
91053             var args = [];
91054             for (var _i = 0; _i < arguments.length; _i++) {
91055                 args[_i] = arguments[_i];
91056             }
91057             var result = originalGetSourceFile.call.apply(originalGetSourceFile, __spreadArrays([compilerHost], args));
91058             if (result) {
91059                 result.version = computeHash(result.text);
91060             }
91061             return result;
91062         };
91063     }
91064     ts.setGetSourceFileAsHashVersioned = setGetSourceFileAsHashVersioned;
91065     function createProgramHost(system, createProgram) {
91066         var getDefaultLibLocation = ts.memoize(function () { return ts.getDirectoryPath(ts.normalizePath(system.getExecutingFilePath())); });
91067         return {
91068             useCaseSensitiveFileNames: function () { return system.useCaseSensitiveFileNames; },
91069             getNewLine: function () { return system.newLine; },
91070             getCurrentDirectory: ts.memoize(function () { return system.getCurrentDirectory(); }),
91071             getDefaultLibLocation: getDefaultLibLocation,
91072             getDefaultLibFileName: function (options) { return ts.combinePaths(getDefaultLibLocation(), ts.getDefaultLibFileName(options)); },
91073             fileExists: function (path) { return system.fileExists(path); },
91074             readFile: function (path, encoding) { return system.readFile(path, encoding); },
91075             directoryExists: function (path) { return system.directoryExists(path); },
91076             getDirectories: function (path) { return system.getDirectories(path); },
91077             readDirectory: function (path, extensions, exclude, include, depth) { return system.readDirectory(path, extensions, exclude, include, depth); },
91078             realpath: ts.maybeBind(system, system.realpath),
91079             getEnvironmentVariable: ts.maybeBind(system, system.getEnvironmentVariable),
91080             trace: function (s) { return system.write(s + system.newLine); },
91081             createDirectory: function (path) { return system.createDirectory(path); },
91082             writeFile: function (path, data, writeByteOrderMark) { return system.writeFile(path, data, writeByteOrderMark); },
91083             createHash: ts.maybeBind(system, system.createHash),
91084             createProgram: createProgram || ts.createEmitAndSemanticDiagnosticsBuilderProgram
91085         };
91086     }
91087     ts.createProgramHost = createProgramHost;
91088     function createWatchCompilerHost(system, createProgram, reportDiagnostic, reportWatchStatus) {
91089         if (system === void 0) { system = ts.sys; }
91090         var writeFileName = function (s) { return system.write(s + system.newLine); };
91091         var result = createProgramHost(system, createProgram);
91092         ts.copyProperties(result, createWatchHost(system, reportWatchStatus));
91093         result.afterProgramCreate = function (builderProgram) {
91094             var compilerOptions = builderProgram.getCompilerOptions();
91095             var newLine = ts.getNewLineCharacter(compilerOptions, function () { return system.newLine; });
91096             emitFilesAndReportErrors(builderProgram, reportDiagnostic, writeFileName, function (errorCount) { return result.onWatchStatusChange(ts.createCompilerDiagnostic(getWatchErrorSummaryDiagnosticMessage(errorCount), errorCount), newLine, compilerOptions, errorCount); });
91097         };
91098         return result;
91099     }
91100     function reportUnrecoverableDiagnostic(system, reportDiagnostic, diagnostic) {
91101         reportDiagnostic(diagnostic);
91102         system.exit(ts.ExitStatus.DiagnosticsPresent_OutputsSkipped);
91103     }
91104     function createWatchCompilerHostOfConfigFile(_a) {
91105         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;
91106         var diagnosticReporter = reportDiagnostic || createDiagnosticReporter(system);
91107         var host = createWatchCompilerHost(system, createProgram, diagnosticReporter, reportWatchStatus);
91108         host.onUnRecoverableConfigFileDiagnostic = function (diagnostic) { return reportUnrecoverableDiagnostic(system, diagnosticReporter, diagnostic); };
91109         host.configFileName = configFileName;
91110         host.optionsToExtend = optionsToExtend;
91111         host.watchOptionsToExtend = watchOptionsToExtend;
91112         host.extraFileExtensions = extraFileExtensions;
91113         return host;
91114     }
91115     ts.createWatchCompilerHostOfConfigFile = createWatchCompilerHostOfConfigFile;
91116     function createWatchCompilerHostOfFilesAndCompilerOptions(_a) {
91117         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;
91118         var host = createWatchCompilerHost(system, createProgram, reportDiagnostic || createDiagnosticReporter(system), reportWatchStatus);
91119         host.rootFiles = rootFiles;
91120         host.options = options;
91121         host.watchOptions = watchOptions;
91122         host.projectReferences = projectReferences;
91123         return host;
91124     }
91125     ts.createWatchCompilerHostOfFilesAndCompilerOptions = createWatchCompilerHostOfFilesAndCompilerOptions;
91126     function performIncrementalCompilation(input) {
91127         var system = input.system || ts.sys;
91128         var host = input.host || (input.host = ts.createIncrementalCompilerHost(input.options, system));
91129         var builderProgram = ts.createIncrementalProgram(input);
91130         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);
91131         if (input.afterProgramEmitAndDiagnostics)
91132             input.afterProgramEmitAndDiagnostics(builderProgram);
91133         return exitStatus;
91134     }
91135     ts.performIncrementalCompilation = performIncrementalCompilation;
91136 })(ts || (ts = {}));
91137 var ts;
91138 (function (ts) {
91139     function readBuilderProgram(compilerOptions, host) {
91140         if (ts.outFile(compilerOptions))
91141             return undefined;
91142         var buildInfoPath = ts.getTsBuildInfoEmitOutputFilePath(compilerOptions);
91143         if (!buildInfoPath)
91144             return undefined;
91145         var content = host.readFile(buildInfoPath);
91146         if (!content)
91147             return undefined;
91148         var buildInfo = ts.getBuildInfo(content);
91149         if (buildInfo.version !== ts.version)
91150             return undefined;
91151         if (!buildInfo.program)
91152             return undefined;
91153         return ts.createBuildProgramUsingProgramBuildInfo(buildInfo.program, buildInfoPath, host);
91154     }
91155     ts.readBuilderProgram = readBuilderProgram;
91156     function createIncrementalCompilerHost(options, system) {
91157         if (system === void 0) { system = ts.sys; }
91158         var host = ts.createCompilerHostWorker(options, undefined, system);
91159         host.createHash = ts.maybeBind(system, system.createHash);
91160         ts.setGetSourceFileAsHashVersioned(host, system);
91161         ts.changeCompilerHostLikeToUseCache(host, function (fileName) { return ts.toPath(fileName, host.getCurrentDirectory(), host.getCanonicalFileName); });
91162         return host;
91163     }
91164     ts.createIncrementalCompilerHost = createIncrementalCompilerHost;
91165     function createIncrementalProgram(_a) {
91166         var rootNames = _a.rootNames, options = _a.options, configFileParsingDiagnostics = _a.configFileParsingDiagnostics, projectReferences = _a.projectReferences, host = _a.host, createProgram = _a.createProgram;
91167         host = host || createIncrementalCompilerHost(options);
91168         createProgram = createProgram || ts.createEmitAndSemanticDiagnosticsBuilderProgram;
91169         var oldProgram = readBuilderProgram(options, host);
91170         return createProgram(rootNames, options, host, oldProgram, configFileParsingDiagnostics, projectReferences);
91171     }
91172     ts.createIncrementalProgram = createIncrementalProgram;
91173     function createWatchCompilerHost(rootFilesOrConfigFileName, options, system, createProgram, reportDiagnostic, reportWatchStatus, projectReferencesOrWatchOptionsToExtend, watchOptionsOrExtraFileExtensions) {
91174         if (ts.isArray(rootFilesOrConfigFileName)) {
91175             return ts.createWatchCompilerHostOfFilesAndCompilerOptions({
91176                 rootFiles: rootFilesOrConfigFileName,
91177                 options: options,
91178                 watchOptions: watchOptionsOrExtraFileExtensions,
91179                 projectReferences: projectReferencesOrWatchOptionsToExtend,
91180                 system: system,
91181                 createProgram: createProgram,
91182                 reportDiagnostic: reportDiagnostic,
91183                 reportWatchStatus: reportWatchStatus,
91184             });
91185         }
91186         else {
91187             return ts.createWatchCompilerHostOfConfigFile({
91188                 configFileName: rootFilesOrConfigFileName,
91189                 optionsToExtend: options,
91190                 watchOptionsToExtend: projectReferencesOrWatchOptionsToExtend,
91191                 extraFileExtensions: watchOptionsOrExtraFileExtensions,
91192                 system: system,
91193                 createProgram: createProgram,
91194                 reportDiagnostic: reportDiagnostic,
91195                 reportWatchStatus: reportWatchStatus,
91196             });
91197         }
91198     }
91199     ts.createWatchCompilerHost = createWatchCompilerHost;
91200     function createWatchProgram(host) {
91201         var builderProgram;
91202         var reloadLevel;
91203         var missingFilesMap;
91204         var watchedWildcardDirectories;
91205         var timerToUpdateProgram;
91206         var timerToInvalidateFailedLookupResolutions;
91207         var sourceFilesCache = new ts.Map();
91208         var missingFilePathsRequestedForRelease;
91209         var hasChangedCompilerOptions = false;
91210         var useCaseSensitiveFileNames = host.useCaseSensitiveFileNames();
91211         var currentDirectory = host.getCurrentDirectory();
91212         var configFileName = host.configFileName, _a = host.optionsToExtend, optionsToExtendForConfigFile = _a === void 0 ? {} : _a, watchOptionsToExtend = host.watchOptionsToExtend, extraFileExtensions = host.extraFileExtensions, createProgram = host.createProgram;
91213         var rootFileNames = host.rootFiles, compilerOptions = host.options, watchOptions = host.watchOptions, projectReferences = host.projectReferences;
91214         var configFileSpecs;
91215         var configFileParsingDiagnostics;
91216         var canConfigFileJsonReportNoInputFiles = false;
91217         var hasChangedConfigFileParsingErrors = false;
91218         var cachedDirectoryStructureHost = configFileName === undefined ? undefined : ts.createCachedDirectoryStructureHost(host, currentDirectory, useCaseSensitiveFileNames);
91219         var directoryStructureHost = cachedDirectoryStructureHost || host;
91220         var parseConfigFileHost = ts.parseConfigHostFromCompilerHostLike(host, directoryStructureHost);
91221         var newLine = updateNewLine();
91222         if (configFileName && host.configFileParsingResult) {
91223             setConfigFileParsingResult(host.configFileParsingResult);
91224             newLine = updateNewLine();
91225         }
91226         reportWatchDiagnostic(ts.Diagnostics.Starting_compilation_in_watch_mode);
91227         if (configFileName && !host.configFileParsingResult) {
91228             newLine = ts.getNewLineCharacter(optionsToExtendForConfigFile, function () { return host.getNewLine(); });
91229             ts.Debug.assert(!rootFileNames);
91230             parseConfigFile();
91231             newLine = updateNewLine();
91232         }
91233         var _b = ts.createWatchFactory(host, compilerOptions), watchFile = _b.watchFile, watchFilePath = _b.watchFilePath, watchDirectory = _b.watchDirectory, writeLog = _b.writeLog;
91234         var getCanonicalFileName = ts.createGetCanonicalFileName(useCaseSensitiveFileNames);
91235         writeLog("Current directory: " + currentDirectory + " CaseSensitiveFileNames: " + useCaseSensitiveFileNames);
91236         var configFileWatcher;
91237         if (configFileName) {
91238             configFileWatcher = watchFile(host, configFileName, scheduleProgramReload, ts.PollingInterval.High, watchOptions, ts.WatchType.ConfigFile);
91239         }
91240         var compilerHost = ts.createCompilerHostFromProgramHost(host, function () { return compilerOptions; }, directoryStructureHost);
91241         ts.setGetSourceFileAsHashVersioned(compilerHost, host);
91242         var getNewSourceFile = compilerHost.getSourceFile;
91243         compilerHost.getSourceFile = function (fileName) {
91244             var args = [];
91245             for (var _i = 1; _i < arguments.length; _i++) {
91246                 args[_i - 1] = arguments[_i];
91247             }
91248             return getVersionedSourceFileByPath.apply(void 0, __spreadArrays([fileName, toPath(fileName)], args));
91249         };
91250         compilerHost.getSourceFileByPath = getVersionedSourceFileByPath;
91251         compilerHost.getNewLine = function () { return newLine; };
91252         compilerHost.fileExists = fileExists;
91253         compilerHost.onReleaseOldSourceFile = onReleaseOldSourceFile;
91254         compilerHost.toPath = toPath;
91255         compilerHost.getCompilationSettings = function () { return compilerOptions; };
91256         compilerHost.useSourceOfProjectReferenceRedirect = ts.maybeBind(host, host.useSourceOfProjectReferenceRedirect);
91257         compilerHost.watchDirectoryOfFailedLookupLocation = function (dir, cb, flags) { return watchDirectory(host, dir, cb, flags, watchOptions, ts.WatchType.FailedLookupLocations); };
91258         compilerHost.watchTypeRootsDirectory = function (dir, cb, flags) { return watchDirectory(host, dir, cb, flags, watchOptions, ts.WatchType.TypeRoots); };
91259         compilerHost.getCachedDirectoryStructureHost = function () { return cachedDirectoryStructureHost; };
91260         compilerHost.scheduleInvalidateResolutionsOfFailedLookupLocations = scheduleInvalidateResolutionsOfFailedLookupLocations;
91261         compilerHost.onInvalidatedResolution = scheduleProgramUpdate;
91262         compilerHost.onChangedAutomaticTypeDirectiveNames = scheduleProgramUpdate;
91263         compilerHost.fileIsOpen = ts.returnFalse;
91264         compilerHost.getCurrentProgram = getCurrentProgram;
91265         compilerHost.writeLog = writeLog;
91266         var resolutionCache = ts.createResolutionCache(compilerHost, configFileName ?
91267             ts.getDirectoryPath(ts.getNormalizedAbsolutePath(configFileName, currentDirectory)) :
91268             currentDirectory, false);
91269         compilerHost.resolveModuleNames = host.resolveModuleNames ?
91270             (function () {
91271                 var args = [];
91272                 for (var _i = 0; _i < arguments.length; _i++) {
91273                     args[_i] = arguments[_i];
91274                 }
91275                 return host.resolveModuleNames.apply(host, args);
91276             }) :
91277             (function (moduleNames, containingFile, reusedNames, redirectedReference) { return resolutionCache.resolveModuleNames(moduleNames, containingFile, reusedNames, redirectedReference); });
91278         compilerHost.resolveTypeReferenceDirectives = host.resolveTypeReferenceDirectives ?
91279             (function () {
91280                 var args = [];
91281                 for (var _i = 0; _i < arguments.length; _i++) {
91282                     args[_i] = arguments[_i];
91283                 }
91284                 return host.resolveTypeReferenceDirectives.apply(host, args);
91285             }) :
91286             (function (typeDirectiveNames, containingFile, redirectedReference) { return resolutionCache.resolveTypeReferenceDirectives(typeDirectiveNames, containingFile, redirectedReference); });
91287         var userProvidedResolution = !!host.resolveModuleNames || !!host.resolveTypeReferenceDirectives;
91288         builderProgram = readBuilderProgram(compilerOptions, compilerHost);
91289         synchronizeProgram();
91290         watchConfigFileWildCardDirectories();
91291         return configFileName ?
91292             { getCurrentProgram: getCurrentBuilderProgram, getProgram: updateProgram, close: close } :
91293             { getCurrentProgram: getCurrentBuilderProgram, getProgram: updateProgram, updateRootFileNames: updateRootFileNames, close: close };
91294         function close() {
91295             clearInvalidateResolutionsOfFailedLookupLocations();
91296             resolutionCache.clear();
91297             ts.clearMap(sourceFilesCache, function (value) {
91298                 if (value && value.fileWatcher) {
91299                     value.fileWatcher.close();
91300                     value.fileWatcher = undefined;
91301                 }
91302             });
91303             if (configFileWatcher) {
91304                 configFileWatcher.close();
91305                 configFileWatcher = undefined;
91306             }
91307             if (watchedWildcardDirectories) {
91308                 ts.clearMap(watchedWildcardDirectories, ts.closeFileWatcherOf);
91309                 watchedWildcardDirectories = undefined;
91310             }
91311             if (missingFilesMap) {
91312                 ts.clearMap(missingFilesMap, ts.closeFileWatcher);
91313                 missingFilesMap = undefined;
91314             }
91315         }
91316         function getCurrentBuilderProgram() {
91317             return builderProgram;
91318         }
91319         function getCurrentProgram() {
91320             return builderProgram && builderProgram.getProgramOrUndefined();
91321         }
91322         function synchronizeProgram() {
91323             writeLog("Synchronizing program");
91324             clearInvalidateResolutionsOfFailedLookupLocations();
91325             var program = getCurrentBuilderProgram();
91326             if (hasChangedCompilerOptions) {
91327                 newLine = updateNewLine();
91328                 if (program && ts.changesAffectModuleResolution(program.getCompilerOptions(), compilerOptions)) {
91329                     resolutionCache.clear();
91330                 }
91331             }
91332             var hasInvalidatedResolution = resolutionCache.createHasInvalidatedResolution(userProvidedResolution);
91333             if (ts.isProgramUptoDate(getCurrentProgram(), rootFileNames, compilerOptions, getSourceVersion, fileExists, hasInvalidatedResolution, hasChangedAutomaticTypeDirectiveNames, projectReferences)) {
91334                 if (hasChangedConfigFileParsingErrors) {
91335                     builderProgram = createProgram(undefined, undefined, compilerHost, builderProgram, configFileParsingDiagnostics, projectReferences);
91336                     hasChangedConfigFileParsingErrors = false;
91337                 }
91338             }
91339             else {
91340                 createNewProgram(hasInvalidatedResolution);
91341             }
91342             if (host.afterProgramCreate && program !== builderProgram) {
91343                 host.afterProgramCreate(builderProgram);
91344             }
91345             return builderProgram;
91346         }
91347         function createNewProgram(hasInvalidatedResolution) {
91348             writeLog("CreatingProgramWith::");
91349             writeLog("  roots: " + JSON.stringify(rootFileNames));
91350             writeLog("  options: " + JSON.stringify(compilerOptions));
91351             var needsUpdateInTypeRootWatch = hasChangedCompilerOptions || !getCurrentProgram();
91352             hasChangedCompilerOptions = false;
91353             hasChangedConfigFileParsingErrors = false;
91354             resolutionCache.startCachingPerDirectoryResolution();
91355             compilerHost.hasInvalidatedResolution = hasInvalidatedResolution;
91356             compilerHost.hasChangedAutomaticTypeDirectiveNames = hasChangedAutomaticTypeDirectiveNames;
91357             builderProgram = createProgram(rootFileNames, compilerOptions, compilerHost, builderProgram, configFileParsingDiagnostics, projectReferences);
91358             resolutionCache.finishCachingPerDirectoryResolution();
91359             ts.updateMissingFilePathsWatch(builderProgram.getProgram(), missingFilesMap || (missingFilesMap = new ts.Map()), watchMissingFilePath);
91360             if (needsUpdateInTypeRootWatch) {
91361                 resolutionCache.updateTypeRootsWatch();
91362             }
91363             if (missingFilePathsRequestedForRelease) {
91364                 for (var _i = 0, missingFilePathsRequestedForRelease_1 = missingFilePathsRequestedForRelease; _i < missingFilePathsRequestedForRelease_1.length; _i++) {
91365                     var missingFilePath = missingFilePathsRequestedForRelease_1[_i];
91366                     if (!missingFilesMap.has(missingFilePath)) {
91367                         sourceFilesCache.delete(missingFilePath);
91368                     }
91369                 }
91370                 missingFilePathsRequestedForRelease = undefined;
91371             }
91372         }
91373         function updateRootFileNames(files) {
91374             ts.Debug.assert(!configFileName, "Cannot update root file names with config file watch mode");
91375             rootFileNames = files;
91376             scheduleProgramUpdate();
91377         }
91378         function updateNewLine() {
91379             return ts.getNewLineCharacter(compilerOptions || optionsToExtendForConfigFile, function () { return host.getNewLine(); });
91380         }
91381         function toPath(fileName) {
91382             return ts.toPath(fileName, currentDirectory, getCanonicalFileName);
91383         }
91384         function isFileMissingOnHost(hostSourceFile) {
91385             return typeof hostSourceFile === "boolean";
91386         }
91387         function isFilePresenceUnknownOnHost(hostSourceFile) {
91388             return typeof hostSourceFile.version === "boolean";
91389         }
91390         function fileExists(fileName) {
91391             var path = toPath(fileName);
91392             if (isFileMissingOnHost(sourceFilesCache.get(path))) {
91393                 return false;
91394             }
91395             return directoryStructureHost.fileExists(fileName);
91396         }
91397         function getVersionedSourceFileByPath(fileName, path, languageVersion, onError, shouldCreateNewSourceFile) {
91398             var hostSourceFile = sourceFilesCache.get(path);
91399             if (isFileMissingOnHost(hostSourceFile)) {
91400                 return undefined;
91401             }
91402             if (hostSourceFile === undefined || shouldCreateNewSourceFile || isFilePresenceUnknownOnHost(hostSourceFile)) {
91403                 var sourceFile = getNewSourceFile(fileName, languageVersion, onError);
91404                 if (hostSourceFile) {
91405                     if (sourceFile) {
91406                         hostSourceFile.sourceFile = sourceFile;
91407                         hostSourceFile.version = sourceFile.version;
91408                         if (!hostSourceFile.fileWatcher) {
91409                             hostSourceFile.fileWatcher = watchFilePath(host, fileName, onSourceFileChange, ts.PollingInterval.Low, watchOptions, path, ts.WatchType.SourceFile);
91410                         }
91411                     }
91412                     else {
91413                         if (hostSourceFile.fileWatcher) {
91414                             hostSourceFile.fileWatcher.close();
91415                         }
91416                         sourceFilesCache.set(path, false);
91417                     }
91418                 }
91419                 else {
91420                     if (sourceFile) {
91421                         var fileWatcher = watchFilePath(host, fileName, onSourceFileChange, ts.PollingInterval.Low, watchOptions, path, ts.WatchType.SourceFile);
91422                         sourceFilesCache.set(path, { sourceFile: sourceFile, version: sourceFile.version, fileWatcher: fileWatcher });
91423                     }
91424                     else {
91425                         sourceFilesCache.set(path, false);
91426                     }
91427                 }
91428                 return sourceFile;
91429             }
91430             return hostSourceFile.sourceFile;
91431         }
91432         function nextSourceFileVersion(path) {
91433             var hostSourceFile = sourceFilesCache.get(path);
91434             if (hostSourceFile !== undefined) {
91435                 if (isFileMissingOnHost(hostSourceFile)) {
91436                     sourceFilesCache.set(path, { version: false });
91437                 }
91438                 else {
91439                     hostSourceFile.version = false;
91440                 }
91441             }
91442         }
91443         function getSourceVersion(path) {
91444             var hostSourceFile = sourceFilesCache.get(path);
91445             return !hostSourceFile || !hostSourceFile.version ? undefined : hostSourceFile.version;
91446         }
91447         function onReleaseOldSourceFile(oldSourceFile, _oldOptions, hasSourceFileByPath) {
91448             var hostSourceFileInfo = sourceFilesCache.get(oldSourceFile.resolvedPath);
91449             if (hostSourceFileInfo !== undefined) {
91450                 if (isFileMissingOnHost(hostSourceFileInfo)) {
91451                     (missingFilePathsRequestedForRelease || (missingFilePathsRequestedForRelease = [])).push(oldSourceFile.path);
91452                 }
91453                 else if (hostSourceFileInfo.sourceFile === oldSourceFile) {
91454                     if (hostSourceFileInfo.fileWatcher) {
91455                         hostSourceFileInfo.fileWatcher.close();
91456                     }
91457                     sourceFilesCache.delete(oldSourceFile.resolvedPath);
91458                     if (!hasSourceFileByPath) {
91459                         resolutionCache.removeResolutionsOfFile(oldSourceFile.path);
91460                     }
91461                 }
91462             }
91463         }
91464         function reportWatchDiagnostic(message) {
91465             if (host.onWatchStatusChange) {
91466                 host.onWatchStatusChange(ts.createCompilerDiagnostic(message), newLine, compilerOptions || optionsToExtendForConfigFile);
91467             }
91468         }
91469         function hasChangedAutomaticTypeDirectiveNames() {
91470             return resolutionCache.hasChangedAutomaticTypeDirectiveNames();
91471         }
91472         function clearInvalidateResolutionsOfFailedLookupLocations() {
91473             if (!timerToInvalidateFailedLookupResolutions)
91474                 return false;
91475             host.clearTimeout(timerToInvalidateFailedLookupResolutions);
91476             timerToInvalidateFailedLookupResolutions = undefined;
91477             return true;
91478         }
91479         function scheduleInvalidateResolutionsOfFailedLookupLocations() {
91480             if (!host.setTimeout || !host.clearTimeout) {
91481                 return resolutionCache.invalidateResolutionsOfFailedLookupLocations();
91482             }
91483             var pending = clearInvalidateResolutionsOfFailedLookupLocations();
91484             writeLog("Scheduling invalidateFailedLookup" + (pending ? ", Cancelled earlier one" : ""));
91485             timerToInvalidateFailedLookupResolutions = host.setTimeout(invalidateResolutionsOfFailedLookup, 250);
91486         }
91487         function invalidateResolutionsOfFailedLookup() {
91488             timerToInvalidateFailedLookupResolutions = undefined;
91489             if (resolutionCache.invalidateResolutionsOfFailedLookupLocations()) {
91490                 scheduleProgramUpdate();
91491             }
91492         }
91493         function scheduleProgramUpdate() {
91494             if (!host.setTimeout || !host.clearTimeout) {
91495                 return;
91496             }
91497             if (timerToUpdateProgram) {
91498                 host.clearTimeout(timerToUpdateProgram);
91499             }
91500             writeLog("Scheduling update");
91501             timerToUpdateProgram = host.setTimeout(updateProgramWithWatchStatus, 250);
91502         }
91503         function scheduleProgramReload() {
91504             ts.Debug.assert(!!configFileName);
91505             reloadLevel = ts.ConfigFileProgramReloadLevel.Full;
91506             scheduleProgramUpdate();
91507         }
91508         function updateProgramWithWatchStatus() {
91509             timerToUpdateProgram = undefined;
91510             reportWatchDiagnostic(ts.Diagnostics.File_change_detected_Starting_incremental_compilation);
91511             updateProgram();
91512         }
91513         function updateProgram() {
91514             switch (reloadLevel) {
91515                 case ts.ConfigFileProgramReloadLevel.Partial:
91516                     ts.perfLogger.logStartUpdateProgram("PartialConfigReload");
91517                     reloadFileNamesFromConfigFile();
91518                     break;
91519                 case ts.ConfigFileProgramReloadLevel.Full:
91520                     ts.perfLogger.logStartUpdateProgram("FullConfigReload");
91521                     reloadConfigFile();
91522                     break;
91523                 default:
91524                     ts.perfLogger.logStartUpdateProgram("SynchronizeProgram");
91525                     synchronizeProgram();
91526                     break;
91527             }
91528             ts.perfLogger.logStopUpdateProgram("Done");
91529             return getCurrentBuilderProgram();
91530         }
91531         function reloadFileNamesFromConfigFile() {
91532             writeLog("Reloading new file names and options");
91533             var result = ts.getFileNamesFromConfigSpecs(configFileSpecs, ts.getNormalizedAbsolutePath(ts.getDirectoryPath(configFileName), currentDirectory), compilerOptions, parseConfigFileHost, extraFileExtensions);
91534             if (ts.updateErrorForNoInputFiles(result, ts.getNormalizedAbsolutePath(configFileName, currentDirectory), configFileSpecs, configFileParsingDiagnostics, canConfigFileJsonReportNoInputFiles)) {
91535                 hasChangedConfigFileParsingErrors = true;
91536             }
91537             rootFileNames = result.fileNames;
91538             synchronizeProgram();
91539         }
91540         function reloadConfigFile() {
91541             writeLog("Reloading config file: " + configFileName);
91542             reloadLevel = ts.ConfigFileProgramReloadLevel.None;
91543             if (cachedDirectoryStructureHost) {
91544                 cachedDirectoryStructureHost.clearCache();
91545             }
91546             parseConfigFile();
91547             hasChangedCompilerOptions = true;
91548             synchronizeProgram();
91549             watchConfigFileWildCardDirectories();
91550         }
91551         function parseConfigFile() {
91552             setConfigFileParsingResult(ts.getParsedCommandLineOfConfigFile(configFileName, optionsToExtendForConfigFile, parseConfigFileHost, undefined, watchOptionsToExtend, extraFileExtensions));
91553         }
91554         function setConfigFileParsingResult(configFileParseResult) {
91555             rootFileNames = configFileParseResult.fileNames;
91556             compilerOptions = configFileParseResult.options;
91557             watchOptions = configFileParseResult.watchOptions;
91558             configFileSpecs = configFileParseResult.configFileSpecs;
91559             projectReferences = configFileParseResult.projectReferences;
91560             configFileParsingDiagnostics = ts.getConfigFileParsingDiagnostics(configFileParseResult).slice();
91561             canConfigFileJsonReportNoInputFiles = ts.canJsonReportNoInputFiles(configFileParseResult.raw);
91562             hasChangedConfigFileParsingErrors = true;
91563         }
91564         function onSourceFileChange(fileName, eventKind, path) {
91565             updateCachedSystemWithFile(fileName, path, eventKind);
91566             if (eventKind === ts.FileWatcherEventKind.Deleted && sourceFilesCache.has(path)) {
91567                 resolutionCache.invalidateResolutionOfFile(path);
91568             }
91569             resolutionCache.removeResolutionsFromProjectReferenceRedirects(path);
91570             nextSourceFileVersion(path);
91571             scheduleProgramUpdate();
91572         }
91573         function updateCachedSystemWithFile(fileName, path, eventKind) {
91574             if (cachedDirectoryStructureHost) {
91575                 cachedDirectoryStructureHost.addOrDeleteFile(fileName, path, eventKind);
91576             }
91577         }
91578         function watchMissingFilePath(missingFilePath) {
91579             return watchFilePath(host, missingFilePath, onMissingFileChange, ts.PollingInterval.Medium, watchOptions, missingFilePath, ts.WatchType.MissingFile);
91580         }
91581         function onMissingFileChange(fileName, eventKind, missingFilePath) {
91582             updateCachedSystemWithFile(fileName, missingFilePath, eventKind);
91583             if (eventKind === ts.FileWatcherEventKind.Created && missingFilesMap.has(missingFilePath)) {
91584                 missingFilesMap.get(missingFilePath).close();
91585                 missingFilesMap.delete(missingFilePath);
91586                 nextSourceFileVersion(missingFilePath);
91587                 scheduleProgramUpdate();
91588             }
91589         }
91590         function watchConfigFileWildCardDirectories() {
91591             if (configFileSpecs) {
91592                 ts.updateWatchingWildcardDirectories(watchedWildcardDirectories || (watchedWildcardDirectories = new ts.Map()), new ts.Map(ts.getEntries(configFileSpecs.wildcardDirectories)), watchWildcardDirectory);
91593             }
91594             else if (watchedWildcardDirectories) {
91595                 ts.clearMap(watchedWildcardDirectories, ts.closeFileWatcherOf);
91596             }
91597         }
91598         function watchWildcardDirectory(directory, flags) {
91599             return watchDirectory(host, directory, function (fileOrDirectory) {
91600                 ts.Debug.assert(!!configFileName);
91601                 var fileOrDirectoryPath = toPath(fileOrDirectory);
91602                 if (cachedDirectoryStructureHost) {
91603                     cachedDirectoryStructureHost.addOrDeleteFileOrDirectory(fileOrDirectory, fileOrDirectoryPath);
91604                 }
91605                 nextSourceFileVersion(fileOrDirectoryPath);
91606                 if (ts.isIgnoredFileFromWildCardWatching({
91607                     watchedDirPath: toPath(directory),
91608                     fileOrDirectory: fileOrDirectory,
91609                     fileOrDirectoryPath: fileOrDirectoryPath,
91610                     configFileName: configFileName,
91611                     configFileSpecs: configFileSpecs,
91612                     extraFileExtensions: extraFileExtensions,
91613                     options: compilerOptions,
91614                     program: getCurrentBuilderProgram(),
91615                     currentDirectory: currentDirectory,
91616                     useCaseSensitiveFileNames: useCaseSensitiveFileNames,
91617                     writeLog: writeLog
91618                 }))
91619                     return;
91620                 if (reloadLevel !== ts.ConfigFileProgramReloadLevel.Full) {
91621                     reloadLevel = ts.ConfigFileProgramReloadLevel.Partial;
91622                     scheduleProgramUpdate();
91623                 }
91624             }, flags, watchOptions, ts.WatchType.WildcardDirectory);
91625         }
91626     }
91627     ts.createWatchProgram = createWatchProgram;
91628 })(ts || (ts = {}));
91629 var ts;
91630 (function (ts) {
91631     var UpToDateStatusType;
91632     (function (UpToDateStatusType) {
91633         UpToDateStatusType[UpToDateStatusType["Unbuildable"] = 0] = "Unbuildable";
91634         UpToDateStatusType[UpToDateStatusType["UpToDate"] = 1] = "UpToDate";
91635         UpToDateStatusType[UpToDateStatusType["UpToDateWithUpstreamTypes"] = 2] = "UpToDateWithUpstreamTypes";
91636         UpToDateStatusType[UpToDateStatusType["OutOfDateWithPrepend"] = 3] = "OutOfDateWithPrepend";
91637         UpToDateStatusType[UpToDateStatusType["OutputMissing"] = 4] = "OutputMissing";
91638         UpToDateStatusType[UpToDateStatusType["OutOfDateWithSelf"] = 5] = "OutOfDateWithSelf";
91639         UpToDateStatusType[UpToDateStatusType["OutOfDateWithUpstream"] = 6] = "OutOfDateWithUpstream";
91640         UpToDateStatusType[UpToDateStatusType["UpstreamOutOfDate"] = 7] = "UpstreamOutOfDate";
91641         UpToDateStatusType[UpToDateStatusType["UpstreamBlocked"] = 8] = "UpstreamBlocked";
91642         UpToDateStatusType[UpToDateStatusType["ComputingUpstream"] = 9] = "ComputingUpstream";
91643         UpToDateStatusType[UpToDateStatusType["TsVersionOutputOfDate"] = 10] = "TsVersionOutputOfDate";
91644         UpToDateStatusType[UpToDateStatusType["ContainerOnly"] = 11] = "ContainerOnly";
91645     })(UpToDateStatusType = ts.UpToDateStatusType || (ts.UpToDateStatusType = {}));
91646     function resolveConfigFileProjectName(project) {
91647         if (ts.fileExtensionIs(project, ".json")) {
91648             return project;
91649         }
91650         return ts.combinePaths(project, "tsconfig.json");
91651     }
91652     ts.resolveConfigFileProjectName = resolveConfigFileProjectName;
91653 })(ts || (ts = {}));
91654 var ts;
91655 (function (ts) {
91656     var minimumDate = new Date(-8640000000000000);
91657     var maximumDate = new Date(8640000000000000);
91658     var BuildResultFlags;
91659     (function (BuildResultFlags) {
91660         BuildResultFlags[BuildResultFlags["None"] = 0] = "None";
91661         BuildResultFlags[BuildResultFlags["Success"] = 1] = "Success";
91662         BuildResultFlags[BuildResultFlags["DeclarationOutputUnchanged"] = 2] = "DeclarationOutputUnchanged";
91663         BuildResultFlags[BuildResultFlags["ConfigFileErrors"] = 4] = "ConfigFileErrors";
91664         BuildResultFlags[BuildResultFlags["SyntaxErrors"] = 8] = "SyntaxErrors";
91665         BuildResultFlags[BuildResultFlags["TypeErrors"] = 16] = "TypeErrors";
91666         BuildResultFlags[BuildResultFlags["DeclarationEmitErrors"] = 32] = "DeclarationEmitErrors";
91667         BuildResultFlags[BuildResultFlags["EmitErrors"] = 64] = "EmitErrors";
91668         BuildResultFlags[BuildResultFlags["AnyErrors"] = 124] = "AnyErrors";
91669     })(BuildResultFlags || (BuildResultFlags = {}));
91670     function getOrCreateValueFromConfigFileMap(configFileMap, resolved, createT) {
91671         var existingValue = configFileMap.get(resolved);
91672         var newValue;
91673         if (!existingValue) {
91674             newValue = createT();
91675             configFileMap.set(resolved, newValue);
91676         }
91677         return existingValue || newValue;
91678     }
91679     function getOrCreateValueMapFromConfigFileMap(configFileMap, resolved) {
91680         return getOrCreateValueFromConfigFileMap(configFileMap, resolved, function () { return new ts.Map(); });
91681     }
91682     function newer(date1, date2) {
91683         return date2 > date1 ? date2 : date1;
91684     }
91685     function isDeclarationFile(fileName) {
91686         return ts.fileExtensionIs(fileName, ".d.ts");
91687     }
91688     function isCircularBuildOrder(buildOrder) {
91689         return !!buildOrder && !!buildOrder.buildOrder;
91690     }
91691     ts.isCircularBuildOrder = isCircularBuildOrder;
91692     function getBuildOrderFromAnyBuildOrder(anyBuildOrder) {
91693         return isCircularBuildOrder(anyBuildOrder) ? anyBuildOrder.buildOrder : anyBuildOrder;
91694     }
91695     ts.getBuildOrderFromAnyBuildOrder = getBuildOrderFromAnyBuildOrder;
91696     function createBuilderStatusReporter(system, pretty) {
91697         return function (diagnostic) {
91698             var output = pretty ? "[" + ts.formatColorAndReset(ts.getLocaleTimeString(system), ts.ForegroundColorEscapeSequences.Grey) + "] " : ts.getLocaleTimeString(system) + " - ";
91699             output += "" + ts.flattenDiagnosticMessageText(diagnostic.messageText, system.newLine) + (system.newLine + system.newLine);
91700             system.write(output);
91701         };
91702     }
91703     ts.createBuilderStatusReporter = createBuilderStatusReporter;
91704     function createSolutionBuilderHostBase(system, createProgram, reportDiagnostic, reportSolutionBuilderStatus) {
91705         var host = ts.createProgramHost(system, createProgram);
91706         host.getModifiedTime = system.getModifiedTime ? function (path) { return system.getModifiedTime(path); } : ts.returnUndefined;
91707         host.setModifiedTime = system.setModifiedTime ? function (path, date) { return system.setModifiedTime(path, date); } : ts.noop;
91708         host.deleteFile = system.deleteFile ? function (path) { return system.deleteFile(path); } : ts.noop;
91709         host.reportDiagnostic = reportDiagnostic || ts.createDiagnosticReporter(system);
91710         host.reportSolutionBuilderStatus = reportSolutionBuilderStatus || createBuilderStatusReporter(system);
91711         host.now = ts.maybeBind(system, system.now);
91712         return host;
91713     }
91714     function createSolutionBuilderHost(system, createProgram, reportDiagnostic, reportSolutionBuilderStatus, reportErrorSummary) {
91715         if (system === void 0) { system = ts.sys; }
91716         var host = createSolutionBuilderHostBase(system, createProgram, reportDiagnostic, reportSolutionBuilderStatus);
91717         host.reportErrorSummary = reportErrorSummary;
91718         return host;
91719     }
91720     ts.createSolutionBuilderHost = createSolutionBuilderHost;
91721     function createSolutionBuilderWithWatchHost(system, createProgram, reportDiagnostic, reportSolutionBuilderStatus, reportWatchStatus) {
91722         if (system === void 0) { system = ts.sys; }
91723         var host = createSolutionBuilderHostBase(system, createProgram, reportDiagnostic, reportSolutionBuilderStatus);
91724         var watchHost = ts.createWatchHost(system, reportWatchStatus);
91725         ts.copyProperties(host, watchHost);
91726         return host;
91727     }
91728     ts.createSolutionBuilderWithWatchHost = createSolutionBuilderWithWatchHost;
91729     function getCompilerOptionsOfBuildOptions(buildOptions) {
91730         var result = {};
91731         ts.commonOptionsWithBuild.forEach(function (option) {
91732             if (ts.hasProperty(buildOptions, option.name))
91733                 result[option.name] = buildOptions[option.name];
91734         });
91735         return result;
91736     }
91737     function createSolutionBuilder(host, rootNames, defaultOptions) {
91738         return createSolutionBuilderWorker(false, host, rootNames, defaultOptions);
91739     }
91740     ts.createSolutionBuilder = createSolutionBuilder;
91741     function createSolutionBuilderWithWatch(host, rootNames, defaultOptions, baseWatchOptions) {
91742         return createSolutionBuilderWorker(true, host, rootNames, defaultOptions, baseWatchOptions);
91743     }
91744     ts.createSolutionBuilderWithWatch = createSolutionBuilderWithWatch;
91745     function createSolutionBuilderState(watch, hostOrHostWithWatch, rootNames, options, baseWatchOptions) {
91746         var host = hostOrHostWithWatch;
91747         var hostWithWatch = hostOrHostWithWatch;
91748         var currentDirectory = host.getCurrentDirectory();
91749         var getCanonicalFileName = ts.createGetCanonicalFileName(host.useCaseSensitiveFileNames());
91750         var baseCompilerOptions = getCompilerOptionsOfBuildOptions(options);
91751         var compilerHost = ts.createCompilerHostFromProgramHost(host, function () { return state.projectCompilerOptions; });
91752         ts.setGetSourceFileAsHashVersioned(compilerHost, host);
91753         compilerHost.getParsedCommandLine = function (fileName) { return parseConfigFile(state, fileName, toResolvedConfigFilePath(state, fileName)); };
91754         compilerHost.resolveModuleNames = ts.maybeBind(host, host.resolveModuleNames);
91755         compilerHost.resolveTypeReferenceDirectives = ts.maybeBind(host, host.resolveTypeReferenceDirectives);
91756         var moduleResolutionCache = !compilerHost.resolveModuleNames ? ts.createModuleResolutionCache(currentDirectory, getCanonicalFileName) : undefined;
91757         if (!compilerHost.resolveModuleNames) {
91758             var loader_3 = function (moduleName, containingFile, redirectedReference) { return ts.resolveModuleName(moduleName, containingFile, state.projectCompilerOptions, compilerHost, moduleResolutionCache, redirectedReference).resolvedModule; };
91759             compilerHost.resolveModuleNames = function (moduleNames, containingFile, _reusedNames, redirectedReference) {
91760                 return ts.loadWithLocalCache(ts.Debug.checkEachDefined(moduleNames), containingFile, redirectedReference, loader_3);
91761             };
91762         }
91763         var _a = ts.createWatchFactory(hostWithWatch, options), watchFile = _a.watchFile, watchFilePath = _a.watchFilePath, watchDirectory = _a.watchDirectory, writeLog = _a.writeLog;
91764         var state = {
91765             host: host,
91766             hostWithWatch: hostWithWatch,
91767             currentDirectory: currentDirectory,
91768             getCanonicalFileName: getCanonicalFileName,
91769             parseConfigFileHost: ts.parseConfigHostFromCompilerHostLike(host),
91770             writeFileName: host.trace ? function (s) { return host.trace(s); } : undefined,
91771             options: options,
91772             baseCompilerOptions: baseCompilerOptions,
91773             rootNames: rootNames,
91774             baseWatchOptions: baseWatchOptions,
91775             resolvedConfigFilePaths: new ts.Map(),
91776             configFileCache: new ts.Map(),
91777             projectStatus: new ts.Map(),
91778             buildInfoChecked: new ts.Map(),
91779             extendedConfigCache: new ts.Map(),
91780             builderPrograms: new ts.Map(),
91781             diagnostics: new ts.Map(),
91782             projectPendingBuild: new ts.Map(),
91783             projectErrorsReported: new ts.Map(),
91784             compilerHost: compilerHost,
91785             moduleResolutionCache: moduleResolutionCache,
91786             buildOrder: undefined,
91787             readFileWithCache: function (f) { return host.readFile(f); },
91788             projectCompilerOptions: baseCompilerOptions,
91789             cache: undefined,
91790             allProjectBuildPending: true,
91791             needsSummary: true,
91792             watchAllProjectsPending: watch,
91793             currentInvalidatedProject: undefined,
91794             watch: watch,
91795             allWatchedWildcardDirectories: new ts.Map(),
91796             allWatchedInputFiles: new ts.Map(),
91797             allWatchedConfigFiles: new ts.Map(),
91798             timerToBuildInvalidatedProject: undefined,
91799             reportFileChangeDetected: false,
91800             watchFile: watchFile,
91801             watchFilePath: watchFilePath,
91802             watchDirectory: watchDirectory,
91803             writeLog: writeLog,
91804         };
91805         return state;
91806     }
91807     function toPath(state, fileName) {
91808         return ts.toPath(fileName, state.currentDirectory, state.getCanonicalFileName);
91809     }
91810     function toResolvedConfigFilePath(state, fileName) {
91811         var resolvedConfigFilePaths = state.resolvedConfigFilePaths;
91812         var path = resolvedConfigFilePaths.get(fileName);
91813         if (path !== undefined)
91814             return path;
91815         var resolvedPath = toPath(state, fileName);
91816         resolvedConfigFilePaths.set(fileName, resolvedPath);
91817         return resolvedPath;
91818     }
91819     function isParsedCommandLine(entry) {
91820         return !!entry.options;
91821     }
91822     function parseConfigFile(state, configFileName, configFilePath) {
91823         var configFileCache = state.configFileCache;
91824         var value = configFileCache.get(configFilePath);
91825         if (value) {
91826             return isParsedCommandLine(value) ? value : undefined;
91827         }
91828         var diagnostic;
91829         var parseConfigFileHost = state.parseConfigFileHost, baseCompilerOptions = state.baseCompilerOptions, baseWatchOptions = state.baseWatchOptions, extendedConfigCache = state.extendedConfigCache, host = state.host;
91830         var parsed;
91831         if (host.getParsedCommandLine) {
91832             parsed = host.getParsedCommandLine(configFileName);
91833             if (!parsed)
91834                 diagnostic = ts.createCompilerDiagnostic(ts.Diagnostics.File_0_not_found, configFileName);
91835         }
91836         else {
91837             parseConfigFileHost.onUnRecoverableConfigFileDiagnostic = function (d) { return diagnostic = d; };
91838             parsed = ts.getParsedCommandLineOfConfigFile(configFileName, baseCompilerOptions, parseConfigFileHost, extendedConfigCache, baseWatchOptions);
91839             parseConfigFileHost.onUnRecoverableConfigFileDiagnostic = ts.noop;
91840         }
91841         configFileCache.set(configFilePath, parsed || diagnostic);
91842         return parsed;
91843     }
91844     function resolveProjectName(state, name) {
91845         return ts.resolveConfigFileProjectName(ts.resolvePath(state.currentDirectory, name));
91846     }
91847     function createBuildOrder(state, roots) {
91848         var temporaryMarks = new ts.Map();
91849         var permanentMarks = new ts.Map();
91850         var circularityReportStack = [];
91851         var buildOrder;
91852         var circularDiagnostics;
91853         for (var _i = 0, roots_1 = roots; _i < roots_1.length; _i++) {
91854             var root = roots_1[_i];
91855             visit(root);
91856         }
91857         return circularDiagnostics ?
91858             { buildOrder: buildOrder || ts.emptyArray, circularDiagnostics: circularDiagnostics } :
91859             buildOrder || ts.emptyArray;
91860         function visit(configFileName, inCircularContext) {
91861             var projPath = toResolvedConfigFilePath(state, configFileName);
91862             if (permanentMarks.has(projPath))
91863                 return;
91864             if (temporaryMarks.has(projPath)) {
91865                 if (!inCircularContext) {
91866                     (circularDiagnostics || (circularDiagnostics = [])).push(ts.createCompilerDiagnostic(ts.Diagnostics.Project_references_may_not_form_a_circular_graph_Cycle_detected_Colon_0, circularityReportStack.join("\r\n")));
91867                 }
91868                 return;
91869             }
91870             temporaryMarks.set(projPath, true);
91871             circularityReportStack.push(configFileName);
91872             var parsed = parseConfigFile(state, configFileName, projPath);
91873             if (parsed && parsed.projectReferences) {
91874                 for (var _i = 0, _a = parsed.projectReferences; _i < _a.length; _i++) {
91875                     var ref = _a[_i];
91876                     var resolvedRefPath = resolveProjectName(state, ref.path);
91877                     visit(resolvedRefPath, inCircularContext || ref.circular);
91878                 }
91879             }
91880             circularityReportStack.pop();
91881             permanentMarks.set(projPath, true);
91882             (buildOrder || (buildOrder = [])).push(configFileName);
91883         }
91884     }
91885     function getBuildOrder(state) {
91886         return state.buildOrder || createStateBuildOrder(state);
91887     }
91888     function createStateBuildOrder(state) {
91889         var buildOrder = createBuildOrder(state, state.rootNames.map(function (f) { return resolveProjectName(state, f); }));
91890         state.resolvedConfigFilePaths.clear();
91891         var currentProjects = new ts.Map(getBuildOrderFromAnyBuildOrder(buildOrder).map(function (resolved) { return [toResolvedConfigFilePath(state, resolved), true]; }));
91892         var noopOnDelete = { onDeleteValue: ts.noop };
91893         ts.mutateMapSkippingNewValues(state.configFileCache, currentProjects, noopOnDelete);
91894         ts.mutateMapSkippingNewValues(state.projectStatus, currentProjects, noopOnDelete);
91895         ts.mutateMapSkippingNewValues(state.buildInfoChecked, currentProjects, noopOnDelete);
91896         ts.mutateMapSkippingNewValues(state.builderPrograms, currentProjects, noopOnDelete);
91897         ts.mutateMapSkippingNewValues(state.diagnostics, currentProjects, noopOnDelete);
91898         ts.mutateMapSkippingNewValues(state.projectPendingBuild, currentProjects, noopOnDelete);
91899         ts.mutateMapSkippingNewValues(state.projectErrorsReported, currentProjects, noopOnDelete);
91900         if (state.watch) {
91901             ts.mutateMapSkippingNewValues(state.allWatchedConfigFiles, currentProjects, { onDeleteValue: ts.closeFileWatcher });
91902             ts.mutateMapSkippingNewValues(state.allWatchedWildcardDirectories, currentProjects, { onDeleteValue: function (existingMap) { return existingMap.forEach(ts.closeFileWatcherOf); } });
91903             ts.mutateMapSkippingNewValues(state.allWatchedInputFiles, currentProjects, { onDeleteValue: function (existingMap) { return existingMap.forEach(ts.closeFileWatcher); } });
91904         }
91905         return state.buildOrder = buildOrder;
91906     }
91907     function getBuildOrderFor(state, project, onlyReferences) {
91908         var resolvedProject = project && resolveProjectName(state, project);
91909         var buildOrderFromState = getBuildOrder(state);
91910         if (isCircularBuildOrder(buildOrderFromState))
91911             return buildOrderFromState;
91912         if (resolvedProject) {
91913             var projectPath_1 = toResolvedConfigFilePath(state, resolvedProject);
91914             var projectIndex = ts.findIndex(buildOrderFromState, function (configFileName) { return toResolvedConfigFilePath(state, configFileName) === projectPath_1; });
91915             if (projectIndex === -1)
91916                 return undefined;
91917         }
91918         var buildOrder = resolvedProject ? createBuildOrder(state, [resolvedProject]) : buildOrderFromState;
91919         ts.Debug.assert(!isCircularBuildOrder(buildOrder));
91920         ts.Debug.assert(!onlyReferences || resolvedProject !== undefined);
91921         ts.Debug.assert(!onlyReferences || buildOrder[buildOrder.length - 1] === resolvedProject);
91922         return onlyReferences ? buildOrder.slice(0, buildOrder.length - 1) : buildOrder;
91923     }
91924     function enableCache(state) {
91925         if (state.cache) {
91926             disableCache(state);
91927         }
91928         var compilerHost = state.compilerHost, host = state.host;
91929         var originalReadFileWithCache = state.readFileWithCache;
91930         var originalGetSourceFile = compilerHost.getSourceFile;
91931         var _a = ts.changeCompilerHostLikeToUseCache(host, function (fileName) { return toPath(state, fileName); }, function () {
91932             var args = [];
91933             for (var _i = 0; _i < arguments.length; _i++) {
91934                 args[_i] = arguments[_i];
91935             }
91936             return originalGetSourceFile.call.apply(originalGetSourceFile, __spreadArrays([compilerHost], args));
91937         }), originalReadFile = _a.originalReadFile, originalFileExists = _a.originalFileExists, originalDirectoryExists = _a.originalDirectoryExists, originalCreateDirectory = _a.originalCreateDirectory, originalWriteFile = _a.originalWriteFile, getSourceFileWithCache = _a.getSourceFileWithCache, readFileWithCache = _a.readFileWithCache;
91938         state.readFileWithCache = readFileWithCache;
91939         compilerHost.getSourceFile = getSourceFileWithCache;
91940         state.cache = {
91941             originalReadFile: originalReadFile,
91942             originalFileExists: originalFileExists,
91943             originalDirectoryExists: originalDirectoryExists,
91944             originalCreateDirectory: originalCreateDirectory,
91945             originalWriteFile: originalWriteFile,
91946             originalReadFileWithCache: originalReadFileWithCache,
91947             originalGetSourceFile: originalGetSourceFile,
91948         };
91949     }
91950     function disableCache(state) {
91951         if (!state.cache)
91952             return;
91953         var cache = state.cache, host = state.host, compilerHost = state.compilerHost, extendedConfigCache = state.extendedConfigCache, moduleResolutionCache = state.moduleResolutionCache;
91954         host.readFile = cache.originalReadFile;
91955         host.fileExists = cache.originalFileExists;
91956         host.directoryExists = cache.originalDirectoryExists;
91957         host.createDirectory = cache.originalCreateDirectory;
91958         host.writeFile = cache.originalWriteFile;
91959         compilerHost.getSourceFile = cache.originalGetSourceFile;
91960         state.readFileWithCache = cache.originalReadFileWithCache;
91961         extendedConfigCache.clear();
91962         if (moduleResolutionCache) {
91963             moduleResolutionCache.directoryToModuleNameMap.clear();
91964             moduleResolutionCache.moduleNameToDirectoryMap.clear();
91965         }
91966         state.cache = undefined;
91967     }
91968     function clearProjectStatus(state, resolved) {
91969         state.projectStatus.delete(resolved);
91970         state.diagnostics.delete(resolved);
91971     }
91972     function addProjToQueue(_a, proj, reloadLevel) {
91973         var projectPendingBuild = _a.projectPendingBuild;
91974         var value = projectPendingBuild.get(proj);
91975         if (value === undefined) {
91976             projectPendingBuild.set(proj, reloadLevel);
91977         }
91978         else if (value < reloadLevel) {
91979             projectPendingBuild.set(proj, reloadLevel);
91980         }
91981     }
91982     function setupInitialBuild(state, cancellationToken) {
91983         if (!state.allProjectBuildPending)
91984             return;
91985         state.allProjectBuildPending = false;
91986         if (state.options.watch) {
91987             reportWatchStatus(state, ts.Diagnostics.Starting_compilation_in_watch_mode);
91988         }
91989         enableCache(state);
91990         var buildOrder = getBuildOrderFromAnyBuildOrder(getBuildOrder(state));
91991         buildOrder.forEach(function (configFileName) {
91992             return state.projectPendingBuild.set(toResolvedConfigFilePath(state, configFileName), ts.ConfigFileProgramReloadLevel.None);
91993         });
91994         if (cancellationToken) {
91995             cancellationToken.throwIfCancellationRequested();
91996         }
91997     }
91998     var InvalidatedProjectKind;
91999     (function (InvalidatedProjectKind) {
92000         InvalidatedProjectKind[InvalidatedProjectKind["Build"] = 0] = "Build";
92001         InvalidatedProjectKind[InvalidatedProjectKind["UpdateBundle"] = 1] = "UpdateBundle";
92002         InvalidatedProjectKind[InvalidatedProjectKind["UpdateOutputFileStamps"] = 2] = "UpdateOutputFileStamps";
92003     })(InvalidatedProjectKind = ts.InvalidatedProjectKind || (ts.InvalidatedProjectKind = {}));
92004     function doneInvalidatedProject(state, projectPath) {
92005         state.projectPendingBuild.delete(projectPath);
92006         state.currentInvalidatedProject = undefined;
92007         return state.diagnostics.has(projectPath) ?
92008             ts.ExitStatus.DiagnosticsPresent_OutputsSkipped :
92009             ts.ExitStatus.Success;
92010     }
92011     function createUpdateOutputFileStampsProject(state, project, projectPath, config, buildOrder) {
92012         var updateOutputFileStampsPending = true;
92013         return {
92014             kind: InvalidatedProjectKind.UpdateOutputFileStamps,
92015             project: project,
92016             projectPath: projectPath,
92017             buildOrder: buildOrder,
92018             getCompilerOptions: function () { return config.options; },
92019             getCurrentDirectory: function () { return state.currentDirectory; },
92020             updateOutputFileStatmps: function () {
92021                 updateOutputTimestamps(state, config, projectPath);
92022                 updateOutputFileStampsPending = false;
92023             },
92024             done: function () {
92025                 if (updateOutputFileStampsPending) {
92026                     updateOutputTimestamps(state, config, projectPath);
92027                 }
92028                 return doneInvalidatedProject(state, projectPath);
92029             }
92030         };
92031     }
92032     var BuildStep;
92033     (function (BuildStep) {
92034         BuildStep[BuildStep["CreateProgram"] = 0] = "CreateProgram";
92035         BuildStep[BuildStep["SyntaxDiagnostics"] = 1] = "SyntaxDiagnostics";
92036         BuildStep[BuildStep["SemanticDiagnostics"] = 2] = "SemanticDiagnostics";
92037         BuildStep[BuildStep["Emit"] = 3] = "Emit";
92038         BuildStep[BuildStep["EmitBundle"] = 4] = "EmitBundle";
92039         BuildStep[BuildStep["EmitBuildInfo"] = 5] = "EmitBuildInfo";
92040         BuildStep[BuildStep["BuildInvalidatedProjectOfBundle"] = 6] = "BuildInvalidatedProjectOfBundle";
92041         BuildStep[BuildStep["QueueReferencingProjects"] = 7] = "QueueReferencingProjects";
92042         BuildStep[BuildStep["Done"] = 8] = "Done";
92043     })(BuildStep || (BuildStep = {}));
92044     function createBuildOrUpdateInvalidedProject(kind, state, project, projectPath, projectIndex, config, buildOrder) {
92045         var step = kind === InvalidatedProjectKind.Build ? BuildStep.CreateProgram : BuildStep.EmitBundle;
92046         var program;
92047         var buildResult;
92048         var invalidatedProjectOfBundle;
92049         return kind === InvalidatedProjectKind.Build ?
92050             {
92051                 kind: kind,
92052                 project: project,
92053                 projectPath: projectPath,
92054                 buildOrder: buildOrder,
92055                 getCompilerOptions: function () { return config.options; },
92056                 getCurrentDirectory: function () { return state.currentDirectory; },
92057                 getBuilderProgram: function () { return withProgramOrUndefined(ts.identity); },
92058                 getProgram: function () {
92059                     return withProgramOrUndefined(function (program) { return program.getProgramOrUndefined(); });
92060                 },
92061                 getSourceFile: function (fileName) {
92062                     return withProgramOrUndefined(function (program) { return program.getSourceFile(fileName); });
92063                 },
92064                 getSourceFiles: function () {
92065                     return withProgramOrEmptyArray(function (program) { return program.getSourceFiles(); });
92066                 },
92067                 getOptionsDiagnostics: function (cancellationToken) {
92068                     return withProgramOrEmptyArray(function (program) { return program.getOptionsDiagnostics(cancellationToken); });
92069                 },
92070                 getGlobalDiagnostics: function (cancellationToken) {
92071                     return withProgramOrEmptyArray(function (program) { return program.getGlobalDiagnostics(cancellationToken); });
92072                 },
92073                 getConfigFileParsingDiagnostics: function () {
92074                     return withProgramOrEmptyArray(function (program) { return program.getConfigFileParsingDiagnostics(); });
92075                 },
92076                 getSyntacticDiagnostics: function (sourceFile, cancellationToken) {
92077                     return withProgramOrEmptyArray(function (program) { return program.getSyntacticDiagnostics(sourceFile, cancellationToken); });
92078                 },
92079                 getAllDependencies: function (sourceFile) {
92080                     return withProgramOrEmptyArray(function (program) { return program.getAllDependencies(sourceFile); });
92081                 },
92082                 getSemanticDiagnostics: function (sourceFile, cancellationToken) {
92083                     return withProgramOrEmptyArray(function (program) { return program.getSemanticDiagnostics(sourceFile, cancellationToken); });
92084                 },
92085                 getSemanticDiagnosticsOfNextAffectedFile: function (cancellationToken, ignoreSourceFile) {
92086                     return withProgramOrUndefined(function (program) {
92087                         return (program.getSemanticDiagnosticsOfNextAffectedFile) &&
92088                             program.getSemanticDiagnosticsOfNextAffectedFile(cancellationToken, ignoreSourceFile);
92089                     });
92090                 },
92091                 emit: function (targetSourceFile, writeFile, cancellationToken, emitOnlyDtsFiles, customTransformers) {
92092                     if (targetSourceFile || emitOnlyDtsFiles) {
92093                         return withProgramOrUndefined(function (program) { return program.emit(targetSourceFile, writeFile, cancellationToken, emitOnlyDtsFiles, customTransformers); });
92094                     }
92095                     executeSteps(BuildStep.SemanticDiagnostics, cancellationToken);
92096                     if (step === BuildStep.EmitBuildInfo) {
92097                         return emitBuildInfo(writeFile, cancellationToken);
92098                     }
92099                     if (step !== BuildStep.Emit)
92100                         return undefined;
92101                     return emit(writeFile, cancellationToken, customTransformers);
92102                 },
92103                 done: done
92104             } :
92105             {
92106                 kind: kind,
92107                 project: project,
92108                 projectPath: projectPath,
92109                 buildOrder: buildOrder,
92110                 getCompilerOptions: function () { return config.options; },
92111                 getCurrentDirectory: function () { return state.currentDirectory; },
92112                 emit: function (writeFile, customTransformers) {
92113                     if (step !== BuildStep.EmitBundle)
92114                         return invalidatedProjectOfBundle;
92115                     return emitBundle(writeFile, customTransformers);
92116                 },
92117                 done: done,
92118             };
92119         function done(cancellationToken, writeFile, customTransformers) {
92120             executeSteps(BuildStep.Done, cancellationToken, writeFile, customTransformers);
92121             return doneInvalidatedProject(state, projectPath);
92122         }
92123         function withProgramOrUndefined(action) {
92124             executeSteps(BuildStep.CreateProgram);
92125             return program && action(program);
92126         }
92127         function withProgramOrEmptyArray(action) {
92128             return withProgramOrUndefined(action) || ts.emptyArray;
92129         }
92130         function createProgram() {
92131             ts.Debug.assert(program === undefined);
92132             if (state.options.dry) {
92133                 reportStatus(state, ts.Diagnostics.A_non_dry_build_would_build_project_0, project);
92134                 buildResult = BuildResultFlags.Success;
92135                 step = BuildStep.QueueReferencingProjects;
92136                 return;
92137             }
92138             if (state.options.verbose)
92139                 reportStatus(state, ts.Diagnostics.Building_project_0, project);
92140             if (config.fileNames.length === 0) {
92141                 reportAndStoreErrors(state, projectPath, ts.getConfigFileParsingDiagnostics(config));
92142                 buildResult = BuildResultFlags.None;
92143                 step = BuildStep.QueueReferencingProjects;
92144                 return;
92145             }
92146             var host = state.host, compilerHost = state.compilerHost;
92147             state.projectCompilerOptions = config.options;
92148             updateModuleResolutionCache(state, project, config);
92149             program = host.createProgram(config.fileNames, config.options, compilerHost, getOldProgram(state, projectPath, config), ts.getConfigFileParsingDiagnostics(config), config.projectReferences);
92150             if (state.watch) {
92151                 state.builderPrograms.set(projectPath, program);
92152             }
92153             step++;
92154         }
92155         function handleDiagnostics(diagnostics, errorFlags, errorType) {
92156             var _a;
92157             if (diagnostics.length) {
92158                 (_a = buildErrors(state, projectPath, program, config, diagnostics, errorFlags, errorType), buildResult = _a.buildResult, step = _a.step);
92159             }
92160             else {
92161                 step++;
92162             }
92163         }
92164         function getSyntaxDiagnostics(cancellationToken) {
92165             ts.Debug.assertIsDefined(program);
92166             handleDiagnostics(__spreadArrays(program.getConfigFileParsingDiagnostics(), program.getOptionsDiagnostics(cancellationToken), program.getGlobalDiagnostics(cancellationToken), program.getSyntacticDiagnostics(undefined, cancellationToken)), BuildResultFlags.SyntaxErrors, "Syntactic");
92167         }
92168         function getSemanticDiagnostics(cancellationToken) {
92169             handleDiagnostics(ts.Debug.checkDefined(program).getSemanticDiagnostics(undefined, cancellationToken), BuildResultFlags.TypeErrors, "Semantic");
92170         }
92171         function emit(writeFileCallback, cancellationToken, customTransformers) {
92172             var _a;
92173             ts.Debug.assertIsDefined(program);
92174             ts.Debug.assert(step === BuildStep.Emit);
92175             program.backupState();
92176             var declDiagnostics;
92177             var reportDeclarationDiagnostics = function (d) { return (declDiagnostics || (declDiagnostics = [])).push(d); };
92178             var outputFiles = [];
92179             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;
92180             if (declDiagnostics) {
92181                 program.restoreState();
92182                 (_a = buildErrors(state, projectPath, program, config, declDiagnostics, BuildResultFlags.DeclarationEmitErrors, "Declaration file"), buildResult = _a.buildResult, step = _a.step);
92183                 return {
92184                     emitSkipped: true,
92185                     diagnostics: emitResult.diagnostics
92186                 };
92187             }
92188             var host = state.host, compilerHost = state.compilerHost;
92189             var resultFlags = BuildResultFlags.DeclarationOutputUnchanged;
92190             var newestDeclarationFileContentChangedTime = minimumDate;
92191             var anyDtsChanged = false;
92192             var emitterDiagnostics = ts.createDiagnosticCollection();
92193             var emittedOutputs = new ts.Map();
92194             outputFiles.forEach(function (_a) {
92195                 var name = _a.name, text = _a.text, writeByteOrderMark = _a.writeByteOrderMark;
92196                 var priorChangeTime;
92197                 if (!anyDtsChanged && isDeclarationFile(name)) {
92198                     if (host.fileExists(name) && state.readFileWithCache(name) === text) {
92199                         priorChangeTime = host.getModifiedTime(name);
92200                     }
92201                     else {
92202                         resultFlags &= ~BuildResultFlags.DeclarationOutputUnchanged;
92203                         anyDtsChanged = true;
92204                     }
92205                 }
92206                 emittedOutputs.set(toPath(state, name), name);
92207                 ts.writeFile(writeFileCallback ? { writeFile: writeFileCallback } : compilerHost, emitterDiagnostics, name, text, writeByteOrderMark);
92208                 if (priorChangeTime !== undefined) {
92209                     newestDeclarationFileContentChangedTime = newer(priorChangeTime, newestDeclarationFileContentChangedTime);
92210                 }
92211             });
92212             finishEmit(emitterDiagnostics, emittedOutputs, newestDeclarationFileContentChangedTime, anyDtsChanged, outputFiles.length ? outputFiles[0].name : ts.getFirstProjectOutput(config, !host.useCaseSensitiveFileNames()), resultFlags);
92213             return emitResult;
92214         }
92215         function emitBuildInfo(writeFileCallback, cancellationToken) {
92216             ts.Debug.assertIsDefined(program);
92217             ts.Debug.assert(step === BuildStep.EmitBuildInfo);
92218             var emitResult = program.emitBuildInfo(writeFileCallback, cancellationToken);
92219             if (emitResult.diagnostics.length) {
92220                 reportErrors(state, emitResult.diagnostics);
92221                 state.diagnostics.set(projectPath, __spreadArrays(state.diagnostics.get(projectPath), emitResult.diagnostics));
92222                 buildResult = BuildResultFlags.EmitErrors & buildResult;
92223             }
92224             if (emitResult.emittedFiles && state.writeFileName) {
92225                 emitResult.emittedFiles.forEach(function (name) { return listEmittedFile(state, config, name); });
92226             }
92227             afterProgramDone(state, program, config);
92228             step = BuildStep.QueueReferencingProjects;
92229             return emitResult;
92230         }
92231         function finishEmit(emitterDiagnostics, emittedOutputs, priorNewestUpdateTime, newestDeclarationFileContentChangedTimeIsMaximumDate, oldestOutputFileName, resultFlags) {
92232             var _a;
92233             var emitDiagnostics = emitterDiagnostics.getDiagnostics();
92234             if (emitDiagnostics.length) {
92235                 (_a = buildErrors(state, projectPath, program, config, emitDiagnostics, BuildResultFlags.EmitErrors, "Emit"), buildResult = _a.buildResult, step = _a.step);
92236                 return emitDiagnostics;
92237             }
92238             if (state.writeFileName) {
92239                 emittedOutputs.forEach(function (name) { return listEmittedFile(state, config, name); });
92240             }
92241             var newestDeclarationFileContentChangedTime = updateOutputTimestampsWorker(state, config, priorNewestUpdateTime, ts.Diagnostics.Updating_unchanged_output_timestamps_of_project_0, emittedOutputs);
92242             state.diagnostics.delete(projectPath);
92243             state.projectStatus.set(projectPath, {
92244                 type: ts.UpToDateStatusType.UpToDate,
92245                 newestDeclarationFileContentChangedTime: newestDeclarationFileContentChangedTimeIsMaximumDate ?
92246                     maximumDate :
92247                     newestDeclarationFileContentChangedTime,
92248                 oldestOutputFileName: oldestOutputFileName
92249             });
92250             afterProgramDone(state, program, config);
92251             step = BuildStep.QueueReferencingProjects;
92252             buildResult = resultFlags;
92253             return emitDiagnostics;
92254         }
92255         function emitBundle(writeFileCallback, customTransformers) {
92256             ts.Debug.assert(kind === InvalidatedProjectKind.UpdateBundle);
92257             if (state.options.dry) {
92258                 reportStatus(state, ts.Diagnostics.A_non_dry_build_would_update_output_of_project_0, project);
92259                 buildResult = BuildResultFlags.Success;
92260                 step = BuildStep.QueueReferencingProjects;
92261                 return undefined;
92262             }
92263             if (state.options.verbose)
92264                 reportStatus(state, ts.Diagnostics.Updating_output_of_project_0, project);
92265             var compilerHost = state.compilerHost;
92266             state.projectCompilerOptions = config.options;
92267             var outputFiles = ts.emitUsingBuildInfo(config, compilerHost, function (ref) {
92268                 var refName = resolveProjectName(state, ref.path);
92269                 return parseConfigFile(state, refName, toResolvedConfigFilePath(state, refName));
92270             }, customTransformers);
92271             if (ts.isString(outputFiles)) {
92272                 reportStatus(state, ts.Diagnostics.Cannot_update_output_of_project_0_because_there_was_error_reading_file_1, project, relName(state, outputFiles));
92273                 step = BuildStep.BuildInvalidatedProjectOfBundle;
92274                 return invalidatedProjectOfBundle = createBuildOrUpdateInvalidedProject(InvalidatedProjectKind.Build, state, project, projectPath, projectIndex, config, buildOrder);
92275             }
92276             ts.Debug.assert(!!outputFiles.length);
92277             var emitterDiagnostics = ts.createDiagnosticCollection();
92278             var emittedOutputs = new ts.Map();
92279             outputFiles.forEach(function (_a) {
92280                 var name = _a.name, text = _a.text, writeByteOrderMark = _a.writeByteOrderMark;
92281                 emittedOutputs.set(toPath(state, name), name);
92282                 ts.writeFile(writeFileCallback ? { writeFile: writeFileCallback } : compilerHost, emitterDiagnostics, name, text, writeByteOrderMark);
92283             });
92284             var emitDiagnostics = finishEmit(emitterDiagnostics, emittedOutputs, minimumDate, false, outputFiles[0].name, BuildResultFlags.DeclarationOutputUnchanged);
92285             return { emitSkipped: false, diagnostics: emitDiagnostics };
92286         }
92287         function executeSteps(till, cancellationToken, writeFile, customTransformers) {
92288             while (step <= till && step < BuildStep.Done) {
92289                 var currentStep = step;
92290                 switch (step) {
92291                     case BuildStep.CreateProgram:
92292                         createProgram();
92293                         break;
92294                     case BuildStep.SyntaxDiagnostics:
92295                         getSyntaxDiagnostics(cancellationToken);
92296                         break;
92297                     case BuildStep.SemanticDiagnostics:
92298                         getSemanticDiagnostics(cancellationToken);
92299                         break;
92300                     case BuildStep.Emit:
92301                         emit(writeFile, cancellationToken, customTransformers);
92302                         break;
92303                     case BuildStep.EmitBuildInfo:
92304                         emitBuildInfo(writeFile, cancellationToken);
92305                         break;
92306                     case BuildStep.EmitBundle:
92307                         emitBundle(writeFile, customTransformers);
92308                         break;
92309                     case BuildStep.BuildInvalidatedProjectOfBundle:
92310                         ts.Debug.checkDefined(invalidatedProjectOfBundle).done(cancellationToken);
92311                         step = BuildStep.Done;
92312                         break;
92313                     case BuildStep.QueueReferencingProjects:
92314                         queueReferencingProjects(state, project, projectPath, projectIndex, config, buildOrder, ts.Debug.checkDefined(buildResult));
92315                         step++;
92316                         break;
92317                     case BuildStep.Done:
92318                     default:
92319                         ts.assertType(step);
92320                 }
92321                 ts.Debug.assert(step > currentStep);
92322             }
92323         }
92324     }
92325     function needsBuild(_a, status, config) {
92326         var options = _a.options;
92327         if (status.type !== ts.UpToDateStatusType.OutOfDateWithPrepend || options.force)
92328             return true;
92329         return config.fileNames.length === 0 ||
92330             !!ts.getConfigFileParsingDiagnostics(config).length ||
92331             !ts.isIncrementalCompilation(config.options);
92332     }
92333     function getNextInvalidatedProject(state, buildOrder, reportQueue) {
92334         if (!state.projectPendingBuild.size)
92335             return undefined;
92336         if (isCircularBuildOrder(buildOrder))
92337             return undefined;
92338         if (state.currentInvalidatedProject) {
92339             return ts.arrayIsEqualTo(state.currentInvalidatedProject.buildOrder, buildOrder) ?
92340                 state.currentInvalidatedProject :
92341                 undefined;
92342         }
92343         var options = state.options, projectPendingBuild = state.projectPendingBuild;
92344         for (var projectIndex = 0; projectIndex < buildOrder.length; projectIndex++) {
92345             var project = buildOrder[projectIndex];
92346             var projectPath = toResolvedConfigFilePath(state, project);
92347             var reloadLevel = state.projectPendingBuild.get(projectPath);
92348             if (reloadLevel === undefined)
92349                 continue;
92350             if (reportQueue) {
92351                 reportQueue = false;
92352                 reportBuildQueue(state, buildOrder);
92353             }
92354             var config = parseConfigFile(state, project, projectPath);
92355             if (!config) {
92356                 reportParseConfigFileDiagnostic(state, projectPath);
92357                 projectPendingBuild.delete(projectPath);
92358                 continue;
92359             }
92360             if (reloadLevel === ts.ConfigFileProgramReloadLevel.Full) {
92361                 watchConfigFile(state, project, projectPath, config);
92362                 watchWildCardDirectories(state, project, projectPath, config);
92363                 watchInputFiles(state, project, projectPath, config);
92364             }
92365             else if (reloadLevel === ts.ConfigFileProgramReloadLevel.Partial) {
92366                 var result = ts.getFileNamesFromConfigSpecs(config.configFileSpecs, ts.getDirectoryPath(project), config.options, state.parseConfigFileHost);
92367                 ts.updateErrorForNoInputFiles(result, project, config.configFileSpecs, config.errors, ts.canJsonReportNoInputFiles(config.raw));
92368                 config.fileNames = result.fileNames;
92369                 watchInputFiles(state, project, projectPath, config);
92370             }
92371             var status = getUpToDateStatus(state, config, projectPath);
92372             verboseReportProjectStatus(state, project, status);
92373             if (!options.force) {
92374                 if (status.type === ts.UpToDateStatusType.UpToDate) {
92375                     reportAndStoreErrors(state, projectPath, ts.getConfigFileParsingDiagnostics(config));
92376                     projectPendingBuild.delete(projectPath);
92377                     if (options.dry) {
92378                         reportStatus(state, ts.Diagnostics.Project_0_is_up_to_date, project);
92379                     }
92380                     continue;
92381                 }
92382                 if (status.type === ts.UpToDateStatusType.UpToDateWithUpstreamTypes) {
92383                     reportAndStoreErrors(state, projectPath, ts.getConfigFileParsingDiagnostics(config));
92384                     return createUpdateOutputFileStampsProject(state, project, projectPath, config, buildOrder);
92385                 }
92386             }
92387             if (status.type === ts.UpToDateStatusType.UpstreamBlocked) {
92388                 reportAndStoreErrors(state, projectPath, ts.getConfigFileParsingDiagnostics(config));
92389                 projectPendingBuild.delete(projectPath);
92390                 if (options.verbose) {
92391                     reportStatus(state, status.upstreamProjectBlocked ?
92392                         ts.Diagnostics.Skipping_build_of_project_0_because_its_dependency_1_was_not_built :
92393                         ts.Diagnostics.Skipping_build_of_project_0_because_its_dependency_1_has_errors, project, status.upstreamProjectName);
92394                 }
92395                 continue;
92396             }
92397             if (status.type === ts.UpToDateStatusType.ContainerOnly) {
92398                 reportAndStoreErrors(state, projectPath, ts.getConfigFileParsingDiagnostics(config));
92399                 projectPendingBuild.delete(projectPath);
92400                 continue;
92401             }
92402             return createBuildOrUpdateInvalidedProject(needsBuild(state, status, config) ?
92403                 InvalidatedProjectKind.Build :
92404                 InvalidatedProjectKind.UpdateBundle, state, project, projectPath, projectIndex, config, buildOrder);
92405         }
92406         return undefined;
92407     }
92408     function listEmittedFile(_a, proj, file) {
92409         var writeFileName = _a.writeFileName;
92410         if (writeFileName && proj.options.listEmittedFiles) {
92411             writeFileName("TSFILE: " + file);
92412         }
92413     }
92414     function getOldProgram(_a, proj, parsed) {
92415         var options = _a.options, builderPrograms = _a.builderPrograms, compilerHost = _a.compilerHost;
92416         if (options.force)
92417             return undefined;
92418         var value = builderPrograms.get(proj);
92419         if (value)
92420             return value;
92421         return ts.readBuilderProgram(parsed.options, compilerHost);
92422     }
92423     function afterProgramDone(state, program, config) {
92424         if (program) {
92425             if (program && state.writeFileName)
92426                 ts.listFiles(program, state.writeFileName);
92427             if (state.host.afterProgramEmitAndDiagnostics) {
92428                 state.host.afterProgramEmitAndDiagnostics(program);
92429             }
92430             program.releaseProgram();
92431         }
92432         else if (state.host.afterEmitBundle) {
92433             state.host.afterEmitBundle(config);
92434         }
92435         state.projectCompilerOptions = state.baseCompilerOptions;
92436     }
92437     function buildErrors(state, resolvedPath, program, config, diagnostics, buildResult, errorType) {
92438         var canEmitBuildInfo = !(buildResult & BuildResultFlags.SyntaxErrors) && program && !ts.outFile(program.getCompilerOptions());
92439         reportAndStoreErrors(state, resolvedPath, diagnostics);
92440         state.projectStatus.set(resolvedPath, { type: ts.UpToDateStatusType.Unbuildable, reason: errorType + " errors" });
92441         if (canEmitBuildInfo)
92442             return { buildResult: buildResult, step: BuildStep.EmitBuildInfo };
92443         afterProgramDone(state, program, config);
92444         return { buildResult: buildResult, step: BuildStep.QueueReferencingProjects };
92445     }
92446     function updateModuleResolutionCache(state, proj, config) {
92447         if (!state.moduleResolutionCache)
92448             return;
92449         var moduleResolutionCache = state.moduleResolutionCache;
92450         var projPath = toPath(state, proj);
92451         if (moduleResolutionCache.directoryToModuleNameMap.redirectsMap.size === 0) {
92452             ts.Debug.assert(moduleResolutionCache.moduleNameToDirectoryMap.redirectsMap.size === 0);
92453             moduleResolutionCache.directoryToModuleNameMap.redirectsMap.set(projPath, moduleResolutionCache.directoryToModuleNameMap.ownMap);
92454             moduleResolutionCache.moduleNameToDirectoryMap.redirectsMap.set(projPath, moduleResolutionCache.moduleNameToDirectoryMap.ownMap);
92455         }
92456         else {
92457             ts.Debug.assert(moduleResolutionCache.moduleNameToDirectoryMap.redirectsMap.size > 0);
92458             var ref = {
92459                 sourceFile: config.options.configFile,
92460                 commandLine: config
92461             };
92462             moduleResolutionCache.directoryToModuleNameMap.setOwnMap(moduleResolutionCache.directoryToModuleNameMap.getOrCreateMapOfCacheRedirects(ref));
92463             moduleResolutionCache.moduleNameToDirectoryMap.setOwnMap(moduleResolutionCache.moduleNameToDirectoryMap.getOrCreateMapOfCacheRedirects(ref));
92464         }
92465         moduleResolutionCache.directoryToModuleNameMap.setOwnOptions(config.options);
92466         moduleResolutionCache.moduleNameToDirectoryMap.setOwnOptions(config.options);
92467     }
92468     function checkConfigFileUpToDateStatus(state, configFile, oldestOutputFileTime, oldestOutputFileName) {
92469         var tsconfigTime = state.host.getModifiedTime(configFile) || ts.missingFileModifiedTime;
92470         if (oldestOutputFileTime < tsconfigTime) {
92471             return {
92472                 type: ts.UpToDateStatusType.OutOfDateWithSelf,
92473                 outOfDateOutputFileName: oldestOutputFileName,
92474                 newerInputFileName: configFile
92475             };
92476         }
92477     }
92478     function getUpToDateStatusWorker(state, project, resolvedPath) {
92479         var newestInputFileName = undefined;
92480         var newestInputFileTime = minimumDate;
92481         var host = state.host;
92482         for (var _i = 0, _a = project.fileNames; _i < _a.length; _i++) {
92483             var inputFile = _a[_i];
92484             if (!host.fileExists(inputFile)) {
92485                 return {
92486                     type: ts.UpToDateStatusType.Unbuildable,
92487                     reason: inputFile + " does not exist"
92488                 };
92489             }
92490             var inputTime = host.getModifiedTime(inputFile) || ts.missingFileModifiedTime;
92491             if (inputTime > newestInputFileTime) {
92492                 newestInputFileName = inputFile;
92493                 newestInputFileTime = inputTime;
92494             }
92495         }
92496         if (!project.fileNames.length && !ts.canJsonReportNoInputFiles(project.raw)) {
92497             return {
92498                 type: ts.UpToDateStatusType.ContainerOnly
92499             };
92500         }
92501         var outputs = ts.getAllProjectOutputs(project, !host.useCaseSensitiveFileNames());
92502         var oldestOutputFileName = "(none)";
92503         var oldestOutputFileTime = maximumDate;
92504         var newestOutputFileName = "(none)";
92505         var newestOutputFileTime = minimumDate;
92506         var missingOutputFileName;
92507         var newestDeclarationFileContentChangedTime = minimumDate;
92508         var isOutOfDateWithInputs = false;
92509         for (var _b = 0, outputs_1 = outputs; _b < outputs_1.length; _b++) {
92510             var output = outputs_1[_b];
92511             if (!host.fileExists(output)) {
92512                 missingOutputFileName = output;
92513                 break;
92514             }
92515             var outputTime = host.getModifiedTime(output) || ts.missingFileModifiedTime;
92516             if (outputTime < oldestOutputFileTime) {
92517                 oldestOutputFileTime = outputTime;
92518                 oldestOutputFileName = output;
92519             }
92520             if (outputTime < newestInputFileTime) {
92521                 isOutOfDateWithInputs = true;
92522                 break;
92523             }
92524             if (outputTime > newestOutputFileTime) {
92525                 newestOutputFileTime = outputTime;
92526                 newestOutputFileName = output;
92527             }
92528             if (isDeclarationFile(output)) {
92529                 var outputModifiedTime = host.getModifiedTime(output) || ts.missingFileModifiedTime;
92530                 newestDeclarationFileContentChangedTime = newer(newestDeclarationFileContentChangedTime, outputModifiedTime);
92531             }
92532         }
92533         var pseudoUpToDate = false;
92534         var usesPrepend = false;
92535         var upstreamChangedProject;
92536         if (project.projectReferences) {
92537             state.projectStatus.set(resolvedPath, { type: ts.UpToDateStatusType.ComputingUpstream });
92538             for (var _c = 0, _d = project.projectReferences; _c < _d.length; _c++) {
92539                 var ref = _d[_c];
92540                 usesPrepend = usesPrepend || !!(ref.prepend);
92541                 var resolvedRef = ts.resolveProjectReferencePath(ref);
92542                 var resolvedRefPath = toResolvedConfigFilePath(state, resolvedRef);
92543                 var refStatus = getUpToDateStatus(state, parseConfigFile(state, resolvedRef, resolvedRefPath), resolvedRefPath);
92544                 if (refStatus.type === ts.UpToDateStatusType.ComputingUpstream ||
92545                     refStatus.type === ts.UpToDateStatusType.ContainerOnly) {
92546                     continue;
92547                 }
92548                 if (refStatus.type === ts.UpToDateStatusType.Unbuildable ||
92549                     refStatus.type === ts.UpToDateStatusType.UpstreamBlocked) {
92550                     return {
92551                         type: ts.UpToDateStatusType.UpstreamBlocked,
92552                         upstreamProjectName: ref.path,
92553                         upstreamProjectBlocked: refStatus.type === ts.UpToDateStatusType.UpstreamBlocked
92554                     };
92555                 }
92556                 if (refStatus.type !== ts.UpToDateStatusType.UpToDate) {
92557                     return {
92558                         type: ts.UpToDateStatusType.UpstreamOutOfDate,
92559                         upstreamProjectName: ref.path
92560                     };
92561                 }
92562                 if (!missingOutputFileName) {
92563                     if (refStatus.newestInputFileTime && refStatus.newestInputFileTime <= oldestOutputFileTime) {
92564                         continue;
92565                     }
92566                     if (refStatus.newestDeclarationFileContentChangedTime && refStatus.newestDeclarationFileContentChangedTime <= oldestOutputFileTime) {
92567                         pseudoUpToDate = true;
92568                         upstreamChangedProject = ref.path;
92569                         continue;
92570                     }
92571                     ts.Debug.assert(oldestOutputFileName !== undefined, "Should have an oldest output filename here");
92572                     return {
92573                         type: ts.UpToDateStatusType.OutOfDateWithUpstream,
92574                         outOfDateOutputFileName: oldestOutputFileName,
92575                         newerProjectName: ref.path
92576                     };
92577                 }
92578             }
92579         }
92580         if (missingOutputFileName !== undefined) {
92581             return {
92582                 type: ts.UpToDateStatusType.OutputMissing,
92583                 missingOutputFileName: missingOutputFileName
92584             };
92585         }
92586         if (isOutOfDateWithInputs) {
92587             return {
92588                 type: ts.UpToDateStatusType.OutOfDateWithSelf,
92589                 outOfDateOutputFileName: oldestOutputFileName,
92590                 newerInputFileName: newestInputFileName
92591             };
92592         }
92593         else {
92594             var configStatus = checkConfigFileUpToDateStatus(state, project.options.configFilePath, oldestOutputFileTime, oldestOutputFileName);
92595             if (configStatus)
92596                 return configStatus;
92597             var extendedConfigStatus = ts.forEach(project.options.configFile.extendedSourceFiles || ts.emptyArray, function (configFile) { return checkConfigFileUpToDateStatus(state, configFile, oldestOutputFileTime, oldestOutputFileName); });
92598             if (extendedConfigStatus)
92599                 return extendedConfigStatus;
92600         }
92601         if (!state.buildInfoChecked.has(resolvedPath)) {
92602             state.buildInfoChecked.set(resolvedPath, true);
92603             var buildInfoPath = ts.getTsBuildInfoEmitOutputFilePath(project.options);
92604             if (buildInfoPath) {
92605                 var value = state.readFileWithCache(buildInfoPath);
92606                 var buildInfo = value && ts.getBuildInfo(value);
92607                 if (buildInfo && (buildInfo.bundle || buildInfo.program) && buildInfo.version !== ts.version) {
92608                     return {
92609                         type: ts.UpToDateStatusType.TsVersionOutputOfDate,
92610                         version: buildInfo.version
92611                     };
92612                 }
92613             }
92614         }
92615         if (usesPrepend && pseudoUpToDate) {
92616             return {
92617                 type: ts.UpToDateStatusType.OutOfDateWithPrepend,
92618                 outOfDateOutputFileName: oldestOutputFileName,
92619                 newerProjectName: upstreamChangedProject
92620             };
92621         }
92622         return {
92623             type: pseudoUpToDate ? ts.UpToDateStatusType.UpToDateWithUpstreamTypes : ts.UpToDateStatusType.UpToDate,
92624             newestDeclarationFileContentChangedTime: newestDeclarationFileContentChangedTime,
92625             newestInputFileTime: newestInputFileTime,
92626             newestOutputFileTime: newestOutputFileTime,
92627             newestInputFileName: newestInputFileName,
92628             newestOutputFileName: newestOutputFileName,
92629             oldestOutputFileName: oldestOutputFileName
92630         };
92631     }
92632     function getUpToDateStatus(state, project, resolvedPath) {
92633         if (project === undefined) {
92634             return { type: ts.UpToDateStatusType.Unbuildable, reason: "File deleted mid-build" };
92635         }
92636         var prior = state.projectStatus.get(resolvedPath);
92637         if (prior !== undefined) {
92638             return prior;
92639         }
92640         var actual = getUpToDateStatusWorker(state, project, resolvedPath);
92641         state.projectStatus.set(resolvedPath, actual);
92642         return actual;
92643     }
92644     function updateOutputTimestampsWorker(state, proj, priorNewestUpdateTime, verboseMessage, skipOutputs) {
92645         var host = state.host;
92646         var outputs = ts.getAllProjectOutputs(proj, !host.useCaseSensitiveFileNames());
92647         if (!skipOutputs || outputs.length !== skipOutputs.size) {
92648             var reportVerbose = !!state.options.verbose;
92649             var now = host.now ? host.now() : new Date();
92650             for (var _i = 0, outputs_2 = outputs; _i < outputs_2.length; _i++) {
92651                 var file = outputs_2[_i];
92652                 if (skipOutputs && skipOutputs.has(toPath(state, file))) {
92653                     continue;
92654                 }
92655                 if (reportVerbose) {
92656                     reportVerbose = false;
92657                     reportStatus(state, verboseMessage, proj.options.configFilePath);
92658                 }
92659                 if (isDeclarationFile(file)) {
92660                     priorNewestUpdateTime = newer(priorNewestUpdateTime, host.getModifiedTime(file) || ts.missingFileModifiedTime);
92661                 }
92662                 host.setModifiedTime(file, now);
92663             }
92664         }
92665         return priorNewestUpdateTime;
92666     }
92667     function updateOutputTimestamps(state, proj, resolvedPath) {
92668         if (state.options.dry) {
92669             return reportStatus(state, ts.Diagnostics.A_non_dry_build_would_update_timestamps_for_output_of_project_0, proj.options.configFilePath);
92670         }
92671         var priorNewestUpdateTime = updateOutputTimestampsWorker(state, proj, minimumDate, ts.Diagnostics.Updating_output_timestamps_of_project_0);
92672         state.projectStatus.set(resolvedPath, {
92673             type: ts.UpToDateStatusType.UpToDate,
92674             newestDeclarationFileContentChangedTime: priorNewestUpdateTime,
92675             oldestOutputFileName: ts.getFirstProjectOutput(proj, !state.host.useCaseSensitiveFileNames())
92676         });
92677     }
92678     function queueReferencingProjects(state, project, projectPath, projectIndex, config, buildOrder, buildResult) {
92679         if (buildResult & BuildResultFlags.AnyErrors)
92680             return;
92681         if (!config.options.composite)
92682             return;
92683         for (var index = projectIndex + 1; index < buildOrder.length; index++) {
92684             var nextProject = buildOrder[index];
92685             var nextProjectPath = toResolvedConfigFilePath(state, nextProject);
92686             if (state.projectPendingBuild.has(nextProjectPath))
92687                 continue;
92688             var nextProjectConfig = parseConfigFile(state, nextProject, nextProjectPath);
92689             if (!nextProjectConfig || !nextProjectConfig.projectReferences)
92690                 continue;
92691             for (var _i = 0, _a = nextProjectConfig.projectReferences; _i < _a.length; _i++) {
92692                 var ref = _a[_i];
92693                 var resolvedRefPath = resolveProjectName(state, ref.path);
92694                 if (toResolvedConfigFilePath(state, resolvedRefPath) !== projectPath)
92695                     continue;
92696                 var status = state.projectStatus.get(nextProjectPath);
92697                 if (status) {
92698                     switch (status.type) {
92699                         case ts.UpToDateStatusType.UpToDate:
92700                             if (buildResult & BuildResultFlags.DeclarationOutputUnchanged) {
92701                                 if (ref.prepend) {
92702                                     state.projectStatus.set(nextProjectPath, {
92703                                         type: ts.UpToDateStatusType.OutOfDateWithPrepend,
92704                                         outOfDateOutputFileName: status.oldestOutputFileName,
92705                                         newerProjectName: project
92706                                     });
92707                                 }
92708                                 else {
92709                                     status.type = ts.UpToDateStatusType.UpToDateWithUpstreamTypes;
92710                                 }
92711                                 break;
92712                             }
92713                         case ts.UpToDateStatusType.UpToDateWithUpstreamTypes:
92714                         case ts.UpToDateStatusType.OutOfDateWithPrepend:
92715                             if (!(buildResult & BuildResultFlags.DeclarationOutputUnchanged)) {
92716                                 state.projectStatus.set(nextProjectPath, {
92717                                     type: ts.UpToDateStatusType.OutOfDateWithUpstream,
92718                                     outOfDateOutputFileName: status.type === ts.UpToDateStatusType.OutOfDateWithPrepend ? status.outOfDateOutputFileName : status.oldestOutputFileName,
92719                                     newerProjectName: project
92720                                 });
92721                             }
92722                             break;
92723                         case ts.UpToDateStatusType.UpstreamBlocked:
92724                             if (toResolvedConfigFilePath(state, resolveProjectName(state, status.upstreamProjectName)) === projectPath) {
92725                                 clearProjectStatus(state, nextProjectPath);
92726                             }
92727                             break;
92728                     }
92729                 }
92730                 addProjToQueue(state, nextProjectPath, ts.ConfigFileProgramReloadLevel.None);
92731                 break;
92732             }
92733         }
92734     }
92735     function build(state, project, cancellationToken, onlyReferences) {
92736         var buildOrder = getBuildOrderFor(state, project, onlyReferences);
92737         if (!buildOrder)
92738             return ts.ExitStatus.InvalidProject_OutputsSkipped;
92739         setupInitialBuild(state, cancellationToken);
92740         var reportQueue = true;
92741         var successfulProjects = 0;
92742         while (true) {
92743             var invalidatedProject = getNextInvalidatedProject(state, buildOrder, reportQueue);
92744             if (!invalidatedProject)
92745                 break;
92746             reportQueue = false;
92747             invalidatedProject.done(cancellationToken);
92748             if (!state.diagnostics.has(invalidatedProject.projectPath))
92749                 successfulProjects++;
92750         }
92751         disableCache(state);
92752         reportErrorSummary(state, buildOrder);
92753         startWatching(state, buildOrder);
92754         return isCircularBuildOrder(buildOrder)
92755             ? ts.ExitStatus.ProjectReferenceCycle_OutputsSkipped
92756             : !buildOrder.some(function (p) { return state.diagnostics.has(toResolvedConfigFilePath(state, p)); })
92757                 ? ts.ExitStatus.Success
92758                 : successfulProjects
92759                     ? ts.ExitStatus.DiagnosticsPresent_OutputsGenerated
92760                     : ts.ExitStatus.DiagnosticsPresent_OutputsSkipped;
92761     }
92762     function clean(state, project, onlyReferences) {
92763         var buildOrder = getBuildOrderFor(state, project, onlyReferences);
92764         if (!buildOrder)
92765             return ts.ExitStatus.InvalidProject_OutputsSkipped;
92766         if (isCircularBuildOrder(buildOrder)) {
92767             reportErrors(state, buildOrder.circularDiagnostics);
92768             return ts.ExitStatus.ProjectReferenceCycle_OutputsSkipped;
92769         }
92770         var options = state.options, host = state.host;
92771         var filesToDelete = options.dry ? [] : undefined;
92772         for (var _i = 0, buildOrder_1 = buildOrder; _i < buildOrder_1.length; _i++) {
92773             var proj = buildOrder_1[_i];
92774             var resolvedPath = toResolvedConfigFilePath(state, proj);
92775             var parsed = parseConfigFile(state, proj, resolvedPath);
92776             if (parsed === undefined) {
92777                 reportParseConfigFileDiagnostic(state, resolvedPath);
92778                 continue;
92779             }
92780             var outputs = ts.getAllProjectOutputs(parsed, !host.useCaseSensitiveFileNames());
92781             for (var _a = 0, outputs_3 = outputs; _a < outputs_3.length; _a++) {
92782                 var output = outputs_3[_a];
92783                 if (host.fileExists(output)) {
92784                     if (filesToDelete) {
92785                         filesToDelete.push(output);
92786                     }
92787                     else {
92788                         host.deleteFile(output);
92789                         invalidateProject(state, resolvedPath, ts.ConfigFileProgramReloadLevel.None);
92790                     }
92791                 }
92792             }
92793         }
92794         if (filesToDelete) {
92795             reportStatus(state, ts.Diagnostics.A_non_dry_build_would_delete_the_following_files_Colon_0, filesToDelete.map(function (f) { return "\r\n * " + f; }).join(""));
92796         }
92797         return ts.ExitStatus.Success;
92798     }
92799     function invalidateProject(state, resolved, reloadLevel) {
92800         if (state.host.getParsedCommandLine && reloadLevel === ts.ConfigFileProgramReloadLevel.Partial) {
92801             reloadLevel = ts.ConfigFileProgramReloadLevel.Full;
92802         }
92803         if (reloadLevel === ts.ConfigFileProgramReloadLevel.Full) {
92804             state.configFileCache.delete(resolved);
92805             state.buildOrder = undefined;
92806         }
92807         state.needsSummary = true;
92808         clearProjectStatus(state, resolved);
92809         addProjToQueue(state, resolved, reloadLevel);
92810         enableCache(state);
92811     }
92812     function invalidateProjectAndScheduleBuilds(state, resolvedPath, reloadLevel) {
92813         state.reportFileChangeDetected = true;
92814         invalidateProject(state, resolvedPath, reloadLevel);
92815         scheduleBuildInvalidatedProject(state);
92816     }
92817     function scheduleBuildInvalidatedProject(state) {
92818         var hostWithWatch = state.hostWithWatch;
92819         if (!hostWithWatch.setTimeout || !hostWithWatch.clearTimeout) {
92820             return;
92821         }
92822         if (state.timerToBuildInvalidatedProject) {
92823             hostWithWatch.clearTimeout(state.timerToBuildInvalidatedProject);
92824         }
92825         state.timerToBuildInvalidatedProject = hostWithWatch.setTimeout(buildNextInvalidatedProject, 250, state);
92826     }
92827     function buildNextInvalidatedProject(state) {
92828         state.timerToBuildInvalidatedProject = undefined;
92829         if (state.reportFileChangeDetected) {
92830             state.reportFileChangeDetected = false;
92831             state.projectErrorsReported.clear();
92832             reportWatchStatus(state, ts.Diagnostics.File_change_detected_Starting_incremental_compilation);
92833         }
92834         var buildOrder = getBuildOrder(state);
92835         var invalidatedProject = getNextInvalidatedProject(state, buildOrder, false);
92836         if (invalidatedProject) {
92837             invalidatedProject.done();
92838             if (state.projectPendingBuild.size) {
92839                 if (state.watch && !state.timerToBuildInvalidatedProject) {
92840                     scheduleBuildInvalidatedProject(state);
92841                 }
92842                 return;
92843             }
92844         }
92845         disableCache(state);
92846         reportErrorSummary(state, buildOrder);
92847     }
92848     function watchConfigFile(state, resolved, resolvedPath, parsed) {
92849         if (!state.watch || state.allWatchedConfigFiles.has(resolvedPath))
92850             return;
92851         state.allWatchedConfigFiles.set(resolvedPath, state.watchFile(state.hostWithWatch, resolved, function () {
92852             invalidateProjectAndScheduleBuilds(state, resolvedPath, ts.ConfigFileProgramReloadLevel.Full);
92853         }, ts.PollingInterval.High, parsed === null || parsed === void 0 ? void 0 : parsed.watchOptions, ts.WatchType.ConfigFile, resolved));
92854     }
92855     function watchWildCardDirectories(state, resolved, resolvedPath, parsed) {
92856         if (!state.watch)
92857             return;
92858         ts.updateWatchingWildcardDirectories(getOrCreateValueMapFromConfigFileMap(state.allWatchedWildcardDirectories, resolvedPath), new ts.Map(ts.getEntries(parsed.configFileSpecs.wildcardDirectories)), function (dir, flags) { return state.watchDirectory(state.hostWithWatch, dir, function (fileOrDirectory) {
92859             if (ts.isIgnoredFileFromWildCardWatching({
92860                 watchedDirPath: toPath(state, dir),
92861                 fileOrDirectory: fileOrDirectory,
92862                 fileOrDirectoryPath: toPath(state, fileOrDirectory),
92863                 configFileName: resolved,
92864                 configFileSpecs: parsed.configFileSpecs,
92865                 currentDirectory: state.currentDirectory,
92866                 options: parsed.options,
92867                 program: state.builderPrograms.get(resolvedPath),
92868                 useCaseSensitiveFileNames: state.parseConfigFileHost.useCaseSensitiveFileNames,
92869                 writeLog: function (s) { return state.writeLog(s); }
92870             }))
92871                 return;
92872             invalidateProjectAndScheduleBuilds(state, resolvedPath, ts.ConfigFileProgramReloadLevel.Partial);
92873         }, flags, parsed === null || parsed === void 0 ? void 0 : parsed.watchOptions, ts.WatchType.WildcardDirectory, resolved); });
92874     }
92875     function watchInputFiles(state, resolved, resolvedPath, parsed) {
92876         if (!state.watch)
92877             return;
92878         ts.mutateMap(getOrCreateValueMapFromConfigFileMap(state.allWatchedInputFiles, resolvedPath), ts.arrayToMap(parsed.fileNames, function (fileName) { return toPath(state, fileName); }), {
92879             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); },
92880             onDeleteValue: ts.closeFileWatcher,
92881         });
92882     }
92883     function startWatching(state, buildOrder) {
92884         if (!state.watchAllProjectsPending)
92885             return;
92886         state.watchAllProjectsPending = false;
92887         for (var _i = 0, _a = getBuildOrderFromAnyBuildOrder(buildOrder); _i < _a.length; _i++) {
92888             var resolved = _a[_i];
92889             var resolvedPath = toResolvedConfigFilePath(state, resolved);
92890             var cfg = parseConfigFile(state, resolved, resolvedPath);
92891             watchConfigFile(state, resolved, resolvedPath, cfg);
92892             if (cfg) {
92893                 watchWildCardDirectories(state, resolved, resolvedPath, cfg);
92894                 watchInputFiles(state, resolved, resolvedPath, cfg);
92895             }
92896         }
92897     }
92898     function stopWatching(state) {
92899         ts.clearMap(state.allWatchedConfigFiles, ts.closeFileWatcher);
92900         ts.clearMap(state.allWatchedWildcardDirectories, function (watchedWildcardDirectories) { return ts.clearMap(watchedWildcardDirectories, ts.closeFileWatcherOf); });
92901         ts.clearMap(state.allWatchedInputFiles, function (watchedWildcardDirectories) { return ts.clearMap(watchedWildcardDirectories, ts.closeFileWatcher); });
92902     }
92903     function createSolutionBuilderWorker(watch, hostOrHostWithWatch, rootNames, options, baseWatchOptions) {
92904         var state = createSolutionBuilderState(watch, hostOrHostWithWatch, rootNames, options, baseWatchOptions);
92905         return {
92906             build: function (project, cancellationToken) { return build(state, project, cancellationToken); },
92907             clean: function (project) { return clean(state, project); },
92908             buildReferences: function (project, cancellationToken) { return build(state, project, cancellationToken, true); },
92909             cleanReferences: function (project) { return clean(state, project, true); },
92910             getNextInvalidatedProject: function (cancellationToken) {
92911                 setupInitialBuild(state, cancellationToken);
92912                 return getNextInvalidatedProject(state, getBuildOrder(state), false);
92913             },
92914             getBuildOrder: function () { return getBuildOrder(state); },
92915             getUpToDateStatusOfProject: function (project) {
92916                 var configFileName = resolveProjectName(state, project);
92917                 var configFilePath = toResolvedConfigFilePath(state, configFileName);
92918                 return getUpToDateStatus(state, parseConfigFile(state, configFileName, configFilePath), configFilePath);
92919             },
92920             invalidateProject: function (configFilePath, reloadLevel) { return invalidateProject(state, configFilePath, reloadLevel || ts.ConfigFileProgramReloadLevel.None); },
92921             buildNextInvalidatedProject: function () { return buildNextInvalidatedProject(state); },
92922             getAllParsedConfigs: function () { return ts.arrayFrom(ts.mapDefinedIterator(state.configFileCache.values(), function (config) { return isParsedCommandLine(config) ? config : undefined; })); },
92923             close: function () { return stopWatching(state); },
92924         };
92925     }
92926     function relName(state, path) {
92927         return ts.convertToRelativePath(path, state.currentDirectory, function (f) { return state.getCanonicalFileName(f); });
92928     }
92929     function reportStatus(state, message) {
92930         var args = [];
92931         for (var _i = 2; _i < arguments.length; _i++) {
92932             args[_i - 2] = arguments[_i];
92933         }
92934         state.host.reportSolutionBuilderStatus(ts.createCompilerDiagnostic.apply(void 0, __spreadArrays([message], args)));
92935     }
92936     function reportWatchStatus(state, message) {
92937         var args = [];
92938         for (var _i = 2; _i < arguments.length; _i++) {
92939             args[_i - 2] = arguments[_i];
92940         }
92941         if (state.hostWithWatch.onWatchStatusChange) {
92942             state.hostWithWatch.onWatchStatusChange(ts.createCompilerDiagnostic.apply(void 0, __spreadArrays([message], args)), state.host.getNewLine(), state.baseCompilerOptions);
92943         }
92944     }
92945     function reportErrors(_a, errors) {
92946         var host = _a.host;
92947         errors.forEach(function (err) { return host.reportDiagnostic(err); });
92948     }
92949     function reportAndStoreErrors(state, proj, errors) {
92950         reportErrors(state, errors);
92951         state.projectErrorsReported.set(proj, true);
92952         if (errors.length) {
92953             state.diagnostics.set(proj, errors);
92954         }
92955     }
92956     function reportParseConfigFileDiagnostic(state, proj) {
92957         reportAndStoreErrors(state, proj, [state.configFileCache.get(proj)]);
92958     }
92959     function reportErrorSummary(state, buildOrder) {
92960         if (!state.needsSummary)
92961             return;
92962         state.needsSummary = false;
92963         var canReportSummary = state.watch || !!state.host.reportErrorSummary;
92964         var diagnostics = state.diagnostics;
92965         var totalErrors = 0;
92966         if (isCircularBuildOrder(buildOrder)) {
92967             reportBuildQueue(state, buildOrder.buildOrder);
92968             reportErrors(state, buildOrder.circularDiagnostics);
92969             if (canReportSummary)
92970                 totalErrors += ts.getErrorCountForSummary(buildOrder.circularDiagnostics);
92971         }
92972         else {
92973             buildOrder.forEach(function (project) {
92974                 var projectPath = toResolvedConfigFilePath(state, project);
92975                 if (!state.projectErrorsReported.has(projectPath)) {
92976                     reportErrors(state, diagnostics.get(projectPath) || ts.emptyArray);
92977                 }
92978             });
92979             if (canReportSummary)
92980                 diagnostics.forEach(function (singleProjectErrors) { return totalErrors += ts.getErrorCountForSummary(singleProjectErrors); });
92981         }
92982         if (state.watch) {
92983             reportWatchStatus(state, ts.getWatchErrorSummaryDiagnosticMessage(totalErrors), totalErrors);
92984         }
92985         else if (state.host.reportErrorSummary) {
92986             state.host.reportErrorSummary(totalErrors);
92987         }
92988     }
92989     function reportBuildQueue(state, buildQueue) {
92990         if (state.options.verbose) {
92991             reportStatus(state, ts.Diagnostics.Projects_in_this_build_Colon_0, buildQueue.map(function (s) { return "\r\n    * " + relName(state, s); }).join(""));
92992         }
92993     }
92994     function reportUpToDateStatus(state, configFileName, status) {
92995         switch (status.type) {
92996             case ts.UpToDateStatusType.OutOfDateWithSelf:
92997                 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));
92998             case ts.UpToDateStatusType.OutOfDateWithUpstream:
92999                 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));
93000             case ts.UpToDateStatusType.OutputMissing:
93001                 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));
93002             case ts.UpToDateStatusType.UpToDate:
93003                 if (status.newestInputFileTime !== undefined) {
93004                     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 || ""));
93005                 }
93006                 break;
93007             case ts.UpToDateStatusType.OutOfDateWithPrepend:
93008                 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));
93009             case ts.UpToDateStatusType.UpToDateWithUpstreamTypes:
93010                 return reportStatus(state, ts.Diagnostics.Project_0_is_up_to_date_with_d_ts_files_from_its_dependencies, relName(state, configFileName));
93011             case ts.UpToDateStatusType.UpstreamOutOfDate:
93012                 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));
93013             case ts.UpToDateStatusType.UpstreamBlocked:
93014                 return reportStatus(state, status.upstreamProjectBlocked ?
93015                     ts.Diagnostics.Project_0_can_t_be_built_because_its_dependency_1_was_not_built :
93016                     ts.Diagnostics.Project_0_can_t_be_built_because_its_dependency_1_has_errors, relName(state, configFileName), relName(state, status.upstreamProjectName));
93017             case ts.UpToDateStatusType.Unbuildable:
93018                 return reportStatus(state, ts.Diagnostics.Failed_to_parse_file_0_Colon_1, relName(state, configFileName), status.reason);
93019             case ts.UpToDateStatusType.TsVersionOutputOfDate:
93020                 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);
93021             case ts.UpToDateStatusType.ContainerOnly:
93022             case ts.UpToDateStatusType.ComputingUpstream:
93023                 break;
93024             default:
93025                 ts.assertType(status);
93026         }
93027     }
93028     function verboseReportProjectStatus(state, configFileName, status) {
93029         if (state.options.verbose) {
93030             reportUpToDateStatus(state, configFileName, status);
93031         }
93032     }
93033 })(ts || (ts = {}));
93034 var ts;
93035 (function (ts) {
93036     function countLines(program) {
93037         var count = 0;
93038         ts.forEach(program.getSourceFiles(), function (file) {
93039             count += ts.getLineStarts(file).length;
93040         });
93041         return count;
93042     }
93043     function updateReportDiagnostic(sys, existing, options) {
93044         return shouldBePretty(sys, options) ?
93045             ts.createDiagnosticReporter(sys, true) :
93046             existing;
93047     }
93048     function defaultIsPretty(sys) {
93049         return !!sys.writeOutputIsTTY && sys.writeOutputIsTTY();
93050     }
93051     function shouldBePretty(sys, options) {
93052         if (!options || typeof options.pretty === "undefined") {
93053             return defaultIsPretty(sys);
93054         }
93055         return options.pretty;
93056     }
93057     function getOptionsForHelp(commandLine) {
93058         return !!commandLine.options.all ?
93059             ts.sort(ts.optionDeclarations, function (a, b) { return ts.compareStringsCaseInsensitive(a.name, b.name); }) :
93060             ts.filter(ts.optionDeclarations.slice(), function (v) { return !!v.showInSimplifiedHelpView; });
93061     }
93062     function printVersion(sys) {
93063         sys.write(ts.getDiagnosticText(ts.Diagnostics.Version_0, ts.version) + sys.newLine);
93064     }
93065     function printHelp(sys, optionsList, syntaxPrefix) {
93066         if (syntaxPrefix === void 0) { syntaxPrefix = ""; }
93067         var output = [];
93068         var syntaxLength = ts.getDiagnosticText(ts.Diagnostics.Syntax_Colon_0, "").length;
93069         var examplesLength = ts.getDiagnosticText(ts.Diagnostics.Examples_Colon_0, "").length;
93070         var marginLength = Math.max(syntaxLength, examplesLength);
93071         var syntax = makePadding(marginLength - syntaxLength);
93072         syntax += "tsc " + syntaxPrefix + "[" + ts.getDiagnosticText(ts.Diagnostics.options) + "] [" + ts.getDiagnosticText(ts.Diagnostics.file) + "...]";
93073         output.push(ts.getDiagnosticText(ts.Diagnostics.Syntax_Colon_0, syntax));
93074         output.push(sys.newLine + sys.newLine);
93075         var padding = makePadding(marginLength);
93076         output.push(ts.getDiagnosticText(ts.Diagnostics.Examples_Colon_0, makePadding(marginLength - examplesLength) + "tsc hello.ts") + sys.newLine);
93077         output.push(padding + "tsc --outFile file.js file.ts" + sys.newLine);
93078         output.push(padding + "tsc @args.txt" + sys.newLine);
93079         output.push(padding + "tsc --build tsconfig.json" + sys.newLine);
93080         output.push(sys.newLine);
93081         output.push(ts.getDiagnosticText(ts.Diagnostics.Options_Colon) + sys.newLine);
93082         marginLength = 0;
93083         var usageColumn = [];
93084         var descriptionColumn = [];
93085         var optionsDescriptionMap = new ts.Map();
93086         for (var _i = 0, optionsList_1 = optionsList; _i < optionsList_1.length; _i++) {
93087             var option = optionsList_1[_i];
93088             if (!option.description) {
93089                 continue;
93090             }
93091             var usageText_1 = " ";
93092             if (option.shortName) {
93093                 usageText_1 += "-" + option.shortName;
93094                 usageText_1 += getParamType(option);
93095                 usageText_1 += ", ";
93096             }
93097             usageText_1 += "--" + option.name;
93098             usageText_1 += getParamType(option);
93099             usageColumn.push(usageText_1);
93100             var description = void 0;
93101             if (option.name === "lib") {
93102                 description = ts.getDiagnosticText(option.description);
93103                 var element = option.element;
93104                 var typeMap = element.type;
93105                 optionsDescriptionMap.set(description, ts.arrayFrom(typeMap.keys()).map(function (key) { return "'" + key + "'"; }));
93106             }
93107             else {
93108                 description = ts.getDiagnosticText(option.description);
93109             }
93110             descriptionColumn.push(description);
93111             marginLength = Math.max(usageText_1.length, marginLength);
93112         }
93113         var usageText = " @<" + ts.getDiagnosticText(ts.Diagnostics.file) + ">";
93114         usageColumn.push(usageText);
93115         descriptionColumn.push(ts.getDiagnosticText(ts.Diagnostics.Insert_command_line_options_and_files_from_a_file));
93116         marginLength = Math.max(usageText.length, marginLength);
93117         for (var i = 0; i < usageColumn.length; i++) {
93118             var usage = usageColumn[i];
93119             var description = descriptionColumn[i];
93120             var kindsList = optionsDescriptionMap.get(description);
93121             output.push(usage + makePadding(marginLength - usage.length + 2) + description + sys.newLine);
93122             if (kindsList) {
93123                 output.push(makePadding(marginLength + 4));
93124                 for (var _a = 0, kindsList_1 = kindsList; _a < kindsList_1.length; _a++) {
93125                     var kind = kindsList_1[_a];
93126                     output.push(kind + " ");
93127                 }
93128                 output.push(sys.newLine);
93129             }
93130         }
93131         for (var _b = 0, output_1 = output; _b < output_1.length; _b++) {
93132             var line = output_1[_b];
93133             sys.write(line);
93134         }
93135         return;
93136         function getParamType(option) {
93137             if (option.paramType !== undefined) {
93138                 return " " + ts.getDiagnosticText(option.paramType);
93139             }
93140             return "";
93141         }
93142         function makePadding(paddingLength) {
93143             return Array(paddingLength + 1).join(" ");
93144         }
93145     }
93146     function executeCommandLineWorker(sys, cb, commandLine) {
93147         var reportDiagnostic = ts.createDiagnosticReporter(sys);
93148         if (commandLine.options.build) {
93149             reportDiagnostic(ts.createCompilerDiagnostic(ts.Diagnostics.Option_build_must_be_the_first_command_line_argument));
93150             return sys.exit(ts.ExitStatus.DiagnosticsPresent_OutputsSkipped);
93151         }
93152         var configFileName;
93153         if (commandLine.options.locale) {
93154             ts.validateLocaleAndSetLanguage(commandLine.options.locale, sys, commandLine.errors);
93155         }
93156         if (commandLine.errors.length > 0) {
93157             commandLine.errors.forEach(reportDiagnostic);
93158             return sys.exit(ts.ExitStatus.DiagnosticsPresent_OutputsSkipped);
93159         }
93160         if (commandLine.options.init) {
93161             writeConfigFile(sys, reportDiagnostic, commandLine.options, commandLine.fileNames);
93162             return sys.exit(ts.ExitStatus.Success);
93163         }
93164         if (commandLine.options.version) {
93165             printVersion(sys);
93166             return sys.exit(ts.ExitStatus.Success);
93167         }
93168         if (commandLine.options.help || commandLine.options.all) {
93169             printVersion(sys);
93170             printHelp(sys, getOptionsForHelp(commandLine));
93171             return sys.exit(ts.ExitStatus.Success);
93172         }
93173         if (commandLine.options.watch && commandLine.options.listFilesOnly) {
93174             reportDiagnostic(ts.createCompilerDiagnostic(ts.Diagnostics.Options_0_and_1_cannot_be_combined, "watch", "listFilesOnly"));
93175             return sys.exit(ts.ExitStatus.DiagnosticsPresent_OutputsSkipped);
93176         }
93177         if (commandLine.options.project) {
93178             if (commandLine.fileNames.length !== 0) {
93179                 reportDiagnostic(ts.createCompilerDiagnostic(ts.Diagnostics.Option_project_cannot_be_mixed_with_source_files_on_a_command_line));
93180                 return sys.exit(ts.ExitStatus.DiagnosticsPresent_OutputsSkipped);
93181             }
93182             var fileOrDirectory = ts.normalizePath(commandLine.options.project);
93183             if (!fileOrDirectory || sys.directoryExists(fileOrDirectory)) {
93184                 configFileName = ts.combinePaths(fileOrDirectory, "tsconfig.json");
93185                 if (!sys.fileExists(configFileName)) {
93186                     reportDiagnostic(ts.createCompilerDiagnostic(ts.Diagnostics.Cannot_find_a_tsconfig_json_file_at_the_specified_directory_Colon_0, commandLine.options.project));
93187                     return sys.exit(ts.ExitStatus.DiagnosticsPresent_OutputsSkipped);
93188                 }
93189             }
93190             else {
93191                 configFileName = fileOrDirectory;
93192                 if (!sys.fileExists(configFileName)) {
93193                     reportDiagnostic(ts.createCompilerDiagnostic(ts.Diagnostics.The_specified_path_does_not_exist_Colon_0, commandLine.options.project));
93194                     return sys.exit(ts.ExitStatus.DiagnosticsPresent_OutputsSkipped);
93195                 }
93196             }
93197         }
93198         else if (commandLine.fileNames.length === 0) {
93199             var searchPath = ts.normalizePath(sys.getCurrentDirectory());
93200             configFileName = ts.findConfigFile(searchPath, function (fileName) { return sys.fileExists(fileName); });
93201         }
93202         if (commandLine.fileNames.length === 0 && !configFileName) {
93203             if (commandLine.options.showConfig) {
93204                 reportDiagnostic(ts.createCompilerDiagnostic(ts.Diagnostics.Cannot_find_a_tsconfig_json_file_at_the_current_directory_Colon_0, ts.normalizePath(sys.getCurrentDirectory())));
93205             }
93206             else {
93207                 printVersion(sys);
93208                 printHelp(sys, getOptionsForHelp(commandLine));
93209             }
93210             return sys.exit(ts.ExitStatus.DiagnosticsPresent_OutputsSkipped);
93211         }
93212         var currentDirectory = sys.getCurrentDirectory();
93213         var commandLineOptions = ts.convertToOptionsWithAbsolutePaths(commandLine.options, function (fileName) { return ts.getNormalizedAbsolutePath(fileName, currentDirectory); });
93214         if (configFileName) {
93215             var configParseResult = ts.parseConfigFileWithSystem(configFileName, commandLineOptions, commandLine.watchOptions, sys, reportDiagnostic);
93216             if (commandLineOptions.showConfig) {
93217                 if (configParseResult.errors.length !== 0) {
93218                     reportDiagnostic = updateReportDiagnostic(sys, reportDiagnostic, configParseResult.options);
93219                     configParseResult.errors.forEach(reportDiagnostic);
93220                     return sys.exit(ts.ExitStatus.DiagnosticsPresent_OutputsSkipped);
93221                 }
93222                 sys.write(JSON.stringify(ts.convertToTSConfig(configParseResult, configFileName, sys), null, 4) + sys.newLine);
93223                 return sys.exit(ts.ExitStatus.Success);
93224             }
93225             reportDiagnostic = updateReportDiagnostic(sys, reportDiagnostic, configParseResult.options);
93226             if (ts.isWatchSet(configParseResult.options)) {
93227                 if (reportWatchModeWithoutSysSupport(sys, reportDiagnostic))
93228                     return;
93229                 return createWatchOfConfigFile(sys, cb, reportDiagnostic, configParseResult, commandLineOptions, commandLine.watchOptions);
93230             }
93231             else if (ts.isIncrementalCompilation(configParseResult.options)) {
93232                 performIncrementalCompilation(sys, cb, reportDiagnostic, configParseResult);
93233             }
93234             else {
93235                 performCompilation(sys, cb, reportDiagnostic, configParseResult);
93236             }
93237         }
93238         else {
93239             if (commandLineOptions.showConfig) {
93240                 sys.write(JSON.stringify(ts.convertToTSConfig(commandLine, ts.combinePaths(currentDirectory, "tsconfig.json"), sys), null, 4) + sys.newLine);
93241                 return sys.exit(ts.ExitStatus.Success);
93242             }
93243             reportDiagnostic = updateReportDiagnostic(sys, reportDiagnostic, commandLineOptions);
93244             if (ts.isWatchSet(commandLineOptions)) {
93245                 if (reportWatchModeWithoutSysSupport(sys, reportDiagnostic))
93246                     return;
93247                 return createWatchOfFilesAndCompilerOptions(sys, cb, reportDiagnostic, commandLine.fileNames, commandLineOptions, commandLine.watchOptions);
93248             }
93249             else if (ts.isIncrementalCompilation(commandLineOptions)) {
93250                 performIncrementalCompilation(sys, cb, reportDiagnostic, __assign(__assign({}, commandLine), { options: commandLineOptions }));
93251             }
93252             else {
93253                 performCompilation(sys, cb, reportDiagnostic, __assign(__assign({}, commandLine), { options: commandLineOptions }));
93254             }
93255         }
93256     }
93257     function isBuild(commandLineArgs) {
93258         if (commandLineArgs.length > 0 && commandLineArgs[0].charCodeAt(0) === 45) {
93259             var firstOption = commandLineArgs[0].slice(commandLineArgs[0].charCodeAt(1) === 45 ? 2 : 1).toLowerCase();
93260             return firstOption === "build" || firstOption === "b";
93261         }
93262         return false;
93263     }
93264     ts.isBuild = isBuild;
93265     function executeCommandLine(system, cb, commandLineArgs) {
93266         if (isBuild(commandLineArgs)) {
93267             var _a = ts.parseBuildCommand(commandLineArgs.slice(1)), buildOptions_1 = _a.buildOptions, watchOptions_1 = _a.watchOptions, projects_1 = _a.projects, errors_1 = _a.errors;
93268             if (buildOptions_1.generateCpuProfile && system.enableCPUProfiler) {
93269                 system.enableCPUProfiler(buildOptions_1.generateCpuProfile, function () { return performBuild(system, cb, buildOptions_1, watchOptions_1, projects_1, errors_1); });
93270             }
93271             else {
93272                 return performBuild(system, cb, buildOptions_1, watchOptions_1, projects_1, errors_1);
93273             }
93274         }
93275         var commandLine = ts.parseCommandLine(commandLineArgs, function (path) { return system.readFile(path); });
93276         if (commandLine.options.generateCpuProfile && system.enableCPUProfiler) {
93277             system.enableCPUProfiler(commandLine.options.generateCpuProfile, function () { return executeCommandLineWorker(system, cb, commandLine); });
93278         }
93279         else {
93280             return executeCommandLineWorker(system, cb, commandLine);
93281         }
93282     }
93283     ts.executeCommandLine = executeCommandLine;
93284     function reportWatchModeWithoutSysSupport(sys, reportDiagnostic) {
93285         if (!sys.watchFile || !sys.watchDirectory) {
93286             reportDiagnostic(ts.createCompilerDiagnostic(ts.Diagnostics.The_current_host_does_not_support_the_0_option, "--watch"));
93287             sys.exit(ts.ExitStatus.DiagnosticsPresent_OutputsSkipped);
93288             return true;
93289         }
93290         return false;
93291     }
93292     function performBuild(sys, cb, buildOptions, watchOptions, projects, errors) {
93293         var reportDiagnostic = updateReportDiagnostic(sys, ts.createDiagnosticReporter(sys), buildOptions);
93294         if (buildOptions.locale) {
93295             ts.validateLocaleAndSetLanguage(buildOptions.locale, sys, errors);
93296         }
93297         if (errors.length > 0) {
93298             errors.forEach(reportDiagnostic);
93299             return sys.exit(ts.ExitStatus.DiagnosticsPresent_OutputsSkipped);
93300         }
93301         if (buildOptions.help) {
93302             printVersion(sys);
93303             printHelp(sys, ts.buildOpts, "--build ");
93304             return sys.exit(ts.ExitStatus.Success);
93305         }
93306         if (projects.length === 0) {
93307             printVersion(sys);
93308             printHelp(sys, ts.buildOpts, "--build ");
93309             return sys.exit(ts.ExitStatus.Success);
93310         }
93311         if (!sys.getModifiedTime || !sys.setModifiedTime || (buildOptions.clean && !sys.deleteFile)) {
93312             reportDiagnostic(ts.createCompilerDiagnostic(ts.Diagnostics.The_current_host_does_not_support_the_0_option, "--build"));
93313             return sys.exit(ts.ExitStatus.DiagnosticsPresent_OutputsSkipped);
93314         }
93315         if (buildOptions.watch) {
93316             if (reportWatchModeWithoutSysSupport(sys, reportDiagnostic))
93317                 return;
93318             var buildHost_1 = ts.createSolutionBuilderWithWatchHost(sys, undefined, reportDiagnostic, ts.createBuilderStatusReporter(sys, shouldBePretty(sys, buildOptions)), createWatchStatusReporter(sys, buildOptions));
93319             updateSolutionBuilderHost(sys, cb, buildHost_1);
93320             var builder_1 = ts.createSolutionBuilderWithWatch(buildHost_1, projects, buildOptions, watchOptions);
93321             builder_1.build();
93322             return builder_1;
93323         }
93324         var buildHost = ts.createSolutionBuilderHost(sys, undefined, reportDiagnostic, ts.createBuilderStatusReporter(sys, shouldBePretty(sys, buildOptions)), createReportErrorSummary(sys, buildOptions));
93325         updateSolutionBuilderHost(sys, cb, buildHost);
93326         var builder = ts.createSolutionBuilder(buildHost, projects, buildOptions);
93327         var exitStatus = buildOptions.clean ? builder.clean() : builder.build();
93328         ts.tracing.dumpLegend();
93329         return sys.exit(exitStatus);
93330     }
93331     function createReportErrorSummary(sys, options) {
93332         return shouldBePretty(sys, options) ?
93333             function (errorCount) { return sys.write(ts.getErrorSummaryText(errorCount, sys.newLine)); } :
93334             undefined;
93335     }
93336     function performCompilation(sys, cb, reportDiagnostic, config) {
93337         var fileNames = config.fileNames, options = config.options, projectReferences = config.projectReferences;
93338         var host = ts.createCompilerHostWorker(options, undefined, sys);
93339         var currentDirectory = host.getCurrentDirectory();
93340         var getCanonicalFileName = ts.createGetCanonicalFileName(host.useCaseSensitiveFileNames());
93341         ts.changeCompilerHostLikeToUseCache(host, function (fileName) { return ts.toPath(fileName, currentDirectory, getCanonicalFileName); });
93342         enableStatisticsAndTracing(sys, options, false);
93343         var programOptions = {
93344             rootNames: fileNames,
93345             options: options,
93346             projectReferences: projectReferences,
93347             host: host,
93348             configFileParsingDiagnostics: ts.getConfigFileParsingDiagnostics(config)
93349         };
93350         var program = ts.createProgram(programOptions);
93351         var exitStatus = ts.emitFilesAndReportErrorsAndGetExitStatus(program, reportDiagnostic, function (s) { return sys.write(s + sys.newLine); }, createReportErrorSummary(sys, options));
93352         reportStatistics(sys, program);
93353         cb(program);
93354         return sys.exit(exitStatus);
93355     }
93356     function performIncrementalCompilation(sys, cb, reportDiagnostic, config) {
93357         var options = config.options, fileNames = config.fileNames, projectReferences = config.projectReferences;
93358         enableStatisticsAndTracing(sys, options, false);
93359         var host = ts.createIncrementalCompilerHost(options, sys);
93360         var exitStatus = ts.performIncrementalCompilation({
93361             host: host,
93362             system: sys,
93363             rootNames: fileNames,
93364             options: options,
93365             configFileParsingDiagnostics: ts.getConfigFileParsingDiagnostics(config),
93366             projectReferences: projectReferences,
93367             reportDiagnostic: reportDiagnostic,
93368             reportErrorSummary: createReportErrorSummary(sys, options),
93369             afterProgramEmitAndDiagnostics: function (builderProgram) {
93370                 reportStatistics(sys, builderProgram.getProgram());
93371                 cb(builderProgram);
93372             }
93373         });
93374         return sys.exit(exitStatus);
93375     }
93376     function updateSolutionBuilderHost(sys, cb, buildHost) {
93377         updateCreateProgram(sys, buildHost);
93378         buildHost.afterProgramEmitAndDiagnostics = function (program) {
93379             reportStatistics(sys, program.getProgram());
93380             cb(program);
93381         };
93382         buildHost.afterEmitBundle = cb;
93383     }
93384     function updateCreateProgram(sys, host) {
93385         var compileUsingBuilder = host.createProgram;
93386         host.createProgram = function (rootNames, options, host, oldProgram, configFileParsingDiagnostics, projectReferences) {
93387             ts.Debug.assert(rootNames !== undefined || (options === undefined && !!oldProgram));
93388             if (options !== undefined) {
93389                 enableStatisticsAndTracing(sys, options, true);
93390             }
93391             return compileUsingBuilder(rootNames, options, host, oldProgram, configFileParsingDiagnostics, projectReferences);
93392         };
93393     }
93394     function updateWatchCompilationHost(sys, cb, watchCompilerHost) {
93395         updateCreateProgram(sys, watchCompilerHost);
93396         var emitFilesUsingBuilder = watchCompilerHost.afterProgramCreate;
93397         watchCompilerHost.afterProgramCreate = function (builderProgram) {
93398             emitFilesUsingBuilder(builderProgram);
93399             reportStatistics(sys, builderProgram.getProgram());
93400             cb(builderProgram);
93401         };
93402     }
93403     function createWatchStatusReporter(sys, options) {
93404         return ts.createWatchStatusReporter(sys, shouldBePretty(sys, options));
93405     }
93406     function createWatchOfConfigFile(system, cb, reportDiagnostic, configParseResult, optionsToExtend, watchOptionsToExtend) {
93407         var watchCompilerHost = ts.createWatchCompilerHostOfConfigFile({
93408             configFileName: configParseResult.options.configFilePath,
93409             optionsToExtend: optionsToExtend,
93410             watchOptionsToExtend: watchOptionsToExtend,
93411             system: system,
93412             reportDiagnostic: reportDiagnostic,
93413             reportWatchStatus: createWatchStatusReporter(system, configParseResult.options)
93414         });
93415         updateWatchCompilationHost(system, cb, watchCompilerHost);
93416         watchCompilerHost.configFileParsingResult = configParseResult;
93417         return ts.createWatchProgram(watchCompilerHost);
93418     }
93419     function createWatchOfFilesAndCompilerOptions(system, cb, reportDiagnostic, rootFiles, options, watchOptions) {
93420         var watchCompilerHost = ts.createWatchCompilerHostOfFilesAndCompilerOptions({
93421             rootFiles: rootFiles,
93422             options: options,
93423             watchOptions: watchOptions,
93424             system: system,
93425             reportDiagnostic: reportDiagnostic,
93426             reportWatchStatus: createWatchStatusReporter(system, options)
93427         });
93428         updateWatchCompilationHost(system, cb, watchCompilerHost);
93429         return ts.createWatchProgram(watchCompilerHost);
93430     }
93431     function canReportDiagnostics(system, compilerOptions) {
93432         return system === ts.sys && (compilerOptions.diagnostics || compilerOptions.extendedDiagnostics);
93433     }
93434     function canTrace(system, compilerOptions) {
93435         return system === ts.sys && compilerOptions.generateTrace;
93436     }
93437     function enableStatisticsAndTracing(system, compilerOptions, isBuildMode) {
93438         if (canReportDiagnostics(system, compilerOptions)) {
93439             ts.performance.enable();
93440         }
93441         if (canTrace(system, compilerOptions)) {
93442             ts.tracing.startTracing(compilerOptions.configFilePath, compilerOptions.generateTrace, isBuildMode);
93443         }
93444     }
93445     function reportStatistics(sys, program) {
93446         var compilerOptions = program.getCompilerOptions();
93447         if (canTrace(sys, compilerOptions)) {
93448             ts.tracing.stopTracing(program.getTypeCatalog());
93449         }
93450         var statistics;
93451         if (canReportDiagnostics(sys, compilerOptions)) {
93452             statistics = [];
93453             var memoryUsed = sys.getMemoryUsage ? sys.getMemoryUsage() : -1;
93454             reportCountStatistic("Files", program.getSourceFiles().length);
93455             reportCountStatistic("Lines", countLines(program));
93456             reportCountStatistic("Nodes", program.getNodeCount());
93457             reportCountStatistic("Identifiers", program.getIdentifierCount());
93458             reportCountStatistic("Symbols", program.getSymbolCount());
93459             reportCountStatistic("Types", program.getTypeCount());
93460             reportCountStatistic("Instantiations", program.getInstantiationCount());
93461             if (memoryUsed >= 0) {
93462                 reportStatisticalValue("Memory used", Math.round(memoryUsed / 1000) + "K");
93463             }
93464             var isPerformanceEnabled = ts.performance.isEnabled();
93465             var programTime = isPerformanceEnabled ? ts.performance.getDuration("Program") : 0;
93466             var bindTime = isPerformanceEnabled ? ts.performance.getDuration("Bind") : 0;
93467             var checkTime = isPerformanceEnabled ? ts.performance.getDuration("Check") : 0;
93468             var emitTime = isPerformanceEnabled ? ts.performance.getDuration("Emit") : 0;
93469             if (compilerOptions.extendedDiagnostics) {
93470                 var caches = program.getRelationCacheSizes();
93471                 reportCountStatistic("Assignability cache size", caches.assignable);
93472                 reportCountStatistic("Identity cache size", caches.identity);
93473                 reportCountStatistic("Subtype cache size", caches.subtype);
93474                 reportCountStatistic("Strict subtype cache size", caches.strictSubtype);
93475                 if (isPerformanceEnabled) {
93476                     ts.performance.forEachMeasure(function (name, duration) { return reportTimeStatistic(name + " time", duration); });
93477                 }
93478             }
93479             else if (isPerformanceEnabled) {
93480                 reportTimeStatistic("I/O read", ts.performance.getDuration("I/O Read"));
93481                 reportTimeStatistic("I/O write", ts.performance.getDuration("I/O Write"));
93482                 reportTimeStatistic("Parse time", programTime);
93483                 reportTimeStatistic("Bind time", bindTime);
93484                 reportTimeStatistic("Check time", checkTime);
93485                 reportTimeStatistic("Emit time", emitTime);
93486             }
93487             if (isPerformanceEnabled) {
93488                 reportTimeStatistic("Total time", programTime + bindTime + checkTime + emitTime);
93489             }
93490             reportStatistics();
93491             if (!isPerformanceEnabled) {
93492                 sys.write(ts.Diagnostics.Performance_timings_for_diagnostics_or_extendedDiagnostics_are_not_available_in_this_session_A_native_implementation_of_the_Web_Performance_API_could_not_be_found.message + "\n");
93493             }
93494             else {
93495                 ts.performance.disable();
93496             }
93497         }
93498         function reportStatistics() {
93499             var nameSize = 0;
93500             var valueSize = 0;
93501             for (var _i = 0, statistics_1 = statistics; _i < statistics_1.length; _i++) {
93502                 var _a = statistics_1[_i], name = _a.name, value = _a.value;
93503                 if (name.length > nameSize) {
93504                     nameSize = name.length;
93505                 }
93506                 if (value.length > valueSize) {
93507                     valueSize = value.length;
93508                 }
93509             }
93510             for (var _b = 0, statistics_2 = statistics; _b < statistics_2.length; _b++) {
93511                 var _c = statistics_2[_b], name = _c.name, value = _c.value;
93512                 sys.write(ts.padRight(name + ":", nameSize + 2) + ts.padLeft(value.toString(), valueSize) + sys.newLine);
93513             }
93514         }
93515         function reportStatisticalValue(name, value) {
93516             statistics.push({ name: name, value: value });
93517         }
93518         function reportCountStatistic(name, count) {
93519             reportStatisticalValue(name, "" + count);
93520         }
93521         function reportTimeStatistic(name, time) {
93522             reportStatisticalValue(name, (time / 1000).toFixed(2) + "s");
93523         }
93524     }
93525     function writeConfigFile(sys, reportDiagnostic, options, fileNames) {
93526         var currentDirectory = sys.getCurrentDirectory();
93527         var file = ts.normalizePath(ts.combinePaths(currentDirectory, "tsconfig.json"));
93528         if (sys.fileExists(file)) {
93529             reportDiagnostic(ts.createCompilerDiagnostic(ts.Diagnostics.A_tsconfig_json_file_is_already_defined_at_Colon_0, file));
93530         }
93531         else {
93532             sys.writeFile(file, ts.generateTSConfig(options, fileNames, sys.newLine));
93533             reportDiagnostic(ts.createCompilerDiagnostic(ts.Diagnostics.Successfully_created_a_tsconfig_json_file));
93534         }
93535         return;
93536     }
93537 })(ts || (ts = {}));
93538 // This file actually uses arguments passed on commandline and executes it
93539 ts.Debug.loggingHost = {
93540     log: function (_level, s) {
93541         ts.sys.write("" + (s || "") + ts.sys.newLine);
93542     }
93543 };
93544 if (ts.Debug.isDebugging) {
93545     ts.Debug.enableDebugInfo();
93546 }
93547 if (ts.sys.tryEnableSourceMapsForHost && /^development$/i.test(ts.sys.getEnvironmentVariable("NODE_ENV"))) {
93548     ts.sys.tryEnableSourceMapsForHost();
93549 }
93550 if (ts.sys.setBlocking) {
93551     ts.sys.setBlocking();
93552 }
93553 ts.executeCommandLine(ts.sys, ts.noop, ts.sys.args);